예제 #1
0
 private void UpdateSoLuongDaXuat()
 {
     for (int i = 0; i < lisx.Count; i++)
     {
         SanXuatCTietLenhInfo sx = new SanXuatCTietLenhInfo();
         sx.SoLuongDaXuat = Convert.ToInt32(txtSoLuongCT.Text) * lisx[i].SoLuongTrenTPham;
         sx.MaLenh        = frm.MaLenh;
         sx.MaLinhKien    = lisx[i].MaLinhKien;
         SanXuatCTietLenhProvider.UpdateSL(sx);
     }
 }
예제 #2
0
        private void SynsNhapThanhPham()
        {
            currentTrungTam = DMTrungTamDataProvider.GetTrungTamByIdInfo(Declare.IdTrungTam);
            currentKho      = DMKhoDataProvider.GetKhoByIdInfo(Declare.IdKho);

            string inventoryOrg = currentTrungTam.MaTrungTam;
            string inventorySub = currentKho.MaKho;

            frmProgress.Instance.Description = "Đang xóa dữ liệu tạm...";

            //NhapHangProvider.ClearTemporary(inventoryOrg, inventorySub, Declare.UserId);
            SanXuatLenhProvier.tmpSanXuatDelete(inventoryOrg);
            SanXuatLenhProvier.tmpSanXuatCTietDelete(inventoryOrg);

            frmProgress.Instance.Value += 1;

            frmProgress.Instance.Description = "Đang đồng bộ dữ liệu...";

            bool success = false;

            success = BusinessSynchronize.Instance.LenhSanXuatSyncV2(dteLastSync.DateTime.ToString("yyyy/MM/dd hh:mm:ss"), inventoryOrg, "GHEPMA");

            frmProgress.Instance.Value += 1;

            frmProgress.Instance.Description = "Đang cập nhật lại lịch sử...";

            litmpSX = SanXuatLenhProvier.GetAlltmpSanXuatLenh(MaTrungTam, "GHEPMA");
            litmpCT = SanXuatLenhProvier.GetAlltmpCTSanXuatLenh(MaTrungTam);
            for (int i = 0; i < litmpSX.Count; i++)
            {
                sx.MaLenh           = litmpSX[i].MaLenh;
                sx.MaThanhPham      = litmpSX[i].MaThanhPham;
                sx.NgayLap          = litmpSX[i].NgayLap;
                sx.NguoiLap         = litmpSX[i].NguoiLap;
                sx.OrgCode          = litmpSX[i].OrgCode;
                sx.SoLuongTP        = litmpSX[i].SoLuongTP;
                sx.Status           = litmpSX[i].Status;
                sx.Loai_Ma_Lenh     = litmpSX[i].Loai_Ma_Lenh;
                sx.Last_update_date = litmpSX[i].Last_update_date;
                int SoLuongHT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                    Convert.ToInt32(TransactionType.NHAP_COMBO), litmpSX[i].MaLenh, currentTrungTam.MaTrungTam);
                if (SoLuongHT == 0)
                {
                    liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.ChoXuat);
                }
                if (SoLuongHT > 0 && SoLuongHT < litmpSX[i].SoLuongTP &&
                    (litmpSX[i].Status != 2 || litmpSX[i].Status != 3))
                {
                    liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX);
                }
                if (SoLuongHT == litmpSX[i].SoLuongTP && litmpSX[i].Status != 2)
                {
                    liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.DaSanXuatXong);
                }
                if (litmpSX[i].Status == 2)
                {
                    liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.HuyLenh);
                }
                if (SoLuongHT != litmpSX[i].SoLuongTP && litmpSX[i].Status == 3)
                {
                    liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.NgungSanXuat);
                }


                if (SanXuatLenhProvier.CheckMaLenh(litmpSX[i].MaLenh, litmpSX[i].MaThanhPham, currentTrungTam.MaTrungTam) == 0)
                {
                    SanXuatLenhProvier.Insert(sx);
                }
                else
                {
                    SanXuatLenhProvier.Update(sx);
                }
            }
            for (int i = 0; i < litmpSX.Count; i++)
            {
                SanXuatCTietLenhProvider.Delete(litmpSX[i].MaLenh, currentTrungTam.MaTrungTam);
            }
            for (int i = 0; i < litmpCT.Count; i++)
            {
                sxct.MaLenh           = litmpCT[i].MaLenh;
                sxct.MaLinhKien       = litmpCT[i].MaLinhKien;
                sxct.NgayCanXuat      = litmpCT[i].NgayCanXuat;
                sxct.OrgCode          = litmpCT[i].OrgCode;
                sxct.SoLuongCanXuat   = litmpCT[i].SoLuongCanXuat;
                sxct.SoLuongDaXuat    = litmpCT[i].SoLuongDaXuat;
                sxct.SoLuongTrenTPham = litmpCT[i].SoLuongTrenTPham;
                sxct.KhoXuat          = litmpCT[i].KhoXuat;
                if (SanXuatLenhProvier.CheckCtietMaLenh(litmpCT[i].MaLenh, currentTrungTam.MaTrungTam, litmpCT[i].MaLinhKien) == 0)
                {
                    SanXuatCTietLenhProvider.Insert(sxct);
                }
                else
                {
                    SanXuatCTietLenhProvider.Update(sxct);
                }
                //SanXuatCTietLenhProvider.Insert(sxct);
            }
            if (!success)
            {
                frmProgress.Instance.Value       = frmProgress.Instance.MaxValue;
                frmProgress.Instance.Description = "Không hoàn thành.";
                frmProgress.Instance.IsCompleted = true;
                MessageBox.Show("Gọi webservice không thành công!");
                return;
            }

            frmProgress.Instance.Value       = frmProgress.Instance.MaxValue;
            frmProgress.Instance.Description = "Đã hoàn thành.";
            frmProgress.Instance.IsCompleted = true;

            LockControl.Unlock("SynsNhapThanhPham");
        }
