Esempio n. 1
0
        public void LoadDuLieu()
        {
            frmProgress.Instance.Caption     = Text;
            frmProgress.Instance.Description = "Đang nạp dữ liệu";
            frmProgress.Instance.Value       = 0;
            frmProgress.Instance.MaxValue    = 6;
            liChiTiet.Clear();
            dgvChiTiet.RefreshDataSource();
            frmProgress.Instance.Value += 1;
            MaTrungTam = GetMaTrungTam();
            frmProgress.Instance.Value += 1;
            MaKho = GetMaKho();
            frmProgress.Instance.Value += 1;

            if (!dteLastSync.InvokeRequired)
            {
                dteLastSync.DateTime = SanXuatLenhProvier.GetMaxDateSanXuatLenh(MaTrungTam);
            }
            else
            {
                Invoke(
                    (MethodInvoker)
                    delegate { dteLastSync.DateTime = SanXuatLenhProvier.GetMaxDateSanXuatLenh(MaTrungTam); });
            }

            frmProgress.Instance.Value += 1;
            liChiTiet.AddRange(SanXuatLenhProvier.GetRecentSanXuatLenh(txtMaLenhSX.Text, MaKho, MaTrungTam, "NXDM"));
            frmProgress.Instance.Value += 1;
            CheckTrangthai();
            frmProgress.Instance.Value += 1;
            dgvChiTiet.RefreshDataSource();
            frmProgress.Instance.Description = "Đã xong";
            frmProgress.Instance.Value       = frmProgress.Instance.MaxValue;
            frmProgress.Instance.IsCompleted = true;
        }
Esempio n. 2
0
 public void ReLoad()
 {
     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;
 }
Esempio n. 3
0
        private void CheckTrangthai()
        {
            for (int i = 0; i < liChiTiet.Count; i++)
            {
                liChiTiet[i].SoLuongHT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                    Convert.ToInt32(TransactionType.NHAP_COMBO), liChiTiet[i].MaLenh, currentTrungTam.MaTrungTam);

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

            LoadTrangthai();
        }
Esempio n. 4
0
 private void frmDanhSachXacNhanNhapThanhPhan_Load(object sender, EventArgs e)
 {
     clsUtils.NullColumnDateTimeGrid(repdtngaylap);
     btnChiTiet.Text       = Resources.btnInfor;
     MaTrungTam            = GetMaTrungTam();
     MaKho                 = GetMaKho();
     dteLastSync.EditValue = SanXuatNhapTachDataProvider.Instance.GetMaxDateNhapTach(MaTrungTam);
     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.GetSoLuongChungTu(
             Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
             liChiTiet[i].MaLenh, 1, liChiTiet[i].TransactionID.ToString()) +
                                  SanXuatLenhProvier.GetSoLuongChungTu(
             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 = "Đã đủ";
         }
     }
     dgvChiTiet.DataSource = liChiTiet;
 }
 public void Reload()
 {
     liChiTiet.Clear();
     liChiTiet.AddRange(SanXuatLenhProvier.GetRecentSanXuatLenh(txtMaLenhSX.Text, MaKho, MaTrungTam, "LSX"));
     CheckTrangthai();
     dgvChiTiet.RefreshDataSource();
 }
Esempio n. 6
0
        public void Reload()
        {
            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, 2, 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 = null;
            dgvChiTiet.DataSource = liChiTiet;
        }
        private void CheckTrangthai()
        {
            dgvChiTiet.RefreshDataSource();

            dgvChiTiet.SuspendLayout();

            int currentProgress = frmProgress.Instance.Value;

            frmProgress.Instance.Value = 0;

            frmProgress.Instance.MaxValue = liChiTiet.Count;

            for (int i = 0; i < liChiTiet.Count; i++)
            {
                if (liChiTiet[i].TrangThai == 0 ||
                    liChiTiet[i].TrangThai == Convert.ToInt32(TrangThaiSanXuat.ChoXuat) ||
                    liChiTiet[i].TrangThai == Convert.ToInt32(TrangThaiSanXuat.DangSX))
                {
                    liChiTiet[i].SoLuongHT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), liChiTiet[i].MaLenh,
                        currentTrungTam.MaTrungTam);

                    if (liChiTiet[i].SoLuongHT == 0)
                    {
                        liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.ChoXuat);
                    }
                    if (liChiTiet[i].SoLuongHT > 0 && liChiTiet[i].SoLuongHT < liChiTiet[i].SoLuongTP &&
                        (liChiTiet[i].Status != 2 || liChiTiet[i].Status != 3))
                    {
                        liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX);
                    }
                    if (liChiTiet[i].SoLuongHT == liChiTiet[i].SoLuongTP && liChiTiet[i].Status != 2)
                    {
                        liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.DaSanXuatXong);
                    }
                    if (liChiTiet[i].Status == 2)
                    {
                        liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.HuyLenh);
                    }
                    if (liChiTiet[i].SoLuongHT != liChiTiet[i].SoLuongTP && liChiTiet[i].Status == 3)
                    {
                        liChiTiet[i].TrangThai = Convert.ToInt32(TrangThaiSanXuat.NgungSanXuat);
                    }

                    SanXuatLenhProvier.Update1(liChiTiet[i]);
                }

                frmProgress.Instance.Value += 1;
            }

            dgvChiTiet.RefreshDataSource();

            dgvChiTiet.ResumeLayout();

            frmProgress.Instance.Value = currentProgress;
        }
