protected void updateChargeableBtn_Click(object sender, EventArgs e) { TimesheetManager tm = new TimesheetManager(); bool result, valid = true; int count = 0, cDist = Convert.ToInt32(totalDistanceLBL.Text), tDist = Convert.ToInt32(totalTruckLBL.Text); decimal cHours = Convert.ToDecimal(totalHoursLBL.Text), cExpense = Convert.ToDecimal(Convert.ToDecimal(totalExpensesLBL.Text)); ; int id = tm.idForProjectNo(projectNumTB.Text); // sunday if (sunCHoursTB.Text != string.Empty) { if (!hoursValidator(sunCHoursTB.Text, "Sunday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(sunCHoursTB.Text, sunAccomTB.Text, sunDistTB.Text, sunTruckDistTB.Text, sunMiscTB.Text, "Sunday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, sunCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(sunCHoursTB.Text, sunAccomTB.Text, sunDistTB.Text, sunTruckDistTB.Text, sunMiscTB.Text, "Sunday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, sunCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // monday if (monCHoursTB.Text != string.Empty) { if (!hoursValidator(monCHoursTB.Text, "Monday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(monCHoursTB.Text, monAccomTB.Text, monDistTB.Text, monTruckDistTB.Text, monMiscTB.Text, "Monday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, monCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(monCHoursTB.Text, monAccomTB.Text, monDistTB.Text, monTruckDistTB.Text, monMiscTB.Text, "Monday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, monCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // tuesday if (tuesCHoursTB.Text != string.Empty) { if (!hoursValidator(tuesCHoursTB.Text, "Tuesday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(tuesCHoursTB.Text, tuesAccomTB.Text, tuesDistTB.Text, tuesTruckDistTB.Text, tuesMiscTB.Text, "Tuesday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, tuesCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(tuesCHoursTB.Text, tuesAccomTB.Text, tuesDistTB.Text, tuesTruckDistTB.Text, tuesMiscTB.Text, "Tuesday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, tuesCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Wednesday if (wedsCHoursTB.Text != string.Empty) { if (!hoursValidator(wedsCHoursTB.Text, "Wednesday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(wedsCHoursTB.Text, wedsAccomTB.Text, wedsDistTB.Text, wedsTruckDistTB.Text, wedsMiscTB.Text, "Wednesday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, wedsCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(wedsCHoursTB.Text, wedsAccomTB.Text, wedsDistTB.Text, wedsTruckDistTB.Text, wedsMiscTB.Text, "Wednesday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, wedsCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Thursday if (thursCHoursTB.Text != string.Empty) { if (!hoursValidator(thursCHoursTB.Text, "Thursday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(thursCHoursTB.Text, thursAccomTB.Text, thursDistTB.Text, thursTruckDistTB.Text, thursMiscTB.Text, "Thursday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, thursCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(thursCHoursTB.Text, thursAccomTB.Text, thursDistTB.Text, thursTruckDistTB.Text, thursMiscTB.Text, "Thursday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, thursCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // friday if (friCHoursTB.Text != string.Empty) { if (!hoursValidator(friCHoursTB.Text, "Friday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(friCHoursTB.Text, friAccomTB.Text, friDistTB.Text, friTruckDistTB.Text, friMiscTB.Text, "Friday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, friCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(friCHoursTB.Text, friAccomTB.Text, friDistTB.Text, friTruckDistTB.Text, friMiscTB.Text, "Friday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, friCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Saturday if (satCHoursTB.Text != string.Empty) { if (!hoursValidator(satCHoursTB.Text, "Saturday", true)) { valid = false; } } if (valid) { result = tm.updateChargeable(satCHoursTB.Text, satAccomTB.Text, satDistTB.Text, satTruckDistTB.Text, satMiscTB.Text, "Saturday", id, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, satCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); if (result) { count++; } else { timesheetStatusLBL.Text = tm.createChargeable(satCHoursTB.Text, satAccomTB.Text, satDistTB.Text, satTruckDistTB.Text, satMiscTB.Text, "Saturday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, satCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // update the totalized labels totalHoursLBL.Text = cHours.ToString("0.0"); totalExpensesLBL.Text = cExpense.ToString("0.00##"); totalDistanceLBL.Text = cDist.ToString(); totalTruckLBL.Text = tDist.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); } // 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(), "FillOTForm", "throwDialog();", true); } tm.updateTimeSheet(timesheetID, cHours, cDist, tDist, cExpense, "Updated", " ", " "); // update gridview summaryGV.DataBind(); updateChargeableBtn.Visible = false; chargeableBtn.Visible = true; // update totals updateChargeableTotals(); updateLabTotals(); updateNonChargeableTotals(); // clear form fields clearChargeable(); // chargeable fields clientNameTB.Text = string.Empty; projectNameTB.Text = string.Empty; projectNumTB.Text = string.Empty; classificationDDL.Items.Clear(); activitiesDDL.Items.Clear(); }