protected void verifyBtn_Click(object sender, EventArgs e)
    {
        // if chargeable or non chargeable are being edited prompt user to save or update changes, else execute intended code for verify
        if (activitiesDDL.Items.Count > 0 || specifyDDL.SelectedValue != "Select" || detailsDDL.SelectedValue != "Select")
        {
            // throw a dialog
            msg = "You have Un-Saved work on this Page, Please save,update or Clear the form";
            dialogTitle = "Warning: Un-saved Work";

            ScriptManager.RegisterStartupScript(this, this.GetType(), "unsavedwork", "throwDialog();", true);
        }
        else
        {
            if (weekEndingTB.Text != string.Empty)
            {
                // disable the non chargeable hours and expense panels
                NonChargeHoursPanel.Visible = false;
                NonChargeExpensesPanel.Visible = false;
                specifyDDL.SelectedIndex = 0;
                detailsDDL.SelectedIndex = 0;

                TimesheetManager tm = new TimesheetManager();
                ScriptManager.RegisterStartupScript(this, this.GetType(), "populate", "populate();", true);
                int userID = tm.idForUsername(Membership.GetUser().UserName);
                timesheetID = tm.idForDate(weekEndingTB.Text, userID);
                projectNumTB.Enabled = true;

                // if a timesheet does not exist for the weekending date, create a new one
                if (timesheetID == 0)
                {
                    TimeSheet t = new TimeSheet();
                    t.WeekEnding = weekEndingTB.Text;
                    t.EmployeeId = userID;
                    t.DateCreated = DateTime.Now;
                    t.DateModified = DateTime.Now;
                    t.Status = "Started";
                    t.EmployeeName = nameTB.Text;
                    t.TotalHours = 0;
                    t.TotalExpenses = 0;
                    t.TotalDistance = 0;
                    t.Branch = departmentTB.Text;
                    totalDistanceLBL.Text = "0";
                    totalExpensesLBL.Text = "0";
                    totalHoursLBL.Text = "0";
                    totalTruckLBL.Text = "0";

                    // populate global variables
                    timesheetID = tm.createTimesheet(t);

                    HiddenField1.Value = t.TimeSheetId.ToString();
                    // enable controls
                    projectNumTB.Enabled = true;
                }
                else
                {
                    TimeSheet ts = tm.getTimesheetForID(timesheetID);
                    if (ts != null)
                    {
                        if (ts.Status == "Completed" || ts.Status == "Approved" || ts.Status == "Manager - Updated" || ts.Status == "Synchronized")
                        {
                            // throw a dialog
                            dialogTitle = "Completed TimeSheet";
                            msg = "The timesheet for this weekending date has already been Completed and Approved";
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "projectNumInvalid", "throwDialog();", true);

                            // disable edit and delete columns
                            summaryGV.Columns[0].Visible = false;
                            summaryGV.Columns[1].Visible = false;
                            summaryGV.Columns[0].Visible = false;
                            summaryGV.Columns[1].Visible = false;
                            // disable the save buttons
                            chargeableBtn.Visible = false;
                            nonChargeBtn.Visible = false;
                            labTestsBtn.Visible = false;
                            updateChargeableBtn.Visible = false;
                            updateNonChargeableBtn.Visible = false;
                            updateLabTestsBtn.Visible = false;

                            // update totals
                            updateTimeSheetTotals();
                        }
                        else
                        {
                            // UPDATE TOTALS
                            updateTimeSheetTotals();
                            // for gridview
                            HiddenField1.Value = timesheetID.ToString();
                            // enable controls
                            projectNumTB.Enabled = true;

                            // re-ENABLE edit and delete columns
                            summaryGV.Columns[0].Visible = true;
                            summaryGV.Columns[1].Visible = true;
                            summaryGV.Columns[0].Visible = true;
                            summaryGV.Columns[1].Visible = true;
                            // re-enable the save buttons
                            chargeableBtn.Visible = true;
                            nonChargeBtn.Visible = true;
                            labTestsBtn.Visible = true;
                        }
                    }
                }
                // re-populate the dates
                ScriptManager.RegisterStartupScript(this, this.GetType(), "populate", "populate();", true);
                summaryGV.DataBind();
            }
        }
    }
 /// <summary>
 /// Create a new TimeSheet object.
 /// </summary>
 /// <param name="timeSheetId">Initial value of the TimeSheetId property.</param>
 /// <param name="employeeId">Initial value of the EmployeeId property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static TimeSheet CreateTimeSheet(global::System.Int32 timeSheetId, global::System.Int32 employeeId, global::System.String status)
 {
     TimeSheet timeSheet = new TimeSheet();
     timeSheet.TimeSheetId = timeSheetId;
     timeSheet.EmployeeId = employeeId;
     timeSheet.Status = status;
     return timeSheet;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the TimeSheets EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTimeSheets(TimeSheet timeSheet)
 {
     base.AddObject("TimeSheets", timeSheet);
 }
 /// <summary>
 /// create timesheet instance singleton for weekending. returns timesheetID
 /// </summary>
 /// <param name="t"></param>
 public int createTimesheet(TimeSheet t)
 {
     using (var context = new PetoEntities())
     {
         try
         {
             if (context.TimeSheets.FirstOrDefault(x => x.TimeSheetId == t.TimeSheetId) == null)
             {
                 context.TimeSheets.AddObject(t);
                 context.SaveChanges();
                 return t.TimeSheetId;
             }
             else
             {
                 return context.TimeSheets.FirstOrDefault(x => x.TimeSheetId == t.TimeSheetId).TimeSheetId;
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
 }