protected void nonChargeBtn_Click(object sender, EventArgs e) { bool valid = true; int nCDist = Convert.ToInt32(totalDistanceLBL.Text), tDist = Convert.ToInt32(totalTruckLBL.Text); decimal nCHours = Convert.ToDecimal(totalHoursLBL.Text), nCExpense = Convert.ToDecimal(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.createManagerNonChargeable(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.createManagerNonChargeable(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.createManagerNonChargeable(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.createManagerNonChargeable(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.createManagerNonChargeable(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)) { valid = false; } } if (valid) { timesheetStatusLBL.Text = tm.createManagerNonChargeable(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.createManagerNonChargeable(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 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, tDist, nCExpense, "Updated - Manager", " ", " "); //update totals updateNonChargeableTotals(); // 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 clearChargeable(); // 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; }