Exemple #1
0
 public frmChiTietNhapThanhPham(string maLenh, string maThanhPham, string tenThanhPham, string maTrungTam, string maVachThanhPham, int soLuongYc, int soLuongCt, List <ChungTuNhapNccChiTietHangHoaInfo> liMaVach, ChungTuXuatNhapNccInfo ct, int check)
 {
     InitializeComponent();
     this.MaLenh          = maLenh;
     this.MaThanhPham     = maThanhPham;
     this.MaTrungTam      = maTrungTam;
     this.TenThanhPham    = tenThanhPham;
     this.SoLuongYC       = soLuongYc;
     this.SLCT            = soLuongCt;
     this.MaVachThanhPham = maVachThanhPham;
     this.liMaVach        = liMaVach;
     this.check           = check; //0: them moi, 2: sua
     XLKBussiness         = new XuatLinhKienSanXuatBussiness(new ChungTuXuatNhapNccInfo {
         IdChungTu = liMaVach[0].IdChungTu, SoChungTu = liMaVach[0].SoChungTu, IdKho = liMaVach[0].IdKho
     });
     NTPBussiness   = new NhapThanhPhamSanXuatBussiness(ct);
     XNNTPBussiness = new XacNhanNhapThanhPhanSanXuatBussiness(ct);
 }
Exemple #2
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;
            }
        }