Esempio n. 8
0
        private void Tim(string MaVach)
        {
            //string MaLenh;
            //string MaThanhPham;
            //string TenThanhPham;
            string MaVachThanhPham;
            //int SoLuongYC;
            int SoLuongDN;
            List <DMChungTuNhapInfo> liTim = new List <DMChungTuNhapInfo>();
            List <ChungTuNhapNccChiTietHangHoaInfo> liMaVach = new List <ChungTuNhapNccChiTietHangHoaInfo>();
            List <SanXuatLenhInfo> liSX      = new List <SanXuatLenhInfo>();
            DMChungTuNhapInfo      liChungTu = new DMChungTuNhapInfo();
            ChungTuXuatNhapNccInfo ct;

            liTim = tblChungTuDataProvider.GetChungTuByMaVach(MaVach);

            if (liTim.Count > 0)
            {
                ct = new ChungTuXuatNhapNccInfo
                {
                    IdChungTu   = liTim[0].IdChungTu,
                    LoaiChungTu = liTim[0].LoaiChungTu,
                    IdKho       = liTim[0].IdKho,
                    IdNhanVien  = liTim[0].IdNhanVien,
                    NgayLap     = liTim[0].NgayLap,
                    SoChungTu   = liTim[0].SoChungTu,
                    SoPO        = liTim[0].SoChungTuGoc
                };
                if (liTim[0].LoaiChungTu == Convert.ToInt32(TransactionType.NHAP_DOIMA))
                {
                    liSX            = SanXuatLenhProvier.GetSanXuatLenhByMaLenh(liTim[0].SoChungTuGoc, liTim[0].IdChungTu);
                    MaVachThanhPham = liSX[0].MaVachThanhPham;
                    MaThanhPham     = liSX[0].MaThanhPham;
                    TenThanhPham    = liSX[0].TenThanhPham;
                    SoLuongYC       = liSX[0].SoLuongTP;
                    MaLenh          = liTim[0].SoChungTuGoc;
                    SoLuongDN       = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                        Convert.ToInt32(TransactionType.NHAP_DOIMA), liTim[0].SoChungTuGoc, this.MaTrungTam);
                    liMaVach = tblChungTuDataProvider.GetMaVachByChungTuGoc(liTim[0].SoChungTu);
                }
                else
                {
                    throw new ManagedException("Không tìm thấy dữ liệu phù hợp !");
                }

                Form frm = new frmChiTietNhapThanhPham(MaLenh, MaThanhPham, TenThanhPham, MaTrungTam,
                                                       MaVachThanhPham, SoLuongYC, SoLuongDN,
                                                       liMaVach, ct, 2);
                frm.ShowDialog();
            }
            else
            {
                throw new ManagedException("Không tìm thấy dữ liệu phù hợp !");
            }
        }
Esempio n. 9
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;
        }
Esempio n. 10
0
 private void UpdateTrangthai()
 {
     if (SanXuatLenhProvier.GetSoLuongSanXuatLenh(Declare.IdKho, Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                                                  txtMaLenh.Text.Trim(), 1) == frm.SoLuongYC)
     {
         SanXuatLenhProvier.UpdateTrangThai(new SanXuatLenhInfo
         {
             MaLenh      = txtMaLenh.Text.Trim(),
             MaThanhPham = txtMaSP.Text.Trim(),
             TrangThai   = Convert.ToInt32(TrangThaiSanXuat.DaSanXuatXong)
         });
     }
 }
        private void GetValue()
        {
            SanXuatLenhInfo sx = (SanXuatLenhInfo)grvChiTiet.GetRow(grvChiTiet.FocusedRowHandle);

            MaLenh       = liChiTiet[liChiTiet.IndexOf(sx)].MaLenh;
            MaThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].MaThanhPham;
            TenThanhPham = liChiTiet[liChiTiet.IndexOf(sx)].TenThanhPham;
            SoLuongYC    = liChiTiet[liChiTiet.IndexOf(sx)].SoLuongTP;
            idThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].idThanhPham;
            Trangthai    = liChiTiet[liChiTiet.IndexOf(sx)].TrangThai;
            status       = liChiTiet[liChiTiet.IndexOf(sx)].Status;
            NgayLap      = liChiTiet[liChiTiet.IndexOf(sx)].NgayLap;
            SoLuongCT    = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), liChiTiet[liChiTiet.IndexOf(sx)].MaLenh, currentTrungTam.MaTrungTam);
        }
