private void BaoCaoChiTietPhieuThu(int stt) { Thread thr = Thread.CurrentThread; Status = String.Format("{0} [Lần thực hiện thứ {1} ({2})] ...", thr.Name, stt, DateTime.Now.ToString());// String.Format("{0} đang thực hiện ...", thr.Name); Stopwatch watch = Stopwatch.StartNew(); MsgTest msg = new MsgTest(); try { TimKiemPhieuThuFilterInfor filter = new TimKiemPhieuThuFilterInfor(); filter.SoBatDau = 0; filter.SoKetThuc = Common.IntValue(SoChungTu) != 0 ? Common.IntValue(SoChungTu) : 100;//-1 msg.Infors = String.Format("{0} [Lần thực hiện thứ {1} ({2})]: {3}", thr.Name, stt, DateTime.Now.ToString(), "Báo cáo chi tiết phiếu thu"); msg.Result = "Đang thực hiện ..."; arrImportMsg.Add(msg); List <ChungTuThanhToanInfor> liTimKiem = BaoCaoChiTietPhieuThuChiDataProvider.Instance.TimKiemPThuCTietPg(filter); watch.Stop(); msg.Result = String.Format("Thành công (Thời gian {0}/{1} kết quả)", watch.ElapsedMilliseconds, liTimKiem.Count); msg.Ok = 1; msg.Fail = 0; } catch (Exception ex) { watch.Stop(); msg.Result = String.Format("Thất bại (Thời gian {0}/err: {1})", watch.ElapsedMilliseconds, ex.ToString()); msg.Ok = 0; msg.Fail = 1; //CancelThread(thr); } }
private void BangGiaHienTai(int stt) { Thread thr = Thread.CurrentThread; Status = String.Format("{0} [Lần thực hiện thứ {1} ({2})] ...", thr.Name, stt, DateTime.Now.ToString());// String.Format("{0} đang thực hiện ...", thr.Name); Stopwatch watch = Stopwatch.StartNew(); MsgTest msg = new MsgTest(); try { int soBatDau = 0; int soKetThuc = Common.IntValue(SoChungTu) != 0 ? Common.IntValue(SoChungTu) : 100; //-1 int idTrungTam = Declare.IdTrungTam; int coTon = 1; // : 0; msg.Infors = String.Format("{0} [Lần thực hiện thứ {1} ({2})]: {3}", thr.Name, stt, DateTime.Now.ToString(), "Bảng giá hiện tại"); msg.Result = "Đang thực hiện ..."; arrImportMsg.Add(msg); List <BangGiaBanChiTietBCInfor> liTimKiem = BangGiaDataProvider.Instance.GetBangGiaBanPg(idTrungTam, coTon, soBatDau, soKetThuc, "", "", Declare.SOLUONG_HIENTHI_TON, -1); watch.Stop(); msg.Result = String.Format("Thành công (Thời gian {0}/{1} kết quả)", watch.ElapsedMilliseconds, liTimKiem.Count); msg.Ok = 1; msg.Fail = 0; } catch (Exception ex) { watch.Stop(); msg.Result = String.Format("Thất bại (Thời gian {0}/err: {1})", watch.ElapsedMilliseconds, ex.ToString()); msg.Ok = 0; msg.Fail = 1; //CancelThread(thr); } }
private void LapDonHang_ThuTien_XuatKho(int stt) { Thread thr = Thread.CurrentThread; Status = String.Format("{0} [Lần thực hiện thứ {1} ({2})] ...", thr.Name, stt, DateTime.Now.ToString());// String.Format("{0} đang thực hiện ...", thr.Name); Stopwatch watch = Stopwatch.StartNew(); MsgTest msg = new MsgTest(); arrImportMsg.Add(msg); try { msg.Infors = String.Format("{0} [Lần thực hiện thứ {1} ({2})]: {3}", thr.Name, stt, DateTime.Now.ToString(), "Lập đơn hàng => Thu tiền => Xuất kho"); msg.Result = "Đang load chứng từ ..."; string soChungTu = String.IsNullOrEmpty(txtSoChungTu.Text) ? soCT : txtSoChungTu.Text.Trim(); ChungTuBanHangInfor ctu = ImportChungTuDataProvider.Instance.LoadChungTuBySoChungTuGoc(soChungTu); if (ctu != null) { ImportDonHangBusiness Business = new ImportDonHangBusiness(ctu); msg.Result = "Đã nạp chứng từ. Đang nạp chi tiết chứng từ ..."; Business.ListChiTietChungTu = ImportChungTuDataProvider.Instance.GetListChiTietChungTuBySoChungTuGoc(ctu.SoChungTuGoc); if (Business.ListChiTietChungTu.Count == 0) { throw new ManagedException("Không tìm thấy chi tiết đơn hàng."); } msg.Result = "Đã nạp chứng từ, chi tiết chứng từ. Đang nạp phiếu xuất ..."; Business.ListChiTietHangHoa = ImportChungTuDataProvider.Instance.GetListChiTietHangHoaBySoChungTuGoc(ctu.SoChungTuGoc, ctu.IdKho); if (Business.ListChiTietHangHoa.Count == 0) { throw new ManagedException("Không tìm thấy chi tiết phiếu xuất kho."); } msg.Result = "Đã nạp chứng từ, chi tiết chứng từ, phiếu xuất. Đang nạp phiếu thu ..."; Business.ListChungTuThanhToan = ImportChungTuDataProvider.Instance.GetListChungTuThanhToanBySoChungTuGoc(ctu.SoChungTuGoc); //cap nhat chi tiet phieu thu double tienThu = 0; foreach (ChungTuThanhToanInfor tt in Business.ListChungTuThanhToan) { tt.SoPhieu = String.Format("TP-{0}-{1}-{2}-{3}", Declare.Prefix.PhieuThanhToan, thr.Name, stt, DateTime.Now.Millisecond); tt.IdTienTe = Declare.IdTienTe; tt.TyGia = 1; tt.SoTienChu = Common.ReadNumner_(Common.Double2Str(tt.SoTienThanhToan)); //tt.IdTrungTamThu = ctu.IdTrungTam; tienThu += tt.SoTienThanhToan; tt.TenMayTao = Declare.TenMay; tt.TenMaySua = Declare.TenMay; } if (ctu.TongTienThanhToan < tienThu) { Business.ListChungTuThanhToan.Clear();//khong cho phep thu ctu.TienThanhToanThuc = 0; ctu.TienConNo = ctu.TongTienThanhToan; } else { ctu.TienThanhToanThuc = tienThu; ctu.TienConNo = ctu.TongTienThanhToan - tienThu; } ctu.IdChungTu = 0; ctu.SoChungTu = String.Format("TP-{0}-{1}-{2}-{3}", Declare.Prefix.TaoDonHangBan, thr.Name, stt, DateTime.Now.Millisecond); ctu.SoPhieuXuat = String.Format("TP-{0}-{1}-{2}-{3}", Declare.Prefix.PhieuXuatKhoHangBan, thr.Name, stt, DateTime.Now.Millisecond); ctu.TenMayTao = Declare.TenMay; ctu.TenMaySua = Declare.TenMay; msg.Result = "Đã nạp dữ liệu. Đang tạo đơn hàng ..."; //import vao pos //lock (syncObj) //{ try { //ConnectionUtil.Instance.BeginTransaction(); Business.SaveChungTu(); //ConnectionUtil.Instance.CommitTransaction(); watch.Stop(); msg.Result = String.Format("Thành công (Thời gian thực hiện {0})", watch.ElapsedMilliseconds); msg.Ok = 1; msg.Fail = 0; } catch (Exception ex) { //ConnectionUtil.Instance.RollbackTransaction(); watch.Stop(); msg.Result = String.Format("Thất bại (Thời gian {0}/err: {1})", watch.ElapsedMilliseconds, ex.ToString()); msg.Ok = 0; msg.Fail = 1; } //} } else { throw new ManagedException("Không có dữ liệu!"); } } catch (Exception ex) { watch.Stop(); msg.Result = String.Format("Thất bại (Thời gian {0}/err: {1})", watch.ElapsedMilliseconds, ex.ToString()); msg.Ok = 0; msg.Fail = 1; //CancelThread(thr); } }