Пример #1
0
        private void btnUpdateMovie_Click(object sender, EventArgs e)
        {
            int a;

            if (!int.TryParse(txtYear.Text, out a))
            {
                MessageBox.Show("Year and Copies must be a valid integer");
            }
            else
            {
                int rental = 0;
                if ((DateTime.Now.Year - a) > 5)
                {
                    rental = 2;
                }
                else
                {
                    rental = 5;
                }
                AllFunctions database = new AllFunctions();
                database.EditMovie(txtRating.Text, txtTitle.Text, txtYear.Text, txtCopies.Text, rental.ToString(), txtPlot.Text, txtGenre.Text, DateTime.Now, txtMoviesID.Text);
                MessageBox.Show("Movie Updated");
                Dispose();
            }
        }
        private void btnAddMovies_Click(object sender, EventArgs e)
        {
            int a, b;

            if (rating.Text == "" || title.Text == "" || year.Text == "" || copies.Text == "" || plot.Text == "" || genre.Text == "")
            {
                MessageBox.Show("All fields are required");
            }
            else if (!int.TryParse(year.Text, out a) || !(int.TryParse(copies.Text, out b)))
            {
                MessageBox.Show("Year and Copies must be a valid integer");
            }
            else
            {
                int rental = 0;
                if ((DateTime.Now.Year - a) > 5)
                {
                    rental = 2;
                }
                else
                {
                    rental = 5;
                }

                AllFunctions db   = new AllFunctions();
                DateTime     date = DateTime.Now;
                db.AddNewMovie(rating.Text, title.Text, year.Text, rental.ToString(), copies.Text, plot.Text, genre.Text, date);

                MessageBox.Show("Movie Added");
            }
        }
        private void btnDaleteCust_Click(object sender, EventArgs e)
        {
            AllFunctions db = new AllFunctions();

            db.DeleteCustomer(txtCustomerID.Text);
            MessageBox.Show("Customer Deleted");
            Dispose();
        }
        private void btnUpdateCust_Click(object sender, EventArgs e)
        {
            AllFunctions db = new AllFunctions();

            db.EditCustomer(txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtPhoneNo.Text, txtCustomerID.Text);
            MessageBox.Show("Customer Updated");
            Dispose();
        }
Пример #5
0
        private void btnDeleteMovie_Click(object sender, EventArgs e)
        {
            AllFunctions database = new AllFunctions();

            database.DeleteMovie(txtMoviesID.Text);
            MessageBox.Show("Movie Deleted");
            Dispose();
        }
Пример #6
0
 private void btnIssue_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         MessageBox.Show("Enter valid Customer ID");
     }
     else
     {
         AllFunctions database = new AllFunctions();
         database.AddRentalRecord(Convert.ToInt32(comboBox1.SelectedValue), Convert.ToInt32(comboBox2.SelectedValue.ToString()), Convert.ToDateTime(dateTimePicker1.Text));
         MessageBox.Show("Movie Rented");
     }
 }
Пример #7
0
        private void returnMovieToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure to return this rental?", "Return Confirmation", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                AllFunctions database = new AllFunctions();
                //string rmid = dataGridViewReturn.SelectedRows[0].Cells[0].Value.ToString();
                string rmid = this.dataGridViewReturn.CurrentRow.Cells[0].Value.ToString();
                database.UpdateReturnRecord(Convert.ToDateTime(DateTime.Now.ToString()), rmid);
                MessageBox.Show("Movie Returned");
                dataGridViewReturn.DataSource = new AllFunctions().GetPendingRentals();
            }
        }
Пример #8
0
 private void btnAddCust_Click(object sender, EventArgs e)//Add button code
 {
     if (txtFirstName.Text == "" || txtLastName.Text == "" || txtAddress.Text == "" || txtPhoneNumber.Text == "")
     {
         MessageBox.Show("All fields are required");
     }
     else
     {
         AllFunctions db = new AllFunctions();                                                      //instance of all functions
         db.AddCustomer(txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtPhoneNumber.Text); //calling add customer method
         MessageBox.Show("Customer Added");
         Dispose();
     }
 }
Пример #9
0
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

            DataTable table = new AllFunctions().FindCustomerByID(comboBox2.SelectedValue.ToString());

            if (table.Rows.Count > 0)
            {
                textBox1.Text = table.Rows[0]["FirstName"].ToString();
                textBox2.Text = table.Rows[0]["Address"].ToString();
                textBox3.Text = table.Rows[0]["Phone"].ToString();
            }
        }