Esempio n. 12
0
 private void frmDanhSachNhapComBo_Load(object sender, EventArgs e)
 {
     btnTim.Visible = false;
     clsUtils.NullColumnDateTimeGrid(repdtngaylap);
     LoadTrangthai();
     btnTim.Text          = Resources.btnSearch;
     btnChiTiet.Text      = Resources.btnInfor;
     MaTrungTam           = GetMaTrungTam();
     MaKho                = GetMaKho();
     dteLastSync.DateTime = SanXuatLenhProvier.GetMaxDateSanXuatLenh(MaTrungTam);
     //LoadDateTime();
     liChiTiet = SanXuatLenhProvier.GetAllSanXuatLenh(MaKho, MaTrungTam, "GHEPMA");
     CheckTrangthai();
     dgvChiTiet.DataSource = liChiTiet;
 }
Esempio n. 13
0
        private void GetValue()
        {
            SanXuatNhapTachInfo sx = (SanXuatNhapTachInfo)grvChiTiet.GetRow(grvChiTiet.FocusedRowHandle);

            MaLenh        = liChiTiet[liChiTiet.IndexOf(sx)].MaLenh;
            MaThanhPham   = liChiTiet[liChiTiet.IndexOf(sx)].MaThanhPham;
            TenThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].TenThanhPham;
            SoLuongYC     = liChiTiet[liChiTiet.IndexOf(sx)].SoLuongYC;
            IdSanPham     = liChiTiet[liChiTiet.IndexOf(sx)].idthanhpham;
            TrangThai     = liChiTiet[liChiTiet.IndexOf(sx)].TrangThai;
            TransactionID = liChiTiet[liChiTiet.IndexOf(sx)].TransactionID.ToString();
            NgayLap       = liChiTiet[liChiTiet.IndexOf(sx)].NgayLap;
            SoLuongCT     = SanXuatLenhProvier.GetSoLuongChungTu(
                Convert.ToInt32(TransactionType.XUAT_THANH_PHAM),
                liChiTiet[liChiTiet.IndexOf(sx)].MaLenh, 1, liChiTiet[liChiTiet.IndexOf(sx)].TransactionID.ToString());
        }
Esempio n. 14
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
            }
        }
Esempio n. 15
0
        private void GetValue()
        {
            if (grvChiTiet.FocusedRowHandle == null)
            {
                throw new ManagedException("Xin hãy chọn dữ liệu !");
            }
            SanXuatLenhInfo sx = (SanXuatLenhInfo)grvChiTiet.GetRow(grvChiTiet.FocusedRowHandle);

            MaLenh       = liChiTiet[liChiTiet.IndexOf(sx)].MaLenh;
            MaThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].MaThanhPham;
            TenThanhPham = liChiTiet[liChiTiet.IndexOf(sx)].TenThanhPham;
            SoLuongYC    = liChiTiet[liChiTiet.IndexOf(sx)].SoLuongTP;
            idThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].idThanhPham;
            Trangthai    = liChiTiet[liChiTiet.IndexOf(sx)].TrangThai;
            status       = liChiTiet[liChiTiet.IndexOf(sx)].Status;
            NgayLap      = liChiTiet[liChiTiet.IndexOf(sx)].NgayLap;
            SoLuongCT    = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                Convert.ToInt32(TransactionType.NHAP_COMBO), liChiTiet[liChiTiet.IndexOf(sx)].MaLenh, currentTrungTam.MaTrungTam);
        }
Esempio n. 16
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
            }
        }
