private void btnConfirmUpdate_Click(object sender, EventArgs e) { //Validate Data if (!Validation.checkEmptyText(txtUpdatedAmount)) { return; } if (!Validation.checkNumeric(txtUpdatedAmount)) { return; } if (!Validation.checkEmptyText(txtUpdatedDescription)) { return; } if (!Validation.checkNonNumeric(txtUpdatedDescription)) { return; } //Sets the Rate Details Rates myRate = new Rates(); myRate.setRoom_Type(txtSelectedRateType.Text); myRate.setDescription(txtUpdatedDescription.Text); myRate.setRate(Convert.ToDecimal(txtUpdatedAmount.Text)); //Updates the Rate in the Rates File myRate.updRate(); //Display confirmation message MessageBox.Show("You have updated a rate.", "Rate Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI cboSelectRate.SelectedIndex = -1; grpUpdateRate.Hide(); Size = new Size(400, 225); grpSelectRate.Show(); //Loads the Rates again from the Rates File(shows updates) DataSet ds = new DataSet(); cboSelectRate.Items.Clear(); ds = Rates.getAllRates(ds); for (int i = 0; i < ds.Tables["ss"].Rows.Count; i++) { cboSelectRate.Items.Add(ds.Tables[0].Rows[i][0].ToString() + " " + ds.Tables[0].Rows[i][1].ToString()); } }
private void btnConfirm_Click(object sender, EventArgs e) { //Validate Data if (!Validation.checkNonNumeric(txtFname)) return; if (!Validation.checkNonNumeric(txtSname)) return; if (!Validation.checkNonNumeric(txtStreet)) return; if (!Validation.checkNonNumeric(txtTown)) return; if (!Validation.checkNonNumeric(txtCounty)) return; if (!Validation.checkNumeric(txtTelNo)) return; if (!Validation.checkNumeric(txtCardNo)) return; if (!Validation.checkNonNumeric(txtCardName)) return; if (!Validation.checkEmptyText(txtFname)) return; if (!Validation.checkEmptyText(txtSname)) return; if (!Validation.checkEmptyText(txtStreet)) return; if (!Validation.checkEmptyText(txtTown)) return; if (!Validation.checkEmptyText(txtCounty)) return; if (!Validation.checkEmptyText(txtTelNo)) return; if (!Validation.checkEmptyText(txtCardNo)) return; if (!Validation.checkEmptyText(txtCardName)) return; //Sets the Customer Details Customer newCust = new Customer(); newCust.setCustID(Customer.nextCustomer()); newCust.setFname(txtFname.Text); newCust.setSName(txtSname.Text); newCust.setStreet(txtStreet.Text); newCust.setTown(txtTown.Text); newCust.setCounty(txtCounty.Text); newCust.setTel_No(txtTelNo.Text); newCust.setCardNo(Convert.ToInt16(txtCardNo.Text)); newCust.setCardName(txtCardName.Text); //Saves the Customer Detail to the Customer File newCust.addCustomer(); //Sets the ResNo and CustID for the Reservation newRes.setResNo(Reservation.nextRes()); newRes.setCustID(newCust.getCustID()); //Saves data to the Reservation File newRes.addReservation(); //Display Confirmation MessageBox.Show("You have successfully added a reservation for " + txtFname.Text + " " + txtSname.Text, "Reservation added", MessageBoxButtons.OK, MessageBoxIcon.Information); //Resetting UI dtpArrDate.ResetText(); dtpDeptDate.ResetText(); cboType.SelectedIndex = -1; cboRoomNo.SelectedIndex = -1; txtFname.Text = ""; txtSname.Text = ""; txtStreet.Text = ""; txtTown.Text = ""; txtCounty.Text = ""; txtTelNo.Text = ""; txtCardNo.Text = ""; txtCardName.Text = ""; //Resetting UI to first step grpCustomer.Hide(); cboRoomNo.Enabled = true; btnSelectRoom.Enabled = true; grpSelectRoom.Hide(); Size = new Size(350, 330); dtpArrDate.Enabled = true; dtpDeptDate.Enabled = true; cboType.Enabled = true; btnSelectRes.Enabled = true; grpSelectRes.Show(); }
private void btnAddRate_Click(object sender, EventArgs e) { // validate data if (!Validation.checkEmptyText(txtRateType)) { return; } if (!Validation.checkNonNumeric(txtRateType)) { return; } if (!Validation.checkEmptyText(txtRateDesc)) { return; } if (!Validation.checkNonNumeric(txtRateDesc)) { return; } if (!Validation.checkEmptyText(txtRateAmount)) { return; } if (!Validation.checkNumeric(txtRateAmount)) { return; } if (!Rates.rateExists(txtRateType.Text)) { MessageBox.Show("This rate has already been entered in the database. Please enter a new rate.", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtRateType.Focus(); txtRateType.Text = ""; txtRateDesc.Text = ""; txtRateAmount.Text = ""; return; } //Sets the details of new rate from form Rates newRate = new Rates(); newRate.setRoom_Type(txtRateType.Text); newRate.setDescription(txtRateDesc.Text); newRate.setRate(Convert.ToDecimal(txtRateAmount.Text)); //Saves details in the Rates File newRate.addRate(); //Display confirmation message MessageBox.Show("You have added a new rate for '" + txtRateDesc.Text + "'.", "Rate Added", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI txtRateType.Text = ""; txtRateDesc.Text = ""; txtRateAmount.Text = ""; txtRateType.Focus(); }