Exemplo n.º 1
0
        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());
            }
        }
Exemplo n.º 2
0
        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();
        }