private void dataGridViewX1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn xóa không?", "Phieu Nhan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                DataRowView                       view = (DataRowView)bindingNavigator1.BindingSource.Current;
                ChiTietPhieuNhanControl           ctrl = new ChiTietPhieuNhanControl();
                IList <ChiTietPhieuNhanPhongInFo> ds   = ctrl.ChiTietPhieuNhan(view["MaNhanPhong"].ToString());

                ctrl.Save();
            }
        }
Exemplo n.º 2
0
        void ThemMoi()
        {
            DataRow row = ctrl.NewRow();

            row["MaNhanPhong"] = txtMaNhanPhong.Text;
            row["MaPhieuThue"] = cmbMaPThue.SelectedValue;
            row["MaKhachHang"] = cmbMaKH.SelectedValue;

            ctrl.Add(row);

            PhieuNhanPhongControl ctrlPN = new PhieuNhanPhongControl();

            if (ctrlPN.LayPhieuNhan(txtMaNhanPhong.Text) != null)
            {
                MessageBox.Show("Mã Phiếu này đã tồn tại !", "Phieu Nhan", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ThamSo.LaSoNguyen(txtMaNhanPhong.Text))
            {
                int so = Convert.ToInt32(txtMaNhanPhong.Text);
                if (so >= ThamSo.LayPhieuNhan())
                {
                    ThamSo.GanPhieuNhan(so + 1);
                }
            }

            ctrl.Update();
            DataTable tblCTP = (DataTable)bindingNavigator1.BindingSource.DataSource;

            ctpnctrl.Update();
            ctrl.Save();
            ctpnctrl.Save();
            khctrl.Save();
            ptctrl.Save();
        }