Exemple #1
0
        private void btnInPhieu_Click(object sender, EventArgs e)
        {
            frmChonBaoCao frm = new frmChonBaoCao(true);

            frm.ShowDialog();
            if (frm.DialogResult == DialogResult.OK)
            {
                if (frm.Value == 1)
                {
                    DMSanPhamInfo sp = DmSanPhamProvider.Instance.GetSanPhamByMa(txtMaThanhPham.Text.Trim());
                    foreach (ChungTuNhapNccChiTietHangHoaInfo pt in liMaVach)
                    {
                        if (pt.ThoiHanBH != 0)
                        {
                            pt.ThoiHanBH = sp.BaoHanhHang;
                        }
                    }
                    rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                    rpt.DataSource = liMaVach;
                    rpt.ShowPreview();
                }
                else
                {
                    rptInPhieuBHSX rpt = new rptInPhieuBHSX(txtTenThanhPham.Text.Trim(), txtMaLenh.Text.Trim(), txtMaVachTP.Text.Trim());
                    rpt.DataSource = liMaVach;
                    rpt.ShowPreview();
                }
            }
        }
Exemple #2
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;
     }
 }