/// <summary> /// check hours if they were entered /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void updateNonChargeableBtn_Click(object sender, EventArgs e) { TimesheetManager tm = new TimesheetManager(); bool result, valid = true; int count = 0, nCDist = Convert.ToInt32(totalDistanceLBL.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.updateManagerNonChargeable(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.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(sunNCHoursTB.Text, "Monday", true)) { valid = false; } } if (valid) { result = tm.updateManagerNonChargeable(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.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(sunNCHoursTB.Text, "Tuesday", true)) { valid = false; } } if (valid) { result = tm.updateManagerNonChargeable(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.createManagerNonChargeable(tuesNCHoursTB.Text, tuesNCAccomTB.Text, tuesNCDistanceTB.Text, tuesNCMiscTB.Text, "Tuesday", detailsDDL.SelectedValue, specifyDDL.SelectedValue, timesheetID, tuesNCRemarksTB.Text, ref nCHours, ref nCDist, ref nCExpense); } } // wednesday if (wedsNCHoursTB.Text != string.Empty) { if (!hoursValidator(wedsNCHoursTB.Text, "Wednesday", true)) { valid = false; } } if (valid) { result = tm.updateManagerNonChargeable(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.createManagerNonChargeable(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.updateManagerNonChargeable(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.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", true)) { valid = false; } } if (valid) { result = tm.updateManagerNonChargeable(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.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", true)) { valid = false; } } if (valid) { result = tm.updateManagerNonChargeable(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.createManagerNonChargeable(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.#"); totalExpensesLBL.Text = nCExpense.ToString("0.####"); totalDistanceLBL.Text = nCDist.ToString(); // if hours exceed 60 throw a dialog if (nCHours > 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, nCHours, nCDist, -1, nCExpense, "Updated - Manager", " ", " "); // update totals updateNonChargeableTotals(); // update gridview summaryGV.DataBind(); // clear form fields clearNonChargeable(); // 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; }