Esempio n. 17
0
        private void GetValue()
        {
            if (grvChiTiet.FocusedRowHandle == null)
            {
                throw new ManagedException("Xin hãy chọn dữ liệu !");
            }
            SanXuatNhapTachInfo sx = (SanXuatNhapTachInfo)grvChiTiet.GetRow(grvChiTiet.FocusedRowHandle);

            MaLenh        = liChiTiet[liChiTiet.IndexOf(sx)].MaLenh;
            MaThanhPham   = liChiTiet[liChiTiet.IndexOf(sx)].MaThanhPham;
            TenThanhPham  = liChiTiet[liChiTiet.IndexOf(sx)].TenThanhPham;
            SoLuongYC     = liChiTiet[liChiTiet.IndexOf(sx)].SoLuongYC;
            idThanhPham   = liChiTiet[liChiTiet.IndexOf(sx)].idthanhpham;
            TrangThai     = liChiTiet[liChiTiet.IndexOf(sx)].TrangThai;
            TransactionID = liChiTiet[liChiTiet.IndexOf(sx)].TransactionID.ToString();
            NgayLap       = liChiTiet[liChiTiet.IndexOf(sx)].NgayLap;
            SoLuongCT     = SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                liChiTiet[liChiTiet.IndexOf(sx)].MaLenh, 1, liChiTiet[liChiTiet.IndexOf(sx)].TransactionID.ToString()) +
                            SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                liChiTiet[liChiTiet.IndexOf(sx)].MaLenh, 2, liChiTiet[liChiTiet.IndexOf(sx)].TransactionID.ToString());
        }
        private void Save()
        {
            for (int i = 0; i < liChiTiet.Count; i++)
            {
                if (liChiTiet[i].check == false)
                {
                    throw new ManagedException("Bạn chưa xác nhận đủ mã vạch linh kiện để tách thành phẩm !");
                }
            }
            int SoLuongCT = SanXuatLenhProvier.GetSoLuongChungTu(
                Convert.ToInt32(TransactionType.XUAT_THANH_PHAM),
                txtMaLenh.Text.Trim(), 1, frm.TransactionID);

            if (Convert.ToInt32(txtSoLuongYC.Text) <= SoLuongCT)
            {
                throw new ManagedException("Số lượng yêu cầu đã đủ không thể nhập thêm !");
            }
            if (string.IsNullOrEmpty(dtNgayLap.Text))
            {
                dtNgayLap.Focus();
                throw new ManagedException("Bạn chưa trọn ngày lập !");
            }
            if (Convert.ToDateTime(dtNgayLap.EditValue) < frm.NgayLap)
            {
                dtNgayLap.Focus();
                throw new ManagedException("Ngày nhập thành phẩm không được nhỏ hơn ngày lập của mã lệnh!");
            }
            try
            {
                SaveNhapLinhKien(SaveXuatThanhPham());

                string maLenh        = txtMaVachLK.Text.Trim();
                string maThanhPham   = txtMaSP.Text.Trim();
                int    soLuongYc     = frm.SoLuongYC;
                string transactionId = frm.TransactionID;

                frmProgress.Instance.Caption     = Text;
                frmProgress.Instance.Description = "Đang thực hiện ...";
                frmProgress.Instance.MaxValue    = 100;
                frmProgress.Instance.Value       = 0;

                frmProgress.Instance.DoWork(
                    delegate
                {
                    try
                    {
                        ConnectionUtil.Instance.BeginTransaction();

                        ChungTuBusinessBase businessCloned = XTP.Clone();

                        ((XuatThanhPhamSXBussiness)businessCloned).ChungTu.NgayLap =
                            CommonProvider.Instance.GetSysDate();

                        ((XuatThanhPhamSXBussiness)businessCloned).ChungTu.NgayXuatHang =
                            CommonProvider.Instance.GetSysDate();

                        businessCloned.SaveChungTu();

                        businessCloned = NLK.Clone();

                        ((NhapLinhKienSXBussiness)businessCloned).ChungTu.NgayLap =
                            CommonProvider.Instance.GetSysDate();

                        ((NhapLinhKienSXBussiness)businessCloned).ChungTu.NgayXuatHang =
                            CommonProvider.Instance.GetSysDate();

                        businessCloned.SaveChungTu();

                        KhoNhapNccDataProvider.Instance.UpdateTrangThaiChungTu(new ChungTuXuatNhapNccInfo {
                            IdChungTu = sanXuatNhapTachInfo.IdChungTu, TrangThai = 2
                        });

                        if (SanXuatLenhProvier.GetSoLuongSanXuatLenh(Declare.IdKho, Convert.ToInt32(TransactionType.XUAT_LINK_KIEN_SX), maLenh, 1) != soLuongYc)
                        {
                            SanXuatLenhProvier.UpdateTrangThai(new SanXuatLenhInfo
                            {
                                MaLenh      = maLenh,
                                MaThanhPham = maThanhPham,
                                TrangThai   = Convert.ToInt32(TrangThaiSanXuat.DangSX)
                            });
                        }

                        SoLuongCT = SanXuatLenhProvier.GetSoLuongChungTu(
                            Convert.ToInt32(TransactionType.XUAT_THANH_PHAM), maLenh, 1, transactionId);

                        if (soLuongYc < SoLuongCT)
                        {
                            throw new ManagedException("Số lượng yêu cầu đã đủ không thể nhập thêm!");
                        }

                        ConnectionUtil.Instance.CommitTransaction();

                        frmProgress.Instance.Description = "Đã xong!";

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

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

                        MessageBox.Show(ex.Message);

                        frmProgress.Instance.Description = "Giao dịch không thành công!";

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

                        frmProgress.Instance.IsCompleted = true;

                        if (!(ex is ManagedException))
                        {
                            EventLogProvider.Instance.WriteOfflineLog(ex.ToString(), "Tách thành phẩm SX");
                        }
                    }
                });

                //ConnectionUtil.Instance.DoSerializableWorkInTransaction(
                //    delegate
                //        {
                //            ChungTuBusinessBase businessCloned = XTP.Clone();

                //            ((XuatThanhPhamSXBussiness)businessCloned).ChungTu.NgayLap =
                //                CommonProvider.Instance.GetSysDate();

                //            ((XuatThanhPhamSXBussiness)businessCloned).ChungTu.NgayXuatHang =
                //                CommonProvider.Instance.GetSysDate();

                //            businessCloned.SaveChungTu();

                //            businessCloned = NLK.Clone();

                //            ((NhapLinhKienSXBussiness) businessCloned).ChungTu.NgayLap =
                //                CommonProvider.Instance.GetSysDate();

                //            ((NhapLinhKienSXBussiness)businessCloned).ChungTu.NgayXuatHang =
                //                CommonProvider.Instance.GetSysDate();

                //            businessCloned.SaveChungTu();

                //            KhoNhapNccDataProvider.Instance.UpdateTrangThaiChungTu(new ChungTuXuatNhapNccInfo { IdChungTu = sanXuatNhapTachInfo.IdChungTu, TrangThai = 2 });

                //            if (SanXuatLenhProvier.GetSoLuongSanXuatLenh(Declare.IdKho, Convert.ToInt32(TransactionType.XUAT_LINK_KIEN_SX), maLenh, 1) != soLuongYc)
                //            {
                //                SanXuatLenhProvier.UpdateTrangThai(new SanXuatLenhInfo
                //                {
                //                    MaLenh = maLenh,
                //                    MaThanhPham = maThanhPham,
                //                    TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX)
                //                });
                //            }

                //            SoLuongCT = SanXuatLenhProvier.GetSoLuongChungTu(
                //                Convert.ToInt32(TransactionType.XUAT_THANH_PHAM), maLenh, 1, transactionId);

                //            if (soLuongYc < SoLuongCT)
                //            {
                //                throw new ManagedException("Số lượng yêu cầu đã đủ không thể nhập thêm!");
                //            }
                //        });

                Clear();
                frm.Reload();
                //clsUtils.MsgThongBao("Tách thành công 1 thành phẩm !");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 19
0
 private void Save()
 {
     if (txtMaVachTP.Text == "")
     {
         throw new ManagedException("Mã vạch cho thành phẩm không được để trống !");
     }
     for (int i = 0; i < lisx.Count; i++)
     {
         if (lisx[i].SoLuongDaQuet < lisx[i].SoLuongTrenTPham)
         {
             throw new ManagedException("Linh kiện " + lisx[i].TenLinhKien + " chưa nhập đủ số lượng mã vạch !");
         }
     }
     if (check == 0)
     {
         int SoLuongCT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
             Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), Declare.MaTrungTam);
         if (Convert.ToInt32(txtSoLuongYC.Text) <= SoLuongCT)
         {
             throw new ManagedException("Số lượng yêu cầu đã đủ, bạn không thể nhập thêm");
         }
     }
     if (check == 0 && isXuatLoi == false)
     {
         if (TblHangHoaChiTietDataProvider.IsUsedForAnotherProduct(txtMaVachTP.Text.Trim(), frm.idThanhPham))
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
         if (NhapThanhPhamSanXuatDataProvider.Instance.CheckMaVachNTP(frm.idThanhPham, txtMaVachTP.Text.Trim()) > 0)
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
         if (NhapThanhPhamSanXuatDataProvider.Instance.CheckMaVach(frm.idThanhPham, txtMaVachTP.Text.Trim()) > 0)
         {
             throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy kiểm tra lại !");
         }
     }
     for (int i = 0; i < lisx.Count; i++)
     {
         if (lisx[i].SoLuongDaQuet < lisx[i].SoLuongTrenTPham)
         {
             throw new ManagedException("Bạn chưa nhập đủ số lượng mã vạch cho linh kiện " + lisx[i].MaLinhKien + " !");
         }
     }
     if (string.IsNullOrEmpty(dtNgayLap.Text))
     {
         dtNgayLap.Focus();
         throw new ManagedException("Bạn chưa chọn ngày lập !");
     }
     if (Convert.ToDateTime(dtNgayLap.EditValue) < frm.NgayLap)
     {
         dtNgayLap.Focus();
         throw new ManagedException("Ngày xuất linh kiện không được nhỏ hơn ngày lập của mã lệnh !");
     }
     try
     {
         ConnectionUtil.Instance.BeginTransaction();
         if (check == 0)
         {
             SaveXuatLinhKien(SaveNhapThanhPham());
             SLCT++;
         }
         else
         {
             XLKBussiness.SaveChungTu();
         }
         txtSoLuongCT.Text = SLCT.ToString();
         UpdateSoLuongDaXuat();
         if (SanXuatLenhProvier.GetSoLuongSanXuatLenh(Declare.IdKho, Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), 0) > 0)
         {
             SanXuatLenhProvier.UpdateTrangThai(new SanXuatLenhInfo {
                 MaLenh = txtMaLenh.Text.Trim(), MaThanhPham = txtMaThanhPham.Text.Trim(), TrangThai = Convert.ToInt32(TrangThaiSanXuat.DangSX)
             });
         }
         if (check == 0)
         {
             int SoLuongCT = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                 Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), txtMaLenh.Text.Trim(), Declare.MaTrungTam);
             if (Convert.ToInt32(txtSoLuongYC.Text) < SoLuongCT)
             {
                 throw new ManagedException("Số lượng yêu cầu đã đủ,bạn không thể nhập thêm");
             }
         }
         ConnectionUtil.Instance.CommitTransaction();
         clsUtils.MsgThongBao("Xuất thành công !");
         if (clsUtils.MsgXoa("Bạn có muốn in phiếu bảo hành cho bộ linh kiện không ?") == System.Windows.Forms.DialogResult.Yes)
         {
             List <ChungTuNhapNccChiTietHangHoaInfo> lst = new List <ChungTuNhapNccChiTietHangHoaInfo>();
             lst.AddRange(liMaVach);
             frmChonBaoCao frm1 = new frmChonBaoCao(true);
             frm1.ShowDialog();
             if (frm1.DialogResult == DialogResult.OK)
             {
                 if (frm1.Value == 1)
                 {
                     DMSanPhamInfo sp = DmSanPhamProvider.Instance.GetSanPhamByMa(txtMaThanhPham.Text.Trim());
                     foreach (ChungTuNhapNccChiTietHangHoaInfo pt in lst)
                     {
                         pt.ThoiHanBH = sp.BaoHanhHang;
                     }
                     rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                     rpt.DataSource = lst;
                     rpt.ShowPreview();
                 }
                 else
                 {
                     rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                     rpt.DataSource = lst;
                     rpt.ShowPreview();
                 }
             }
         }
         Clear();
         frm.LoadDuLieu();
     }
     catch (Exception ex)
     {
         ConnectionUtil.Instance.RollbackTransaction();
         throw ex;
     }
 }
