protected void Capture(ControlRect rect, bool value)
        {
            var pctrl = this.ParentControlRect;

            if (pctrl != null)
            {
                pctrl.Capture(rect, value);
                return;
            }

            if (LockControl != null)
            {
                LockControl.Capture = value;

                if (value)
                {
                    m_captureControl = rect;
                }
                else
                {
                    m_captureControl = null;
                    MouseChild(LockControl.PointToClient(Control.MousePosition));
                }
            }
        }
        private void TryLock()
        {
            const int MAX_INTERVAL = 10;
            int       interval     = MAX_INTERVAL;

            bool isLocked = false;

            while (!isLocked)
            {
                try
                {
                    frmProgress.Instance.Description = currentKho.MaKho + ": Đang thử lại...";
                    LockControl.Lock("SysnChungTuNhap");
                    isLocked = true;
                    Thread.SpinWait(5000);
                    frmProgress.Instance.Value = frmProgress.Instance.MaxValue;
                }
                catch (ManagedException ex)
                {
                    frmProgress.Instance.Description = String.Format(ex.Message);
                    Thread.Sleep(2000);
                    frmProgress.Instance.MaxValue = MAX_INTERVAL;
                    frmProgress.Instance.Value    = 0;
                    interval = MAX_INTERVAL;
                    while (interval > 0)
                    {
                        frmProgress.Instance.Description = String.Format(currentKho.MaKho + ": Sẽ thử lại trong vòng {0} giây nữa.", interval);
                        frmProgress.Instance.Value      += 1;
                        interval -= 1;
                        Thread.Sleep(1000);
                    }
                }
            }
        }
Пример #3
0
        private void btnDongBo_Click(object sender, EventArgs e)
        {
            string functionName = "SynsNhapDoiMa";

            LockControl.Lock(functionName);
            frmProgress.Instance.DoWork(SynsNhapDoiMa);
            frmProgress.Instance.DoWork(LoadDuLieu);
        }
