protected void btnSubmit_Click(object sender, EventArgs e) { //if (!Page.IsValid) //{ // return; //} if (String.IsNullOrEmpty(txtPassword.Text)) { lblVerifyError.Visible = true; lblVerifyError.Text = "Password field cannot be empty"; ScriptManager.RegisterStartupScript(this, GetType(), "emailPopup", "document.body.style.padding = '0';$('.modal-backdrop').remove();$('#emailModal').modal('show');", true); return; } if (!VerifyLoginUser(Context.User.Identity.Name, txtPassword.Text)) { lblVerifyError.Visible = true; lblVerifyError.Text = "Incorrect password!"; ScriptManager.RegisterStartupScript(this, GetType(), "emailPopup", "document.body.style.padding = '0';$('.modal-backdrop').remove();$('#emailModal').modal('show');", true); return; } ScriptManager.RegisterStartupScript(this, GetType(), "emailPopup", "document.body.style.padding = '0';$('.modal-backdrop').remove();$('#emailModal').modal('hide');", true); var purchaseItems = (List <PurchaseItem>)Session["purchaseItems"]; try { List <PurchaseOrder> poList = scController.CreatePurchaseOrders(purchaseItems, Context.User.Identity.Name); Session["CreatedPO"] = true; //send email string fromEmail = emailController.GetUserEmail(Context.User.Identity.Name); string password = txtPassword.Text; string username = Context.User.Identity.Name; try { emailController.CreatePurchaseOrdersSendEmail(fromEmail, password, username, poList); //Session["SendCreatePOEmail"] = true; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Purchase orders have been successfully created! Email notifications have been sent successfully!');window.location ='ViewPurchaseOrders';", true); } catch (Exception ex) { //Session["SendCreatePOEmail"] = false; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Purchase orders have been successfully created! However an error has occurred when sending email!');window.location ='ViewPurchaseOrders';", true); } } catch (Exception ex) { //Session["CreatedPO"] = false; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('An error has occurred when creating purchase orders!');window.location ='ViewPurchaseOrders';", true); } Session["purchaseItems"] = null; //Response.Redirect("/Store/ViewPurchaseOrders"); }