public void LapPhieuXuat(GD_PHIEU_XUAT phieu_xuat, BindingList <GD_HANG> ip_lst_to_insert) { using (var uow = new UnitOfWork()) { uow.Repository <GD_PHIEU_XUAT>().Insert(phieu_xuat); foreach (var item in ip_lst_to_insert) { item.ObjectState = MODEL.Common.ObjectState.Modified; item.ID_TRANG_THAI = Convert.ToInt64(ReadDataConfig.ReadByKey("XUAT_KHO")); uow.Repository <GD_HANG>().Update(item); var chiTietPhieu = new GD_PHIEU_XUAT_CHI_TIET(); chiTietPhieu.ObjectState = MODEL.Common.ObjectState.Added; uow.Repository <GD_PHIEU_XUAT_CHI_TIET>().SaveWithSyncObjectState(chiTietPhieu); chiTietPhieu.GD_HANG = item; } uow.Save(); } }
private void lap_phieu() { if (!ControlUtility.ValidateControlEmpty(m_txt_so_phieu, m_dat_ngay_chung_tu, m_le_kho, m_sle_nhan_vien)) { XtraMessageBox.Show("Hoàn thiện dữ liệu trước", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (m_grv_ds_hang.RowCount <= 0) { XtraMessageBox.Show("Chưa có hàng để nhập", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var phieu_xuat = new GD_PHIEU_XUAT() { SO_CHUNG_TU = m_txt_so_phieu.Text, NGAY_CHUNG_TU = m_dat_ngay_chung_tu.DateTime, ID_NHAN_VIEN_LIEN_QUAN = (long)m_sle_nhan_vien.EditValue, NGAY_NHAP_PHAN_MEM = DateTime.Now.Date, ID_KHACH_HANG = (long?)m_sle_khach_hang.EditValue }; BS_MAT_HANG.Instance.LapPhieuXuat(phieu_xuat, m_lst_hang); var dlg = XtraMessageBox.Show("Lập phiếu nhập thành công! Bạn muốn lập phiếu nhập mới?", "THÔNG BÁO", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlg == System.Windows.Forms.DialogResult.OK) { reset_xuat_hang(); reset_phieu_nhap(); m_lst_hang = new BindingList <GD_HANG>(); } else { Dispose(); } }