protected void Button_login_Click(object sender, EventArgs e) { // Initialise connection as client to SOAP service. Employee_WebApp.WebAppServiceReference.TheWebServiceSoapClient client = new WebAppServiceReference.TheWebServiceSoapClient(); try { // Attempt to login with form data if (client.login_employee(TextBox_email.Text, TextBox_password.Text) == false) { // IF it failed then show error to notify user of system status. Response.Write("Failed to log you in"); } else { // IF login was successful Session["CurrentUser"] = TextBox_email.Text; // Start a session // Redirect to holiday page on successful login Response.Redirect("SubmitHoliday.aspx"); } } catch (Exception es) { Console.WriteLine(es); } }
protected void Page_Load(object sender, EventArgs e) { // Initialise connection as client to SOAP service. Employee_WebApp.WebAppServiceReference.TheWebServiceSoapClient client = new WebAppServiceReference.TheWebServiceSoapClient(); try { // Get holidays for user using the session started on login. var holidays_avail = client.get_outstanding_holiday_requests_for_employee(Session["CurrentUser"].ToString()); // Display data in table. foreach (var holiday in holidays_avail) { // Define a row to host the the data TableRow row = new TableRow(); // Cells for each column TableCell Firstcell = new TableCell(); TableCell SecondCell = new TableCell(); TableCell ThirdCell = new TableCell(); // Set text for each holiday Firstcell.Text = $"{holiday.Holiday_start}"; SecondCell.Text = $"{holiday.Holiday_end}"; ThirdCell.Text = $"{holiday.Holiday_status}"; // Add the populated cell to this row row.Cells.Add(Firstcell); row.Cells.Add(SecondCell); row.Cells.Add(ThirdCell); // Add modified row to table. Table1.Rows.Add(row); } } catch (Exception es) { Console.WriteLine(es); } }
protected void Button_submitHoliday_Click(object sender, EventArgs e) { // Initialise connection as client to SOAP service. Employee_WebApp.WebAppServiceReference.TheWebServiceSoapClient client = new WebAppServiceReference.TheWebServiceSoapClient(); // On Submission of holiday do stuff try { // Submit user holiday request on submit button click client.submit_holiday_with_constraint_checking(Session["CurrentUser"].ToString(), Convert.ToDateTime(TextBox_holidayStart.Text), Convert.ToDateTime(TextBox_holidayEnd.Text)); // Clear textboxes on successful submission TextBox_holidayStart.Text = ""; TextBox_holidayEnd.Text = ""; Response.Write("<script> alert('Your holiday was successfully submitted!'); </script>"); } catch (Exception es) { // Show an error if it failed. Response.Write("<script> alert('Failed to submit holiday, please check the format of the dates you entered!'); </script>"); Console.WriteLine(es); } }