public Business GetBusinessDetails() { Business business = null; using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetBusinessDetails", CommandType.StoredProcedure)) { if (table.Rows.Count >= 1) { DataRow row = table.Rows[0]; business = new Business(); business.BusinessID = Convert.ToInt32(row["BusinessID"]); business.Name = row["Name"].ToString(); business.PhoneNo = row["PhoneNo"].ToString(); business.Email = row["Email"].ToString(); business.EmailPassword = row["EmailPassword"].ToString(); business.EmailServer = row["EmailServer"].ToString(); business.EmailPort = Convert.ToInt32(row["EmailPort"]); business.AddressLine1 = row["AddressLine1"].ToString(); business.AddressLine2 = row["AddressLine2"].ToString(); business.DepositPercent = Convert.ToInt32(row["DepositPercent"]); business.BankName = row["BankName"].ToString(); business.AccountNo = row["BankAccountNo"].ToString(); business.BranchCode = row["BranchCode"].ToString(); } } return business; }
protected void Page_Load(object sender, EventArgs e) { BusinessHandler businessHandler = new BusinessHandler(); Business business = new Business(); business = businessHandler.GetBusinessDetails(); lblBusinessName.Text = business.Name; /*lblEmail.Text = business.Email; lblAddress1.Text = business.AddressLine1; lblAddress2.Text = business.AddressLine2;*/ }
protected void Page_Load(object sender, EventArgs e) { BusinessHandler businessHandler = new BusinessHandler(); Business business = new Business(); business = businessHandler.GetBusinessDetails(); lblName.Text = business.Name; lblPhoneNo.Text = business.PhoneNo; lblEmail.Text = business.Email; lblServer.Text = business.EmailServer; lblPort.Text = Convert.ToString(business.EmailPort); lblAddressLine1.Text = business.AddressLine1; lblAddressLine2.Text = business.AddressLine2; lblPercentage.Text = Convert.ToString(business.DepositPercent); lblBankName.Text = business.BankName; lblAccountNo.Text = business.AccountNo; lblBranchCode.Text = business.BranchCode; }
public bool UpdateBusinessDetails(Business business) { SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@Name", business.Name), new SqlParameter("@PhoneNo", business.PhoneNo), new SqlParameter("@Email", business.Email), new SqlParameter("@Server", business.EmailServer), new SqlParameter("@Port", business.EmailPort), new SqlParameter("@EmailPassword", business.EmailPassword), new SqlParameter("@Address1", business.AddressLine1), new SqlParameter("@Address2", business.AddressLine2), new SqlParameter("@Percentage", business.DepositPercent), new SqlParameter("@BankName", business.BankName), new SqlParameter("@AccountNo", business.AccountNo), new SqlParameter("@BranchCode", business.BranchCode) }; return DBHelper.ExecuteNonQuery("sp_UpdateBusinessDetails", CommandType.StoredProcedure, parameters); }
public Business GetBusinessDetails() { Business business = null; using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetBusinessDetails", CommandType.StoredProcedure)) { if (table.Rows.Count >= 1) { DataRow row = table.Rows[0]; business = new Business(); business.BusinessID = Convert.ToInt32(row["BusinessID"]); business.Name = row["Name"].ToString(); business.Email = row["Email"].ToString(); business.EmailPassword = row["EmailPassword"].ToString(); business.EmailServer = row["EmailServer"].ToString(); business.EmailPort = Convert.ToInt32(row["EmailPort"]); } } return business; }
protected void Page_Load(object sender, EventArgs e) { lblPercentageIsNumberValidator.Visible = false; business = businessHandler.GetBusinessDetails(); if (IsPostBack == false) { txtName.Text = business.Name; txtPhone.Text = business.PhoneNo; txtEmail.Text = business.Email; txtServer.Text = business.EmailServer; txtPort.Text = Convert.ToString(business.EmailPort); hiddenPassword.Value = Convert.ToString(business.EmailPassword); txtAddressLine1.Text = business.AddressLine1; txtAddressLine2.Text = business.AddressLine2; txtPercentage.Text = Convert.ToString(business.DepositPercent); txtBankName.Text = Convert.ToString(business.BankName); txtAccountNo.Text = Convert.ToString(business.AccountNo); txtBranchCode.Text = Convert.ToString(business.BranchCode); } }
protected void btnEdit_Click(object sender, EventArgs e) { business = new Business(); string option = ""; int num = 0; option = txtPercentage.Text.Trim(); if (int.TryParse(option, out num) == true) { lblPercentageIsNumberValidator.Visible = false; business.Name = txtName.Text; business.PhoneNo = txtPhone.Text; business.Email = txtEmail.Text; business.EmailServer = txtServer.Text; business.EmailPort = Convert.ToInt32(txtPort.Text); business.EmailPassword = hiddenPassword.Value; if (txtPassword.Text != "") { business.EmailPassword = txtPassword.Text; } business.AddressLine1 = txtAddressLine1.Text; business.AddressLine2 = txtAddressLine2.Text; business.DepositPercent = Convert.ToInt32(txtPercentage.Text); business.BankName = txtBankName.Text; business.AccountNo = txtAccountNo.Text; business.BranchCode = txtBranchCode.Text; businessHandler.UpdateBusinessDetails(business); Response.Redirect("Settings.aspx"); } else { lblPercentageIsNumberValidator.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { //get dynamic page info BusinessHandler businessHandler = new BusinessHandler(); Business business = new Business(); business = businessHandler.GetBusinessDetails(); lblBusinessEmail.Text = business.Email; lblDepositPercent.Text = business.DepositPercent.ToString(); }
protected void btnRecoverPassword_Click(object sender, EventArgs e) { LecturerHandler lecturerHandler = new LecturerHandler(); Lecturer lecturer = null; BusinessHandler businessHandler = null; Business business = null; string destinationEmail = txtEmail.Value; //check email exists if (lecturerHandler.ValidateEmail(destinationEmail) == false) { //email doesn't exist in DB litAlert.Text = "<div class='alert alert-danger'>Invalid Email Address</div>"; } else { //get business email and password string name, email, password, emailServer, newPassword; int port; businessHandler = new BusinessHandler(); business = new Business(); business = businessHandler.GetBusinessDetails(); name = business.Name; email = business.Email; password = business.EmailPassword; emailServer = business.EmailServer; port = business.EmailPort; //generate new password newPassword = Membership.GeneratePassword(7, 0); //update database lecturer = new Lecturer(); lecturer.Email = destinationEmail; lecturer.Password = newPassword; //send email try { MailMessage mail = new MailMessage(); SmtpClient smtpClient = new SmtpClient(emailServer); mail.From = new MailAddress(email); mail.To.Add(destinationEmail); mail.Subject = name + " Password Reset"; mail.Body = "Your password has been reset. Please use the following phrase as your new password when you log in: " + newPassword; //code to include an attatchment //System.Net.Mail.Attachment attachment; //attachment = new System.Net.Mail.Attachment("attatchment.jpg"); //mail.Attachments.Add(attachment); smtpClient.Port = port; smtpClient.Credentials = new NetworkCredential(email, password); smtpClient.EnableSsl = true; smtpClient.Send(mail); lecturerHandler.UpdateLecturerPassword(lecturer); litAlert.Text = "<div class='alert alert-success'>An email was sent, check you email for your new password.</div>"; //delay redirect to alert user of page change /*lblRedirect.Text = "Redirecting to log in, in 5 seconds."; Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"Login.aspx\"; }, 5000);</script>");*/ } catch (Exception) { litAlert.Text = "<div class='alert alert-warning'>Failed to send an email</div>"; } } }
protected void SendMail(int bookingID, bool confirmed) { //get member who created the booking BookingHandler bookingHandler = new BookingHandler(); int memberID = bookingHandler.GetBookingOwner(bookingID); //the get members email MemberHandler memberHandler = new MemberHandler(); Member member = new Member(); member = memberHandler.GetMemberDetails(memberID); BusinessHandler businessHandler = null; Business business = null; //get business email and password string businessName, businessEmail, businessPassword, emailServer; int port; businessHandler = new BusinessHandler(); business = new Business(); business = businessHandler.GetBusinessDetails(); businessName = business.Name; businessEmail = business.Email; businessPassword = business.EmailPassword; emailServer = business.EmailServer; port = business.EmailPort; //send email MailMessage mail = new MailMessage(); SmtpClient smtpClient = new SmtpClient(emailServer); mail.From = new MailAddress(businessEmail); mail.To.Add(member.Email); if (confirmed) { mail.Subject = businessName + " Booking Confirmed"; mail.Body = "We are pleased to inform you, your booking at " + businessName + " has been confirmed. Please supply the following booking referance number when checking in: " + bookingID.ToString(); } else { mail.Subject = businessName + " Booking Declined"; mail.Body = "We are sad to inform you, your booking at " + businessName + " has been declined. If you have any queries please contact us for assistance."; } smtpClient.Port = port; smtpClient.Credentials = new NetworkCredential(businessEmail, businessPassword); smtpClient.EnableSsl = true; smtpClient.Send(mail); memberHandler.UpdateMemberPassword(member); /* lblProgress.CssClass = "label label-success"; lblProgress.Text = "An email was sent, check you email for your new password."; //delay redirect to alert user of page change lblRedirect.Text = "Redirecting to log in, in 5 seconds."; Response.Write("<script type=\"text/javascript\">setTimeout(function () { window.location.href = \"Login.aspx\"; }, 5000);</script>"); */ }
public bool UpdateBusinessDetails(Business business) { return businessDB.UpdateBusinessDetails(business); }