//Saving discount to transaction table; protected void isDiscount(String id, String discount, String discount_percent, frmdiscount suspend, double totalPrices) { try { conn = new MySqlConnection(this.connection()); conn.Open(); DialogResult result = MessageBox.Show("Add this discount?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { using (command = new MySqlCommand("UPDATE transaction SET discount_percent = @disc_percent, discount = @desc, total = @ttal WHERE transaction_id = @id", conn)) { command.Parameters.AddWithValue("@disc_percent", Convert.ToDouble(discount_percent)); command.Parameters.AddWithValue("@desc", Convert.ToDouble(discount)); command.Parameters.AddWithValue("@ttal", totalPrices); command.Parameters.AddWithValue("@id", Convert.ToInt32(id)); bool checkResult = (int)command.ExecuteNonQuery() > 0; if (checkResult == true) { MessageBox.Show("Discount added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); suspend.Hide(); } } } else { MessageBox.Show("discount not added"); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void discount(String id, String discount, String discount_percent, frmdiscount suspend, double totalPrice) { this.isDiscount(id, discount, discount_percent, suspend, totalPrice); }