Example #1
0
        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 btnAndraPodcast_Click(object sender, EventArgs e)
        {
            try
            {
                var valdKategori = cbAndraPodKategori.Text;
                var valdPodcast  = cbAndraPod.Text;

                var nyUrl         = tbAndraPodUrl.Text;
                var nyttNamn      = tbAndraPodNamn.Text;
                var nyttIntervall = cbAndraPodIntervall.Text;
                var nyKategori    = cbAndraPodAndraKategori.Text;

                if ((Validation.comboBoxInteTomt(cbAndraPodKategori, "Podkategori") && Validation.comboBoxInteTomt(cbAndraPod, "Podcast") &&
                     Validation.kollaUrl(nyUrl) && Validation.textFieldInteTomt(tbAndraPodNamn, "Podnamn") && Validation.comboBoxInteTomt(cbAndraPodAndraKategori, "Kategori")))
                {
                    if (cbAndraPodIntervall.SelectedItem == null)
                    {
                        MessageBox.Show("Vänligen ange en uppdateringsintervall för podcasten");
                        return;
                    }

                    else
                    {
                        Podcast podelm = new Podcast();
                        podelm.andraPodcast(valdKategori, valdPodcast, nyUrl, nyttNamn, nyttIntervall, nyKategori);

                        Kategori kategori = new Kategori();
                        kategori.bytKategori(valdKategori, valdPodcast, nyKategori);

                        podelm.rensaFaltAndraPod(cbAndraPod, tbAndraPodUrl, tbAndraPodNamn, cbAndraPodIntervall, cbAndraPodAndraKategori);
                        fyllComboBoxKategorier();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void btnTaBortPod_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation.comboBoxInteTomt(cbAndraPodKategori, "Podkategori") && Validation.comboBoxInteTomt(cbAndraPod, "Podcast") &&
                    Validation.kollaUrl(tbAndraPodUrl.Text) && Validation.textFieldInteTomt(tbAndraPodNamn, "Podnamn") &&
                    Validation.comboBoxInteTomt(cbAndraPodAndraKategori, "Kategori"))
                {
                    var     valdKategori = cbAndraPodKategori.Text;
                    var     valdPod      = cbAndraPod.Text;
                    Podcast podcast      = new Podcast();
                    podcast.taBortPodcast(valdKategori, valdPod, tbAndraPodNamn, tbAndraPodUrl, cbAndraPodIntervall, cbAndraPod);

                    fyllComboBoxKategorier();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #4
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();
        }