Пример #4
0
        private void btnNapDuLieu_Click(object sender, EventArgs e)
        {
            string functionName = "SysnChungTuTraNCC";

            try
            {
                LockControl.Lock(functionName);
                frmProgress.Instance.Text     = "Đồng bộ dữ liệu";
                frmProgress.Instance.MaxValue = 5;
                frmProgress.Instance.DoWork(SynsChungTuNhap);
                lichitiet = tmp_NhapHang_UserProvider.GetTraHangUserInfor();
                //for (int i = 0; i < lichitiet.Count; i++)
                //{
                //    ChungTuXuatNhapNccInfo chungTuXuatNhapNccInfo = tblChungTuDataProvider.GetChungTuNhapNCCFromSoPO(lichitiet[i].SoPO, lichitiet[i].SoPhieuNhap, Convert.ToInt32(TransactionType.TRA_LAI_PO), Declare.IdKho, lichitiet[i].NgayNhap);
                //    if (chungTuXuatNhapNccInfo != null)
                //    {
                //        if (chungTuXuatNhapNccInfo.TrangThai == 1)
                //        {
                //            lichitiet[i].Trangthai = "Chưa nhập đủ";
                //        }
                //        else
                //        {
                //            lichitiet[i].Trangthai = "Đã nhập đủ";
                //        }
                //    }
                //    else
                //    {
                //        lichitiet[i].Trangthai = "Chưa nhập";
                //    }
                //}
                dgvList.DataSource = lichitiet;
            }
            catch (ManagedException ex)
            {
                LockControl.Unlock(functionName);
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
            catch (Exception ex)
            {
                LockControl.Unlock(functionName);
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif

                EventLogProvider.Instance.WriteLog(ex.ToString()
                                                   + "\nUser: "******"\nKho: " + Declare.IdKho,
                                                   this.Name);
            }
        }
Пример #5
0
        private void btnDongBo_Click(object sender, EventArgs e)
        {
            string functionName = "SynsNhapThanhPham";

            LockControl.Lock(functionName);
            frmProgress.Instance.Text     = "Đồng bộ dữ liệu";
            frmProgress.Instance.MaxValue = 3;
            frmProgress.Instance.DoWork(SynsNhapThanhPham);
            liChiTiet = SanXuatLenhProvier.GetAllSanXuatLenh(MaKho, MaTrungTam, "GHEPMA");

            CheckTrangthai();
            dgvChiTiet.DataSource = liChiTiet;
        }
        public async Task <List <Announcement> > GetAnnouncementsByAreaTimeLocknew(string AreaName, DateTime?DateTimeStamp = null)
        {
            List <Announcement> result = new List <Announcement>();

            await Task.Run <List <Announcement> >(() =>
            {
                LockControl mylock = null;
                try
                {
                    if (DateTimeStamp == null)
                    {
                        DateTimeStamp = DateTime.Now.AddDays(-1);
                    }
                    result = InMemoryList.Where(myarea => myarea.AreaName == AreaName && myarea.TimeStamp >= DateTimeStamp).ToList();

                    if (result.Count == 0)
                    {
                        mylock          = new LockControl();
                        mylock.AreaName = AreaName;
                        mylock.IsLocked = true;
                        WaitLocks.Add(mylock);


                        Monitor.TryEnter(mylock.LockObject, 500);
                        {
                            Monitor.Wait(mylock.LockObject, milliseconds);
                        }

                        if (mylock.IsLocked == false)
                        {
                            result = InMemoryList.Where(myarea => myarea.AreaName == AreaName && myarea.TimeStamp >= DateTimeStamp).ToList();
                        }
                    }
                    return(result);
                }


                finally
                {
                    if (mylock != null)
                    {
                        mylock.IsLocked = false;
                        Monitor.Exit(mylock.LockObject);
                    }
                }
            });

            return(result);
        }
Пример #7
0
        private void LoadData()
        {
            try
            {
                string functionName = "SynsXacNhanNhapThanhPham";

                LockControl.Lock(functionName);
                frmProgress.Instance.Text     = "Đồng bộ dữ liệu";
                frmProgress.Instance.MaxValue = 3;
                frmProgress.Instance.DoWork(SynsNhapThanhPham);
                liChiTiet = SanXuatNhapTachDataProvider.Instance.GetListAllSanXuatNhapTach(Convert.ToInt32(LoaiGiaoDichSanXuat.NHAP_THANH_PHAM_SAN_XUAT), Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), MaTrungTam, 1);
                for (int i = 0; i < liChiTiet.Count; i++)
                {
                    liChiTiet[i].SoLuongHT = SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        liChiTiet[i].MaLenh, 1, liChiTiet[i].TransactionID.ToString()) + SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        liChiTiet[i].MaLenh, 2, liChiTiet[i].TransactionID.ToString());
                }
                for (int i = 0; i < liChiTiet.Count; i++)
                {
                    if (liChiTiet[i].SoLuongHT == 0)
                    {
                        liChiTiet[i].TenTrangThai = "Chờ xác nhận";
                    }
                    if (liChiTiet[i].SoLuongHT > 0 && liChiTiet[i].SoLuongHT < liChiTiet[i].SoLuongYC)
                    {
                        liChiTiet[i].TenTrangThai = "Chưa đủ";
                    }
                    if (liChiTiet[i].SoLuongHT == liChiTiet[i].SoLuongYC)
                    {
                        liChiTiet[i].TenTrangThai = "Đã sản xuất xong";
                    }
                }
                dgvChiTiet.DataSource = liChiTiet;
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Пример #8
0
        private void btnDongBo_Click(object sender, EventArgs e)
        {
            try
            {
                string functionName = "SynsTachThanhPham";

                LockControl.Lock(functionName);
                frmProgress.Instance.Text     = "Đồng bộ dữ liệu";
                frmProgress.Instance.MaxValue = 3;
                frmProgress.Instance.DoWork(SynsNhapThanhPham);
                liChiTiet = SanXuatNhapTachDataProvider.Instance.GetListAllSanXuatNhapTach(Convert.ToInt32(LoaiGiaoDichSanXuat.TACH_THANH_PHAM_SAN_XUAT), Convert.ToInt32(TransactionType.XUAT_LINK_KIEN_SX), MaTrungTam, 2);
                for (int i = 0; i < liChiTiet.Count; i++)
                {
                    liChiTiet[i].SoLuongHT = SanXuatLenhProvier.GetSoLuongChungTu(
                        Convert.ToInt32(TransactionType.XUAT_THANH_PHAM),
                        liChiTiet[i].MaLenh, 1, liChiTiet[i].TransactionID.ToString());
                }
                for (int i = 0; i < liChiTiet.Count; i++)
                {
                    if (liChiTiet[i].SoLuongHT == 0)
                    {
                        liChiTiet[i].TenTrangThai = "Chờ tách";
                    }
                    if (liChiTiet[i].SoLuongHT > 0 && liChiTiet[i].SoLuongHT < liChiTiet[i].SoLuongYC)
                    {
                        liChiTiet[i].TenTrangThai = "Đang tách";
                    }
                    if (liChiTiet[i].SoLuongHT == liChiTiet[i].SoLuongYC)
                    {
                        liChiTiet[i].TenTrangThai = "Đã tách xong";
                    }
                }
                dgvChiTiet.DataSource = liChiTiet;
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Пример #9
0
        private void frmDM_ListBase_OnSync(object sender, EventArgs e)
        {
            try
            {
                if (IsSync)
                {
                    LockControl.Lock(this.Name);
                    frmProgress.Instance.Text = String.Format("Đồng bộ {0}", this.Text);
                    frmProgress.Instance.DoWork(SyncProvider.Synchronize);
                    LoadData();
                    LockControl.Unlock(this.Name);
                }
            }
            catch (Exception ex)
            {
                LockControl.Unlock(this.Name);
#if DEBUG
                MessageBox.Show(ex.ToString(), Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#else
                MessageBox.Show(ex.Message, Declare.titleError, MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
            }
        }
Пример #10
0
        private void btnNapDuLieu_Click(object sender, EventArgs e)
        {
            string functionName = "SysnChungTuNhap";

            try
            {
                LockControl.Lock(functionName);
                frmProgress.Instance.Text     = "Đồng bộ dữ liệu";
                frmProgress.Instance.MaxValue = 5;
                frmProgress.Instance.DoWork(SynsChungTuNhap);

                dgvList.DataSource = tmp_NhapHang_UserProvider.GetNhapHangUserInfor();
            }
            catch (Exception ex)
            {
                LockControl.Unlock(functionName);
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Пример #11
0
        private void btnNapDuLieu_Click(object sender, EventArgs e)
        {
            string functionName = "SysnChungTuNhap";

            try
            {
                LockControl.Lock(functionName);

                isComplete = true;

                frmProgress.Instance.DoWork(SynsChungTuNhap);
            }
            catch (ManagedException ex)
            {
                LockControl.Unlock(functionName);
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
            catch (Exception ex)
            {
                EventLogProvider.Instance.WriteOfflineLog(ex
                                                          + "\nUser: "******"\nKho: " + Declare.IdKho,
                                                          Name);

                LockControl.Unlock(functionName);
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Пример #12
0
        private void SynsChungTuNhap()
        {
            try
            {
                ConnectionUtil.Instance.BeginTransaction();

                string inventoryOrg = currentTrungTam.MaTrungTam;

                string inventorySub = currentKho.MaKho;

                frmProgress.Instance.Caption = Text;

                frmProgress.Instance.MaxValue = 5;

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

                PurchaseOrderProvider.Instance.ClearTemporary(inventoryOrg, inventorySub, Declare.UserId);

                frmProgress.Instance.Value += 1;

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

                bool success = false;

                if (dteLastSync.DateTime.AddDays(15) < CommonProvider.Instance.GetSysDate())
                {
                    dteLastSync.DateTime = CommonProvider.Instance.GetSysDate().AddDays(-15);
                }

                success = BusinessSynchronize.Instance.ChungTuNhapNCCSync(inventoryOrg, inventorySub,
                                                                          dteLastSync.DateTime.ToString(
                                                                              "yyyy/MM/dd hh:mm:ss"));
                if (success)
                {
                    frmProgress.Instance.Value += 1;

                    PurchaseOrderProvider.Instance.TransferToUserData(inventoryOrg, inventorySub, Declare.UserId);

                    frmProgress.Instance.Value += 1;

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

                    PurchaseOrderProvider.Instance.ClearNhapHangHistory(inventoryOrg, inventorySub);

                    frmProgress.Instance.Value += 1;

                    PurchaseOrderProvider.Instance.LogHistory(inventoryOrg, inventorySub,
                                                              Convert.ToInt32(LoaiGiaoDichPO.NHAP_HANG_NHA_CUNG_CAP));

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

                    frmProgress.Instance.Description = "Đã đồng bộ xong.";

                    ConnectionUtil.Instance.CommitTransaction();

                    LockControl.Unlock("SysnChungTuNhap", currentKho.IdKho);

                    LoadDuLieu();

                    Thread.CurrentThread.Join(2500);

                    frmProgress.Instance.IsCompleted = true;
                }
                else
                {
                    ConnectionUtil.Instance.RollbackTransaction();

                    LockControl.Unlock("SysnChungTuNhap", currentKho.IdKho);

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

                    frmProgress.Instance.Description = "Không đồng bộ được dữ liệu!!!";

                    Thread.CurrentThread.Join(2500);

                    frmProgress.Instance.IsCompleted = true;
                }
            }
            catch (Exception ex)
            {
                ConnectionUtil.Instance.RollbackTransaction();

                LockControl.Unlock("SysnChungTuNhap", currentKho.IdKho);

                EventLogProvider.Instance.
                WriteOfflineLog(ex
                                + "\nUser: "******"\nKho: " + Declare.IdKho,
                                this.Name);

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

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

                Thread.CurrentThread.Join(2500);

                frmProgress.Instance.IsCompleted = true;
            }
        }
Пример #13
0
        private void SynsNhapThanhPham()
        {
            try
            {
                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...";

                //SanXuatNhapTachDataProvider.Instance.DeleteNhapThanhPham(inventoryOrg);

                frmProgress.Instance.Value += 1;

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

                bool success = false;

                DateTime tuNgay = new DateTime(2013, 6, 1);

                if (dteLastSync.DateTime < tuNgay)
                {
                    dteLastSync.DateTime = tuNgay;
                }

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

                frmProgress.Instance.Value += 1;

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

                liSXNT = SanXuatNhapTachDataProvider.Instance.GetListAllTmpSanXuatNhapTach(MaTrungTam, Convert.ToInt32(LoaiGiaoDichSanXuat.NHAP_THANH_PHAM_SAN_XUAT));

                for (int i = 0; i < liSXNT.Count; i++)
                {
                    liMaLenh = SanXuatNhapTachDataProvider.Instance.SanXuatNhapTachGetByMaLenh(liSXNT[i].MaLenh,
                                                                                               liSXNT[i].MaThanhPham,
                                                                                               liSXNT[i].OrgCode,
                                                                                               liSXNT[i].TransactionID);
                    if (liMaLenh.Count == 0)
                    {
                        SanXuatNhapTachDataProvider.Instance.Insert(new SanXuatNhapTachInfo
                        {
                            MaLenh        = liSXNT[i].MaLenh,
                            MaThanhPham   = liSXNT[i].MaThanhPham,
                            OrgCode       = liSXNT[i].OrgCode,
                            LoaiGiaoDich  = Convert.ToInt32(LoaiGiaoDichSanXuat.NHAP_THANH_PHAM_SAN_XUAT),
                            SoLuongYC     = liSXNT[i].SoLuongYC,
                            NguoiLap      = liSXNT[i].NguoiLap,
                            NgayGiaoDich  = liSXNT[i].NgayGiaoDich,
                            TransactionID = liSXNT[i].TransactionID
                        });
                    }
                    else
                    {
                        SanXuatNhapTachDataProvider.Instance.Update(new SanXuatNhapTachInfo
                        {
                            MaLenh        = liSXNT[i].MaLenh,
                            MaThanhPham   = liSXNT[i].MaThanhPham,
                            OrgCode       = liSXNT[i].OrgCode,
                            LoaiGiaoDich  = Convert.ToInt32(LoaiGiaoDichSanXuat.NHAP_THANH_PHAM_SAN_XUAT),
                            SoLuongYC     = liSXNT[i].SoLuongYC,
                            NguoiLap      = liSXNT[i].NguoiLap,
                            NgayGiaoDich  = liSXNT[i].NgayGiaoDich,
                            TransactionID = liSXNT[i].TransactionID
                        });
                    }
                }
                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("SynsXacNhanNhapThanhPham");
            }
            catch (Exception ex)
            {
                frmProgress.Instance.Value       = frmProgress.Instance.MaxValue;
                frmProgress.Instance.Description = "Không hoàn thành.";
                frmProgress.Instance.IsCompleted = true;
                LockControl.Unlock("SynsXacNhanNhapThanhPham");
#if DEBUG
                MessageBox.Show(ex.ToString());
#else
                MessageBox.Show(ex.Message);
#endif
            }
        }
Пример #14
0
 private void btnDong_Click(object sender, EventArgs e)
 {
     LockControl.Unlock("SynsXuatLinhKien");
     this.Close();
 }
Пример #15
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");
        }
Пример #16
0
 private void btnDong_Click(object sender, EventArgs e)
 {
     LockControl.Unlock("SynsNhapThanhPham");
     this.Close();
 }
Пример #17
0
 public LockControlHelperException(LockControl.LockInfo li)
     : base("Elemento bloqueado")
 {
     _li = li;
 }
Пример #18
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;
            }
        }
Пример #19
0
        private void SynsChungTuNhap()
        {
            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);

            frmProgress.Instance.Value += 1;

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

            bool success = false;

            //success = BusinessSynchronize.Instance.ChungTuNhapNCCSync(inventoryOrg, inventorySub, NhapHangProvider.NhapHangLastUpdateDate(inventoryOrg, inventorySub));

            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 += 1;

            NhapHangProvider.TransferToUserData(inventoryOrg, inventorySub, Declare.UserId);

            frmProgress.Instance.Value += 1;

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

            NhapHangProvider.ClearNhapHangHistory(inventoryOrg, inventorySub);

            frmProgress.Instance.Value += 1;

            NhapHangProvider.LogHistory(inventoryOrg, inventorySub, Convert.ToInt32(LoaiGiaoDichPO.NHAP_HANG_NHA_CUNG_CAP));

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

            //sql = String.Format("SELECT COUNT(*) FROM tbl_Tmp_NhapHang WHERE MaSanPham NOT IN (SELECT MaSanPham FROM tbl_SanPham WHERE sudung=1) AND InventoryOrg='{0}' AND InventorySub='{1}'", inventoryOrg, inventorySub);
            ////sql += String.Format("AND SoPO=N'{0}' AND SoPhieuNhap=N'{1}'", txtSoPO.Text, txtPhieuNhap.Text);
            //object countNotMa = SqlHelper.ExecuteScalar(ConnectionUtil.Instance.GetConnection(), CommandType.Text, sql);
            //cmdShowNotMa.Visible = false;
            //if (Convert.ToInt32(countNotMa) > 0)
            //{
            //    cmdShowNotMa.Visible = true;
            //    cmdShowNotMa.Text = String.Format("{0} mặt hàng có mã không hợp lệ", countNotMa);
            //}

            //string sql = String.Format("SELECT t1.SoPhieuNhap, t1.SoPO, ct.IdChungTu, SUM(SoLuong) AS TongSoLuong, N'Hàng bán' AS TrangThai FROM tbl_Tmp_NhapHang t1 "
            //        + "LEFT OUTER JOIN tbl_ChungTu ct ON ct.SoChungTu=t1.SoPhieuNhap AND ct.SoSeri=t1.SoPO AND ct.LoaiChungTu={0} AND ct.IdKho={5} "
            //        + "AND (SELECT TOP (1) soluong FROM tbl_chungtu_chitiet WHERE tbl_chungtu_chitiet.idchungtu = ct.idchungtu)>=0 "
            //        + "WHERE InventoryOrg='{1}' AND InventorySub='{2}' AND ThoiGian < '{3}' AND ThoiGian > '{4}' AND SoLuong >= 0 GROUP BY SoPhieuNhap, SoPO, IdChungTu "
            //        + "UNION ALL "
            //        + "SELECT t1.SoPhieuNhap, t1.SoPO, ct.IdChungTu, SUM(SoLuong) AS TongSoLuong, N'Hàng trả lại' AS TrangThai FROM tbl_Tmp_NhapHang t1 "
            //        + "LEFT OUTER JOIN tbl_ChungTu ct ON ct.SoChungTu=t1.SoPhieuNhap AND ct.SoSeri=t1.SoPO AND ct.LoaiChungTu={0} AND ct.IdKho={5} "
            //        + "AND (SELECT TOP (1) soluong FROM tbl_chungtu_chitiet WHERE tbl_chungtu_chitiet.idchungtu = ct.idchungtu)<0 "
            //        + "WHERE InventoryOrg='{1}' AND InventorySub='{2}' AND ThoiGian < '{3}' AND ThoiGian > '{4}' AND SoLuong < 0 GROUP BY SoPhieuNhap, SoPO, IdChungTu "
            //        + "ORDER BY SoPhieuNhap, SoPO, TongSoLuong DESC",
            //        (int)TransactionType.NHAP,
            //        inventoryOrg,
            //        inventorySub,
            //        dtNgayDongBo.Value.ToString(new CultureInfo("en-US")),
            //        currentKho.LanDongBoTruoc.ToString(new CultureInfo("en-US")),
            //        Declare.IdKho);

            LockControl.Unlock("SysnChungTuNhap");
        }