private void grvPhieuNhap_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            IMP_PhieuNhap pn = (IMP_PhieuNhap)grvPhieuNhap.GetFocusedRow();

            if (pn != null)
            {
                PhieuNhapCTCtrl.LoadBindingSource(pn.ID_phieu_nhap, iMPPhieuNhapCTBindingSource);
            }
        }
        private void frmSuaPhieuNhap_Load(object sender, EventArgs e)
        {
            if (pn == null)
            {
                XtraMessageBox.Show("Có lỗi xảy ra, không tìm thấy phiếu nhập!", "Sửa phiếu nhập", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.Cancel;
            }

            Entities db = new Entities();

            VaiTroQuyenCtrl.ReconfigFormControls(this, db);
            VatTuCtrl.LoadLookUpEdit(repositoryItemLookUpEdit1, db);
            NhanVienCtrl.LoadLookUpEdit(ledNhanVienNhap, db);
            KhoVatTuCtrl.LoadLookUpEdit(ledKhoNhap, db);

            if (pn.ID_loai_nhap == 1)
            {
                NhaCungCapCtrl.LoadLookUpEdit(ledNhaCungCap, db);
            }
            else
            {
                txtChungTuGoc.Properties.ReadOnly = true;
                ledNhaCungCap.Properties.ReadOnly = true;
            }

            ledNhanVienNhap.EditValue = pn.ID_nhan_vien_nhap;
            ledKhoNhap.EditValue      = pn.ID_kho;
            mmoGhiChu.Text            = pn.Ghi_chu;
            txtChungTuGoc.Text        = pn.So_chung_tu_goc;
            ledNhaCungCap.EditValue   = pn.ID_nha_cung_cap;
            dteNgayNhap.EditValue     = pn.Ngay_nhap;

            PhieuNhapCTCtrl.LoadBindingSource(pn.ID_phieu_nhap, iMPPhieuNhapCTBindingSource, db);

            if (pn.Trang_thai != 0)
            {
                colID_vat_tu.OptionsColumn.ReadOnly            = true;
                colSo_luong.OptionsColumn.ReadOnly             = true;
                ledKhoNhap.Properties.ReadOnly                 = true;
                grvPhieuNhapCT.OptionsView.NewItemRowPosition  = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None;
                grvPhieuNhapCT.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False;
            }
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            IMP_PhieuNhap pn = (IMP_PhieuNhap)grvPhieuNhap.GetFocusedRow();

            if (pn != null)
            {
                if (pn.Trang_thai == -1)
                {
                    XtraMessageBox.Show("Phiếu nhập đã được xác thực nên không thể sửa!", "Sửa phiếu nhập", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    frmSuaPhieuNhap frm = new frmSuaPhieuNhap(pn);

                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        btnTimKiem.PerformClick();
                        PhieuNhapCTCtrl.LoadBindingSource(pn.ID_phieu_nhap, iMPPhieuNhapCTBindingSource);
                    }
                }
            }
        }