protected void updateChargeableBtn_Click(object sender, EventArgs e) { TimesheetManager tm = new TimesheetManager(); bool result, valid = false; 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 (sunBCHoursTB.Text != string.Empty) { if (!hoursValidator(sunBCHoursTB.Text, "Sunday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(sunBCHoursTB.Text, sunBAccomTB.Text, sunBDistTB.Text, sunTruckDistTB.Text, sunBMiscTB.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.createManagerChargeable(sunBCHoursTB.Text, sunBAccomTB.Text, sunBDistTB.Text, monTruckDistTB.Text, sunBMiscTB.Text, "Sunday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, sunCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // monday if (monBCHoursTB.Text != string.Empty) { if (!hoursValidator(monBCHoursTB.Text, "Monday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(monBCHoursTB.Text, monBAccomTB.Text, monBDistTB.Text, monTruckDistTB.Text, monBMiscTB.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.createManagerChargeable(monBCHoursTB.Text, monBAccomTB.Text, monBDistTB.Text, monTruckDistTB.Text, monBMiscTB.Text, "Monday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, monCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // tuesday if (tuesBCHoursTB.Text != string.Empty) { if (!hoursValidator(tuesBCHoursTB.Text, "Tuesday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(tuesBCHoursTB.Text, tuesBAccomTB.Text, tuesBDistTB.Text, tuesTruckDistTB.Text, tuesBMiscTB.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.createManagerChargeable(tuesBCHoursTB.Text, tuesBAccomTB.Text, tuesBDistTB.Text, tuesTruckDistTB.Text, tuesBMiscTB.Text, "Tuesday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, tuesCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Wednesday if (wedsBCHoursTB.Text != string.Empty) { if (!hoursValidator(wedsBCHoursTB.Text, "Wednesday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(wedsBCHoursTB.Text, wedsBAccomTB.Text, wedsBDistTB.Text, wedsTruckDistTB.Text, wedsBMiscTB.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.createManagerChargeable(wedsBCHoursTB.Text, wedsBAccomTB.Text, wedsBDistTB.Text, wedsTruckDistTB.Text, wedsBMiscTB.Text, "Wednesday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, wedsCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Thursday if (thursBCHoursTB.Text != string.Empty) { if (!hoursValidator(thursBCHoursTB.Text, "Thursday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(thursBCHoursTB.Text, thursBAccomTB.Text, thursBDistTB.Text, thursTruckDistTB.Text, thursBMiscTB.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.createManagerChargeable(thursBCHoursTB.Text, thursBAccomTB.Text, thursBDistTB.Text, thursTruckDistTB.Text, thursBMiscTB.Text, "Thursday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, thursCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // friday if (friBCHoursTB.Text != string.Empty) { if (!hoursValidator(friBCHoursTB.Text, "Friday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(friBCHoursTB.Text, friBAccomTB.Text, friBDistTB.Text, friTruckDistTB.Text, friBMiscTB.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.createManagerChargeable(friBCHoursTB.Text, friBAccomTB.Text, friBDistTB.Text, friTruckDistTB.Text, friBMiscTB.Text, "Friday", projectNumTB.Text, classificationDDL.SelectedValue, activitiesDDL.SelectedValue, timesheetID, friCRemarksTB.Text, ref cHours, ref cDist, ref tDist, ref cExpense); } } // Saturday if (satBCHoursTB.Text != string.Empty) { if (!hoursValidator(satBCHoursTB.Text, "Saturday", true)) { valid = false; } } if (valid) { result = tm.updateManagerChargeable(satBCHoursTB.Text, satBAccomTB.Text, satBDistTB.Text, satTruckDistTB.Text, satBMiscTB.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.createManagerChargeable(satBCHoursTB.Text, satBAccomTB.Text, satBDistTB.Text, satTruckDistTB.Text, satBMiscTB.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.#"); 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); } tm.updateTimeSheet(timesheetID, cHours, cDist, tDist, cExpense, "Updated - Manager", " ", " "); // update totals updateChargeableTotals(); // update gridview summaryGV.DataBind(); updateChargeableBtn.Visible = false; chargeableBtn.Visible = true; // clear form fields clearChargeable(); // chargeable fields clientNameTB.Text = string.Empty; projectNameTB.Text = string.Empty; projectNumTB.Text = string.Empty; classificationDDL.Items.Clear(); activitiesDDL.Items.Clear(); }