private void button3_Click(object sender, EventArgs e) { if (BranchAddressTextBox.Text == "" || BranchPhoneNumberTextBox.Text == "" || BranchEmailTextBox.Text == "") { MessageBox.Show("Please enter All Values To Insert New Branch"); return; } string Address = Convert.ToString(BranchAddressTextBox.Text); string phonenumber = Convert.ToString(BranchPhoneNumberTextBox.Text); string Email = Convert.ToString(BranchEmailTextBox.Text); if (!Validation.IsValidEmail(Email)) { MessageBox.Show("Enter valid email address"); return; } if (!Validation.IsPhoneNumberVlidate(phonenumber)) { MessageBox.Show("Enter valid phone number"); return; } int T = 0; T = controllerObj.CheckIfEmailExist(Email); if (T != 0) { MessageBox.Show("Please choose another Email.It already exists."); return; } if (phonenumber != "") { T = 0; T = controllerObj.CheckIfPhoneNumberExist(phonenumber); if ((T != 0)) { MessageBox.Show("Please choose another Phone Number.It already exists."); return; } } int r = controllerObj.AddNewBranch(Address, Email, phonenumber); if (r > 0) { MessageBox.Show("New Branch is Inserted"); } else { MessageBox.Show("insertation failed"); } }
private void SaveButton_Click(object sender, EventArgs e) { int i = 0; if (PasswordtextBox.ReadOnly) { try { String Email = EmailtextBox.Text; String Password = PasswordtextBox.Text; String PhoneNumber = PNumbertextBox.Text; if (!Validation.IsValidEmail(Email)) { MessageBox.Show("Please enter a valid Email Adress"); return; } if (!Validation.IsPasswordValid(Password)) { MessageBox.Show("Please enter a valid Password \n" + "It should contain at least one number,one uppercase letter and 8 letters"); return; } if (!String.IsNullOrEmpty(PhoneNumber)) { if (!Validation.IsPhoneNumberVlidate(PhoneNumber)) { MessageBox.Show("Please enter a valid Phone Number \n"); return; } } i = controllerObj.UpdateStaff( FNametextBox.Text.ToString(), LNametextBox.Text.ToString(), EmailtextBox.Text.ToString(), PNumbertextBox.Text.ToString(), Convert.ToInt32(IDTextBox.Text)); if (i > 0) { MessageBox.Show("Saved Successfully!"); } else { MessageBox.Show("Error!"); } } catch { MessageBox.Show("Error!"); } } else { if (!Validation.IsPasswordValid(PasswordtextBox.Text)) { MessageBox.Show("Please enter a valid Password \n" + "It should contain at least one number,one uppercase letter and 8 letters"); return; } else { i = 0; i = controllerObj.UpdateStaffPassword(PasswordtextBox.Text, UserName); if (i > 0) { MessageBox.Show("Password Updated!"); } else { MessageBox.Show("Error!"); } } } }
private void SignUpButton_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(FnameTextBox.Text)) { MessageBox.Show("Please enter the First Name"); return; } if (String.IsNullOrEmpty(LnameTextBox.Text)) { MessageBox.Show("Please enter the Last Name"); return; } if (String.IsNullOrEmpty(UserNameTextBox.Text)) { MessageBox.Show("Please enter a User Name"); return; } if (String.IsNullOrEmpty(PasswordTextBox.Text)) { MessageBox.Show("Please enter a Password"); return; } if (String.IsNullOrEmpty(EmailTextBox.Text)) { MessageBox.Show("Please enter an Email"); return; } if (String.IsNullOrEmpty(CreditCardNumberTextBox.Text)) { MessageBox.Show("Please enter the Credit Card Number"); return; } String Fname = FnameTextBox.Text; String Lname = LnameTextBox.Text; String UserName = UserNameTextBox.Text; String Password = PasswordTextBox.Text; String PhoneNumber; PhoneNumber = PhoneNumberTextBox.Text; String Email = EmailTextBox.Text; String CreditCardNumber = CreditCardNumberTextBox.Text; if (!Validation.IsValidEmail(Email)) { MessageBox.Show("Please enter a valid Email Adress"); return; } if (!Validation.IsPasswordValid(Password)) { MessageBox.Show("Please enter a valid Password \n" + "It should contain at least one number,one uppercase letter and 8 letters"); return; } if (!String.IsNullOrEmpty(PhoneNumber)) { if (!Validation.IsPhoneNumberVlidate(PhoneNumber)) { MessageBox.Show("Please enter a valid Phone Number \n"); return; } } else { } int T = 0; try { T = controllerObj.GetPersonWithUserName(UserName); if (T != 0) { MessageBox.Show("Please choose another username.It already exists."); return; } T = 0; T = controllerObj.CheckIfEmailExist(Email); if (T != 0) { MessageBox.Show("Please choose another Email.It already exists."); return; } if (PhoneNumber != "") { T = 0; T = controllerObj.CheckIfPhoneNumberExist(PhoneNumber); if ((T != 0)) { MessageBox.Show("Please choose another Phone Number.It already exists."); return; } } } catch { } // if (!Validation.IsCardNumberValid(CreditCardNumberTextBox.Text)) //{ // MessageBox.Show("Please enter a valid Credit Card Number"); // return; // } int i = -1; try { i = controllerObj.SignUpCustomer(Fname, Lname, UserName, Password, PhoneNumber, Email, CreditCardNumber); } catch { MessageBox.Show("Couldn't sign up! Please try again later."); return; } if (i == 0 || i == -1) { MessageBox.Show("Couldn't sign up! Please try again later."); return; } MessageBox.Show("You have signed up successfully."); //Write the code for opening the customer's account form here AccountDetailsForm F = new AccountDetailsForm(UserName, this); F.Show(); }