public void FillSupportForm() { //ComboBoxHelper.SelectElement(EnquiryReasonDropDown, value); var modelFaker = new Faker <DataModel>() .RuleFor(o => o.firstName, f => f.Name.FirstName()) .RuleFor(o => o.lastName, f => f.Name.LastName()) .RuleFor(o => o.emailAddress, f => f.Internet.Email()) .RuleFor(o => o.phoneNumber, f => f.Phone.PhoneNumber()) .RuleFor(o => o.websiteUrl, f => f.Internet.Url()) .RuleFor(o => o.company, f => f.Company.CompanyName()) .RuleFor(o => o.reason, f => f.PickRandom <Reason>()) .RuleFor(o => o.message, f => f.Lorem.Sentence()); var dataModel = modelFaker.Generate(); string firstName = dataModel.firstName; string lastName = dataModel.lastName; string emailAddress = dataModel.emailAddress; string phoneNumber = dataModel.phoneNumber; string websiteurl = dataModel.websiteUrl; string company = dataModel.company; string reason = dataModel.reason.ToString(); string message = dataModel.message; FirstNameTextBox.SendKeys(firstName); LastNameTextBox.SendKeys(lastName); EmailAddressTextBox.SendKeys(emailAddress); PhoneNumberTextBox.SendKeys(phoneNumber); WebsiteUrlTextBox.SendKeys(websiteurl); CompanyTextBox.SendKeys(company); EnquiryReasonDropDown.SendKeys(reason); MessageTextBox.SendKeys(message); }
private void ForceValidation() { if (NoNIPCheckBox.IsChecked == false) { NIPTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); } if (NoREGONCheckBox.IsChecked == false) { REGONTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); } if (NoBankAccountCheckBox.IsChecked == false) { BankAccountNumberTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); } CustomerNameTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); CityTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); ZipCodeTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); FlatNumberTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); StreetNumberTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); StreetTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); PhoneNumberTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource(); }
private bool ValidateForm() { if (!Regex.Match(FirstNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("First name must consist of at least 1 character and not exceed 30 characters!"); FirstNameTextBox.Focus(); return(false); } if (!Regex.Match(LastNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("Last name must consist of at least 1 character and not exceed 30 characters!"); LastNameTextBox.Focus(); return(false); } if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success) { MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!"); AddressTextBox.Focus(); return(false); } if (!Regex.Match(PhoneNumberTextBox.Text, @"^\d{10}$").Success) { MessageBox.Show("Phone number must consist of 10 digits!"); PhoneNumberTextBox.Focus(); return(false); } return(true); }
private void newWorkerSubmit_Click(object sender, EventArgs e) { string newUserBannerId = BannerTextBox.Text; string newUserFirstName = FirstNameTextBox.Text; string newUserLastName = LastNameTextBox.Text; string newUserPhoneNumber = PhoneNumberTextBox.Text; string newUserEmail = EmailTextBox.Text; string newUserUserType = UserTypeTextBox.Text; string newUserNotes = NotesTextBox.Text; string newUserStatus = StatusTextBox.Text; User newUser = new User(newUserBannerId, newUserFirstName, newUserLastName, newUserPhoneNumber, newUserEmail, newUserUserType, newUserNotes, newUserStatus); newUser.insert(); BannerTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); EmailTextBox.Clear(); UserTypeTextBox.Clear(); NotesTextBox.Clear(); StatusTextBox.Clear(); NewWorkerNotificationLabel.Text = "User added to database"; }
private bool isFormValid() { if (StudentNameTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Name is required"); StudentNameTextBox.Focus(); return(false); } if (PhoneNumberTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Phone number is required"); PhoneNumberTextBox.Focus(); return(false); } if (DepartmentComboBox.SelectedIndex == -1) { SMSMessageBox.ShowErrorMessage("Department is required"); DepartmentComboBox.Focus(); return(false); } return(true); }
private void MyTabControlSelectedIndexChanged(object sender, EventArgs e) { if (((TabControl)sender).SelectedIndex == 1) { PhoneNumberTextBox.BackgroundFocus(); } }
//Updates the driver's first name, last name, phone number, qualifications, changes status of assigned training, disciplinary records private void Update(int ID, string name, string surname, string PhoneNumber) { //Checks if there is a name and surname in the textbox if (NameTextBox.Text == "" || SurnameTextBox.Text == "") { MessageBox.Show("Please insert First Name and Last Name."); return; } //Checks if the phoneNumber length is == 11 if (PhoneNumber.Length != 11) { MessageBox.Show("Invalid Phone number. Please try again."); PhoneNumberTextBox.Clear(); return; } //Update driver's name, surname, phone number UpdateDriver(ID, name, surname, PhoneNumber); //Deletes assigned qualifications DeleteAssignedQualifications(ID); //Inserts Qualifications InsertQualifications(ID); //Changes the status of assigned qualifications ChangeStatus(ID); //Deletes previous disciplinary records DeleteDisciplinaryRecords(ID); //Inserts Disciplinary Records InsertDisciplinaryRecords(ID); }
public ActPhoneEditPage(ActPhone act) { InitializeComponent(); mAct = act; PhoneActionComboBox.BindControl(mAct, ActPhone.Fields.PhoneAction); PhoneNumberTextBox.BindControl(mAct.GetOrCreateInputParam(ActPhone.Fields.PhoneNumber)); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (orderDetails.CurrentAddress == null) { SearchTextBox.Text = ""; PhoneNumberTextBox.Clear(); HouseNumberTextBox.Clear(); } }
private void InitDBControls() { //Required Fields AssetTagTextBox.SetDBInfo(DevicesBaseCols.AssetTag, true); SerialTextBox.SetDBInfo(DevicesBaseCols.Serial, true); CurrentUserTextBox.SetDBInfo(DevicesBaseCols.CurrentUser, true); DescriptionTextBox.SetDBInfo(DevicesBaseCols.Description, true); PurchaseDatePicker.SetDBInfo(DevicesBaseCols.PurchaseDate, true); EquipTypeComboBox.SetDBInfo(DevicesBaseCols.EQType, Attributes.DeviceAttributes.EquipType, true); LocationComboBox.SetDBInfo(DevicesBaseCols.Location, Attributes.DeviceAttributes.Locations, true); OSVersionComboBox.SetDBInfo(DevicesBaseCols.OSVersion, Attributes.DeviceAttributes.OSType, true); StatusComboBox.SetDBInfo(DevicesBaseCols.Status, Attributes.DeviceAttributes.StatusType, true); //Non-required and Misc Fields PONumberTextBox.SetDBInfo(DevicesBaseCols.PO, false); ReplaceYearTextBox.SetDBInfo(DevicesBaseCols.ReplacementYear, false); PhoneNumberTextBox.SetDBInfo(DevicesBaseCols.PhoneNumber, false); GuidLabel.SetDBInfo(DevicesBaseCols.DeviceGuid, ParseType.DisplayOnly, false); TrackableCheckBox.SetDBInfo(DevicesBaseCols.Trackable, false); HostnameTextBox.SetDBInfo(DevicesBaseCols.HostName, false); iCloudTextBox.SetDBInfo(DevicesBaseCols.iCloudAccount, false); }
private void SubmitButton_Click(object sender, EventArgs e) { myUserToModify.SetFirstName(FirstNameTextBox.Text); myUserToModify.SetLastName(LastNameTextBox.Text); myUserToModify.SetPhoneNumber(PhoneNumberTextBox.Text); myUserToModify.SetEmailAddress(EmailTextBox.Text); myUserToModify.SetUserType(UserTypeTextBox.Text); myUserToModify.SetNotes(NotesTextBox.Text); myUserToModify.SetStatus(StatusTextBox.Text); myUserToModify.update(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); EmailTextBox.Clear(); UserTypeTextBox.Clear(); NotesTextBox.Clear(); StatusTextBox.Clear(); NewWorkerNotificationLabel.Text = "User updated"; }
//TODO: Iterate through properties and dynamically generate controls at runtime. private void InitDBControls() { EntryTimeTextBox.SetDBInfo(HistoricalDevicesCols.ActionDateTime, ParseType.DisplayOnly, false); ActionUserTextBox.SetDBInfo(HistoricalDevicesCols.ActionUser, ParseType.DisplayOnly, false); ChangeTypeTextBox.SetDBInfo(HistoricalDevicesCols.ChangeType, Attributes.DeviceAttributes.ChangeType, ParseType.DisplayOnly, false); DescriptionTextBox.SetDBInfo(HistoricalDevicesCols.Description, ParseType.DisplayOnly, false); GuidTextBox.SetDBInfo(HistoricalDevicesCols.DeviceGuid, ParseType.DisplayOnly, false); CurrentUserTextBox.SetDBInfo(HistoricalDevicesCols.CurrentUser, ParseType.DisplayOnly, false); LocationTextBox.SetDBInfo(HistoricalDevicesCols.Location, Attributes.DeviceAttributes.Locations, ParseType.DisplayOnly, false); PONumberTextBox.SetDBInfo(HistoricalDevicesCols.PO, ParseType.DisplayOnly, false); AssetTagTextBox.SetDBInfo(HistoricalDevicesCols.AssetTag, ParseType.DisplayOnly, false); PurchaseDateTextBox.SetDBInfo(HistoricalDevicesCols.PurchaseDate, ParseType.DisplayOnly, false); OSVersionTextBox.SetDBInfo(HistoricalDevicesCols.OSVersion, Attributes.DeviceAttributes.OSType, ParseType.DisplayOnly, false); SerialTextBox.SetDBInfo(HistoricalDevicesCols.Serial, ParseType.DisplayOnly, false); ReplaceYearTextBox.SetDBInfo(HistoricalDevicesCols.ReplacementYear, ParseType.DisplayOnly, false); EQTypeTextBox.SetDBInfo(HistoricalDevicesCols.EQType, Attributes.DeviceAttributes.EquipType, ParseType.DisplayOnly, false); NotesTextBox.SetDBInfo(HistoricalDevicesCols.Notes, ParseType.DisplayOnly, false); StatusTextBox.SetDBInfo(HistoricalDevicesCols.Status, Attributes.DeviceAttributes.StatusType, ParseType.DisplayOnly, false); EntryGuidTextBox.SetDBInfo(HistoricalDevicesCols.HistoryEntryGuid, ParseType.DisplayOnly, false); chkTrackable.SetDBInfo(HistoricalDevicesCols.Trackable, ParseType.DisplayOnly, false); PhoneNumberTextBox.SetDBInfo(HistoricalDevicesCols.PhoneNumber, ParseType.DisplayOnly, false); HostnameTextBox.SetDBInfo(HistoricalDevicesCols.HostName, ParseType.DisplayOnly, false); iCloudTextBox.SetDBInfo(HistoricalDevicesCols.iCloudAccount, ParseType.DisplayOnly, false); }
//Loads the phone number private void LoadPhoneNumber(int ID) { string query = "SELECT `Phone_Number` FROM `driver` WHERE id = '" + ID + "'"; try { databaseConnection.Open(); using (MySqlCommand cmd = new MySqlCommand(query, databaseConnection)) { using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { PhoneNumberTextBox.SetPhoneNumber((String)reader["Phone_Number"]); } } } databaseConnection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { string letterList = "ABCDEFGHIJKLMNOPRSTUVWXYZabcdefghijklmnoprstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя"; string numList = "1234567890"; if (!String.IsNullOrWhiteSpace(NameTextBox.Text) && !String.IsNullOrWhiteSpace(PhoneNumberTextBox.Text) && !String.IsNullOrWhiteSpace(InnTextBox.Text) && !String.IsNullOrWhiteSpace(OgrnTextBox.Text) && !String.IsNullOrWhiteSpace(KPPTextBox.Text) && !String.IsNullOrWhiteSpace(LastNameTextBox.Text) && !String.IsNullOrWhiteSpace(FirstNameTextBox.Text) && !String.IsNullOrWhiteSpace(MiddleNameTextBox.Text) && !String.IsNullOrWhiteSpace(AreaTextBox.Text) && !String.IsNullOrWhiteSpace(CityTextBox.Text) && !String.IsNullOrWhiteSpace(StreetTextBox.Text) && !String.IsNullOrWhiteSpace(HouseTextBox.Text) && !String.IsNullOrWhiteSpace(BankNameTextBox.Text) && !String.IsNullOrWhiteSpace(PaymentAccountTextBox.Text) && !String.IsNullOrWhiteSpace(CorrespondentAccountTextBox.Text) && !String.IsNullOrWhiteSpace(BIKTextBox.Text)) { if (LastNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1) { if (FirstNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1) { if (MiddleNameTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1) { if (PhoneNumberTextBox.Text.Length == 18 && (PhoneNumberTextBox.Text.IndexOfAny(letterList.ToCharArray()) <= -1) && !PhoneNumberTextBox.Text.Contains('_')) { if (AreaTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1) { if (CityTextBox.Text.IndexOfAny(numList.ToCharArray()) <= -1) { if (!InnTextBox.Text.Contains('_')) { if (!OgrnTextBox.Text.Contains('_')) { if (!KPPTextBox.Text.Contains('_')) { if (!PaymentAccountTextBox.Text.Contains('_')) { if (!CorrespondentAccountTextBox.Text.Contains('_')) { if (!BIKTextBox.Text.Contains('_')) { if (CurrentOrganization == null) { if (AppData.Context.Organization.Where(c => c.Name == NameTextBox.Text).FirstOrDefault() == null) { Address CurrentAddress = new Address() { Region = AreaTextBox.Text, City = CityTextBox.Text, Street = StreetTextBox.Text, House = HouseTextBox.Text, }; AppData.Context.Address.Add(CurrentAddress); BankDetail CurrentBankDetail = new BankDetail() { BankName = BankNameTextBox.Text, PaymentAccount = PaymentAccountTextBox.Text, CorrespondentAccount = CorrespondentAccountTextBox.Text, BIK = BIKTextBox.Text, }; AppData.Context.BankDetail.Add(CurrentBankDetail); CurrentOrganization = new Organization() { Name = NameTextBox.Text, IdAddress = CurrentAddress.Id, OGRN = OgrnTextBox.Text, INN = InnTextBox.Text, KPP = KPPTextBox.Text, IdBankDetail = CurrentBankDetail.Id, PhoneNumber = PhoneNumberTextBox.Text, LastName = LastNameTextBox.Text, FirstName = FirstNameTextBox.Text, MiddleName = MiddleNameTextBox.Text, }; AppData.Context.Organization.Add(CurrentOrganization); AppData.Context.SaveChanges(); MessageBox.Show("Организация успешно добавлена!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information); NavigationService.GoBack(); } else { MessageBox.Show("Организация с таким названием уже существует!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); NameTextBox.Focus(); } } else { CurrentOrganization.Name = NameTextBox.Text; CurrentOrganization.OGRN = OgrnTextBox.Text; CurrentOrganization.INN = InnTextBox.Text; CurrentOrganization.KPP = KPPTextBox.Text; CurrentOrganization.PhoneNumber = PhoneNumberTextBox.Text; CurrentOrganization.LastName = LastNameTextBox.Text; CurrentOrganization.FirstName = FirstNameTextBox.Text; CurrentOrganization.MiddleName = MiddleNameTextBox.Text; CurrentAddress.Region = AreaTextBox.Text; CurrentAddress.City = CityTextBox.Text; CurrentAddress.Street = StreetTextBox.Text; CurrentAddress.House = HouseTextBox.Text; CurrentBankDetail.BankName = BankNameTextBox.Text; CurrentBankDetail.PaymentAccount = PaymentAccountTextBox.Text; CurrentBankDetail.CorrespondentAccount = CorrespondentAccountTextBox.Text; CurrentBankDetail.BIK = BIKTextBox.Text; AppData.Context.SaveChanges(); MessageBox.Show("Информация обновлена!", "Внимание", MessageBoxButton.OK, MessageBoxImage.Information); NavigationService.GoBack(); } } else { MessageBox.Show("БИК указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); BIKTextBox.Focus(); } } else { MessageBox.Show("Корреспондентский счёт указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); CorrespondentAccountTextBox.Focus(); } } else { MessageBox.Show("Расчётный счёт указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); PaymentAccountTextBox.Focus(); } } else { MessageBox.Show("КПП указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); KPPTextBox.Focus(); } } else { MessageBox.Show("ОГРН указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); OgrnTextBox.Focus(); } } else { MessageBox.Show("ИНН указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); InnTextBox.Focus(); } } else { MessageBox.Show("Город указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); CityTextBox.Focus(); } } else { MessageBox.Show("Область указана некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); AreaTextBox.Focus(); } } else { MessageBox.Show("Номер телефона указан некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); PhoneNumberTextBox.Focus(); } } else { MessageBox.Show("Отчество указано некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); MiddleNameTextBox.Focus(); } } else { MessageBox.Show("Имя указано некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); FirstNameTextBox.Focus(); } } else { MessageBox.Show("Фамилия указана некорректно!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); LastNameTextBox.Focus(); } } else { MessageBox.Show("Не все поля заполнены!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void SubmitButton_Click(object sender, EventArgs e) { try //throw this exception if this passenger already exists { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Address addr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); TravelAgent trav1 = new TravelAgent(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), double.Parse(EarningstextBox1.Text), SsnTextBox.Text); trav1.countofEmployees++; foreach (Person p in TravelAgency.people) { if (trav1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Passenger already exists!"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (SsnTextBox.Text == s) { throw new InvalidDataException("Invalid Passport Number"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(trav1); MessageBox.Show("Travel Agent " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); SsnTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; IDNumberTextBox.Clear(); EarningstextBox1.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("Invalid phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (FormatException f) { MessageBox.Show(f.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
private bool ValidateForm() { if (!Regex.Match(FirstNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("First name must consist of at least 1 character and not exceed 30 characters!"); FirstNameTextBox.Focus(); return(false); } if (!Regex.Match(LastNameTextBox.Text, @"^\D{1,30}$").Success) { MessageBox.Show("Last name must consist of at least 1 character and not exceed 30 characters!"); LastNameTextBox.Focus(); return(false); } if (!Regex.Match(PhoneNumberTextBox.Text, @"^\d{10}$").Success) { MessageBox.Show("Phone number must consist of 10 digits!"); PhoneNumberTextBox.Focus(); return(false); } if (!Regex.Match(ExperienceTextBox.Text, @"^[0-9]+$").Success) { MessageBox.Show("Invalid work experience number! It must contain only digits"); ExperienceTextBox.Focus(); return(false); } if (!Regex.Match(AddressTextBox.Text, @"^(Вул\.\s\D{1,40}\,\s\d{1,3})$").Success) { MessageBox.Show("Address must consist of at least 1 character and not exceed 50 characters!"); AddressTextBox.Focus(); return(false); } if (RoleComboBox.SelectedItem == null) { MessageBox.Show("Please select role"); return(false); } if (MarketComboBox.SelectedItem == null) { MessageBox.Show("Please select market"); return(false); } if (CityComboBox.SelectedItem == null) { MessageBox.Show("Please select city"); return(false); } if (!Regex.Match(LoginTextBox.Text, @"^\D{6,20}$").Success) { MessageBox.Show("Login must consist of at least 6 character and not exceed 20 characters!"); LoginTextBox.Focus(); return(false); } if (!Regex.Match(PasswordTextBox.Text, @"^\D{6,20}$").Success) { MessageBox.Show("Login must consist of at least 6 character and not exceed 20 characters!"); PasswordTextBox.Focus(); return(false); } return(true); }
private void SubmitButton_Click(object sender, EventArgs e) { try { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Address addr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); CreditCard cc = new CreditCard(int.Parse(CardNumbertextBox1.Text), int.Parse(PintextBox1.Text), DateTime.Parse(ExpirationDatedateTimePicker1.Text)); Customer cust1 = new Customer(FirstNameTextBox.Text, LastNameTextBox.Text, gender, addr, PhoneNumberTextBox.Text, int.Parse(IDNumberTextBox.Text), cc); foreach (Person p in TravelAgency.people) { if (cust1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Customer already exists!"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (CardNumbertextBox1.Text == s || PintextBox1.Text == s) { throw new InvalidDataException("invalid card"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(cust1); MessageBox.Show("Customer " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); IDNumberTextBox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; PintextBox1.Clear(); ExpirationDatedateTimePicker1.ResetText(); CardNumbertextBox1.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("Invalid phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
private void ConfirmButton_Click(object sender, EventArgs e) { string Str = TransactionNumberTextBox.Text; double Num; bool isNum = double.TryParse(Str, out Num); string Str2 = PhoneNumberTextBox.Text; double Num2; bool isNum2 = double.TryParse(Str2, out Num2); if (isNum) { if (NameTextBox.Text != "") { if (isNum2) { if (EmailTextBox.Text != "") { Message = ("Details of your transaction below\n" + "Transaction id: " + TransactionNumberTextBox.Text + "\n" + "Name: " + NameTextBox.Text + "\n" + "Phone Number: " + PhoneNumberTextBox.Text + "\n" + "Email: " + EmailTextBox.Text + "\n" + "Principal+interest: " + value + "\n" + "If the details above are correct and you wish to proceed click OK "); Heading = "Confirmation"; MessageBoxButtons buttons = MessageBoxButtons.OKCancel; MessageBoxIcon messageIcon = MessageBoxIcon.Question; DialogResult result; result = MessageBox.Show(Message, Heading, buttons, messageIcon); if (result == DialogResult.OK) { FileWriter(); MessageBox.Show("Clients details have been saved ", "Details Saved", MessageBoxButtons.OK); TransCount += TransactionNumberTextBox.Text + "\n"; InvestedAmount += decimal.Parse(InvestAmountTextBox.Text); NumberOfTransactions++; SummaryGB.Visible = true; SummaryButton.Visible = true; } } else { MessageBox.Show("Please enter your email address"); EmailTextBox.Focus(); EmailTextBox.SelectAll(); } } else { MessageBox.Show("Please enter a phone number, Only numeric Input accepted"); PhoneNumberTextBox.Focus(); PhoneNumberTextBox.SelectAll(); } } else { MessageBox.Show("Please enter your name"); NameTextBox.Focus(); NameTextBox.SelectAll(); } } else { MessageBox.Show("Please enter a SIX digit unique key"); TransactionNumberTextBox.Focus(); TransactionNumberTextBox.SelectAll(); } }
//Inserts the driver in the database private void InsertDriver() { //Gets the textbox values string firstName = FirstNameTextBox.Text; string lastName = LastNameTextBox.Text; string phoneNumber = PhoneNumberTextBox.GetPhoneNumber(); //Checks if First Name textbox and Last Name textbox are empty if (FirstNameTextBox.Text == "" || LastNameTextBox.Text == "") { MessageBox.Show("Please insert First Name and Last Name."); return; } //Checks if the phoneNumber length is == 11 if (phoneNumber.Length != 11) { MessageBox.Show("Invalid Phone number. Please try again."); PhoneNumberTextBox.Clear(); return; } //The first query inserts the Driver's name and surname String query = "INSERT INTO `driver`(`first_Name`, `last_Name`, `Phone_Number`) VALUES('" + firstName + "','" + lastName + "','" + phoneNumber + "')"; var Qualification_ID = new List<int>(); try { MySqlDataReader reader = null; databaseConnection.Open(); MySqlCommand getID = databaseConnection.CreateCommand(); getID.CommandText = query; getID.ExecuteNonQuery(); //Get last inserted ID. Using this ID we insert the driver's qualifications long ID = getID.LastInsertedId; MessageBox.Show("Driver successfully added. Name: " + firstName + " " + lastName + ", " + phoneNumber + " ID: " + ID + "."); databaseConnection.Close(); foreach (DataGridViewRow row in AddQualificationsGridView.Rows) { if (!row.IsNewRow) { for (int i = 0; i < AddQualificationsGridView.Columns.Count; i++) { String Qualification = Convert.ToString(row.Cells[i].Value); //The second query selects the qualifications query = "SELECT `Qualification_ID`FROM `qualification` WHERE `Qualification` LIKE '" + Qualification + "'"; databaseConnection.Open(); using (MySqlCommand cmd = new MySqlCommand(query, databaseConnection)) { reader = cmd.ExecuteReader(); while (reader.Read()) { Qualification_ID.Add((int)reader["Qualification_ID"]); } databaseConnection.Close(); foreach (int e in Qualification_ID) { databaseConnection.Open(); MySqlCommand cmd2 = databaseConnection.CreateCommand(); //The third query inserts the qualifications and assigns them to that driver's ID cmd2.CommandText = "INSERT INTO `assigned_qualification` (`id`, `Qualification_ID`) VALUES(@id, @qualification_id)"; cmd2.Parameters.AddWithValue("@id", ID); cmd2.Parameters.AddWithValue("@qualification_id", Qualification_ID[0]); cmd2.ExecuteNonQuery(); databaseConnection.Close(); } Qualification_ID.Clear(); } } } } } catch (Exception e) { MessageBox.Show("Add button error: " + e.Message); } }
private string TextBoxValidation() { string errorMessage = string.Empty; if (FirstNameTextBox.Text.Length > 0 && FirstNameTextBox.Text != null) { this.FirstName = FirstNameTextBox.Text; } else { errorMessage = "Invalid entry for first name. Please enter a valid first name"; FirstNameTextBox.Focus(); } if (MiddleNameTextBox.Text != null) { this.MiddleName = MiddleNameTextBox.Text; } else { errorMessage = "Invalid entry for middle name. Please enter a valid middle name"; MiddleNameTextBox.Focus(); } if (LastNameTextBox.Text.Length > 0 && LastNameTextBox.Text != null) { this.LastName = LastNameTextBox.Text; } else { errorMessage = "Invalid entry for last name. Please enter a valid last name"; LastNameTextBox.Focus(); } if (CityTextBox.Text.Length > 0 && CityTextBox.Text != null) { this.City = CityTextBox.Text; } else { errorMessage = "Invalid entry for city. Please enter a valid city"; CityTextBox.Focus(); } if (StateTextBox.Text.Length > 0 && StateTextBox.Text != null) { this.State = StateTextBox.Text; } else { errorMessage = "Invalid entry for state. Please enter a valid state"; StateTextBox.Focus(); } if (CountryTextBox.Text.Length > 0 && CountryTextBox.Text != null) { this.Country = CountryTextBox.Text; } else { errorMessage = "Invalid entry for Country. Please enter a valid country"; CountryTextBox.Focus(); } if (PhoneNumberTextBox.Text.Length > 0 && PhoneNumberTextBox.Text != null) { this.PhoneNumber = PhoneNumberTextBox.Text; } else { errorMessage = "Invalid entry for phone number. Please enter a valid phone number"; PhoneNumberTextBox.Focus(); } if (EmailAddressTextBox.Text.Length > 0 && EmailAddressTextBox.Text != null) { this.EmailAddress = EmailAddressTextBox.Text; } else { errorMessage = "Invalid entry for email address. Please enter a valid email address"; EmailAddressTextBox.Focus(); } return(errorMessage); }
public void SubmitButton_Click(object sender, EventArgs e) { try { string gender; if (FemaleradioButton1.Checked) { gender = FemaleradioButton1.Text; } else { gender = MaleradioButton2.Text; } Passport pass = new Passport(FirstNameTextBox.Text, LastNameTextBox.Text, CountryOfBirthTextBox.Text, NationalityTextBoox.Text); Address adr = new Address(StreetTextBox.Text, CityTextBox.Text, StateTextBox.Text, ZipTextBox.Text); Person adam1 = new Passenger(int.Parse(IDNumberTextBox.Text), FirstNameTextBox.Text, LastNameTextBox.Text, gender, PhoneNumberTextBox.Text, adr, pass); foreach (Person p in TravelAgency.people) { if (adam1.isEqual(p)) { throw new DuplicateDataExcception("Sorry! This Passenger already exists"); } } string s = " "; if (FirstNameTextBox.Text == s || LastNameTextBox.Text == s) { throw new InvalidName("Invalid Name"); } if (PhoneNumberTextBox.Text == s) { throw new InvalidPhoneNumber("Invalid PhoneNumber"); } if (StreetTextBox.Text == s || CityTextBox.Text == s || StateTextBox.Text == s || ZipTextBox.Text == s) { throw new InvalidAddress("Invalid Address"); } if (CountryOfBirthTextBox.Text == s) { throw new InvalidDataException("Invalid Country of Birth"); } if (NationalityTextBoox.Text == s) { throw new InvalidDataException("Invalid Nationality"); } if (IDNumberTextBox.Text == s) { throw new InvalidDataException("Invalid ID"); } if (PassportNumberTextBox.Text == s) { throw new InvalidDataException("Invalid Passport Number"); } if (!FemaleradioButton1.Checked && !MaleradioButton2.Checked) { throw new InvalidDataException("Invalid Gender"); } TravelAgency.people.Add(adam1); MessageBox.Show("Passenger " + FirstNameTextBox.Text + " " + LastNameTextBox.Text + " was added"); IDNumberTextBox.Clear(); FirstNameTextBox.Clear(); LastNameTextBox.Clear(); PhoneNumberTextBox.Clear(); StreetTextBox.Clear(); CityTextBox.Clear(); StateTextBox.Clear(); ZipTextBox.Clear(); CountryOfBirthTextBox.Clear(); NationalityTextBoox.Clear(); FemaleradioButton1.Checked = false; MaleradioButton2.Checked = false; PassportTextBox.Clear(); } catch (InvalidName) { MessageBox.Show("Invalid Name"); } catch (InvalidPhoneNumber) { MessageBox.Show("invalid Phone Number"); } catch (DuplicateDataExcception ex) { MessageBox.Show(ex.Message); } catch (OverflowException oe) { MessageBox.Show(oe.Message); } catch (Exception q) { MessageBox.Show(q.Message); } }
//Update button listener private void UpdateButton_Click(object sender, EventArgs e) { //gets the values from the setLabel(ID), name and surname Update(Convert.ToInt32(IDLabel.Text), NameTextBox.Text, SurnameTextBox.Text, PhoneNumberTextBox.GetPhoneNumber()); }