Exemple #1
0
        private void SaveDonHang(ChungTuBanHangInfor ctu)
        {
            LapDonHangBusiness Business = new LapDonHangBusiness(ctu);

            Business.ListChiTietChungTu =
                ImportChungTuDataProvider.Instance.GetListChiTietChungTuBySoChungTuGoc(ctu.SoChungTuGoc);
            Business.ListChungTuThanhToan =
                ImportChungTuDataProvider.Instance.GetListChungTuThanhToanBySoChungTuGoc(ctu.SoChungTuGoc);

            //cap nhat chi tiet phieu thu
            foreach (ChungTuThanhToanInfor tt in Business.ListChungTuThanhToan)
            {
                countPT++;
                tt.SoPhieu   = "PTI-" + tt.SoPhieu;// LoadNextChungTu(soPhieuThuGoc, 11, countPT);
                tt.IdTienTe  = Declare.IdTienTe;
                tt.TyGia     = 1;
                tt.SoTienChu = Common.ReadNumner_(Common.Double2Str(tt.SoTienThanhToan));

                tt.TenMayTao = Declare.TenMay;
                tt.TenMaySua = Declare.TenMay;
            }

            ctu.SoChungTu = "ODI-" + ctu.SoChungTuGoc;// LoadNextChungTu(soDonHangGoc, 10, countCT);
            ctu.TenMayTao = Declare.TenMay;
            ctu.TenMaySua = Declare.TenMay;

            //import vao pos
            Business.SaveChungTu();
        }
Exemple #2
0
 private void SaveChungTu(LapDonHangBusiness business)
 {
     //business.SaveChungTu();
     try
     {
         ConnectionUtil.Instance.BeginTransaction();
         business.SaveChungTu();
         ConnectionUtil.Instance.CommitTransaction();
     }
     catch
     {
         ConnectionUtil.Instance.RollbackTransaction();
     }
 }
Exemple #3
0
        private void LapDonHang_ThuTien(int stt)
        {
            object syncObj1 = new object();
            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");
                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)
                {
                    LapDonHangBusiness Business = new LapDonHangBusiness(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 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;
                    }
                    //}
                    //SaveChungTu(Business);
                    //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;
                }
                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);
            }
        }