예제 #3
0
        private void SynsNhapDoiMa()
        {
            try
            {
                frmProgress.Instance.Text = "Đồng bộ dữ liệu";

                frmProgress.Instance.MaxValue = 3;

                ConnectionUtil.Instance.BeginTransaction();

                currentTrungTam = DMTrungTamDataProvider.GetTrungTamByIdInfo(Declare.IdTrungTam);

                currentKho = DMKhoDataProvider.GetKhoByIdInfo(Declare.IdKho);

                string inventoryOrg = currentTrungTam.MaTrungTam;

                string inventorySub = currentKho.MaKho;

                frmProgress.Instance.Description = "Đang xóa dữ liệu tạm...";

                SanXuatLenhProvier.tmpSanXuatDelete(inventoryOrg);

                SanXuatLenhProvier.tmpSanXuatCTietDelete(inventoryOrg);

                frmProgress.Instance.Value += 1;

                frmProgress.Instance.Description = "Đang đồng bộ dữ liệu...";

                bool success = false;

                DateTime sysDate = CommonProvider.Instance.GetSysDate();

                if (dteLastSync.DateTime.AddDays(31) < sysDate)
                {
                    //note: từ 1/6/2013 về trước có dữ liệu lặp trên ORC, nên nếu phải lấy dữ liệu lại từ đầu
                    //note: thì chỉ có thể lấy về từ ngày này, cần hết sức lưu ý.
                    dteLastSync.EditValue = sysDate.AddDays(-31);
                }

                success = BusinessSynchronize.Instance.LenhSanXuatSyncV2(dteLastSync.DateTime.ToString("yyyy/MM/dd hh:mm:ss"), inventoryOrg, "NXDM");

                if (success)
                {
                    frmProgress.Instance.Value += 1;

                    frmProgress.Instance.Description = "Đang cập nhật lại lịch sử...";

                    litmpSX = SanXuatLenhProvier.GetAlltmpSanXuatLenh(MaTrungTam, "NXDM");

                    litmpCT = SanXuatLenhProvier.GetAlltmpCTSanXuatLenh(MaTrungTam);

                    for (int i = 0; i < litmpSX.Count; i++)
                    {
                        sx.MaLenh           = litmpSX[i].MaLenh;
                        sx.MaThanhPham      = litmpSX[i].MaThanhPham;
                        sx.NgayLap          = litmpSX[i].NgayLap;
                        sx.NguoiLap         = litmpSX[i].NguoiLap;
                        sx.OrgCode          = litmpSX[i].OrgCode;
                        sx.SoLuongTP        = litmpSX[i].SoLuongTP;
                        sx.Status           = litmpSX[i].Status;
                        sx.Loai_Ma_Lenh     = litmpSX[i].Loai_Ma_Lenh;
                        sx.Description      = litmpSX[i].Description;
                        sx.Last_update_date = litmpSX[i].Last_update_date;

                        int SoLuongHT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                            Convert.ToInt32(TransactionType.NHAP_DOIMA), litmpSX[i].MaLenh, currentTrungTam.MaTrungTam);

                        if (SoLuongHT == 0)
                        {
                            sx.TrangThai = Convert.ToInt32(TrangThaiSanXuat.ChoXuat);
                        }

                        if (SoLuongHT > 0 && SoLuongHT < litmpSX[i].SoLuongTP &&
                            (litmpSX[i].Status != 2 || litmpSX[i].Status != 3))
                        {
                            sx.TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX);
                        }

                        if (SoLuongHT == litmpSX[i].SoLuongTP && litmpSX[i].Status != 2)
                        {
                            sx.TrangThai = Convert.ToInt32(TrangThaiSanXuat.DaSanXuatXong);
                        }

                        if (litmpSX[i].Status == 2)
                        {
                            sx.TrangThai = Convert.ToInt32(TrangThaiSanXuat.HuyLenh);
                        }

                        if (SoLuongHT != litmpSX[i].SoLuongTP && litmpSX[i].Status == 3)
                        {
                            sx.TrangThai = Convert.ToInt32(TrangThaiSanXuat.NgungSanXuat);
                        }

                        if (SanXuatLenhProvier.CheckMaLenh(litmpSX[i].MaLenh, litmpSX[i].MaThanhPham, currentTrungTam.MaTrungTam) == 0)
                        {
                            SanXuatLenhProvier.Insert(sx);
                        }
                        else
                        {
                            SanXuatLenhProvier.Update(sx);
                        }
                    }

                    for (int i = 0; i < litmpSX.Count; i++)
                    {
                        SanXuatCTietLenhProvider.Delete(litmpSX[i].MaLenh, currentTrungTam.MaTrungTam);
                    }

                    for (int i = 0; i < litmpCT.Count; i++)
                    {
                        sxct.MaLenh           = litmpCT[i].MaLenh;
                        sxct.MaLinhKien       = litmpCT[i].MaLinhKien;
                        sxct.NgayCanXuat      = litmpCT[i].NgayCanXuat;
                        sxct.OrgCode          = litmpCT[i].OrgCode;
                        sxct.SoLuongCanXuat   = litmpCT[i].SoLuongCanXuat;
                        sxct.SoLuongDaXuat    = litmpCT[i].SoLuongDaXuat;
                        sxct.SoLuongTrenTPham = litmpCT[i].SoLuongTrenTPham;
                        sxct.KhoXuat          = litmpCT[i].KhoXuat;
                        if (SanXuatLenhProvier.CheckCtietMaLenh(litmpCT[i].MaLenh, currentTrungTam.MaTrungTam, litmpCT[i].MaLinhKien) == 0)
                        {
                            SanXuatCTietLenhProvider.Insert(sxct);
                        }
                        else
                        {
                            SanXuatCTietLenhProvider.Update(sxct);
                        }
                    }

                    ConnectionUtil.Instance.CommitTransaction();

                    frmProgress.Instance.Value = frmProgress.Instance.MaxValue;

                    frmProgress.Instance.Description = "Đã hoàn thành.";

                    frmProgress.Instance.IsCompleted = true;

                    LockControl.Unlock("SynsNhapDoiMa");
                }
                else
                {
                    ConnectionUtil.Instance.RollbackTransaction();

                    frmProgress.Instance.Value = frmProgress.Instance.MaxValue;

                    frmProgress.Instance.Description = "Không hoàn thành.";

                    frmProgress.Instance.IsCompleted = true;

                    LockControl.Unlock("SynsNhapDoiMa");

                    MessageBox.Show("Gọi webservice không thành công!");

                    return;
                }
            }
            catch (Exception ex)
            {
                ConnectionUtil.Instance.RollbackTransaction();

                LockControl.Unlock("SynsNhapDoiMa");

                EventLogProvider.Instance.WriteOfflineLog(ex.ToString(), this.Name);

                MessageBox.Show(ex.Message);

                frmProgress.Instance.Value = frmProgress.Instance.MaxValue;

                frmProgress.Instance.Description = "Không hoàn thành.";

                frmProgress.Instance.IsCompleted = true;
            }
        }
