Ejemplo n.º 1
0
        private void btnCheckOut_Click(object sender, EventArgs e)
        {
            if (lblNameOfCustomer.Text.Trim().Length == 0)
            {
                XtraMessageBox.Show("Hãy nhập thông tin khách hàng", "Thông báo");
                return;
            }
            try
            {
                tbl_Bill bill = new tbl_Bill();
                bill.AdminID    = SessionInfo.adminID;
                bill.BilledDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
                bill.CustomerID = int.Parse(txtCustomerID.Text);
                tbl_Bill.InsertOnSubmit(bill);

                db.SubmitChanges();

                tbl_Bill curBill = db.tbl_Bills.OrderByDescending(res => res.BillID).FirstOrDefault();

                foreach (DataRow dr in dt.Rows)
                {
                    tbl_DetailedBill detailedBill = new tbl_DetailedBill();
                    detailedBill.IDBill    = curBill.BillID;
                    detailedBill.IDProduct = int.Parse(dr[0].ToString());
                    detailedBill.UnitPrice = int.Parse(dr[3].ToString());
                    detailedBill.Amount    = int.Parse(dr[2].ToString());
                    db.tbl_DetailedBills.InsertOnSubmit(detailedBill);
                }

                db.SubmitChanges();
                XtraMessageBox.Show("Thanh toán thành công", "Thông báo");
                btnCheckOut.Enabled = false;
                btnCreate.Enabled   = false;
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Thanh toán thất bại" + ex.Message, "Thông báo");
            }
        }
 partial void Deletetbl_DetailedBill(tbl_DetailedBill instance);
 partial void Updatetbl_DetailedBill(tbl_DetailedBill instance);
 partial void Inserttbl_DetailedBill(tbl_DetailedBill instance);