public int AddTable(TableData table)
 {
     Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
     sqlStoredProcedureParams.Add("maBan", table.TableId);
     sqlStoredProcedureParams.Add("tenBan", table.TableName);
     sqlStoredProcedureParams.Add("maKhuVuc", table.Area.AreaId);
     sqlStoredProcedureParams.Add("ghiChu", table.Note);
     return provider.ExecuteNonQuery("BAN_proc_insert", sqlStoredProcedureParams);
 }
        /// <summary>
        /// Lấy ra bill chưa thanh toán cuối cùng của bàn.
        /// </summary>
        /// <param name="table"></param>
        /// <returns></returns>
        public BillData GetLastBill(TableData table)
        {
            BillData bill = new BillData();
            Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
            sqlStoredProcedureParams.Add("maBan", table.TableId);
            DataTable dt = provider.ExecuteReader("HOADON_proc_get_last_bill", sqlStoredProcedureParams);

            if (dt.Rows.Count == 1)
            {
                bill.BillId = dt.Rows[0]["MaHoaDon"].ToString();
                bill.Table = new TableData { TableId = dt.Rows[0]["MaBan"].ToString() };
                bill.TableLiquidate = new TableData { TableId = dt.Rows[0]["MaBanThanhToan"].ToString() };
                bill.Time = DateTime.Parse(dt.Rows[0]["ThoiGian"].ToString());
                bill.TotalMoney = Decimal.Parse(dt.Rows[0]["TongTien"].ToString());
            }

            return bill;
        }
        public List<TableData> GetAllTable(AreaData area)
        {
            List<TableData> listTable = new List<TableData>();
            Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
            sqlStoredProcedureParams.Add("maKhuVuc", area.AreaId);
            DataTable dt = provider.ExecuteReader("BAN_proc_load_with_MaKhuVuc", sqlStoredProcedureParams);

            foreach (DataRow row in dt.Rows)
            {
                TableData table = new TableData();
                table.TableId = row["MaBan"].ToString();
                table.TableName = row["TenBan"].ToString();
                table.Area = area;
                table.TableState = row["TinhTrang"].ToString();
                table.Note = row["GhiChu"].ToString();

                listTable.Add(table);
            }

            return listTable;
        }
Beispiel #4
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTenBan.Text.Trim()))
            {
                MessageDialogHelper.CreateErrorMessage("Tên bàn không được để trống.");
                return;
            }
            TableData tableToSave = new TableData();
            tableToSave.TableName = txtTenBan.Text.Trim();

            tableToSave.Area = LocatorBll.AreaAndTableBll.AreaSelected;

            tableToSave.TableState = "Trong";

            LocatorBll.AreaAndTableBll.TableToSave = tableToSave;

            if (LocatorBll.AreaAndTableBll.AddTable())
            {
                if (MessageDialogHelper.CreateInformationMessage("Lưu thành công.") == DialogResult.OK)
                    this.Close();
            }
        }
        public List<TableData> GetAllTable()
        {
            List<TableData> listTable = new List<TableData>();
            DataTable dt = provider.ExecuteReader("BAN_proc_load");

            foreach (DataRow row in dt.Rows)
            {
                TableData table = new TableData();
                table.TableId = row["MaBan"].ToString();
                table.TableName = row["TenBan"].ToString();
                table.Area = new AreaData
                {
                    AreaId = row["MaKhuVuc"].ToString(),
                    AreaName = row["TenKhuVuc"].ToString()
                };

                table.TableState = row["TinhTrang"].ToString();

                listTable.Add(table);
            }

            return listTable;
        }
        public List<TableData> GetAllTableToChoose(AreaData area)
        {
            List<TableData> listTable = new List<TableData>();

            TableData all = new TableData();
            all.TableName = "Tất cả bàn";
            listTable.Add(all);

            DataTable dt = null;

            if (string.IsNullOrEmpty(area.AreaId))
            {
                dt = provider.ExecuteReader("BAN_proc_load");
            }
            else
            {
                Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
                sqlStoredProcedureParams.Add("maKhuVuc", area.AreaId);
                dt = provider.ExecuteReader("BAN_proc_load_with_MaKhuVuc", sqlStoredProcedureParams);
            }

            foreach (DataRow row in dt.Rows)
            {
                TableData table = new TableData();
                table.TableId = row["MaBan"].ToString();
                table.TableName = row["TenBan"].ToString();

                table.Area = new AreaData
                {
                    AreaId = row["MaKhuVuc"].ToString()
                };

                listTable.Add(table);
            }

            return listTable;
        }
Beispiel #7
0
        private void updateInfo(TableData table)
        {
            lblTenBan.Text = table.TableName;
            string trangthai = "???";
            string TableState = table.TableState;
            if ("Trong".Equals(TableState))
            {
                trangthai = "Trống";
            }
            else if ("CoNguoi".Equals(TableState))
            {
                trangthai = "Có Người";
            }
            else if ("ChuaDon".Equals(TableState))
            {
                trangthai = "Chưa Dọn";
            }
            else if ("DaDat".Equals(TableState))
            {
                trangthai = "Đã Đặt Trước";
            }
            lblTrangThai.Text = trangthai;
            if (homePageBll.BillOfTableSelected != null && homePageBll.BillOfTableSelected.TableLiquidate != null)
            {
                TableData tableLiquidate = null;
                tableLiquidate = LocatorDataSource.TableDS.GetTable(homePageBll.BillOfTableSelected.TableLiquidate);
                if (tableLiquidate != null)
                {
                    lblBanThanhToan.Text = tableLiquidate.TableName;
                }

            }
            else
            {
                lblBanThanhToan.Text = String.Empty;
            }
        }
 public int DeleteTable(TableData table)
 {
     Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
     sqlStoredProcedureParams.Add("maBan", table.TableId);
     return provider.ExecuteNonQuery("BAN_proc_delete", sqlStoredProcedureParams);
 }
        public TableData GetTable(TableData table)
        {
            TableData getTable = new TableData();
            Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
            sqlStoredProcedureParams.Add("maBan", table.TableId);
            DataTable dt = provider.ExecuteReader("BAN_proc_get", sqlStoredProcedureParams);

            if (dt.Rows.Count == 1)
            {
                getTable.TableId = dt.Rows[0]["MaBan"].ToString();
                getTable.TableName = dt.Rows[0]["TenBan"].ToString();
                getTable.Area = new AreaData
                {
                    AreaId = dt.Rows[0]["MaKhuVuc"].ToString(),
                    AreaName = dt.Rows[0]["TenKhuVuc"].ToString()
                };

                getTable.TableState = dt.Rows[0]["TinhTrang"].ToString();
            }

            return getTable;
        }