⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timesheet.aspx.vb

📁 Beginning VB.NET DatabasesAll_Code.rar
💻 VB
📖 第 1 页 / 共 2 页
字号:
Public Class TimeSheet
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents btnSave As System.Web.UI.WebControls.Button
    Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
    Protected WithEvents cboWeekEndingDate As System.Web.UI.WebControls.DropDownList

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private intIndex As Integer
    Private intTotal As Integer

    Private blnEvenRow As Boolean = True

    Private strCompany As String = "Wrox"
    Private strApplication As String = "Time Tracker"

    Private dteWeekEndingDate As Date

    Private objTimeSheets As WroxBusinessLogic.WBLTimeSheets

    Private objTimeSheetDS As DataSet

    Private Sub Page_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load
        If IsPostBack Then
            'Are we working with the same date?
            If Session("dteWeekEndingDate") = _
                Request.Form("cboWeekEndingDate") Then
                'Get the Session date back into the variable
                dteWeekEndingDate = Session("dteWeekEndingDate")
                'Get the Session object back into the DataSet
                objTimeSheetDS = Session("objTimeSheetDS")
                'Update the timesheet DataSet
                Call UpdateTimeSheetDS()
            Else
                'Set the new date from the Request.Form
                dteWeekEndingDate = Request.Form("cboWeekEndingDate")
                'Get the timesheet
                Call GetTimeSheet()
                'Set the new Session objects so we save them between requests
                Session("objTimeSheetDS") = objTimeSheetDS
                Session("dteWeekEndingDate") = dteWeekEndingDate
            End If
        Else
            'Set the default week ending date
            dteWeekEndingDate = GetCurrentWeekEndingDate()
            'Load the week ending dates in the form
            cboWeekEndingDate.Items.Add(GetPreviousWeekEndingDate())
            cboWeekEndingDate.Items.Add(GetCurrentWeekEndingDate())
            cboWeekEndingDate.SelectedIndex = 1
            'Get the timesheet
            Call GetTimeSheet()
            'Set the new Session objects so we save them between requests
            Session("objTimeSheetDS") = objTimeSheetDS
            Session("dteWeekEndingDate") = dteWeekEndingDate
        End If
    End Sub

    Private Sub GetTimeSheet()
        'Initialize a new instance of the business logic component
        objTimeSheets = New WroxBusinessLogic.WBLTimeSheets( _
            strCompany, strApplication)

        'Get the timesheet for the user
        objTimeSheetDS = objTimeSheets.GetTimeSheet( _
            New Guid(Request.QueryString("UserID")), dteWeekEndingDate)

        'Initialize a new DataRow object
        Dim objDataRow As DataRow = objTimeSheetDS.Tables("TimeSheet").NewRow

        'Set the values in the columns
        objDataRow.Item("ProjectName") = "Total Hours"

        'Calculate and set the total hours for Monday
        intTotal = 0
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
            intTotal += objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("MondayHours")
        Next
        objDataRow.Item("MondayHours") = intTotal

        'Calculate and set the total hours for Tuesday
        intTotal = 0
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
            intTotal += objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("TuesdayHours")
        Next
        objDataRow.Item("TuesdayHours") = intTotal

        'Calculate and set the total hours for Wednesday
        intTotal = 0
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
            intTotal += objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("WednesdayHours")
        Next
        objDataRow.Item("WednesdayHours") = intTotal

        'Calculate and set the total hours for Thursday
        intTotal = 0
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
            intTotal += objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("ThursdayHours")
        Next
        objDataRow.Item("ThursdayHours") = intTotal

        'Calculate and set the total hours for Friday
        intTotal = 0
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 1
            intTotal += objTimeSheetDS.Tables( _
                "TimeSheet").Rows(intIndex).Item("FridayHours")
        Next
        objDataRow.Item("FridayHours") = intTotal

        'Add the row to the DataSet
        objTimeSheetDS.Tables("TimeSheet").Rows.Add(objDataRow)

        'Cleanup
        objTimeSheets.Dispose()
        objTimeSheets = Nothing
    End Sub

    Public Sub DisplayTimeSheet()
        'Begin table
        Response.Write("<table cellpadding=""3"" cellspacing=""0"" " & _
            "bordercolor=""Black"" border=""1""" & _
            "class=""TimeSheetTable"" >" & ControlChars.CrLf)
        Response.Write("<tr class=""TimeSheetTableHeader"">" & ControlChars.CrLf)
        Response.Write("<td nowrap style=""width:200px;"">Project Name</td>" & _
            ControlChars.CrLf)
        Response.Write("<td style=""width:30px;"">Mon</td>" & ControlChars.CrLf)
        Response.Write("<td style=""width:30px;"">Tue</td>" & ControlChars.CrLf)
        Response.Write("<td style=""width:30px;"">Wed</td>" & ControlChars.CrLf)
        Response.Write("<td style=""width:30px;"">Thu</td>" & ControlChars.CrLf)
        Response.Write("<td style=""width:30px;"">Fri</td>" & ControlChars.CrLf)
        Response.Write("</tr>" & ControlChars.CrLf)

        'Process all rows of data
        For intIndex = 0 To objTimeSheetDS.Tables("TimeSheet").Rows.Count - 2
            WriteTimeSheetRow(objTimeSheetDS.Tables("TimeSheet").Rows(intIndex))
        Next

        'Write the total row
        blnEvenRow = Not blnEvenRow
        If blnEvenRow Then
            Response.Write("<tr class=""EvenRow"">" & ControlChars.CrLf)
        Else
            Response.Write("<tr class=""OddRow"">" & ControlChars.CrLf)
        End If

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -