private void btnSuaBan_Click(object sender, EventArgs e)
        {
            BanDTO banTam = new BanDTO();

            banTam.Soban = Convert.ToInt32(dtgvBan.SelectedCells[0].OwningRow.Cells["colMaBan"].Value.ToString());
            if (txtTenBan.Text == string.Empty)
            {
                MessageBox.Show("Bạn chưa nhập đầy đủ thông tin!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                banTam.Tenban = txtTenBan.Text;
                banTam.Socho  = Convert.ToInt32(nmrSoCho.Value);
            }

            if (banBus.SuaBan(banTam))
            {
                MessageBox.Show("Sửa thành công!", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LoadDsBan();
                AutoCompleteBan();
            }
            else
            {
                MessageBox.Show("Sửa thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (isAdd) // thêm thông tin bàn
            {
                Ban b = new Ban();
                //b.maBan = Convert.ToInt32(txtMaBan.Text);
                b.tenBan    = txtTenBan.Text;
                b.trangThai = cboTrangThai.Text;
                b.maKhuVuc  = Convert.ToInt32(cboKhuVuc.SelectedValue.ToString());
                if (ban.ThemBan(b) == true)
                {
                    MessageBox.Show("Thêm thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else // sai thông tin
                {
                    MessageBox.Show("Thêm thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else // cập nhật thông tin bàn
            {
                Ban b = new Ban();
                b.maKhuVuc  = Convert.ToInt32(cboKhuVuc.SelectedValue);
                b.maBan     = Convert.ToInt32(txtMaBan.Text);
                b.tenBan    = txtTenBan.Text;
                b.trangThai = cboTrangThai.Text;
                if (ban.SuaBan(b) == true)
                {
                    MessageBox.Show("Cập nhật thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else // sai thông tin
                {
                    MessageBox.Show("Cập nhật thất bại!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            EnableProject(false);
            HienThiDanhSachBanTheoKhuVuc(Convert.ToInt32(cboKhuVuc.SelectedValue.ToString()));
        }