示例#1
0
        /// <summary>
        /// 入库操作
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="entryInfo"></param>
        /// <param name="entryDetailInfos"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool EntryOperate(I_Entry entryInfo, List<I_EntryDetail> entryDetailInfos, ref string errorMsg)
        {
            //创建事务
            using (var tran = db.Database.BeginTransaction())
            {
                try
                {
                    this.DoEntry(entryInfo, entryDetailInfos, ref errorMsg);

                    tran.Commit(); //提交事务

                    return true;
                }
                catch (Exception ex)
                {
                    if (tran != null)
                        tran.Rollback();  //回滚事务
                    errorMsg = "入库操作失败! 操作已取消!~~" + ex.Message;
                    return false;
                }
            }
        }
示例#2
0
        /// <summary>
        /// 红充操作
        /// </summary>
        /// <param name="newEntryInfo">新入库单</param>
        /// <param name="orientryDetailInfo">原入单从表</param>
        /// <param name="newEntryDetailInfo">新入库单从表</param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool EntryRedOperate(I_Entry newEntryInfo, I_EntryDetail orientryDetailInfo, I_EntryDetail newEntryDetailInfo, ref string errorMsg)
        {
            //创建事务
            using (var tran = db.Database.BeginTransaction())
            {
                try
                {
                    //修改红冲入库单号  orientryDetailInfo 不能被EF框架跟踪
                    dalContext.II_EntryDetailDAL.Modify(orientryDetailInfo, "RedEntryDetailCode"); //更新被红充编码

                    List<I_EntryDetail> entryDetailInfos = new List<I_EntryDetail>();
                    entryDetailInfos.Add(newEntryDetailInfo);
                    this.DoEntry(newEntryInfo, entryDetailInfos, ref errorMsg); //做入库操作

                    tran.Commit(); //提交事务

                    return true;
                }
                catch (Exception ex)
                {
                    if (tran != null)
                        tran.Rollback();  //回滚事务
                    errorMsg = "入库操作失败! 操作已取消!~~" + ex.Message;
                    return false;
                }
            }
        }
示例#3
0
        /// <summary>
        /// 入库操作
        /// </summary>
        /// <param name="entryInfo"></param>
        /// <param name="entryDetailInfos"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        internal void DoEntry(I_Entry entryInfo, List<I_EntryDetail> entryDetailInfos, ref string errorMsg)
        {
            //1 先插入主表
            I_Entry tempEntry = (from e in db.I_Entry
                                 where e.EntryCode == entryInfo.EntryCode
                                 select e).FirstOrDefault();
            if (tempEntry == null)
                dalContext.II_EntryDAL.Add(entryInfo);

            foreach (I_EntryDetail info in entryDetailInfos)
            {
                I_EntryDetail tempEntryDetail = (from e in db.I_EntryDetail
                                                 where e.EntryDetailCode == info.EntryDetailCode
                                                 select e).FirstOrDefault();
                if (tempEntryDetail != null)
                {
                    info.EntryDetailCode = (Convert.ToInt32(info.EntryDetailCode) + 1).ToString();
                }
                //2. 再插入从表信息   红充流程注意记录RedEntryDetailCode信息
                dalContext.II_EntryDetailDAL.Add(info);

                //3. 保存剩余流水表
                dalContext.II_SurplusDAL.SaveEntrySurplusInfo(info, entryInfo.EntryType, ref errorMsg);
            }
        }
示例#4
0
 public ActionResult SaveEntry()
 {
     string sEntryDetailInfo = Request.Form["sEntryDetailInfo"].ToString();
     List<EntryDetailInfo> relist = JsonHelper.GetJsonInfoBy<List<EntryDetailInfo>>(sEntryDetailInfo);
     I_Entry entryInfo = new I_Entry();
     entryInfo.EntryCode = DateTime.Now.AddSeconds(1).ToString("yyyyMMddHHmmss") + entryInfo.OperatorCode;    //生成入库编码
     entryInfo.EntryDate = Convert.ToDateTime(Request.Form["EntryDate"]);
     entryInfo.EntryType = "MatertalInType-1";
     entryInfo.OperationTime = DateTime.Now;
     entryInfo.OperatorCode = UserOperateContext.Current.Session_UsrInfo.ID;
     entryInfo.EntryStorageID = int.Parse(Request.Form["StorageCode"]);
     entryInfo.Remark = Request.Form["Remark"].ToString().Trim();
     List<I_EntryDetail> list = new List<Model.I_EntryDetail>();
     int ind = 0;
     foreach (EntryDetailInfo item in relist)
     {
         ind++;
         I_EntryDetail detailinfo = new I_EntryDetail();
         detailinfo.EntryDetailCode = entryInfo.EntryCode + entryInfo.OperatorCode + ind.ToString();
         detailinfo.BatchNo = item.BatchNo;
         detailinfo.RealBatchNo = item.RealBatchNo;
         detailinfo.EntryCode = entryInfo.EntryCode;
         detailinfo.EntryCounts = item.EntryCounts;
         detailinfo.EntryDate = item.EntryDate;
         detailinfo.MaterialID = item.MaterialID;
         detailinfo.OperatorCode = UserOperateContext.Current.Session_UsrInfo.ID;
         detailinfo.RedEntryDetailCode = "";
         detailinfo.RelatedOrderNum = item.RelatedOrderNum;
         detailinfo.Remark = item.Remark.Trim();
         detailinfo.Specification = item.Specification;
         detailinfo.StorageCode = item.StorageCode;
         detailinfo.TotalPrice = item.TotalPrice;
         detailinfo.Unit = item.Unit;
         if (item.ValidityDateStr == "无有效期")
             detailinfo.ValidityDate = DateTime.MaxValue;
         else
             detailinfo.ValidityDate = Convert.ToDateTime(item.ValidityDateStr);
         list.Add(detailinfo);
     }
     string errorMsg = "";
     if (new I_EntryBLL().EntryOperate(entryInfo, list, ref errorMsg))
         return this.JsonResult(Utility.E_JsonResult.OK, "入库信息成功!", null, null);
     else
         return this.JsonResult(Utility.E_JsonResult.Error, errorMsg, null, null);
 }