protected void updateLabTestsBtn_Click(object sender, EventArgs e)
    {
        bool valid = true;
        TimesheetManager tm = new TimesheetManager();
        decimal tHours = Convert.ToDecimal(totalHoursLBL.Text);
        // try to update, if cannot update, then create new lab test
        if (sunLabTB.Text != string.Empty && sunLabTB.Text != "0")
        {
            if (!hoursValidator(sunLabTB.Text, "Sunday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Sunday", sunNuclearDensityTestTB.Text, sunLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Sunday", sunNuclearDensityTestTB.Text, sunLabTB.Text, timesheetID, false, ref tHours);
            }
            sunLabTB.Text = string.Empty;
            sunNuclearDensityTestTB.Text = string.Empty;
        }

        if (monLabTB.Text != string.Empty && monLabTB.Text != "0")
        {
            if (!hoursValidator(monLabTB.Text, "Monday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Monday", monNuclearDensityTestTB.Text, monLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Monday", monNuclearDensityTestTB.Text, monLabTB.Text, timesheetID, false, ref tHours);
            }
            monLabTB.Text = string.Empty;
            monNuclearDensityTestTB.Text = string.Empty;
        }

        if (tuesLabTB.Text != string.Empty && tuesLabTB.Text != "0")
        {
            if (!hoursValidator(tuesLabTB.Text, "Tuesday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Tuesday", tuesNuclearDensityTestTB.Text, tuesLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Tuesday", tuesNuclearDensityTestTB.Text, tuesLabTB.Text, timesheetID, false, ref tHours);
            }
            tuesLabTB.Text = string.Empty;
            tuesNuclearDensityTestTB.Text = string.Empty;
        }

        if (wedsLabTB.Text != string.Empty && wedsLabTB.Text != "0")
        {
            if (!hoursValidator(wedsLabTB.Text, "Wednesday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Wednesday", wedsNuclearDensityTestTB.Text, wedsLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Wednesday", wedsNuclearDensityTestTB.Text, wedsLabTB.Text, timesheetID, false, ref tHours);
            }
            wedsLabTB.Text = string.Empty;
            wedsNuclearDensityTestTB.Text = string.Empty;
        }

        if (thursLabTB.Text != string.Empty && thursLabTB.Text != "0")
        {
            if (!hoursValidator(thursLabTB.Text, "Thursday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Thursday", thursNuclearDensityTestTB.Text, thursLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Thursday", thursNuclearDensityTestTB.Text, thursLabTB.Text, timesheetID, false, ref tHours);
            }
            thursLabTB.Text = string.Empty;
            thursNuclearDensityTestTB.Text = string.Empty;
        }

        if (friLabTB.Text != string.Empty && friLabTB.Text != "0")
        {
            if (!hoursValidator(friLabTB.Text, "Friday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Friday", friNuclearDensityTestTB.Text, friLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Friday", friNuclearDensityTestTB.Text, friLabTB.Text, timesheetID, false, ref tHours);
            }
            friLabTB.Text = string.Empty;
            friNuclearDensityTestTB.Text = string.Empty;
        }

        if (satLabTB.Text != string.Empty && satLabTB.Text != "0")
        {
            if (!hoursValidator(satLabTB.Text, "Saturday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            if (!tm.updateLabTest("Saturday", satNuclearDensityTestTB.Text, satLabTB.Text, timesheetID, false, ref tHours))
            {
                tm.createLabTest("Saturday", satNuclearDensityTestTB.Text, satLabTB.Text, timesheetID, false, ref tHours);
            }
            satLabTB.Text = string.Empty;
            satNuclearDensityTestTB.Text = string.Empty;
        }

        totalHoursLBL.Text = tHours.ToString("0.0");
        updateLabTotals();
        // update timesheet
        tm.updateTimeSheet(timesheetID, tHours, Convert.ToInt32(totalDistanceLBL.Text), Convert.ToInt32(totalTruckLBL.Text), Convert.ToDecimal(totalExpensesLBL.Text), "Updated", " ", " ");

        summaryGV.DataBind();
        updateLabTestsBtn.Visible = false;
        labTestsBtn.Visible = true;
    }
    protected void labTestsBtn_Click(object sender, EventArgs e)
    {
        decimal tHours = Convert.ToDecimal(totalHoursLBL.Text);
        bool valid = true;
        // begin to save tests if there is a timesheet id of non zero and weekending date exists
        if (weekEndingTB.Text != string.Empty && timesheetID != 0)
        {
            TimesheetManager tm = new TimesheetManager();
            // Sunday
            if (sunLabTB.Text != string.Empty && sunLabTB.Text != "0")
            {
                if (!hoursValidator(sunLabTB.Text, "Sunday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Sunday", sunNuclearDensityTestTB.Text, sunLabTB.Text, timesheetID, false, ref tHours);
                sunLabTB.Text = string.Empty;
                sunNuclearDensityTestTB.Text = string.Empty;
            }

            // Monday
            if (monLabTB.Text != string.Empty && monLabTB.Text != "0")
            {
                if (!hoursValidator(monLabTB.Text, "Monnday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Monday", monNuclearDensityTestTB.Text, monLabTB.Text, timesheetID, false, ref tHours);
                monLabTB.Text = string.Empty;
                monNuclearDensityTestTB.Text = string.Empty;
            }

            // Tuesday
            if (tuesLabTB.Text != string.Empty && tuesLabTB.Text != "0")
            {
                if (!hoursValidator(tuesLabTB.Text, "Tuesday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Tuesday", tuesNuclearDensityTestTB.Text, tuesLabTB.Text, timesheetID, false, ref tHours);
                tuesLabTB.Text = string.Empty;
                tuesNuclearDensityTestTB.Text = string.Empty;
            }

            // Wednesday
            if (wedsLabTB.Text != string.Empty && wedsLabTB.Text != "0")
            {
                if (!hoursValidator(wedsLabTB.Text, "Wednesday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Wednesday", wedsNuclearDensityTestTB.Text, wedsLabTB.Text, timesheetID, false, ref tHours);
                wedsLabTB.Text = string.Empty;
                wedsNuclearDensityTestTB.Text = string.Empty;
            }

            // Thursday
            if (thursLabTB.Text != string.Empty && thursLabTB.Text != "0")
            {
                if (!hoursValidator(thursLabTB.Text, "Thursday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Thursday", thursNuclearDensityTestTB.Text, thursLabTB.Text, timesheetID, false, ref tHours);
                thursLabTB.Text = string.Empty;
                thursNuclearDensityTestTB.Text = string.Empty;
            }

            // Friday
            if (friLabTB.Text != string.Empty && friLabTB.Text != "0")
            {
                if (!hoursValidator(friLabTB.Text, "Friday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Friday", friNuclearDensityTestTB.Text, friLabTB.Text, timesheetID, false, ref tHours);
                friLabTB.Text = string.Empty;
                friNuclearDensityTestTB.Text = string.Empty;
            }

            // Saturday
            if (satLabTB.Text != string.Empty && satLabTB.Text != "0")
            {
                if (!hoursValidator(satLabTB.Text, "Saturday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Saturday", satNuclearDensityTestTB.Text, satLabTB.Text, timesheetID, false, ref tHours);
                satLabTB.Text = string.Empty;
                satNuclearDensityTestTB.Text = string.Empty;
            }
            updateLabTotals();
            totalHoursLBL.Text = tHours.ToString("0.0");

            // update timesheet
            tm.updateTimeSheet(timesheetID, tHours, Convert.ToInt32(totalDistanceLBL.Text), Convert.ToInt32(totalTruckLBL.Text), Convert.ToDecimal(totalExpensesLBL.Text), "Updated", " ", " ");
            // update gridview
            summaryGV.DataBind();
        }
        else
        {
            dialogTitle = "Missing Weekending Date";
            msg = "The timesheet needs a verified Weekending Date in order to proceed";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "projectNumInvalid", "throwDialog();", true);
        }
    }
    protected void labTestsBtn_Click(object sender, EventArgs e)
    {
        bool valid = true;
        decimal tHours = Convert.ToDecimal(totalHoursLBL.Text);
        if (weekEndingTB.Text != string.Empty && timesheetID > 0)
        {
            TimesheetManager tm = new TimesheetManager();
            // Sunday
            if (sunLabTB.Text != string.Empty && sunLabTB.Text != "0")
            {
                if (!hoursValidator(sunLabTB.Text, "Sunday",false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Sunday", sunNuclearDensityTestTB.Text, sunLabTB.Text, timesheetID, true, ref tHours);
                sunLabTB.Text = string.Empty;
                sunNuclearDensityTestTB.Text = string.Empty;
            }

            // Monday
            if (monLabTB.Text != string.Empty && monLabTB.Text != "0")
            {
                if (!hoursValidator(monLabTB.Text, "Monday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Monday", monNuclearDensityTestTB.Text, monLabTB.Text, timesheetID, true, ref tHours);
                monLabTB.Text = string.Empty;
                monNuclearDensityTestTB.Text = string.Empty;
            }

            // Tuesday
            if (tuesLabTB.Text != string.Empty && tuesLabTB.Text != "0")
            {
                if (!hoursValidator(tuesLabTB.Text, "Tuesday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Tuesday", tuesNuclearDensityTestTB.Text, tuesLabTB.Text, timesheetID, true, ref tHours);
                tuesLabTB.Text = string.Empty;
                tuesNuclearDensityTestTB.Text = string.Empty;
            }

            // Wednesday
            if (wedsLabTB.Text != string.Empty && wedsLabTB.Text != "0")
            {
                if (!hoursValidator(wedsLabTB.Text, "Wednesday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Wednesday", wedsNuclearDensityTestTB.Text, wedsLabTB.Text, timesheetID, true, ref tHours);
                wedsLabTB.Text = string.Empty;
                wedsNuclearDensityTestTB.Text = string.Empty;
            }
            // Thursday
            if (thursLabTB.Text != string.Empty && thursLabTB.Text != "0")
            {
                if (!hoursValidator(thursLabTB.Text, "Thursday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Thursday", thursNuclearDensityTestTB.Text, thursLabTB.Text, timesheetID, true, ref tHours);
                thursLabTB.Text = string.Empty;
                thursNuclearDensityTestTB.Text = string.Empty;
            }
            // Friday
            if (friLabTB.Text != string.Empty && friLabTB.Text != "0")
            {
                if (!hoursValidator(friLabTB.Text, "Friday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Friday", friNuclearDensityTestTB.Text, friLabTB.Text, timesheetID, true, ref tHours);
                friLabTB.Text = string.Empty;
                friNuclearDensityTestTB.Text = string.Empty;
            }

            // SATURDAY
            if (satLabTB.Text != string.Empty && satLabTB.Text != "0")
            {
                if (!hoursValidator(satLabTB.Text, "Saturday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                tm.createLabTest("Saturday", satNuclearDensityTestTB.Text, satLabTB.Text, timesheetID, true, ref tHours);
                satLabTB.Text = string.Empty;
                satNuclearDensityTestTB.Text = string.Empty;
            }

            totalHoursLBL.Text = tHours.ToString("0.0");
            updateLabTotals();
            // update timesheet
            tm.updateTimeSheet(timesheetID, tHours, Convert.ToInt32(totalDistanceLBL.Text), Convert.ToInt32(totalTruckLBL.Text), Convert.ToDecimal(totalExpensesLBL.Text), "Updated", " ", " ");
            // update gridview
            summaryGV.DataBind();
        }
        else
        {
            msg = "Select Weekending date and Verify before attempting to complete Timesheet";
            dialogTitle = "Error: Weekending Date";

            ScriptManager.RegisterStartupScript(this, this.GetType(), "InvalidEntry", "throwDialog();", true);
        }
    }