private void buttonSave_Click(object sender, EventArgs e) { if ((maskedTextBoxfaxnumber.Text == "") || (textBoxcreditlimit.Text == "") || (textBoxclientID.Text == "") || (textBoxinstitutionname.Text == "") || (textBoxstreet.Text == "") || (textBoxcity.Text == "") || (maskedTextBoxPostalCode.Text == "") || (maskedTextBoxphonenumber.Text == "")) { MessageBox.Show("You have to fill out all the boxes, try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { Client clien = new Client(); clien.ClientID = Convert.ToInt32(textBoxclientID.Text); clien.Name = textBoxinstitutionname.Text; clien.Street = textBoxstreet.Text; clien.City = textBoxcity.Text; clien.PostalCode = maskedTextBoxPostalCode.Text; clien.PhoneNumber = maskedTextBoxphonenumber.Text; clien.FaxNumber = maskedTextBoxfaxnumber.Text; clien.CreditLimit = Convert.ToInt32(textBoxcreditlimit.Text); ClientsDA.Save(clien); } ClearAll(); }
private void buttonCliSave_Click(object sender, EventArgs e) { //Client Validators //if (!Validator.IsEmpty(textBoxCliName)) //{ // MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // textBoxCliName.Clear(); // textBoxCliName.Focus(); // return; //} //if (!Validator.IsValidId(textBoxCliName.Text, 4)) //{ // MessageBox.Show("Author ID field must have 4 digits.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); // textBoxCliName.Clear(); // textBoxCliName.Focus(); // return; //} //if (Validator.IsDuplicate(ListE, Convert.ToInt32(textBoxEmpID.Text))) //{ // MessageBox.Show("Employee Id already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpID.Clear(); // textBoxEmpID.Focus(); // return; //} //Employee First and Last Name Validators //if (Validator.IsValidName(textBoxEmpFName)) //{ // MessageBox.Show("Employee First Name cannot have digits or white spaces!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpFName.Clear(); // textBoxEmpFName.Focus(); // return; //} //if (Validator.IsValidName(textBoxEmpLName)) //{ // MessageBox.Show("Employee Last Name cannot have digits or white spaces!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // textBoxEmpLName.Clear(); // textBoxEmpLName.Focus(); // return; //} if (string.IsNullOrEmpty(textBoxCliCredit.Text)) { textBoxCliCredit.Text = "0"; } //Saving the data into the text file Clients aClient = new Clients(); aClient.clientName = textBoxCliName.Text; aClient.phoneNumber = maskedTextBoxCliPhone.Text; aClient.city = textBoxCliCity.Text; aClient.street = textBoxCliStreet.Text; aClient.postalCode = textBoxCliPostalCode.Text; aClient.creditLimit = Convert.ToDecimal(textBoxCliCredit.Text); ClientsDA.Save(aClient); ClearAllCli(); UpdateComboBoxes(); buttonCliList.PerformClick(); }