protected void btnSubmit_Click(Object Sender, EventArgs e) { bool boolApprove = (oApplication.Get(intApplication, "approve_vacation") == "1"); string strEmployees = oApplication.Get(intApplication, "employees_needed"); int intEmployees = 0; if (strEmployees != "") { intEmployees = Int32.Parse(strEmployees); } DataSet dsEmployees = oUser.GetApplication(intApplication); DateTime _date = DateTime.Today; string strError = ""; DateTime _start = DateTime.Parse(txtStart.Text); TimeSpan oSpan = new TimeSpan(); oSpan = _start.Subtract(_date); int intManager = oUser.GetManager(intProfile, true); if (oSpan.Days < intLeadDays) { boolApprove = true; } if (radDays.Checked == true) { DateTime _end = DateTime.Parse(txtEnd.Text); while (_start <= _end) { DataSet dsOff = oVacation.Get(_start, intApplication); int intDiff = dsEmployees.Tables[0].Rows.Count - dsOff.Tables[0].Rows.Count; if (intDiff > intEmployees) { if (_start.DayOfWeek != System.DayOfWeek.Saturday && _start.DayOfWeek != System.DayOfWeek.Sunday) { int intVacation = oVacation.Add(intProfile, intApplication, _start, (radMorning.Checked ? 1 : 0), (radAfternoon.Checked ? 1 : 0), (radVacation.Checked ? 1 : 0), (radHoliday.Checked ? 1 : 0), (radPersonal.Checked ? 1 : 0), ddlReason.SelectedItem.Value, (boolApprove ? 0 : 1)); if (boolApprove == true) { string strDefault = oUser.GetApplicationUrl(intManager, intVacationPage); if (strDefault == "") { oFunction.SendEmail("ClearView Out of Office Request", oUser.GetName(intManager), "", strEMailIdsBCC, "ClearView Out of Office Request", "<p><b>The following out of office request requires your approval...</b><p><p>" + oVacation.GetBody(intVacation, intEnvironment) + "</p>", true, false); } else { oFunction.SendEmail("ClearView Out of Office Request", oUser.GetName(intManager), "", strEMailIdsBCC, "ClearView Out of Office Request", "<p><b>The following out of office request requires your approval...</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(intVacationPage) + "?id=" + intVacation.ToString() + "\" target=\"_blank\">Click here to view this out of office request.</a></p><p>" + oVacation.GetBody(intVacation, intEnvironment) + "</p>", true, false); } } } } else { strError += "<tr><td>" + _start.ToShortDateString() + "</td></tr>"; } _start = _start.AddDays(1); } } else { DataSet dsOff = oVacation.Get(_start, intApplication); int intDiff = dsEmployees.Tables[0].Rows.Count - dsOff.Tables[0].Rows.Count; if (intDiff > intEmployees) { if (_start.DayOfWeek != System.DayOfWeek.Saturday && _start.DayOfWeek != System.DayOfWeek.Sunday) { int intVacation = oVacation.Add(intProfile, intApplication, _start, (radMorning.Checked ? 1 : 0), (radAfternoon.Checked ? 1 : 0), (radVacation.Checked ? 1 : 0), (radHoliday.Checked ? 1 : 0), (radPersonal.Checked ? 1 : 0), ddlReason.SelectedItem.Value, (boolApprove ? 0 : 1)); if (boolApprove == true) { string strDefault = oUser.GetApplicationUrl(intManager, intVacationPage); if (strDefault == "") { oFunction.SendEmail("ClearView Out of Office Request", oUser.GetName(intManager), "", strEMailIdsBCC, "ClearView Out of Office Request", "<p><b>The following out of office request requires your approval...</b><p><p>" + oVacation.GetBody(intVacation, intEnvironment) + "</p>", true, false); } else { oFunction.SendEmail("ClearView Out of Office Request", oUser.GetName(intManager), "", strEMailIdsBCC, "ClearView Out of Office Request", "<p><b>The following out of office request requires your approval...</b><p><p><a href=\"" + oVariable.URL() + "/redirect.aspx?referrer=/" + strDefault + oPage.GetFullLink(intVacationPage) + "?id=" + intVacation.ToString() + "\" target=\"_blank\">Click here to view this out of office request.</a></p><p>" + oVacation.GetBody(intVacation, intEnvironment) + "</p>", true, false); } } } } else { strError += "<tr><td>" + _start.ToShortDateString() + "</td></tr>"; } } try { _date = DateTime.Parse(ddlMonth.SelectedItem.Value + "/1/" + ddlYear.SelectedItem.Value); } catch { } if (strError == "") { Response.Redirect(oPage.GetFullLink(intPage) + "?d=" + Server.UrlPathEncode(_date.ToShortDateString())); } else { lblError.Text += "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">" + strError + "</table>"; } }