Пример #1
0
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            OrderBackLogController orderBackLogController = new OrderBackLogController();
            OrderBackLog           orderBackLog           = new OrderBackLog();

            if (DiscountComboBox.Text.Length == 0 || VatComboBox.Text.Length == 0)
            {
                MessageBox.Show("Please fill properly ...");
            }
            else
            {
                double discount   = Double.Parse(DiscountComboBox.Text);
                double vat        = Double.Parse(VatComboBox.Text);
                double totalPrice = (Price - discount) + (((Price - discount) * vat) / 100);
                //MessageBox.Show(vat.ToString()+discount.ToString()+ Price.ToString() + totalPrice.ToString());
                //new added
                orderBackLog.Price      = Price.ToString();
                orderBackLog.Discount   = discount.ToString();
                orderBackLog.Vat        = vat.ToString();
                orderBackLog.TotalPrice = totalPrice.ToString();
                orderBackLogController.insertOrderBackLog(orderBackLog);
                //new added
                Voucher voucher = new Voucher(Price, discount, vat, totalPrice);
                voucher.Show();
                this.Visible = false;
            }
        }
Пример #2
0
        public bool insertOrderBackLog(OrderBackLog orderBackLog)
        {
            try
            {
                string        connectionString = GetConnection();
                SqlConnection sqlConnection    = new SqlConnection(connectionString);
                sqlConnection.Open();

                string     query      = @"insert into OrderBackLog (Price,Discount,Vat,TotalPrice) values('" + orderBackLog.Price + "','" + orderBackLog.Discount + "','" + orderBackLog.Vat + "','" + orderBackLog.TotalPrice + "')";
                SqlCommand sqlCommand = new SqlCommand(query, sqlConnection);
                if (sqlCommand.ExecuteNonQuery() == 1)
                {
                    sqlConnection.Close();
                    return(true);
                }
                else
                {
                    sqlConnection.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(false);
            }
        }