Ejemplo n.º 1
0
        /// <summary>
        /// 更新入库单信息
        /// </summary>
        /// <param name="info"></param>
        public void Update(InStockBill info)
        {
            InStockDAL isDal = new InStockDAL();

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                isDal.Session = session;
                isDal.Update(info);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成新入库单号
        /// </summary>
        /// <returns></returns>
        public string GetNewBillNO()
        {
            string maxNo = new InStockDAL().GetMaxBillNO();
            string newNo = DateTime.Now.ToString("yyyyMMdd");

            if (string.IsNullOrEmpty(maxNo) || maxNo.Length < 12)
            {
                newNo = newNo + "0001";
            }
            else
            {
                if (newNo == maxNo.Substring(0, 8))
                {
                    newNo = (double.Parse(maxNo) + 1).ToString();
                }
                else
                {
                    newNo = newNo + "0001";
                }
            }

            return(newNo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 入库
        /// </summary>
        /// <param name="bill">入库单</param>
        /// <returns></returns>
        public string InStorage(InStockBill bill)
        {
            string result = "";

            bill.ID         = Guid.NewGuid().ToString();
            bill.CREATEUSER = this.LoginUser.UserID;
            bill.CREATETIME = DateTime.Now;
            bill.UPDATEUSER = this.LoginUser.UserID;
            bill.UPDATETIME = bill.CREATETIME;

            int seq = 1;

            foreach (InStockDetail detail in bill.Details)
            {
                detail.ID         = Guid.NewGuid().ToString();
                detail.BillID     = bill.ID;
                detail.CREATEUSER = bill.CREATEUSER;
                detail.CREATETIME = bill.CREATETIME;
                detail.UPDATEUSER = bill.UPDATEUSER;
                detail.UPDATETIME = bill.UPDATETIME;
                detail.Seq        = seq;
                seq++;
            }

            StockDAL   stockDal = new StockDAL();
            InStockDAL isDal    = new InStockDAL();

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                try
                {
                    stockDal.Session = session;
                    isDal.Session    = session;

                    foreach (InStockDetail detail in bill.Details)
                    {
                        WHMatAmount inStock = new WHMatAmount();
                        inStock.Warehouse     = bill.Warehouse;
                        inStock.SaveSite      = detail.SaveSite;
                        inStock.MatBarCode    = detail.MatBarCode;
                        inStock.MatID         = detail.MatID;
                        inStock.ProductAmount = detail.InAmount;
                        inStock.ProductPrice  = detail.InPrice;
                        inStock.ProductSum    = detail.InSum;
                        inStock.Unit          = detail.UnitCode;
                        inStock.MainAmount    = detail.MainUnitAmount;

                        if (string.IsNullOrEmpty(detail.MatBarCode) == false && string.IsNullOrEmpty(detail.ProduceDate) == false)
                        {
                            inStock.ProduceDate = DateTime.Parse(detail.ProduceDate);
                            //更新条码信息的生产日期
                            new WHMatDAL().UpdateIDCodeProduceDate(new MatIDCode {
                                IDCode = detail.MatBarCode, ProduceDate = detail.ProduceDate
                            });
                        }


                        stockDal.InStock(inStock);
                    }

                    isDal.Insert(bill);

                    session.CommitTs();
                }
                catch (Exception ex)
                {
                    session.RollbackTs();
                    throw ex;
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 入库(货品编号)
        /// </summary>
        /// <param name="bill">入库单</param>
        /// <returns></returns>
        public void InMatStorage(InStockBill bill)
        {
            //设置基本信息
            bill.BillNO   = this.GetNewBillNO();
            bill.BillDate = DateTime.Now;
            bill.Receiver = this.LoginUser.UserID;

            bill.ID         = Guid.NewGuid().ToString();
            bill.CREATEUSER = this.LoginUser.UserID;
            bill.CREATETIME = DateTime.Now;
            bill.UPDATEUSER = this.LoginUser.UserID;
            bill.UPDATETIME = bill.CREATETIME;

            int seq = 1;

            foreach (InStockDetail detail in bill.Details)
            {
                detail.ID         = Guid.NewGuid().ToString();
                detail.BillID     = bill.ID;
                detail.InAmount   = detail.MainUnitAmount;
                detail.CREATEUSER = bill.CREATEUSER;
                detail.CREATETIME = bill.CREATETIME;
                detail.UPDATEUSER = bill.UPDATEUSER;
                detail.UPDATETIME = bill.UPDATETIME;
                detail.Seq        = seq;
                seq++;
            }

            StockDAL   stockDal = new StockDAL();
            InStockDAL isDal    = new InStockDAL();

            using (IDataSession session = AppDataFactory.CreateMainSession())
            {
                try
                {
                    stockDal.Session = session;
                    isDal.Session    = session;

                    foreach (InStockDetail detail in bill.Details)
                    {
                        WHMatAmount inStock = new WHMatAmount();
                        inStock.Warehouse     = bill.Warehouse;
                        inStock.SaveSite      = detail.SaveSite;
                        inStock.MatBarCode    = detail.MatBarCode;
                        inStock.MatID         = detail.MatID;
                        inStock.ProductAmount = detail.InAmount;
                        inStock.ProductPrice  = detail.InPrice;
                        inStock.ProductSum    = detail.InSum;
                        inStock.Unit          = detail.UnitCode;
                        inStock.CreateUser    = this.LoginUser.UserID;
                        inStock.UpdateUser    = this.LoginUser.UserID;
                        inStock.MainAmount    = detail.MainUnitAmount;

                        stockDal.InStock(inStock);
                    }

                    isDal.Insert(bill);

                    session.CommitTs();
                }
                catch (Exception ex)
                {
                    session.RollbackTs();
                    throw ex;
                }
            }
        }