示例#1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaBan.Text == "")
            {
                MessageBox.Show("Mã bàn không được trống", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtMaBan.Focus();
                return;
            }
            if (txtTenBan.Text == "")
            {
                MessageBox.Show("Tên bàn không được trống", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTenBan.Focus();
                return;
            }
            if (frmBan.luu == true)
            {
                if (KiemTraTrung(txtMaBan.Text) == 1)
                {
                    MessageBox.Show("Không lưu được, Bàn này đã tồn tại trong cơ sở dữ liệu", "Thông báo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DTO.MaBan        = txtMaBan.Text;
                DTO.TenBan       = txtTenBan.Text;
                DTO.SoLuongNguoi = nmSoLuongNguoi.Value;
                DTO.GhiChu       = txtGhiChu.Text;

                BUS.Them(DTO);
                MessageBox.Show("Thêm xong ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                gridView.DataSource = BUS.DanhSachBan();
                this.Close();
            }
            else if (frmBan.luu == false)
            {
                if (KiemTraTrung(txtMaBan.Text) == 1 && txtMaBan.Text != frmBan.MaBan)
                {
                    MessageBox.Show("Không lưu được, Tài khoản này đã tồn tại", "Thông báo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DTO.MaBan_Sua    = frmBan.MaBan;
                DTO.MaBan        = txtMaBan.Text;
                DTO.TenBan       = txtTenBan.Text;
                DTO.SoLuongNguoi = nmSoLuongNguoi.Value;
                DTO.GhiChu       = txtGhiChu.Text;

                BUS.Sua(DTO);
                MessageBox.Show("Sửa xong ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                gridView.DataSource = BUS.DanhSachBan();
                this.Close();
            }
        }
示例#2
0
 private void DanhSachBan()
 {
     grdBan.AllowUserToAddRows    = false;
     grdBan.DataSource            = BUS.DanhSachBan();
     grdBan.Columns[0].HeaderText = "Mã ban";
     grdBan.Columns[1].HeaderText = "Tên bàn";
     grdBan.Columns[2].HeaderText = "Số lượng";
     grdBan.Columns[3].HeaderText = "Ghi chú";
     grdBan.Columns[0].Width      = 100;
     grdBan.Columns[1].Width      = 150;
     grdBan.Columns[2].Width      = 100;
     grdBan.Columns[3].Width      = 150;
 }
        private void DanhSachBan()
        {
            DataTable dt = BUS_Ban.DanhSachBan();

            cboMaBan.DataSource    = dt;
            cboMaBan.DisplayMember = "TenBan";
            cboMaBan.ValueMember   = "MaBan";
        }