public void ThemLoaiBanAn()
        {
            Form_ThemLoaiBanAn openf = new Form_ThemLoaiBanAn();

            openf.Mode = mode;
            if (openf.ShowDialog() == DialogResult.OK)
            {
                LoaiBanAn_BUS.ThemLoaiBanAn(openf.LoaiBA);
                gridLoaiBA.DataSource = LoaiBanAn_BUS.DocLoaiBanAn();
            }
        }
        private void UCtrlQLDanhSachBanAn_Load(object sender, EventArgs e)
        {
            gridLoaiBA.DataSource = LoaiBanAn_BUS.DocLoaiBanAn();
            gridKhuVuc.DataSource = KhuVuc_BUS.DocKhuVuc();
            gridBanAn.DataSource  = BanAn_BUS.DocBanAn(maNH);

            DataTable dt = LoaiBanAn_BUS.DocLoaiBanAn();

            if (dt.Rows.Count > 0)
            {
                ArrayMaBan = new string[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    ArrayMaBan[i] = dr[0].ToString();;
                }
            }
        }
Exemplo n.º 3
0
        private void Form_ThemBanAn_Load(object sender, EventArgs e)
        {
            cbbKhuVuc.Properties.Items.Clear();
            DataTable dt = KhuVuc_BUS.DocKhuVuc();

            if (dt.Rows.Count > 0)
            {
                ArrayMaKV = new int[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    cbbKhuVuc.Properties.Items.Add(dr[1]);
                    ArrayMaKV[i] = (int)dr[0];
                }
            }

            // cbbNhaHang.Properties.Items.Clear();
            //DataTable dt1 = KhuVuc_BUS.LayNhaHang();
            //if (dt.Rows.Count > 0)
            //{
            //    ArrayMaNH = new string[dt1.Rows.Count];
            //    for (int i = 0; i < dt1.Rows.Count; i++)
            //    {
            //        DataRow dr = dt1.Rows[i];
            //        cbbNhaHang.Properties.Items.Add(dr[1]);
            //        ArrayMaNH[i] = dr[0].ToString();
            //    }
            //}

            cbbSucChua.Properties.Items.Clear();
            DataTable dt2 = LoaiBanAn_BUS.DocLoaiBanAn();

            if (dt.Rows.Count > 0)
            {
                ArrayLoaiBan = new string[dt2.Rows.Count];
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    DataRow dr = dt2.Rows[i];
                    cbbSucChua.Properties.Items.Add(dr[1]);
                    ArrayLoaiBan[i] = dr[0].ToString();
                }
            }
        }
        public void CapNhatLoaiBA()
        {
            int flag = 0;

            int[] index = gridView_LoaiBanAn.GetSelectedRows();
            if (index.Length > 0)
            {
                string maloai  = gridView_LoaiBanAn.GetRowCellValue(index[0], "Maloai").ToString();
                string sucChua = gridView_LoaiBanAn.GetRowCellValue(index[0], "SucChua").ToString();
                if (maloai != null)
                {
                    DTO.LoaiBanAn_DTO loaiBA = new DTO.LoaiBanAn_DTO();
                    loaiBA.MaLoai  = maloai;
                    loaiBA.SucChua = int.Parse(sucChua);
                    flag           = LoaiBanAn_BUS.CapNhatLoaiBA(loaiBA);
                }
            }
            if (flag != 0)
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("Cập nhật thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        public void XoaLoaiBanAn()
        {
            int flag = 0;

            int[] index = gridView_LoaiBanAn.GetSelectedRows();
            if (index.Length > 0)
            {
                if (DevExpress.XtraEditors.XtraMessageBox.Show("Bạn có muốn xóa dòng thứ " + (index[0] + 1).ToString(), "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string maloai = gridView_LoaiBanAn.GetRowCellValue(index[0], "Maloai").ToString();
                    flag = LoaiBanAn_BUS.XoaLoaiBanAn(maloai);
                }
                if (flag != 0)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Xóa thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Không thể xóa Loại Bàn Ăn khi còn Bàn Ăn trong Loại Bàn Ăn", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
 private void btnXoaLoaiBA_Click(object sender, EventArgs e)
 {
     XoaLoaiBanAn();
     gridLoaiBA.DataSource = LoaiBanAn_BUS.DocLoaiBanAn();
 }