예제 #4
0
        private void LoadData()
        {
            txtMaVachTP.Enabled = false;
            if (check == 0)
            {
                lisx                 = SanXuatCTietLenhProvider.GetSanXuatLenhByMaLenh(MaLenh, MaTrungTam);
                txtMaLenh.Text       = MaLenh;
                txtMaThanhPham.Text  = MaThanhPham;
                txtTenThanhPham.Text = TenThanhPham;
                txtSoLuongYC.Text    = SoLuongYC.ToString();
                //SLCT = frm.SoLuongCT;
            }
            else
            {
                lisx = SanXuatCTietLenhProvider.GetSanXuatLenhByMaLenh(MaLenh, MaTrungTam);
                for (int i = 0; i < lisx.Count; i++)
                {
                    lisx[i].SoLuongDaQuet = lisx[i].SoLuongTrenTPham;
                }
                txtMaLenh.Text       = MaLenh;
                txtMaThanhPham.Text  = MaThanhPham;
                txtTenThanhPham.Text = TenThanhPham;
                txtSoLuongYC.Text    = SoLuongYC.ToString();
                //SLCT = frm1.SoLuongDN;
                txtMaVachTP.Text = MaVachThanhPham;
                btnThem.Enabled  = false;
                btnXoa.Enabled   = false;
                btnNhap.Enabled  = false;
            }
            if (lisx.Count == 0)
            {
                this.Close();
                throw new ManagedException("Mã linh kiện không có trong hệ thống !");
            }


            txtSoLuongCT.Text = SLCT.ToString();
            dgvChiTiet.AutoGenerateColumns = false;
            dgvChiTiet.DataSource          = lisx;
            dgvMaVach.AutoGenerateColumns  = false;
            dgvMaVach.DataSource           = new BindingList <ChungTuNhapNccChiTietHangHoaInfo>(liMaVach);
            MaSanPham           = lisx[0].MaLinhKien;
            HangHoa.IdSanPham   = lisx[0].IdLinhKien;
            HangHoa.TenSanPham  = lisx[0].TenLinhKien;
            HangHoa.SoLuong     = lisx[0].SoLuongCanXuat;
            HangHoa.TrungMaVach = lisx[0].TrungMaVach;
            HangHoa.DonGia      = 0;
            HangHoa.DonViTinh   = lisx[0].DonViTinh;
            liChiTiet           = XLKBussiness.GetListChiTietHangHoaByIdSanPham(lisx[0].IdLinhKien);
            if (XLKBussiness.ChungTu.IdChungTu == 0)
            {
                for (int i = 0; i < lisx.Count; i++)
                {
                    XLKBussiness.ListChiTietChungTu.Add(new ChungTuXuatNhapNccChiTietInfo
                    {
                        IdSanPham    = lisx[i].IdLinhKien,
                        TenSanPham   = lisx[i].TenLinhKien,
                        MaSanPham    = lisx[i].MaLinhKien,
                        TenDonViTinh = lisx[i].DonViTinh,
                        SoLuong      = lisx[i].SoLuongTrenTPham
                    });
                }
            }
        }