private void btnUpdate_Click(object sender, EventArgs e)
        {
            //Validate Data
            if (txtDVDId.Text.Equals("") || txtDVDTitle.Text.Equals("") || txtDVDDescription.Text.Equals("") || txtDVDYearRelease.Text.Equals("") || txtRateCode.Text.Equals(""))
            {
                MessageBox.Show("All field must be entered.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDVDId.Focus();

                return;
            }

            //instantiate Rate Object
            DVD myDVD = new DVD();

            myDVD.setDVDId(Convert.ToInt32(txtDVDId.Text));
            myDVD.setTitle(txtDVDTitle.Text);
            myDVD.setDescription(txtDVDDescription.Text);
            myDVD.setYear(Convert.ToInt32(txtDVDYearRelease.Text));
            myDVD.setRateCode(txtRateCode.Text);

            //INSERT DVD record into table
            myDVD.updDVD();

            //Display Confirmation Message
            MessageBox.Show("DVD has been Updated.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);



            //Reset UI
            grpDVD.Visible = false;

            cboDVD.SelectedIndex = -1;
        }
Пример #2
0
        private void btnRegDVD_Click(object sender, EventArgs e)
        {
            //Validate Data
            if (txtDVDTitle.Text.Equals("") || txtDVDDescription.Text.Equals("") || txtDVDYearRelease.Text.Equals("") || txtRate.Text.Equals(""))
            {
                MessageBox.Show("All field must be entered.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDVDTitle.Focus();

                return;
            }

            //Validates Rate Code
            if (Rate.DVDRateCodeExists(txtRate.Text))
            {
                MessageBox.Show("Rate Code doesnt exist");
                return;
            }

            //Save Data to Registerd DVD file

            DVD myRegDVD = new DVD();

            myRegDVD.setDVDId(Convert.ToInt32(txtDVDId.Text));
            myRegDVD.setTitle(txtDVDTitle.Text);
            myRegDVD.setDescription(txtDVDDescription.Text);
            myRegDVD.setYear(Convert.ToInt32(txtDVDYearRelease.Text));
            myRegDVD.setRateCode(txtRate.Text);
            myRegDVD.setStatus("A");
            myRegDVD.setRentStatus("NR");

            //Insert DVD record into DVD Table
            myRegDVD.setRegisterDVD();


            {
                //Display Confirmation Message
                MessageBox.Show("DVD is Registered.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            //Reset UI
            txtDVDId.Text          = "";
            txtDVDTitle.Text       = "";
            txtDVDDescription.Text = "";
            txtDVDYearRelease.Text = "";
            txtRate.Text           = "";
            txtDVDId.Text          = DVD.nextDVDId().ToString("0000");


            txtDVDTitle.Focus();
        }