protected void btnUpdate_Click(object sender, EventArgs e) { Establishment tempE = EstablishmentDB.getTempEstablishmentByEmail(email.Text); if (ddlStatus.SelectedValue == "pending") { lblOutput.Text = "The status cannot be pending! Please choose approve or dismiss."; return; } else { tempE.Status = ddlStatus.SelectedValue; int num = EstablishmentDB.updatetempStatus(tempE); if (num != 1) { lblOutput.Text = "Cannot Update Status!"; } else { lblOutput.Text = ""; Panel1.Visible = false; SmtpClient client = new SmtpClient("smtp.gmail.com"); client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "inft.3050"); MailMessage msg = new MailMessage("*****@*****.**", tempE.Email); if (ddlStatus.SelectedValue == "approved") { Admins a = AdminDB.getAdminbyEmail(Session["email"].ToString()); Establishment est = new Establishment(tempE.Email, tempE.Name, tempE.Password, tempE.Type, tempE.Phone, tempE.Address, tempE.ID, a); int number = EstablishmentDB.insertEstablishment(est); if (number != 1) { Label2.Text = "Cannot Register to Establishment table!"; return; } else {//sending email to establishment when accept msg.Subject = "Life++ Application!"; msg.Body = "Your request for joining Life++ have been approved. You are now part of our system and can start using now.\n\n Thank you for joining our system. \n\n Team Life++"; client.Send(msg); Label2.Text = "Information successfully Updated! Approval email sent to " + email.Text + " ."; } } else {//sending email to establishment when dismissed msg.Subject = "Life++ Application!"; msg.Body = "Your request for joining Life++ have been dismissed. Thank you for interesting to join our system.\n\n For more information, please contact us at [email protected] \n\n Team Life++ "; client.Send(msg); Label2.Text = "Information successfully Updated! Dismissed email sent to " + email.Text + " ."; } Panel1.Visible = false; List <Establishment> tempestlists = EstablishmentDB.getAllTempEstablishmentsbyStatus("pending"); gvpending.DataSource = tempestlists; gvpending.DataBind(); if (tempestlists.Count == 0) { lblSelectError.Text = "There are no pending request left right now."; } else { lblSelectError.Text = "There are " + tempestlists.Count + " records found"; } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (tbxAEmail.Text == "") { lblEmail.Visible = true; return; } else { lblEmail.Visible = false; } if (tbxName.Text == "") { lblName.Visible = true; return; } else { lblName.Visible = false; } if (tbxPassword.Text == "") { lblPassword.Visible = true; return; } else { lblPassword.Visible = false; } if (tbxPhone.Text == "") { lblPhone.Visible = true; return; } else { lblPhone.Visible = false; } if (tbxAAddress.Text == "") { lblAddress.Visible = true; return; } else { lblAddress.Visible = false; } //check the existing email from the database List <Establishment> alltempesb = EstablishmentDB.getAllTempEstablishments(); foreach (Establishment est in alltempesb) { if (est.Email == tbxAEmail.Text) { lblOutput.Text = "Email already existed! Please change your email or you are already regiestered!"; return; } } Establishment es = new Establishment(tbxAEmail.Text, tbxName.Text, tbxPassword.Text, "Government", Convert.ToInt32(tbxPhone.Text), tbxAAddress.Text); int num = EstablishmentDB.insertTempEstablishment(es); if (num != 1) { lblOutput.Text = "Fail to put to the government tempestablishment account!"; } else { Admins a = AdminDB.getAdminbyEmail(Session["email"].ToString()); Establishment te = EstablishmentDB.getTempEstablishmentByEmail(tbxAEmail.Text); Establishment newG = new Establishment(tbxAEmail.Text, tbxName.Text, tbxPassword.Text, "Government", Convert.ToInt32(tbxPhone.Text), tbxAAddress.Text, te.ID, a); int num2 = EstablishmentDB.insertEstablishment(newG); if (num2 != 1) { lblOutput.Text = "Fail to put to the government establishment account!"; } else { lblOutput.Text = "Government account successfully inserted!"; tbxAAddress.Text = ""; tbxAEmail.Text = ""; tbxName.Text = ""; tbxPassword.Text = ""; tbxPhone.Text = ""; } } }