Example #1
0
        public bool DeleteStockDetail(string checkCode, int AccountID, StockDetail entity, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "Glass ID信息为空";
                return false;
            }
            StockDetail _tmp = entities.StockDetails.FirstOrDefault(p => p.ID == entity.ID);
            if (_tmp == null)
            {
                ErrMsg = "该Glass ID不存在或已删除";
                return false;
            }

            try
            {
                entities.StockDetails.Remove(_tmp);
                if (entities.SaveChanges() <= 0)
                {
                    ErrMsg = "删除失败";
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }
Example #2
0
 public bool ModifyStockDetail(string checkCode, int AccountID, StockDetail entity, ref string ErrMsg)
 {
     //if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
     //    return false;
     if (entity == null)
     {
         ErrMsg = "Glass信息为空";
         return false;
     }
     if (entity.Status == 8 && entity.FanGongNum > 5)
     {
         ErrMsg = "返工次数已达到最大上限(5),无法再进行返工";
         return false;
     }
     if (entities.StockDetails.Any(p => p.GlassID == entity.GlassID&&p.ID!=entity.ID))
     {
         ErrMsg = "GlassID已存在,不能修改成该GlassID";
         return false;
     }
     try
     {
         var entry = entities.Entry<StockDetail>(entity);
         if (entry.State == EntityState.Detached)
         {
             entities.Set<StockDetail>().Attach(entity);
             entry.State = EntityState.Modified;
         }
         if (entities.SaveChanges() <= 0)
         {
             ErrMsg = "修改失败";
             return false;
         }
         return true;
     }
     catch (Exception ex)
     {
         ErrMsg = ex.Message;
         return false;
     }
 }
Example #3
0
        /// <summary>
        /// 添加GlassID,入库时调用!!!其他流程请勿调用
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="QtyCount">添加成功之后,带出该LotNO下实际已入库数量</param>
        /// <param name="IsCheck">是否对比关键字</param>
        /// <param name="ErrMsg"></param>
        /// <returns></returns>
        public bool AddStockDetail(string checkCode, int AccountID, StockDetail entity, bool IsCheck, ref int QtyCount, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "数据为空";
                return false;
            }

            try
            {
                //StockDetail tmpEntity=entities

                StockLot sl = entities.StockLots.Include("StockDetails").FirstOrDefault(p => p.ID == entity.StockLotID);

                if (sl == null)
                {
                    ErrMsg = "LotNo不存在或已删除";
                    return false;
                }
                //2014年2月23日 01:46:44  二期更改
                if (sl.IsImport)//当状态为未入库(导入模版)。
                {
                    StockDetail tmpEntity = sl.StockDetails.FirstOrDefault(p => p.GlassID == entity.GlassID);
                    tmpEntity.Status = entity.Status;
                    tmpEntity.StockInDT = entity.StockInDT;
                    tmpEntity.IsHOLD = entity.IsHOLD;
                    tmpEntity.StockInInfo = entity.StockInInfo;
                    tmpEntity.AccountID = entity.AccountID;
                    tmpEntity.AccountName = entity.AccountName;

                    return ModifyStockDetail(checkCode, AccountID, tmpEntity, ref ErrMsg);
                }

                if (entities.StockDetails.Any(p => p.GlassID == entity.GlassID))
                {
                    ErrMsg = "GlassID 不能重复";
                    return false;
                }

                if (sl.Status > 0)
                {
                    ErrMsg = "LotNo已结束,不能扫描GlassID";
                }
                if (sl.StockDetails != null && sl.PCSQty <= sl.StockDetails.Count())
                {
                    ErrMsg = "当前剩余入库数量为0";
                    return false;
                }
                FormWork fw = entities.FormWorks.FirstOrDefault(p => p.ProductModel == sl.ProModel);
                if (fw == null)
                {
                    ErrMsg = "该型号的模板不存在或已被删除,无法入库";
                    return false;
                }
                if (IsCheck)
                {
                    string[] strArray = fw.IDKeyWords.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    string tmpStr = strArray[strArray.Length - 1];
                    if (entity.GlassID.Length < int.Parse(tmpStr.Substring(0, tmpStr.Length - 1)))
                    {
                        ErrMsg = "与模板的关键字不匹配,不能入库";
                        return false;
                    }
                    for (int i = 0; i < entity.GlassID.Length; i++)
                    {
                        for (int j = 0; j < strArray.Length; j++)
                        {
                            if ((i + 1) == int.Parse(strArray[j].Substring(0, strArray[j].Length - 1)))
                            {
                                if (entity.GlassID[i].ToString() != (strArray[j].Substring(strArray[j].Length - 1)))
                                {
                                    ErrMsg = "与模板的关键字不匹配,不能入库";
                                    return false;
                                }
                            }
                        }
                    }
                }

                entity.CreateDt = DateTime.Now;
                entities.StockDetails.Add(entity);
                if (entities.SaveChanges() <= 0)
                {
                    ErrMsg = "添加失败";
                    return false;
                }
                QtyCount = sl.StockDetails.Count();
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }