Пример #1
0
        private void btnSale_Click(object sender, EventArgs e)
        {
            double newPrice    = Convert.ToDouble(txtNewPrice.Text);
            double oldPrice    = Convert.ToDouble(txtPrice.Text);
            double maxDiscount = oldPrice / 100 * 20;

            if (oldPrice - newPrice > maxDiscount)
            {
                MessageBox.Show("Discount cannot be more than 20%",
                                "Price errror",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
            }
            else
            {
                using (MySqlConnection mysqlCon = new MySqlConnection(connectionString))
                {
                    mysqlCon.Open();
                    MySqlCommand mySqlCmd = new MySqlCommand("Sale", mysqlCon);
                    mySqlCmd.CommandType = CommandType.StoredProcedure;
                    mySqlCmd.Parameters.AddWithValue("_userID", Helper.curUser);

                    mySqlCmd.Parameters.AddWithValue("_carID", this.carForSale.getCarID());

                    mySqlCmd.Parameters.AddWithValue("_clientID", dataGridView1.CurrentRow.Cells[0].Value);

                    mySqlCmd.Parameters.AddWithValue("_newPrice", Convert.ToDouble(newPrice));

                    mySqlCmd.ExecuteNonQuery();
                    MessageBox.Show("Submitted Successfully");
                    this.Close();
                    carCRUD carcr1 = new carCRUD();
                    carcr1.Show();
                }
            }
        }
Пример #2
0
        private void carToolStripMenuItem_Click(object sender, EventArgs e)
        {
            carCRUD car = new carCRUD();

            car.Show();
        }