Beispiel #1
0
        private void btnCash_Click(object sender, RoutedEventArgs e)
        {
            if (billItems.Count == 0)
            {
                ///
                return;
            }

            if (newReceiptID != "")
            {
                MessageBox.Show($"Hóa đơn này đã thanh toán, mã hóa đơn là {newReceiptID}!");
                return;
            }
            BUS_Discount busDiscount = new BUS_Discount();
            DTO_Discount curDiscount = busDiscount.GetCurrentDiscount();
            string       disID       = "";

            if (curDiscount.DiscountValue != 0)
            {
                disID = curDiscount.DiscountID;
            }
            DTO_Receipt newReceipt = new DTO_Receipt("", user, disID);

            BUS_Receipt busReceipt = new BUS_Receipt();

            newReceiptID = busReceipt.CreateReceipt(newReceipt);
            if (newReceiptID != "")
            {
                BUS_ReceiptDetail busReceiptDetail = new BUS_ReceiptDetail();
                bool result = true;
                foreach (BillItem item in billItems)
                {
                    DTO_ReceiptDetail newReceiptDetail = new DTO_ReceiptDetail(newReceiptID, item.id, item.amount, item.unitCost);
                    result = result & busReceiptDetail.CreateReceiptDetail(newReceiptDetail);
                }
                if (result)
                {
                    MessageBox.Show("Tạo hóa đơn thành công!");
                }
                else
                {
                    MessageBox.Show("Đã xảy ra lỗi trong quá trình tạo chi tiết hóa đơn!");
                }
            }
            else
            {
                MessageBox.Show("Đã xảy ra lỗi trong quá trình tạo hóa đơn!");
            }
        }
Beispiel #2
0
        public bool CreateReceiptDetail(DTO_ReceiptDetail newReceiptDetail)
        {
            //insert SQLite
            string        sql    = $"INSERT INTO ReceiptDetail (ReceiptID, BeverageID, Amount, Price) VALUES ('{newReceiptDetail.ReceiptID}', '{newReceiptDetail.BeverageID}', {newReceiptDetail.Amount}, {newReceiptDetail.Price})";
            SQLiteCommand insert = new SQLiteCommand(sql, getConnection().OpenAndReturn());

            try
            {
                insert.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }
Beispiel #3
0
 public bool CreateReceiptDetail(DTO_ReceiptDetail newReceiptDetail)
 {
     return(dalReceiptDetail.CreateReceiptDetail(newReceiptDetail));
 }