Esempio n. 1
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            cDining_Table table = lsvBill.Tag as cDining_Table;

            int idBill = cBill.GetUncheckBillIDByTableID(table.ID);

            if (idBill != -1)
            {
                if (MessageBox.Show("Bạn có chắc thanh toán hóa đơn cho " + table.DiningTableName, "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    DataProvider.ExecuteQuery("UPDATE dbo.Bill SET BillStatus = N'Đã thanh toán', PaymentDate = CURRENT_TIMESTAMP WHERE id = " + idBill);

                    rBill           report = new rBill(idBill);
                    ReportPrintTool print  = new ReportPrintTool(report);
                    report.ShowPreview();

                    ShowBill(table.ID);

                    loadFpnl(cDining_Table.LoadAllTableList());
                    btnPayment.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show("Có lỗi xảy ra !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static List <cDining_Table> LoadEmptyTableList()
        {
            List <cDining_Table> tableList = new List <cDining_Table>();

            DataTable data = DataProvider.ExecuteQuery("SELECT * FROM dbo.Dining_Table WHERE TableStatus = N'Trống'");

            foreach (DataRow item in data.Rows)
            {
                cDining_Table table = new cDining_Table(item);
                tableList.Add(table);
            }

            return(tableList);
        }
Esempio n. 3
0
        private void tsmMenuAdd_Click(object sender, EventArgs e)
        {
            cDining_Table table = lsvBill.Tag as cDining_Table;

            if (table == null)
            {
                MessageBox.Show("Hãy chọn bàn !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            fInput f = new fInput();

            f.ShowDialog();

            if (f.amount == 0)
            {
                return;
            }

            string id = string.Empty;

            if (DataProvider.ExecuteQuery("SELECT dbo.Products.id FROM dbo.Products WHERE dbo.Products.ProductName = N'" + lsvMenu.SelectedItems[0].Text + "'") != null)
            {
                foreach (DataRow dr in DataProvider.ExecuteQuery("SELECT dbo.Products.id FROM dbo.Products WHERE dbo.Products.ProductName = N'" + lsvMenu.SelectedItems[0].Text + "'").Rows)
                {
                    id = dr["id"].ToString();
                }
            }

            int idBill = cBill.GetUncheckBillIDByTableID(table.ID);

            int productID = int.Parse(id);

            int amount = f.amount;

            if (idBill == -1)
            {
                cBill.InsertBill(table.ID);
                cBillInfo.InsertBillInfo(cBill.GetMaxIDBill(), productID, amount);
            }
            else
            {
                cBillInfo.InsertBillInfo(idBill, productID, amount);
            }

            ShowBill(table.ID);
            loadFpnl(cDining_Table.LoadAllTableList());
            btnPayment.Enabled = true;
        }