private void OKButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FullNameTextBox.Text.Trim())) { MessageBox.Show(_translationsDictionary.getStringFromDictionary("enter_name_of_publisher", "Proszę podać nazwę wydawcy"), _translationsDictionary.getStringFromDictionary("to_correct_data", "Popraw dane"), MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = DialogResult.None; FullNameTextBox.Focus(); return; } Publisher = new string[] { FullNameTextBox.Text, ShortTextBox.Text, PlaceTextBox.Text, AddressTextBox.Text, ContactTextBox.Text, CountryTextBox.Text, "new" }; this.Close(); }
private void SubmitButton_Click(object sender, RoutedEventArgs e) { string fullName = FullNameTextBox.Text; string email = EmailTextBox.Text; string password = Core.Models.User.GetHash(PasswordTextBox.Password); string passwordConf = Core.Models.User.GetHash(ConfirmPasswordTextBox.Password); if (string.IsNullOrWhiteSpace(fullName)) { FullNameTextBox.Focus(); return; } if (string.IsNullOrWhiteSpace(email)) { EmailTextBox.Focus(); return; } if (_storage.Users.Items.FirstOrDefault(u => u.Email.ToLower() == email.ToLower()) != null) { MessageBox.Show("Пользователь с таким Email уже существует!"); return; } if (string.IsNullOrWhiteSpace(PasswordTextBox.Password)) { PasswordTextBox.Focus(); return; } if (string.IsNullOrWhiteSpace(ConfirmPasswordTextBox.Password)) { ConfirmPasswordTextBox.Focus(); return; } if (password != passwordConf) { MessageBox.Show("Пароли не совпадают!", "Ошибка"); return; } User NewUser = new User { FullName = fullName, Password = password, Email = email, Goals = new List <Goal>() }; _storage.AddUser(NewUser); _storage.Users.Add(NewUser); Close(); }
private void NewButton_Click(object sender, EventArgs e) { try { Panel.Enabled = true; FullNameTextBox.Focus(); testDBDataSet.test.AddtestRow(testDBDataSet.test.NewtestRow()); testBindingSource.MoveLast(); // testBindingSource.ResetBindings(true); // DataGridView.DataSource = testBindingSource; } catch (Exception exception) { MessageBox.Show(exception.Message, "Exception occured", MessageBoxButtons.OK, MessageBoxIcon.Error); testBindingSource.ResetBindings(false); } }
private bool IsFormValid() { if (FullNameTextBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Full Name is required."); FullNameTextBox.Focus(); return(false); } if (NICTextBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("NIC is required"); NICTextBox.Focus(); return(false); } if ((MobileETextBox.Text.Trim() == string.Empty) && (TelephoneTextBox.Text.Trim() == string.Empty)) { JIMessageBox.ShowErrorMessage("Number is required"); return(false); } if (GenderComboBox.SelectedIndex == -1) { JIMessageBox.ShowErrorMessage("Gender is required"); GenderComboBox.Focus(); return(false); } if (AddressLineTextBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Address is required"); AddressLineTextBox.Focus(); return(false); } if (CityComboBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("City is required"); CityComboBox.Focus(); return(false); } if (DistrictComboBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("District is required"); DistrictComboBox.Focus(); return(false); } if (PostCodeBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Post Code is required"); PostCodeBox.Focus(); return(false); } if (JobTitleComboBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Job Title is required"); JobTitleComboBox.Focus(); return(false); } if (CurrentSalaryTextBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Current Salary is required"); CurrentSalaryTextBox.Focus(); return(false); } else { if (Convert.ToDecimal(CurrentSalaryTextBox.Text.Trim()) < 1) { JIMessageBox.ShowErrorMessage("Current Salary Cannot be Zero or Less"); CurrentSalaryTextBox.Focus(); return(false); } } if (StartingSalaryTextBox.Text.Trim() == string.Empty) { JIMessageBox.ShowErrorMessage("Starting Salary is required"); StartingSalaryTextBox.Focus(); return(false); } else { if (Convert.ToDecimal(StartingSalaryTextBox.Text.Trim()) < 1) { JIMessageBox.ShowErrorMessage("Starting Salary Cannot be Zero or Less"); StartingSalaryTextBox.Focus(); return(false); } } return(true); }
private bool IsFormValidate() { if (FullNameTextBox.Text.Trim() == "") { MessageBox.Show("Full Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); FullNameTextBox.Clear(); FullNameTextBox.Focus(); return(false); } if (EmailAddressTextBox.Text.Trim() == "") { MessageBox.Show("Email is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); EmailAddressTextBox.Clear(); EmailAddressTextBox.Focus(); return(false); } if ((TelephoneTextBox.Text.Trim() == "") && (MobileTextBox.Text.Trim() == "")) { MessageBox.Show("Mobile or Telephone Number is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); TelephoneTextBox.Clear(); TelephoneTextBox.Focus(); return(false); } if (NICTextBox.Text.Trim() == "") { MessageBox.Show("NIC is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); NICTextBox.Clear(); NICTextBox.Focus(); return(false); } if (GenderComboBox.SelectedIndex == -1) { MessageBox.Show("Gender is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (AddressLineTextBox.Text.Trim() == "") { MessageBox.Show("Address is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); AddressLineTextBox.Clear(); AddressLineTextBox.Focus(); return(false); } if (CityComboBox.SelectedIndex == -1) { MessageBox.Show("City is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (DistrictComboBox.SelectedIndex == -1) { MessageBox.Show("District is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (PostCodeTextBox.Text.Trim() == "") { MessageBox.Show("PostCode is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); PostCodeTextBox.Clear(); PostCodeTextBox.Focus(); return(false); } if (JobTitleComboBox.SelectedIndex == -1) { MessageBox.Show("Job Title is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (CurrentSalaryTextBox1.Text.Trim() == "") { MessageBox.Show("Current Salary is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); CurrentSalaryTextBox1.Clear(); CurrentSalaryTextBox1.Focus(); return(false); } else { if (Convert.ToDecimal(CurrentSalaryTextBox1.Text.Trim()) < 1) { MessageBox.Show("Current Salary can not be Zero or less than zero"); CurrentSalaryTextBox1.Focus(); return(false); } } if (StartingSalaryTextBox.Text.Trim() == "") { MessageBox.Show("Starting Salary is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); StartingSalaryTextBox.Clear(); StartingSalaryTextBox.Focus(); return(false); } else { if (Convert.ToDecimal(StartingSalaryTextBox.Text.Trim()) < 1) { MessageBox.Show("Starting Salary can not be Zero or less than zero"); StartingSalaryTextBox.Focus(); return(false); } } return(true); }
private bool IsFormValidate() { if (FullNameTextBox.Text.Trim() == "") { MessageBox.Show("Full Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); FullNameTextBox.Clear(); FullNameTextBox.Focus(); return(false); } if (FatherNameTextBox.Text.Trim() == "") { MessageBox.Show("Father Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); FatherNameTextBox.Clear(); FatherNameTextBox.Focus(); return(false); } if (MotherNameTextBox.Text.Trim() == "") { MessageBox.Show("Mother Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); MotherNameTextBox.Clear(); MotherNameTextBox.Focus(); return(false); } if (AddressTextBox.Text.Trim() == "") { MessageBox.Show("Address is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); AddressTextBox.Clear(); AddressTextBox.Focus(); return(false); } if (EmailTextBox.Text.Trim() == "") { MessageBox.Show("Email Name is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); EmailTextBox.Clear(); EmailTextBox.Focus(); return(false); } if (MobileTextBox.Text.Trim() == "") { MessageBox.Show("Mobile number is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); MobileTextBox.Clear(); MobileTextBox.Focus(); return(false); } if (BloodGroupTextBox.Text.Trim() == "") { MessageBox.Show("Blood Group is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); BloodGroupTextBox.Clear(); BloodGroupTextBox.Focus(); return(false); } if (GenderComboBox.SelectedIndex == -1) { MessageBox.Show("Gender is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (BranchComboBox.SelectedIndex == -1) { MessageBox.Show("Branch is required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } return(true); }
private void EditButton_Click(object sender, EventArgs e) { Panel.Enabled = true; FullNameTextBox.Focus(); }
/* * Event Handler for Confirm Button * -Validating FUll Name, Telephone Number, Email Address * - */ private void ConfirmButton_Click(object sender, EventArgs e) { StreamWriter FileWriter; string DynamicMessage; if (ProceedButton.Enabled == true) { MessageBox.Show("Please Confirm the Term by pressing Proceed button before confirming the membership"); } else { if (NotNullValue(FullNameTextBox.Text, 1)) { //Full Name Regular Express Validation //One Word is mandatory which includes Capital and small Letters if (!Regex.IsMatch(FullNameTextBox.Text, @"^[A-Z a-z]*([A-Z a-z]*)+$")) { MessageBox.Show("Please enter valid name", "Invalid Name", MessageBoxButtons.OK, MessageBoxIcon.Error); FullNameTextBox.Focus(); FullNameTextBox.SelectAll(); } else { if (NotNullValue(TelephoneTextBox.Text, 2)) { //Telephone Number Reguar Expression Validation //Grouping of 3 Number followed by space(not mandatory), then Next 3 numbers followed by space and then last 4 digits if (!Regex.IsMatch(TelephoneTextBox.Text, @"^(\(?\d{3}\)*\s?\d{3}\s?\d{4})$")) { MessageBox.Show("Please enter valid telephone Number", "Invalid Number", MessageBoxButtons.OK, MessageBoxIcon.Error); TelephoneTextBox.Focus(); TelephoneTextBox.SelectAll(); } else { if (NotNullValue(EmailTextBox.Text, 3)) { //Email Validation by Regular Expression bool CorrectEmail = Regex.IsMatch(EmailTextBox.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase); if (!CorrectEmail) { MessageBox.Show("Please enter valid email address", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error); EmailTextBox.Focus(); EmailTextBox.SelectAll(); } else { //If all the detais are correct, providing popup DynamicMessage = "Provided Details are as below:"; DynamicMessage = DynamicMessage + "\n\nMembership Details :"; DynamicMessage = DynamicMessage + "\nMembership ID : " + MembershipIDLabel.Text; DynamicMessage = DynamicMessage + "\nConfirmed Term : " + ConfirmedTerm.ToString(); DynamicMessage = DynamicMessage + "\nMembership Fees : " + ConfirmedTermTotal.ToString(); DynamicMessage = DynamicMessage + "\n\nPersonal Details :"; DynamicMessage = DynamicMessage + "\nFull Name : " + FullNameTextBox.Text; DynamicMessage = DynamicMessage + "\nTelephone No. : " + TelephoneTextBox.Text; DynamicMessage = DynamicMessage + "\nEmail ID : " + EmailTextBox.Text; DynamicMessage = DynamicMessage + "\n\nDo you want to cofirm the Membership Details?"; //Yes No Popup Display decision DialogResult DR = MessageBox.Show(DynamicMessage, "Do you want to Continue?", MessageBoxButtons.YesNo); if (DR == DialogResult.Yes) { try { //Saving details of membership to the Database File FileWriter = File.AppendText(DatabaseFileName); FileWriter.WriteLine(MembershipIDLabel.Text); FileWriter.WriteLine(JoinDayLabel.Text); FileWriter.WriteLine(FullNameTextBox.Text); FileWriter.WriteLine(TelephoneTextBox.Text); FileWriter.WriteLine(EmailTextBox.Text); FileWriter.WriteLine(ConfirmedTerm.ToString()); FileWriter.WriteLine(ConfirmedTermTotal.ToString("N2")); FileWriter.Close(); //closing File Writer if (SummaryButton.Enabled == false) { SummaryButton.Enabled = true; } if (SearchButton.Enabled == false) { SearchButton.Enabled = true; } //Confirmation Message DynamicMessage = "Hello, " + FullNameTextBox.Text + "!. Welcome Aboard. :) \n Your Membership ID is : " + MembershipIDLabel.Text; MessageBox.Show(DynamicMessage, "Membership Confirmed", MessageBoxButtons.OK, MessageBoxIcon.Information); MembershipDetailsGroupBox.Visible = false; //Clearing Fields TermTextBox.Text = ClientConfirmedTextBox.Text = PricePerMonthLabel.Text = PriceFullTermLabel.Text = PriceNextTermLabel.Text = FullNameTextBox.Text = TelephoneTextBox.Text = EmailTextBox.Text = ""; //Enabling Buttons SearchButton.Enabled = SummaryButton.Enabled = TermTextBox.Enabled = ClientConfirmedTextBox.Enabled = true; } catch (Exception ex) { // Display an error message. MessageBox.Show(ex.Message); } } } } } } } } } }
/* * Event handler for Proceed Button * -Generating Membership ID * -Enabling user input fields such as Email and Full Name * -Calculating Total Fees for provided input in Client Confirmed Textbox */ private void ProceedButton_Click(object sender, EventArgs e) { Random RandomNumberGenerator = new Random(); if (ClientConfirmedTextBox.Text == "") { MessageBox.Show("Term can not be Blank. Please enter input in months", "Blank Entry not allowed", MessageBoxButtons.OK, MessageBoxIcon.Error); ClientConfirmedTextBox.Focus(); ClientConfirmedTextBox.SelectAll(); } else { try { ConfirmedTerm = int.Parse(ClientConfirmedTextBox.Text); if (ConfirmedTerm < 0) { MessageBox.Show("Please Enter Positive Number", "Negative Number not Allowed in Terms", MessageBoxButtons.OK, MessageBoxIcon.Error); ClientConfirmedTextBox.Focus(); ClientConfirmedTextBox.SelectAll(); } else if (ConfirmedTerm == 0) { MessageBox.Show("Term can not be Zero. Please enter valid input", "Zero Terms not allowed in Terms", MessageBoxButtons.OK, MessageBoxIcon.Error); ClientConfirmedTextBox.Focus(); ClientConfirmedTextBox.SelectAll(); } else { SearchButton.Enabled = false; SummaryButton.Enabled = false; ProceedButton.Enabled = false; //Checking if user has provided details from mentioned results if (ConfirmedTerm.ToString() == TermTextBox.Text) { ConfirmedTermTotal = EnquiredPrice; } else if (ConfirmedTerm == NextMonth) { ConfirmedTermTotal = SuggestedPrice; } else { //Calculating Final Term Total based on user input ConfirmedTermTotal = CalculateTotalFees(ConfirmedTerm); } int MembershipNumber = RandomNumberGenerator.Next(1, 999999); //Randomly generating Membership ID until we get unique //-Comparing it with file to check if generated ID exists in file while (MembershipIdExists(MembershipNumber.ToString("D6"), false, false)) { MembershipNumber = RandomNumberGenerator.Next(1, 999999); } MembershipIDLabel.Text = MembershipNumber.ToString("D6"); JoinDayLabel.Text = DateTime.Now.ToShortDateString(); MembershipDetailsGroupBox.Visible = true; FullNameTextBox.Focus(); } } catch { MessageBox.Show("Invalid input provided for Terms. Please provide number", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); TermTextBox.Focus(); TermTextBox.SelectAll(); } } }
private bool isFormValid() { if (FullNameTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Full Name is required"); FullNameTextBox.Focus(); return(false); } if (DateOfBirthDateTimePicker.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Date of Birth is required"); DateOfBirthDateTimePicker.Focus(); return(false); } if (CNICTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("CNIC is required"); FullNameTextBox.Focus(); return(false); } if ((MobileTextBox.Text.Trim() == string.Empty) && (TelephoneTextBox.Text.Trim() == string.Empty)) { SMSMessageBox.ShowErrorMessage("Mobile or Telephone number is required"); MobileTextBox.Focus(); return(false); } if (GenderComboBox.SelectedIndex == -1) { SMSMessageBox.ShowErrorMessage("Gender is required"); return(false); } if (EmploymentDateDateTimePicker.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Employment Date is required"); EmploymentDateDateTimePicker.Focus(); return(false); } if (AddressLineTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Address Line is required"); AddressLineTextBox.Focus(); return(false); } if (CityComboBox.SelectedIndex == -1) { SMSMessageBox.ShowErrorMessage("City is required"); return(false); } if (DistrictComboBox.SelectedIndex == -1) { SMSMessageBox.ShowErrorMessage("District is required"); return(false); } if (PostralCodeTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Postral code is required"); PostralCodeTextBox.Focus(); return(false); } if (JobTitleComboBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Job Title is required"); JobTitleComboBox.Focus(); return(false); } if (CurrentSalaryTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Current Salary is required"); CurrentSalaryTextBox.Focus(); return(false); } else { if (Convert.ToDecimal(CurrentSalaryTextBox.Text.Trim()) < 1) { SMSMessageBox.ShowErrorMessage("Current Salary can not be zero or less than zero"); CurrentSalaryTextBox.Focus(); return(false); } } if (StartingSalaryTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Starting Salary is required"); StartingSalaryTextBox.Focus(); return(false); } else { if (Convert.ToDecimal(StartingSalaryTextBox.Text.Trim()) < 1) { SMSMessageBox.ShowErrorMessage("Starting Salary can not be zero or less than zero"); StartingSalaryTextBox.Focus(); return(false); } } if (HasLeftComboBox.Text == "Yes") { if (DateLeftDateTimePicker.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Date Left is required"); DateLeftDateTimePicker.Focus(); return(false); } if (ReasonLeftComboBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Leaving reason is required"); ReasonLeftComboBox.Focus(); return(false); } if (CommentsTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Leaving Comments are required"); CommentsTextBox.Focus(); return(false); } } return(true); }