protected void Button2_submit_Click(object sender, EventArgs e) { DateTime t2 = Convert.ToDateTime("04:59:59 PM"); DateTime t1 = Convert.ToDateTime(TextBox_timeAndDay.Text); if (TimeSpan.Compare(t1.TimeOfDay, t2.TimeOfDay) == 1) //forward to warden { int i = Data_Access.apply_sameDayLeave(Session["sap_id"].ToString(), t1.Date.ToString(), TextBox_reason_sameDay.Text, t1.TimeOfDay.ToString()); if (i == 0) { Label_sameDay_result.Text = "You have already applied for same day leave"; Label_sameDay_result.Visible = true; } else { Label_sameDay_result.Text = "Successfully Applied for Leave"; Label_sameDay_result.Visible = true; } } else { String mentor_email; String i = Data_Access.Apply_Leave(Session["sap_id"].ToString(), t1.Date.ToString(), t1.Date.ToString(), TextBox_reason_sameDay.Text, out mentor_email, 1); Label_sameDay_result.Text = i; Label_sameDay_result.Visible = true; Data_Access.MailSend(mentor_email, "Same Day Leave", "Same day leave has been posted, you may take your action before 4:00 PM"); } }
protected void Button_applyLeave_Click(object sender, EventArgs e) { if (Page.IsValid) { DateTime start_time = Convert.ToDateTime(TextBox_date_from.Text) + new TimeSpan(16, 59, 59); DateTime return_time = Convert.ToDateTime(TextBox_date_from.Text) + new TimeSpan(21, 59, 59); DateTime departure_time = Convert.ToDateTime(TextBox_time_departure.Text); DateTime arrival_time = Convert.ToDateTime(TextBox_time_arrival.Text); if (TimeSpan.Compare(departure_time.TimeOfDay, start_time.TimeOfDay) == 1) { int i = Data_Access.apply_sameDayLeave(Session["sap_id"].ToString(), TextBox_date_from.Text, TextBox_reason.Text, TextBox_time_departure.Text); if (i == 1) { Response.Write("forwarded to warden"); } } else { Response.Write("forward to hod"); } } }