public void addCoupon(Coupon coupon) { using (var connection = new SQLiteConnection(connString)) { connection.Open(); string addCouponQuerry = String.Format(@"INSERT INTO COUPONS (COUPON_NUMBER, COUPON_TYPE, COUPON_DISCOUNT) VALUES ('{0}', '{1}', '{2}')", coupon.NumberOfCoupon, coupon.TypeOfCoupon, coupon.Discount); SQLiteCommand addCouponCommand = new SQLiteCommand(addCouponQuerry, connection); addCouponCommand.ExecuteNonQuery(); } }
private void Button_Coupon_Add_Click(object sender, RoutedEventArgs e) { if (couponNumber.Text.Equals("") || Discount.Text.Equals("")) { MessageBox.Show("Not all fields are filled!"); } else { ComboBoxItem typeItem = (ComboBoxItem)comboBox.SelectedItem; Coupon coupon = new Coupon(Convert.ToInt32(couponNumber.Text), Convert.ToDouble(Discount.Text), typeItem.Content.ToString()); WorkWithDatabase work = new WorkWithDatabase(); work.addCoupon(coupon); couponNumber.Text = ""; Discount.Text = ""; } }