public int UpdateArea(AreaData area)
 {
     Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
     sqlStoredProcedureParams.Add("maKhuVuc", area.AreaId);
     sqlStoredProcedureParams.Add("tenKhuVuc", area.AreaName);
     sqlStoredProcedureParams.Add("ghiChu", area.Note);
     return provider.ExecuteNonQuery("KHUVUC_proc_update", sqlStoredProcedureParams);
 }
        public List<AreaData> GetAllArea()
        {
            List<AreaData> listArea = new List<AreaData>();
            DataTable dt = provider.ExecuteReader("KHUVUC_proc_load");

            foreach (DataRow row in dt.Rows)
            {
                AreaData area = new AreaData();
                area.AreaId = row["MaKhuVuc"].ToString();
                area.AreaName = row["TenKhuVuc"].ToString();

                listArea.Add(area);
            }

            return listArea;
        }
Beispiel #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtKhuVuc.Text.Trim()))
            {
                MessageDialogHelper.CreateErrorMessage("Tên khu vực không được để trống.");
                return;
            }

            AreaData areaToSave = new AreaData();
            areaToSave.AreaName = txtKhuVuc.Text.Trim();
            LocatorBll.AreaAndTableBll.AreaToSave = areaToSave;

            if (LocatorBll.AreaAndTableBll.AddArea())
            {
                if (MessageDialogHelper.CreateInformationMessage("Lưu thành công.") == DialogResult.OK)
                    this.Close();
            }
        }
        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;
        }
        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;
        }
 public int DeleteArea(AreaData area)
 {
     Dictionary<string, object> sqlStoredProcedureParams = new Dictionary<string, object>();
     sqlStoredProcedureParams.Add("maKhuVuc", area.AreaId);
     return provider.ExecuteNonQuery("KHUVUC_proc_delete", sqlStoredProcedureParams);
 }