Esempio n. 20
0
 private void SaveMaVach(string MaVach, int IdSanPham)
 {
     SanXuatLenhProvier.InsertHangHoaChiTiet(new HangHoaChiTietInfo {
         IdSanPham = IdSanPham, MaVach = MaVach, SoLuong = 0, IdKho = Declare.IdKho
     });
 }
Esempio n. 21
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");
        }
Esempio n. 22
0
        private void checkLinhKien()
        {
            ChungTu_ChiTietInfo chungtu =
                SanXuatLenhProvier.ChungTuCTGetByMaVach(Convert.ToInt32(TransactionType.XUAT_LINK_KIEN_SX),
                                                        txtMaVach.Text.Trim());

            sanpham = BangGiaReportDataProvider.Instance.SanPhamGetByMaVach(txtMaVach.Text.Trim());
            if (sanpham != null)
            {
                if (chungtu != null && sanpham.TrungMaVach == 0)
                {
                    ChungTuNhapNccChiTietHangHoaInfo ct = SanXuatLenhProvier.ChungTuGetSoChungTuGoc(chungtu.IdChungTu);
                    if (ct != null)
                    {
                        if (ct.SoChungTugoc.Equals(txtMaLenh.Text.Trim()))
                        {
                            ChungTuNhapNccChiTietHangHoaInfo mv = SanXuatLenhProvier.CheckMaVach(txtMaVach.Text.Trim());
                            if (mv != null)
                            {
                                if (clsUtils.MsgXoa("Mã vạch linh kiện đã tồn tại trong 1 thành phẩm ! bạn có muốn hiện thị thành phẩm này không ?") == DialogResult.Yes)
                                {
                                    isXuatLoi = true;
                                    liMaVach.Clear();
                                    liMaVach             = SanXuatLenhProvier.GetLinhKiemSXbyIdChungTu(chungtu.IdChungTu);
                                    dgvMaVach.DataSource = null;
                                    dgvMaVach.DataSource = liMaVach;
                                    txtMaVachTP.Text     = liMaVach[0].MaVachThanhPham;
                                    for (int i = 0; i < lisx.Count; i++)
                                    {
                                        for (int j = 0; j < liMaVach.Count; j++)
                                        {
                                            if (lisx[i].IdLinhKien == liMaVach[j].IdSanPham)
                                            {
                                                lisx[i].SoLuongDaQuet = lisx[i].SoLuongDaQuet + liMaVach[j].SoLuong;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    txtMaVach.Text = "";
                                    txtMaVach.Focus();
                                }
                            }
                            else
                            {
                                txtMaVach.Text = "";
                                txtMaVach.Focus();
                                throw new ManagedException("Mã vạch đã hết tồn trong kho !");
                            }
                        }
                        else
                        {
                            Them();
                        }
                    }
                    else
                    {
                        Them();
                    }
                }
                else
                {
                    Them();
                }
            }
            else
            {
                Them();
            }
        }
Esempio n. 23
0
 public void Reload()
 {
     liChiTiet = SanXuatLenhProvier.GetAllSanXuatLenh(MaKho, MaTrungTam, "GHEPMA");
     CheckTrangthai();
     dgvChiTiet.DataSource = liChiTiet;
 }
Esempio n. 24
0
        private void Tim(string MaVach)
        {
            liTim = tblChungTuDataProvider.GetChungTuByMaVach(MaVach);

            if (liTim.Count > 0)
            {
                ct = new ChungTuXuatNhapNccInfo
                {
                    IdChungTu   = liTim[0].IdChungTu,
                    LoaiChungTu = liTim[0].LoaiChungTu,
                    IdKho       = liTim[0].IdKho,
                    IdNhanVien  = liTim[0].IdNhanVien,
                    NgayLap     = liTim[0].NgayLap,
                    SoChungTu   = liTim[0].SoChungTu,
                    SoPO        = liTim[0].SoChungTuGoc
                };
                if (liTim[0].LoaiChungTu == Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX))
                {
                    liSX            = SanXuatLenhProvier.GetSanXuatLenhByMaLenh(liTim[0].SoChungTuGoc, liTim[0].IdChungTu);
                    MaVachThanhPham = liSX[0].MaVachThanhPham;
                    MaThanhPham     = liSX[0].MaThanhPham;
                    TenThanhPham    = liSX[0].TenThanhPham;
                    SoLuongYC       = liSX[0].SoLuongTP;
                    MaLenh          = liTim[0].SoChungTuGoc;
                    SoLuongDN       = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), liTim[0].SoChungTuGoc, MaTrungTam);
                    liMaVach = tblChungTuDataProvider.GetMaVachByChungTuGoc(liTim[0].SoChungTu);
                }
                //else if (liTim[0].LoaiChungTu == Convert.ToInt32(TransactionType.XUAT_LINK_KIEN_SX))
                //{
                //    liChungTu = tblChungTuDataProvider.GetChungTuBySoChungTu<DMChungTuNhapInfo>(liTim[0].SoChungTuGoc);
                //    liSX = SanXuatLenhProvier.GetSanXuatLenhByMaLenh(liChungTu.SoChungTuGoc);
                //    if (liSX.Count > 0)
                //    {
                //        MaVachThanhPham = liSX[0].MaVachThanhPham;
                //        MaThanhPham = liSX[0].MaThanhPham;
                //        TenThanhPham = liSX[0].TenThanhPham;
                //        SoLuongYC = liSX[0].SoLuongTP;
                //        MaLenh = liSX[0].MaLenh;
                //        SoLuongDN = SanXuatLenhProvier.GetSoLuongDNSanXuatLenh(
                //        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX), liChungTu.SoChungTuGoc,MaTrungTam);
                //        liMaVach = tblChungTuDataProvider.GetMaVachByChungTuGoc(liTim[0].SoChungTu);
                //    }
                //    liMaVach = tblChungTuDataProvider.GetMaVachByChungTuGoc(liTim[0].SoChungTuGoc);
                //}
                else
                {
                    throw new ManagedException("Không tìm thấy dữ liệu phù hợp !");
                }
                frmChiTietNhapThanhPham frm = new frmChiTietNhapThanhPham(this, MaLenh, liMaVach, ct, 2);
                frm.ShowDialog();
                this.Close();
            }
            //else if (liTim.Count > 1)
            //{
            //    if (clsUtils.MsgXoa("Mã vạch tồn tại trong nhiều thành phẩm khác nhau.Xin hãy chọn thành phẩm ?") == System.Windows.Forms.DialogResult.Yes)
            //    {

            //    }
            //}
            else
            {
                throw new ManagedException("Không tìm thấy dữ liệu phù hợp !");
            }
        }
