Calendar control override

xiaoxiao2021-03-06  72

Imports cyberrs2.aps.businessFacade

Imports cyberrs2.aps.model

Imports cyberrs2.aps.syscommon

Imports cyberrs2.aps.businessFacade.holidayfacade

Public class manageholidayset

Inherits System.Web.ui.page

Protected withevents calendar1 as system.Web.ui.webcontrols.calendar

Protected Withevents Td1 as System.Web.ui.htmlControls.htmltablecell

Protected Withevents TD2 as System.Web.ui.htmlControls.htmltableCell

Protected Withevents TD3 as System.Web.ui.htmlControls.htmltableCell

Protected Withevents TD4 as System.Web.ui.htmlControls.htmltableCell

Protected Withevents DDLYEAR As System.Web.ui.WebControls.dropdownList

Protected Withevents DDLMONTH As System.Web.ui.WebControls.dropdownList

Protected withevents btn_sure1 as system.Web.ui.WebControls.ImageButton

Protected withevents btn_dfhdset1 as system.Web.ui.WebControls.ImageButton

Protected Withevents BTN_RESTORE1 As System.Web.ui.WebControls.ImageButton

#Region "The code" of the web form designer "

'This call is required for the web form designer.

private subinitializecomponent ()

End Sub

Private sub page_init (byval sender as system.object, byval e as system.eventargs) Handles mybase.init

'Codegen: This method call is necessary for the web form designer

'Don't modify it using the code editor.

InitializeComponent ()

End Sub

#End region

Private holiday as string = "" "

Dim defarray () AS STRING

Private DT as new dataable ()

DIM FLAG AS INTEGER

Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.LOAD

'Place the user code of the initialization page here

DIM INTYEAR AS INTEGER

DIM INTMONTH AS INTEGER

IF not me.ispostback then

BTN_SURE1.Attributes.add ("onmouseover", "this.src = '.. / images / btn_sure2.gif';")

BTN_SURE1.ATRIBUTES.ADD ("onmouseout", "this.src = '.. / images / btn_sure1.gif';") btn_dfhdset1.attributes.add ("onmouseover", "this.src = '.. / images / btn_dfhdset2 .gif '; ")

BTN_DFHDSET1.ATRIBUTES.ADD ("onmouseout", "this.src = '.. / images / btn_dfhdset1.gif';")

BTN_RESTORE1.ATRIBUTES.ADD ("OnMouseover", "this.src = '.. / images / btn_restore2.gif';")

BTN_RESTORE1.ATRIBUTES.ADD ("onmouseout", "this.src = '.. / images / btn_restore1.gif';")

Interedear = now.Year ()

INTMONTH = now.MONTH ()

'' '' '' '' '' '' '' '' '' '' '' '' '' ''

Me.ddlyear.selectedIndex = me.ddlyear.items.indexof (me.ddlyear.items.FindByValue (intYear.tostring))

Me.ddlmonth.selectedIndex = me.ddlmonth.Items.indexof (me.ddlmonth.Items.FindByValue (intmonth.tostring))

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''

'Declare Datacolumn and DataRow Variables.

DIM MyDatacolumn As Datacolumn

DIM MyDATAROW AS DATAROW

'Create New Datacolumn, Set DataType, ColumnName and Add to DataTable.

MyDatacolumn = new datacolumn ()

mydatacolumn.datatype = system.type.gettype ("system.string")

mydatacolumn.columnname = "year"

Dt.columns.add (MyDatacolumn)

'CREATE Second Column.

MyDatacolumn = new datacolumn ()

mydatacolumn.DataType = type.gettype ("system.string")

mydatacolumn.columnname = "Month"

Dt.columns.add (MyDatacolumn)

'Create Three Column.

MyDatacolumn = new datacolumn ()

mydatacolumn.DataType = type.gettype ("system.string")

mydatacolumn.columnname = "day"

Dt.columns.add (MyDatacolumn)

'CREATE FOUR Column.

MyDatacolumn = new datacolumn ()

mydatacolumn.DataType = type.gettype ("system.string")

mydatacolumn.columnname = "flag"

Dt.columns.add (MyDatacolumn)

'Define a session

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''

DIM SELSTR AS STRING

Selstr = "SELECT * from sys_holiday"

Dt = HolidayFacade.getMonthholiday (Selstr)

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''

Session ("SelectDays") = DT

END IF

Me.calendar1.selectedDate = Nothing

End Sub

Private sub page_prender (byval e as system.eventargs) Handles mybase.prender

DT = ctype (session ("SelectDays"), DATATABLE)

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'Is only realized when you click on the date on the calendar.

