protected override void OnLoad() { if (idTrungTam == -1) { if (idNhanVien == -1) { ListInitInfo = DMKhoDataProvider.GetListDMKhoInfor(); } else { ListInitInfo = DMKhoDataProvider.GetListKhoInforByIdNhanVien(idNhanVien); } } else { ListInitInfo = DMKhoDataProvider.GetListKhoNhapLaiInfoByTTamNVien(idTrungTam, idNhanVien); } if (baoHanh == 1) { if (ListInitInfo == null) { ListInitInfo = new List <DMKhoInfo>(); } ListInitInfo.Insert(0, new DMKhoInfo() { IdKho = 0, MaKho = "BH.KHACH", TenKho = "Kho khách bảo hành", SuDung = 1, IdTrungTam = idTrungTam }); } }
private void LoadKho() { litype = DMKhoDataProvider.GetListDMKhoInfor(); if (litype.Count > 0) { cboKho.DataSource = litype; cboKho.DisplayMember = "TenKho"; cboKho.ValueMember = "IdKho"; cboKho.SelectedValue = IdKhoDieuChuyen; } else { cboKho.DataSource = null; } }
public frmDmKhoTestUnits() { frmLogin frmLogin = new frmLogin(); frmLogin.TestLogin("quantri", "quantri"); //chuẩn bị dữ liệu để test List <DMKhoInfo> list = DMKhoDataProvider.GetListDMKhoInfor(); if (list != null) { List <DMKhoInfo> listMatch = list.FindAll(delegate(DMKhoInfo match) { return(match.MaKho == "KN1111"); }); foreach (var dmKhoInfor in listMatch) { DMKhoDataProvider.Delete(dmKhoInfor); } } }
public void TestKho07_DeleteSuccess() { TestKho05_InsertSuccess(); List <DMKhoInfo> list = DMKhoDataProvider.GetListDMKhoInfor(); DMKhoInfo infor = list.Find(delegate(DMKhoInfo match) { return(match.MaKho == "KN1111"); }); frmDM_Kho frm = new frmDM_Kho(); frm.isAdd = false; frm.Oid = infor.IdKho; frmChiTiet_Kho frmChiTietKho = new frmChiTiet_Kho(frm); frmChiTietKho.TestDelete(); list = DMKhoDataProvider.GetListDMKhoInfor(); infor = list.Find(delegate(DMKhoInfo match) { return(match.MaKho == "KN1111"); }); Assert.AreEqual(infor, null); }
public void TestKho03_MaKhoHasExistedOnUpdate() { try { TestKho05_InsertSuccess(); List <DMKhoInfo> list = DMKhoDataProvider.GetListDMKhoInfor(); DMKhoInfo infor = list.Find(delegate(DMKhoInfo match) { return(match.MaKho == "KN1111"); }); frmDM_Kho frm = new frmDM_Kho(); frm.isAdd = false; frm.Oid = infor.IdKho; frmChiTiet_Kho frmChiTietKho = new frmChiTiet_Kho(frm); frmChiTietKho.SetInput("Kho nhập", "1610040006", "KN1111", "abcdefgh", "12345678", "hanhbdgmail", "123456", "UnitsTest Kho", 1); frmChiTietKho.TestSave(); list = DMKhoDataProvider.GetListDMKhoInfor(); List <DMKhoInfo> listDuplicate = list.FindAll(delegate(DMKhoInfo match) { return(match.MaKho == "1610040006"); }); frmChiTietKho.TestDelete(); Assert.AreEqual(1, listDuplicate.Count); } catch (Exception ex) { if (ex.GetType() != typeof(AssertFailedException)) { Assert.AreEqual(ex.Message, "Mã Kho đã tồn tại trong hệ thống !"); } else { throw; } } }
private void LoadData() { frmProgress.Instance.Description = "Đang nạp dữ liệu..."; frmProgress.Instance.MaxValue = 100; frmProgress.Instance.Value = 0; frmProgress.Instance.Caption = Text; lstSource.Clear(); Invoke((MethodInvoker) delegate { grcDanhSach.RefreshDataSource(); }); idKho = String.Empty; var lstKho = DMKhoDataProvider.GetListDMKhoInfor(); foreach (DMKhoCBOLoadInfo nguoiDungInfor in ((NguoiDungInfor)Declare.USER_INFOR).KhoNguoiDung) { idKho += ((NguoiDungInfor)Declare.USER_INFOR).IsOnline || ((NguoiDungInfor)Declare.USER_INFOR).IsKinhDoanhThiTruong || ((NguoiDungInfor)Declare.USER_INFOR).IdTrungTamHachToan == nguoiDungInfor.IdTrungTam ? nguoiDungInfor.IdKho + "," : String.Empty; if (!((NguoiDungInfor)Declare.USER_INFOR).IsOnline && !((NguoiDungInfor)Declare.USER_INFOR).IsKinhDoanhThiTruong && ((NguoiDungInfor)Declare.USER_INFOR).IdTrungTamHachToan != nguoiDungInfor.IdTrungTam) { var khoInfo = lstKho.Find(delegate(DMKhoInfo match) { return(match.IdKho == nguoiDungInfor.IdKho); }); if (khoInfo != null) { string otherTrungTam = khoInfo.OtherTrungTam; if (!String.IsNullOrEmpty(otherTrungTam) && otherTrungTam.Contains(String.Format(",{0},", ((NguoiDungInfor)Declare.USER_INFOR).IdTrungTamHachToan))) { idKho += nguoiDungInfor.IdKho + ","; } } } } if (String.IsNullOrEmpty(soGiaoDich) && !String.IsNullOrEmpty(trangThai) && ngayGiaoDich == DateTime.MinValue) { frmProgress.Instance.MaxValue = 32; ngayGiaoDich = Declare.SYSDATE.AddDays(-31); var minDate = NhapDieuChuyenKhoDataProvider.Instance.GetMinDate(idKho, trangThai); if (minDate > DateTime.MinValue) { if (minDate > ngayGiaoDich) { frmProgress.Instance.Value += (int)(minDate.Date - ngayGiaoDich.Date).TotalDays; ngayGiaoDich = minDate; } while (ngayGiaoDich <= Declare.SYSDATE) { lstSource.AddRange(NhapDieuChuyenKhoDataProvider. GetFillterDeNghiNhanDieuChuyen(idKho, soGiaoDich, ngayGiaoDich, trangThai)); Invoke((MethodInvoker) delegate { grcDanhSach.RefreshDataSource(); }); ngayGiaoDich = ngayGiaoDich.AddDays(1); frmProgress.Instance.Value += 1; } } } else { lstSource.AddRange(NhapDieuChuyenKhoDataProvider. GetFillterDeNghiNhanDieuChuyen(idKho, soGiaoDich, ngayGiaoDich, trangThai)); Invoke((MethodInvoker) delegate { grcDanhSach.RefreshDataSource(); }); } frmProgress.Instance.Description = "Đã xong!"; frmProgress.Instance.Value = frmProgress.Instance.MaxValue; frmProgress.Instance.IsCompleted = true; }
private void AutoGenAllChungTu() { try { NhapNccBusiness khoBusiness; int code = 0; List <DMKhoInfo> listKho = DMKhoDataProvider.GetListDMKhoInfor(); frmProgress.Instance.MaxValue = listKho.Count; frmProgress.Instance.Value = 0; foreach (DMKhoInfo dmKhoInfo in listKho) { currentKho = dmKhoInfo; currentTrungTam = DMTrungTamDataProvider.GetTrungTamByIdInfo(dmKhoInfo.IdTrungTam); frmProgress.Instance.PushStatus(); TryLock(); frmProgress.Instance.PopStatus(); frmProgress.Instance.PushStatus(); frmProgress.Instance.MaxValue = 5; frmProgress.Instance.Value = 0; frmProgress.Instance.Description = currentKho.MaKho + ": Đang đồng bộ số liệu ... "; isComplete = false; SynsChungTuNhap(); frmProgress.Instance.PopStatus(); frmProgress.Instance.PushStatus(); frmProgress.Instance.Description = currentKho.MaKho + ": Đang import số liệu ..."; lstDataSource = tmp_NhapHang_UserProvider.GetNhapHangUserInfor(dmKhoInfo.IdKho); frmProgress.Instance.MaxValue = lstDataSource.Count; frmProgress.Instance.Value = 0; foreach (tmp_NhapHang_UserInfo tmpNhapHangUserInfo in lstDataSource) { frmProgress.Instance.Value += 1; ChungTuXuatNhapNccInfo chungTuXuatNhapNccInfo = tblChungTuDataProvider.GetChungTuNhapNCCFromSoPO( tmpNhapHangUserInfo.SoPO, tmpNhapHangUserInfo.SoPhieuNhap, Convert.ToInt32(TransactionType.NHAP_PO), currentKho.IdKho, NgayLap, tmpNhapHangUserInfo.IdChungTu); if (chungTuXuatNhapNccInfo == null) { chungTuXuatNhapNccInfo = new ChungTuXuatNhapNccInfo { SoChungTu = CommonProvider.Instance.GetSoPhieu(Declare.Prefix.PhieuNhapHangMua), NgayLap = tmpNhapHangUserInfo.NgayNhap, SoPO = tmpNhapHangUserInfo.SoPO, SoPhieuNhap = tmpNhapHangUserInfo.SoPhieuNhap, LoaiChungTu = Convert.ToInt32(TransactionType.NHAP_PO), IdDoiTuong = tmpNhapHangUserInfo.IdDoiTuong, IdKho = currentKho.IdKho }; } khoBusiness = new NhapNccBusiness(chungTuXuatNhapNccInfo); if (chungTuXuatNhapNccInfo.IdChungTu == 0) { khoBusiness.ListChiTietChungTu = KeToanNhapNccDataProvider.Instance.GetListNhapHangUserInfoFromOid(khoBusiness.ChungTu.SoPO, khoBusiness.ChungTu.SoPhieuNhap, Convert.ToInt32(LoaiGiaoDichPO.NHAP_HANG_NHA_CUNG_CAP), currentKho.IdKho); foreach (ChungTuXuatNhapNccChiTietInfo chungTuXuatNhapNccChiTietInfo in khoBusiness.ListChiTietChungTu) { if (khoBusiness.ListChiTietHangHoa.Exists(delegate(ChungTuNhapNccChiTietHangHoaInfo match) { return(match.IdSanPham == chungTuXuatNhapNccChiTietInfo.IdSanPham && match.TransactionID == chungTuXuatNhapNccChiTietInfo.TransactionID); })) { continue; } //import ma vach tu file dvFillter.RowFilter = String.Format("SoPO='{0}' and SoPhieuNhap='{1}' and MaSanPham='{2}' and MaKho='{3}'", chungTuXuatNhapNccInfo.SoPO, chungTuXuatNhapNccInfo.SoPhieuNhap, chungTuXuatNhapNccChiTietInfo.MaSanPham, dmKhoInfo.MaKho); DataTable dtTemp = dvFillter.ToTable(); foreach (DataRow dataRow in dtTemp.Rows) { ChungTuNhapNccChiTietHangHoaInfo chungTuNhapNccChiTietHangHoaInfo = new ChungTuNhapNccChiTietHangHoaInfo { DonGia = 0, IdChungTuChiTiet = 0, IdSanPham = chungTuXuatNhapNccChiTietInfo.IdSanPham, TransactionID = chungTuXuatNhapNccChiTietInfo.TransactionID }; chungTuNhapNccChiTietHangHoaInfo.MaVach = Convert.ToString(dataRow["MaVach"]); chungTuNhapNccChiTietHangHoaInfo.SoLuong = Convert.ToInt32(dataRow["SoLuong"]); khoBusiness.ListChiTietHangHoa.Add(chungTuNhapNccChiTietHangHoaInfo); } } try { if (khoBusiness.ListChiTietHangHoa.Count > 0) { khoBusiness.SaveChungTu(); } else { File.AppendAllText(Application.StartupPath + "\\ChuaNhapMaVachResult.txt", "\n" + " - SoChungTu: " + chungTuXuatNhapNccInfo.SoChungTu + " - PO: " + chungTuXuatNhapNccInfo.SoPO + " - PN: " + chungTuXuatNhapNccInfo.SoPhieuNhap); } } catch (Exception ex) { File.AppendAllText(Application.StartupPath + "\\ImportResult.txt", "\n" + ex.Message + " - PO: " + chungTuXuatNhapNccInfo.SoPO + " - PN: " + chungTuXuatNhapNccInfo.SoPhieuNhap); } } else //if (khoBusiness.ListChiTietHangHoa.Count == 0) { DataTable dtTemp = null; foreach (ChungTuXuatNhapNccChiTietInfo chungTuXuatNhapNccChiTietInfo in khoBusiness.ListChiTietChungTu) { if (khoBusiness.GetListChiTietHangHoaByIdSanPham(chungTuXuatNhapNccChiTietInfo.IdSanPham).Count < chungTuXuatNhapNccChiTietInfo.SoLuong) { dvFillter.RowFilter = String.Format("SoPO='{0}' and SoPhieuNhap='{1}' and MaSanPham='{2}' and MaKho='{3}'", chungTuXuatNhapNccInfo.SoPO, chungTuXuatNhapNccInfo.SoPhieuNhap, chungTuXuatNhapNccChiTietInfo.MaSanPham, dmKhoInfo.MaKho); dtTemp = dvFillter.ToTable(); foreach (DataRow dataRow in dtTemp.Rows) { string maVach = Convert.ToString(dataRow["MaVach"]); if (khoBusiness.ListChiTietHangHoa.Exists(delegate(ChungTuNhapNccChiTietHangHoaInfo match) { return(match.MaVach == maVach); })) { continue; } ChungTuNhapNccChiTietHangHoaInfo chungTuNhapNccChiTietHangHoaInfo = new ChungTuNhapNccChiTietHangHoaInfo { DonGia = 0, IdChungTuChiTiet = 0, IdSanPham = chungTuXuatNhapNccChiTietInfo.IdSanPham, TransactionID = chungTuXuatNhapNccChiTietInfo.TransactionID }; chungTuNhapNccChiTietHangHoaInfo.MaVach = maVach; chungTuNhapNccChiTietHangHoaInfo.SoLuong = Convert.ToInt32(dataRow["SoLuong"]); khoBusiness.ListChiTietHangHoa.Add(chungTuNhapNccChiTietHangHoaInfo); } } } try { if (dtTemp != null && dtTemp.Rows.Count > 0 && khoBusiness.ListChiTietHangHoa.Count > 0) { khoBusiness.SaveChungTu(); } else { //try //{ // khoBusiness.DeleteChungTu(); // tmp_NhapHang_LogDataProvider.Delete(chungTuXuatNhapNccInfo.SoPO, chungTuXuatNhapNccInfo.SoPhieuNhap, Convert.ToInt32(LoaiGiaoDichPO.NHAP_HANG_NHA_CUNG_CAP), Declare.IdKho); //} //catch (Exception) //{ // File.AppendAllText(Application.StartupPath + "\\ChuaNhapMaVachResult.txt", "\n" // + " - SoChungTu: " + chungTuXuatNhapNccInfo.SoChungTu // + " - PO: " + chungTuXuatNhapNccInfo.SoPO + " - PN: " + chungTuXuatNhapNccInfo.SoPhieuNhap); //} } } catch (Exception ex) { File.AppendAllText(Application.StartupPath + "\\ImportResult.txt", "\n" + ex.Message + " - PO: " + chungTuXuatNhapNccInfo.SoPO + " - PN: " + chungTuXuatNhapNccInfo.SoPhieuNhap); } } } frmProgress.Instance.PopStatus(); frmProgress.Instance.Value += 1; } frmProgress.Instance.Description = "Đã hoàn thành."; frmProgress.Instance.Value = frmProgress.Instance.MaxValue; frmProgress.Instance.IsCompleted = true; } catch (Exception ex) { #if DEBUG if (isComplete) { MessageBox.Show(ex.ToString()); } #else if (isComplete) { MessageBox.Show(ex.Message); } #endif EventLogProvider.Instance.WriteLog(ex.ToString() + "\nUser: "******"\nKho: " + Declare.IdKho, this.Name); } }