Esempio n. 25
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;
            }
        }
Esempio n. 26
0
        private void Save()
        {
            try
            {
                ConnectionUtil.Instance.BeginTransaction();
                if (liChiTiet.Count > 0)
                {
                    int SoLuongCT = SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        txtMaLenh.Text.Trim(), 1, frm.TransactionID) +
                                    SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        txtMaLenh.Text.Trim(), 2, frm.TransactionID);
                    if (Convert.ToInt32(txtSoLuongYC.Text) <= SoLuongCT)
                    {
                        throw new ManagedException("Số lượng yêu cầu cho thành phẩm đã đủ,không thể nhập thêm !");
                    }
                    if (string.IsNullOrEmpty(dtNgayLap.Text))
                    {
                        dtNgayLap.Focus();
                        throw new ManagedException("Bạn chưa trọn ngày lập!");
                    }
                    if (Convert.ToDateTime(dtNgayLap.EditValue) < frm.NgayLap)
                    {
                        dtNgayLap.Focus();

                        throw new ManagedException("Ngày tách không được nhở hơn ngày lập của mã lệnh!");
                    }
                    if (string.IsNullOrEmpty(txtMaThanhPham.Text.Trim()))
                    {
                        throw new ManagedException("Mã vạch thành phẩm không được để trống !");
                    }

                    if (NhapThanhPhamSanXuatDataProvider.Instance.CheckXacNhanNhapMaVachTP(lst.IdChungTu, frm.idThanhPham, txtMaThanhPham.Text.Trim()) > 0)
                    {
                        txtMaThanhPham.Focus();

                        throw new ManagedException("Mã vạch đã sử dụng cho 1 sản phẩm khác. Xin hãy đổi mã vạch khác !");
                    }
                    ChungTuXuatNhapNccInfo ct = new ChungTuXuatNhapNccInfo();
                    ct.IdChungTu        = lst.IdChungTu;
                    ct.TrangThai        = 1;
                    ct.SoChungTu        = lst.SoChungTu;
                    ct.IdKho            = lst.idKho;
                    ct.IdNhanVien       = lst.idNhanVien;
                    ct.NgayLap          = lst.NgayLap;
                    ct.SoPO             = frm.TransactionID;
                    ct.SoPhieuNhap      = lst.MaLenh;
                    ct.LoaiChungTu      = Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX);
                    dtNgayLap.EditValue = ct.NgayXuatHang;
                    XN = new XacNhanNhapThanhPhanSanXuatBussiness(ct);
                    XN.ListChiTietHangHoa.Clear();
                    XN.ListChiTietHangHoa.Add(new ChungTuNhapNccChiTietHangHoaInfo
                    {
                        IdSanPham = frm.idThanhPham,
                        SoLuong   = 1,
                        MaVach    = XN.ListChiTietChungTu[0].DanhSachMaVach
                    });
                    ct.NgayXuatHang = CommonProvider.Instance.GetSysDate();
                    XN.SaveChungTu();
                    UpdateTrangthai();
                    SoLuongCT = SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        txtMaLenh.Text.Trim(), 1, frm.TransactionID) +
                                SanXuatLenhProvier.GetSoLuongXacNhanNhap(
                        Convert.ToInt32(TransactionType.NHAP_THANH_PHAM_SX),
                        txtMaLenh.Text.Trim(), 2, frm.TransactionID);
                    if (Convert.ToInt32(txtSoLuongYC.Text) < SoLuongCT)
                    {
                        throw new ManagedException("Số lượng yêu cầu cho thành phẩm đã đủ,không thể nhập thêm !");
                    }
                    ConnectionUtil.Instance.CommitTransaction();
                    clsUtils.MsgThongBao("Đã xác nhận 1 thành phẩm !");
                    Clear();
                    frm.ReLoad();
                }
            }
            catch (Exception)
            {
                ConnectionUtil.Instance.RollbackTransaction();
                throw;
            }
        }