If not me.calendar1.selecteddate = Nothing then

Dim newrow as datarow = dt.newrow

Dim Eachrow As DataRow

'Query the session, whether the date already exists in the session, if the record is deleted; not add this record

For Each Eachrow in Dt.Rows

'There is this record to delete it

If Eachrow.Item (0) = me.calendar1.selectedDate.Year and Eachrow.Item (1) = Me.calendar1.selectedDate.month and eachrow.item (2) = me.calendar1.selectedDate.day THEN

Dt.Rows.Remove (Eachrow)

Session ("SelectDays") = DT

Flag = 0

EXIT SUB

END IF

NEXT

'Add it on this record

NEWROW.ITEM (0) = me.calendar1.selectedddate.Year

NEWROW.ITEM (1) = me.calendar1.selectedDate.month

NEWROW.ITEM (2) = me.calendar1.selectedddate.day

NEWROW.ITEM (3) = "1"

Dt.Rows.Add (newrow)

Session ("SelectDays") = DT

Flag = 0

END IF

'Date of clicking on the calendar, implement the following code

'' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' "'' '' '' '' '1.1 page Imports when importing, when this month does not set a holiday, use the default settings, session is empty; otherwise use the record in the database, Records in the database

'2.1 When DropDownList changes, it needs to be implemented. When the newly selected month does not set the holiday, use the default settings, the session is constant; otherwise use the record in the database, add records in the database, such as session

'Get the current display monthly holiday settings

If me.calendar1.selecteddate = Nothing Then

DIM SELSTR AS STRING

Dim Foundrows as DataRow ()

Selstr = "year = '" & me.ddlyear.selecteditem.value & "' and month = '" & me.ddlmonth.selectedItem.Value & "'"

FoundRows = DT.Select (Selstr)

'If there is no record in the database ---- get the default holiday setting, for example: 5, 6

If FOUNDROWS.LENGTH = 0 THEN

HolidayFacade.getdefholidy (Holiday)

'Generate arrays in strings

DEFARRAY = Split (Holiday, ",")

Flag = 1

END IF

END IF

End Sub

Private sub calendar1_dayrender (Byval e as system.web.ui.webcontrols.dayrendereventargs) Handles Calendar1.dayrender

'If the day is not the date of this month, it disables the Enabled, ISSELECTABLE.

If me.calendar1.visibledate <> Nothing Then

If e.day.date.month <> me.calendar1.visibledate.month Then

e.day.isselectable = false

E.cell.enabled = false

EXIT SUB

END IF

Else

If E.day.date.month <> me.calendar1.todaysdate.mont thene.day.isselectable = false

E.cell.enabled = false

EXIT SUB

END IF

END IF

'Make the selected date into a red font

DT = ctype (session ("SelectDays"), DATATABLE)

'If there is no record in the database, get the default holiday setting

IF flag = 1 THEN

Dim Str As String

For Each Str in Me.Defarray

If E.day.date.dayofweek = INTEGER.PARSE (STR) THEN

E.Cell.ForeColor = system.drawing.color.red

'' 'First put the date of the default holiday set into the session variable

Dim newrow as datarow = dt.newrow

NEWROW.ITEM (0) = E.day.date.year

NEWROW.ITEM (1) = E.day.date.month

Newrow.item (2) = E.day.date.day.day.day

NEWROW.ITEM (3) = "1"

Dt.Rows.Add (newrow)

END IF

NEXT

Session ("SelectDays") = DT

'If there is a record of holiday settings in the database, read the value in the session.

Else

DIM I as integer

DT = ctype (session ("SelectDays"), DATATABLE)

For i = 0 to dt.rows.count - 1

If e.day.date.year = dt.Rows.Item (i) .Item (0) and e.day.date.month = dt.rows.item (i) .Item (1) And e.day.date .Day = dt.rows.Item (i) .Item (2) THEN

E.Cell.ForeColor = system.drawing.color.red

END IF

NEXT

END IF

End Sub

Private sub btn_sure1_click (Byval e as system.Object, byval e as system.Web.ui.ImageClickevenTargs) Handles btn_sure1.click

DT = ctype (session ("SelectDays"), DATATABLE)

DIM Content As String

Dim mymsgcode as new cyberrs2.aps.businessFacade.msgcodefacade ()

IF Integer.Parse (HolidayFacade.ModifyHoliday (DT)) = 1 THEN

Content = mymsgcode.getmsg ("MUF11001", Webuiconfig.currentLANGuage)

Page.RegisterStartupScript ("" "