protected void nonChargeBtn_Click(object sender, EventArgs e)
    {
        if (weekEndingTB.Text != string.Empty && timesheetID > 0)
        {
            bool valid = true;
            int nCDist = Convert.ToInt32(totalDistanceLBL.Text);
            decimal nCHours = Convert.ToDecimal(totalHoursLBL.Text), nCExpense = Convert.ToDecimal(totalExpensesLBL.Text);

            TimesheetManager tm = new TimesheetManager();

            // sunday
            if (sunNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(sunNCHoursTB.Text, "Sunday", false))
                {
                    valid = false;
                }
            }
            if (valid)
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(sunNCHoursTB.Text, sunNCAccomTB.Text, sunNCDistanceTB.Text, sunNCMiscTB.Text, "Sunday",
                         detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, sunNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }

            // monday

            if (monNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(monNCHoursTB.Text, "Monday", false))
                {
                    valid = false;
                }
            }
            if (valid)
                {
                    timesheetStatusLBL.Text = tm.createNonChargeable(monNCHoursTB.Text, monNCAccomTB.Text, monNCDistanceTB.Text, monNCMiscTB.Text, "Monday",
                       detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, monNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
                }

            // tuesday

            if (tuesNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(tuesNCHoursTB.Text, "Tuesday", false))
                {
                    valid = false;
                }
            }
                 if (valid)
                {
                    timesheetStatusLBL.Text = tm.createNonChargeable(tuesNCHoursTB.Text, tuesNCAccomTB.Text, tuesNCDistanceTB.Text, tuesNCMiscTB.Text, "Tuesday",
                    detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, tuesNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
                }

            // wednessday
            if (wedsNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(wedsNCHoursTB.Text, "Wednesday", false))
                {
                    valid = false;
                }
            }

                    if (valid)
        {
        timesheetStatusLBL.Text = tm.createNonChargeable(wedsNCHoursTB.Text, wedsNCAccomTB.Text, wedsNCDistanceTB.Text, wedsNCMiscTB.Text, "Wednesday",
            detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, tuesNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
        }

            // thursday
            if (thursNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(thursNCHoursTB.Text, "Thursday", false))
                {
                    valid = false;
                      }
            }
                    if (valid)
        {
        timesheetStatusLBL.Text = tm.createNonChargeable(thursNCHoursTB.Text, thursNCAccomTB.Text, thursNCDistanceTB.Text, thursNCMiscTB.Text, "Thursday",
            detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, thursNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
        }

            // friday
            if (friNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(friNCHoursTB.Text, "Friday", false))
                {
                        }
            }
                    if (valid)
        {
        timesheetStatusLBL.Text = tm.createNonChargeable(friNCHoursTB.Text, friNCAccomTB.Text, friNCDistanceTB.Text, friNCMiscTB.Text, "Friday",
             detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, friNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
        }

            // saturday
            if (satNCHoursTB.Text != string.Empty)
            {
                if (!hoursValidator(satNCHoursTB.Text, "Saturday", false))
                {
                    valid = false;
                       }
            }
                    if (valid)
        {
        timesheetStatusLBL.Text = tm.createNonChargeable(satNCHoursTB.Text, satNCAccomTB.Text, satNCDistanceTB.Text, satNCMiscTB.Text, "Saturday",
               detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, satNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
        }

            // add the totalized labels except truck which does not apply to non-chargeable
            totalHoursLBL.Text = nCHours.ToString("0.#");
            totalExpensesLBL.Text = nCExpense.ToString("0.####");
            totalDistanceLBL.Text = nCDist.ToString();
            // if hours exceed 60 throw a dialog
            if (Convert.ToDecimal(totalHoursLBL.Text) > MAX_WEEKLY_HOURS)
            {
                // throw a dialog
                dialogTitle = "Regular Hours Exceeded";
                msg = "A separate Form must be filled out to accomodate overtime";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "projectNumInvalid", "throwDialog();", true);
            }

            // update timesheet
            tm.updateTimeSheet(timesheetID, nCHours, nCDist, -1, nCExpense, "Updated", " ", " ");

            // update gridview
            summaryGV.DataBind();

            // populate generic non-chargeable drop down list elements
            specifyDDL.DataSource = tm.getWorkType();
            specifyDDL.DataBind();
            specifyDDL.Items.Insert(0, "Select");
            detailsDDL.DataSource = tm.getExpenses();
            detailsDDL.DataBind();
            detailsDDL.Items.Insert(0, "Select");

            // clear form fields
            clearNonChargeable();
            // update totals

            updateNonChargeableTotals();
            // reset drop down list to first index
            detailsDDL.SelectedIndex = 0;
            specifyDDL.SelectedIndex = 0;
            NonChargeHoursPanel.Visible = false;
            NonChargeExpensesPanel.Visible = false;
            updateNonChargeableBtn.Visible = false;
            nonChargeBtn.Visible = true;
        }
        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 updateNonChargeableBtn_Click(object sender, EventArgs e)
    {
        TimesheetManager tm = new TimesheetManager();
        bool result, valid = true;
        int count = 0, nCDist = Convert.ToInt32(totalDistanceLBL.Text), tDist = Convert.ToInt32(totalTruckLBL.Text);
        decimal nCHours = Convert.ToDecimal(totalHoursLBL.Text), nCExpense = Convert.ToDecimal(Convert.ToDecimal(totalExpensesLBL.Text));

        //sunday
        if (sunNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(sunNCHoursTB.Text, "Sunday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(sunNCHoursTB.Text, sunNCAccomTB.Text, sunNCDistanceTB.Text, sunNCMiscTB.Text, "Sunday",
                 detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, sunNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(sunNCHoursTB.Text, sunNCAccomTB.Text, sunNCDistanceTB.Text, sunNCMiscTB.Text, "Sunday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, sunNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // monday
        if (monNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(monNCHoursTB.Text, "Monday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(monNCHoursTB.Text, monNCAccomTB.Text, monNCDistanceTB.Text, monNCMiscTB.Text, "Monday",
                  detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, monNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(monNCHoursTB.Text, monNCAccomTB.Text, monNCDistanceTB.Text, monNCMiscTB.Text, "Monday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, monNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // tuesday
        if (tuesNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(tuesNCHoursTB.Text, "Tuesday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(tuesNCHoursTB.Text, tuesNCAccomTB.Text, tuesNCDistanceTB.Text, tuesNCMiscTB.Text, "Tuesday",
                 detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, tuesNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(tuesNCHoursTB.Text, tuesNCAccomTB.Text, tuesNCDistanceTB.Text, tuesNCMiscTB.Text, "Tuesday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, tuesNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // wednessday
        if (wedsNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(wedsNCHoursTB.Text, "Wednesday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(wedsNCHoursTB.Text, wedsNCAccomTB.Text, wedsNCDistanceTB.Text, wedsNCMiscTB.Text, "Wednesday",
            detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, wedsNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(wedsNCHoursTB.Text, wedsNCAccomTB.Text, wedsNCDistanceTB.Text, wedsNCMiscTB.Text, "Wednesday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, wedsNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // thursday
        if (thursNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(thursNCHoursTB.Text, "Thursday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(thursNCHoursTB.Text, thursNCAccomTB.Text, thursNCDistanceTB.Text, thursNCMiscTB.Text, "Thursday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, thursNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(thursNCHoursTB.Text, thursNCAccomTB.Text, thursNCDistanceTB.Text, thursNCMiscTB.Text, "Thursday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, thursNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // friday
        if (friNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(friNCHoursTB.Text, "Friday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(friNCHoursTB.Text, friNCAccomTB.Text, friNCDistanceTB.Text, friNCMiscTB.Text, "Friday",
            detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, friNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(friNCHoursTB.Text, friNCAccomTB.Text, friNCDistanceTB.Text, friNCMiscTB.Text, "Friday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, friNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // saturday
        if (satNCHoursTB.Text != string.Empty)
        {
            if (!hoursValidator(satNCHoursTB.Text, "Saturday", true))
            {
                valid = false;
            }
        }
        if (valid)
        {
            result = tm.updateNonChargeable(satNCHoursTB.Text, satNCAccomTB.Text, satNCDistanceTB.Text, satNCMiscTB.Text, "Saturday",
             detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, satNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);

            if (result)
            {
                count++;
                timesheetStatusLBL.Text = count + " Row(s) Updated Successfully";
            }
            else
            {
                timesheetStatusLBL.Text = tm.createNonChargeable(satNCHoursTB.Text, satNCAccomTB.Text, satNCDistanceTB.Text, satNCMiscTB.Text, "Saturday",
                detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, satNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense);
            }
        }

        // update the totalized labels
        totalHoursLBL.Text = nCHours.ToString("0.0");
        totalExpensesLBL.Text = nCExpense.ToString("0.00##");
        totalDistanceLBL.Text = nCDist.ToString();

        // if hours exceed 60 throw a dialog
        if (nCHours > MAX_WEEKLY_HOURS)
        {
            // throw a dialog
            dialogTitle = "Regular Weekly Hours Exceeded";
            msg = "You Worked more than 60 hours. A separate Form must be filled out to accomodate overtime";
            ScriptManager.RegisterStartupScript(this, this.GetType(), "projectNumInvalid", "throwDialog();", true);
        }

        tm.updateTimeSheet(timesheetID, nCHours, nCDist, tDist, nCExpense, "Updated", " ", " ");
        // update gridview
        summaryGV.DataBind();
        // clear form fields
        clearNonChargeable();
        // update totals
        updateNonChargeableTotals();
        // reset drop down list to first index
        detailsDDL.SelectedIndex = 0;
        specifyDDL.SelectedIndex = 0;
        NonChargeHoursPanel.Visible = false;
        NonChargeExpensesPanel.Visible = false;

        updateNonChargeableBtn.Visible = false;
        nonChargeBtn.Visible = true;
    }