private void btnUpdate_Click(object sender, EventArgs e) { if (txtboxFirstName.Text == "" || txtboxLastName.Text == "" || textBoxNIC.Text == "" || txtboxAddress.Text == "" || txtboxContactNumber.Text == "" || adults.Text == "" || children.Text == "") { MessageBox.Show("Please fill the fields"); } else if (!ValidationRoomRes.validateName(txtboxFirstName.Text) || txtboxFirstName.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid first Name"); } else if (!ValidationRoomRes.validateName(txtboxLastName.Text) || txtboxLastName.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid Last Name"); } else if (!ValidationRoomRes.validateNIC(textBoxNIC.Text) || textBoxNIC.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid NIC"); } else if (!ValidationRoomRes.validatePhoneNo(txtboxContactNumber.Text) || txtboxContactNumber.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid Phone number"); } else if (!ValidationRoomRes.validateNumbers(adults.Text) || adults.Text.Equals(String.Empty)) { MessageBox.Show("Please enter number of adults 1 - 12"); } else if (!ValidationRoomRes.validateChildren(children.Text) || children.Text.Equals(String.Empty)) { MessageBox.Show("Please enter number of children 0-12"); } else if (cmbDeluxeRoom.Text == "" && cmbSuiteRoom.Text == "" && cmbStandardRoom.Text == "") { MessageBox.Show("Please enter a number of rooms"); } else if (!radioMale.Checked && !radioFemale.Checked) { MessageBox.Show("You forgot to select the gender!"); } else { ContactClass c = new ContactClass(); c.ContactID = Int32.Parse(txtboxContactID.Text); c.FirstName = txtboxFirstName.Text; c.LastName = txtboxLastName.Text; c.NIC = textBoxNIC.Text; c.ContactNo = txtboxContactNumber.Text; c.Address = txtboxAddress.Text; String gender = ""; if (radioMale.Checked) { gender = "Male"; } else if (radioFemale.Checked) { gender = "Female"; } c.Gender = gender; c.checkin = dob.Value.ToString("yyyy-MM-dd"); c.checkout = dateTimePicker1.Value.ToString("yyyy-MM-dd"); c.adults = adults.Text; c.children = children.Text; c.DeluxeRoom = cmbDeluxeRoom.Text; c.SuiteRoom = cmbSuiteRoom.Text; c.StandardRoom = cmbStandardRoom.Text; // c.Room = cmbRoom.Text; // c.Room = Int32.Parse(cmbSuiteRoom.Text); c.UpdateCustomer(); clearAddCustomerForm(); dgvAllCustomers.DataSource = loadAllCustomers(); } }
private void btnUpdate_Click_1(object sender, EventArgs e) { //validation if (txtboxFirstName.Text == "" || txtboxLastName.Text == "" || txtboxAddress.Text == "" || txtboxContactNumber.Text == "" || cmbRoomType.Text == "" || cmbRoom.Text == "") { MessageBox.Show("Please fill the fields"); } else if (!Validation.validateName(txtboxFirstName.Text) || txtboxFirstName.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid first Name"); } else if (!Validation.validateName(txtboxLastName.Text) || txtboxLastName.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid Last Name"); } else if (!Validation.validatePhoneNo(txtboxContactNumber.Text) || txtboxContactNumber.Text.Equals(String.Empty)) { MessageBox.Show("Please enter a valid Phone number"); } else if (cmbRoomType.Text == "") { MessageBox.Show("Please enter a valid Room Type"); } else if (!radioMale.Checked && !radioFemale.Checked) { MessageBox.Show("You forgot to select the gender!"); } else { ContactClass c = new ContactClass(); c.ContactID = Int32.Parse(txtboxContactID.Text); c.FirstName = txtboxFirstName.Text; c.LastName = txtboxLastName.Text; c.ContactNo = txtboxContactNumber.Text; c.Address = txtboxAddress.Text; String gender = ""; if (radioMale.Checked) { gender = "Male"; } else if (radioFemale.Checked) { gender = "Female"; } c.Gender = gender; c.DateOfBirth = dob.Value.ToString("yyyy-MM-dd"); c.RoomType = cmbRoomType.Text; // c.Room = cmbRoom.Text; c.Room = Int32.Parse(cmbRoom.Text); c.UpdateCustomer(); clearAddCustomerForm(); dgvAllCustomers.DataSource = loadAllCustomers(); } }