示例#1
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();
        }
        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;
        }
示例#3
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 !");
            }
        }
        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);
        }
示例#5
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);
        }
示例#6
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");
        }
示例#7
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;
            }
        }
示例#8
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 !");
            }
        }
示例#9
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;
     }
 }