Ejemplo n.º 1
0
        public StockBox ChangeBoxBarCode(string strBarCode, ref string ErrMsg)
        {
            try
            {
                //  string strBarCode = GetMaxBarCode_Ex(checkCode, AccountID, ref ErrMsg);
                if (entities.StockBoxes.Any(p => p.BarCode == strBarCode))
                {
                    ErrMsg = "输入的BOXID已存在";
                    return null;
                }
                StockBox sb = new StockBox();
                sb.BarCode = strBarCode;
                sb.CreateDt = DateTime.Now;
                sb.isPrint = true;

                entities.StockBoxes.Add(sb);
                entities.SaveChanges();
                return sb;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加箱号
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="sdoIDList"></param>
        /// <param name="IsPrintTray">是否需要打印托号</param>
        /// <param name="ErrMsg"></param>
        /// <returns></returns>
        public bool AddStockBox(string checkCode, int AccountID, StockBox entity, List<int> sdoIDList, ref bool IsPrintTray, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "实体不能为空";
                return false;
            }
            if (entities.StockBoxes.Any(p => p.BarCode == entity.BarCode))
            {
                ErrMsg = "Box ID 不能重复";
                return false;
            }
            entity.CreateDt = DateTime.Now;
            try
            {
                entities.StockBoxes.Add(entity);
                // entities.SaveChanges();
                //todo:多次SavaChanges();

                foreach (int item in sdoIDList)
                {
                    var tmpDetail = entities.StockDetails.FirstOrDefault(p => p.ID == item);
                    if (tmpDetail != null)
                        tmpDetail.StockBoxID = entity.ID;
                }
                entities.SaveChanges();
                //todo:是否需要打印托号
                //StockLot sl = entities.StockLots.Include("StockBoxes").FirstOrDefault(p => p.ID == entity.StockLotOutID);
                // sl.StockBoxes
                //   FormWork fw = entities.FormWorks.FirstOrDefault(p => p.ProductModel == sl.ProModel);

                //if ((sl.StockBoxes.Count() % fw.BoxQty) == 0)
                //    IsPrintTray = true;
                //else
                //    IsPrintTray = false;
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }
Ejemplo n.º 3
0
        public StockBox ChangeBoxBarCode_Pro(string strNewBarCode, string strOldBarCode, int AccountID, ref string ErrMsg)
        {
            try
            {
                //  string strBarCode = GetMaxBarCode_Ex(checkCode, AccountID, ref ErrMsg);
                if (entities.StockBoxes.Any(p => p.BarCode == strNewBarCode))
                {
                    ErrMsg = "输入的BOXID已存在";
                    return null;
                }

                StockBox sb = entities.StockBoxes.FirstOrDefault(p => p.BarCode == strOldBarCode);
                sb.isPrint = true;
                //sb.IsModify = true;//首次打印修改BOXID不打标记

                StockBox sbNew = new StockBox();
                sbNew.CreateDt = DateTime.Now;
                sbNew.isPrint = true;
                sbNew.BarCode = strNewBarCode;
                sbNew.CreateAccountID = AccountID;

                entities.StockBoxes.Add(sbNew);
                if (entities.SaveChanges() <= 0)
                {
                    ErrMsg = "修改失败";
                    return null;
                }

                return sbNew;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return null;
            }
        }
Ejemplo n.º 4
0
        public bool ModifyStockBox(string checkCode, int AccountID, StockBox entity, List<int> sdoIDList, List<int> stockLotIDs, ref bool IsPrintTray, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "实体不能为空";
                return false;
            }
            if (entities.StockBoxes.Where(p => p.ID != entity.ID).Any(p => p.BarCode == entity.BarCode))
            {
                ErrMsg = "Box ID 不能重复";
                return false;
            }
            //entity.CreateDt = DateTime.Now;
            try
            {
                //#region 标记为修改状态
                //var entry = entities.Entry<StockBox>(entity);
                //if (entry.State == EntityState.Detached)
                //{
                //    entities.Set<StockBox>().Attach(entity);
                //    entry.State = EntityState.Modified;
                //}
                //entities.SaveChanges();
                //#endregion
                StockBox sb = entities.StockBoxes.FirstOrDefault(p => p.ID == entity.ID);
                sb.BarCode = entity.BarCode;
                sb.isPrint = true;

                foreach (int item in sdoIDList)
                {
                    var tmpDetail = entities.StockDetails.FirstOrDefault(p => p.ID == item);
                    if (tmpDetail != null)
                        tmpDetail.StockBoxID = entity.ID;
                }
                entities.SaveChanges();

                //   IQueryable<StockLot> sls = new Queryable<StockLot>();
                List<StockLot> sls = new List<StockLot>();
                foreach (int item in stockLotIDs)
                {
                    StockLot lot = entities.StockLots.Include("StockDetails").Include("StockDetails.StockBox").Include("StockDetails.StockBox.Tray").FirstOrDefault(p => p.ID == item);
                    if (lot != null)
                        sls.Add(lot);
                }
                // var sls = entities.StockLots.Where(p => stockLotIDs.Any(a => a == p.ID));

                //StockLot sl = entities.StockLots.Include("StockBoxes").FirstOrDefault(p => p.ID == entity.StockLotOutID);
                // sl.StockBoxes
                StockLot tmplot = sls.First();
                FormWork fw = entities.FormWorks.FirstOrDefault(p => p.ProductModel == tmplot.ProModel);

                var slDetail = sls.SelectMany(p => p.StockDetails);
                var boxs = slDetail.Select(p => p.StockBox).Where(p => p != null);
                //(boxs.Distinct().Count() % fw.BoxQty) == 0  2014年5月7日 10:57:27修改判断条件
                if (boxs.Distinct().Where(p => p.Tray == null).Count() >= fw.BoxQty)
                    IsPrintTray = true;
                else
                    IsPrintTray = false;
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 2014年7月22日 16:16:43
        /// </summary>
        /// <param name="checkCode"></param>
        /// <param name="AccountID"></param>
        /// <param name="LotID"></param>
        /// <param name="ErrMsg"></param>
        /// <returns></returns>
        public StockBox GetMaxStockBox_Ex(string checkCode, int AccountID, ref string ErrMsg)
        {
            try
            {
                StockBox s = null;
                string strBarCode = String.Empty;
                StockBox sb = new StockBox();
                start:
                {
                    strBarCode = GetMaxBarCode_Ex(checkCode, AccountID, ref ErrMsg);
                    s = entities.StockBoxes.FirstOrDefault(p => p.BarCode == strBarCode);
                }
                if (s != null)
                {
                    System.Threading.Thread.Sleep(100);
                    goto start;
                }

                sb = new StockBox();
                sb.BarCode = strBarCode;
                sb.CreateDt = DateTime.Now;
                sb.isPrint = false;
                sb.CreateAccountID = AccountID;

                entities.StockBoxes.Add(sb);

                entities.SaveChanges();
                return sb;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return null;
            }
        }
Ejemplo n.º 6
0
        public StockBox GetMaxStockBox(string checkCode, int AccountID, int LotID, ref string ErrMsg)
        {
            try
            {
                string strBarCode = GetMaxBarCode(checkCode, AccountID, ref ErrMsg);
                StockBox sb = new StockBox();
                sb.BarCode = strBarCode;
                sb.CreateDt = DateTime.Now;
                sb.isPrint = true;

                entities.StockBoxes.Add(sb);
                entities.SaveChanges();
                return sb;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return null;
            }
        }