Пример #1
0
        public static Msg EnsureInBunch(Tbl_ProductBatch oBunch, Tbl_ProductStorage oStorage)
        {
            Msg msg = null;

            if (oBunch != null)
            {
                try
                {
                    using (var en = new LingYunEntities())
                    {
                        var oPlan = en.Tbl_Plan.Where(a => a.PlanID == oBunch.PlanID).FirstOrDefault();
                        oPlan.ProductAdmStatus = 128;
                        en.Tbl_ProductBatch.AddObject(oBunch);
                        en.SaveChanges();
                        var obj = en.Tbl_ProductBatch.Where(a => a.MateriesID == oBunch.MateriesID).FirstOrDefault();
                        oStorage.BuildBatchID = int.Parse(obj.BuildBatchID.ToString());
                        en.AddToTbl_ProductStorage(oStorage);

                        msg = Msg.Default;
                    }
                }
                catch (Exception ex)
                {
                    msg = new Msg()
                    {
                        Status = false, Message = ex.Message
                    };
                }
            }
            return(msg);
        }
Пример #2
0
        /// <summary>
        /// 更新入库批次表
        /// </summary>
        /// <param name="matriesId"></param>
        /// <param name="count"></param>
        /// <param name="oStorage">仓储表</param>
        /// <returns></returns>
        public static Msg UpdateInBunch(int matriesId, int count, Tbl_ProductStorage oStorage)
        {
            Msg msg = null;

            try
            {
                using (var en = new LingYunEntities())
                {
                    var obj = en.Tbl_ProductBatch.Where(a => a.BuildBatchID == oStorage.BuildBatchID).FirstOrDefault();
                    obj.Count        = count;
                    obj.NowAdmStatus = 128;
                    obj.NowAdmTime   = DateTime.Now;

                    en.AddToTbl_ProductStorage(oStorage);
                    en.SaveChanges();

                    List <Tbl_ProductBatch> list = en.Tbl_ProductBatch.Where(a => a.PlanID == oStorage.PlanID && a.NowAdmStatus == 128).ToList();

                    int proCount = 0;
                    foreach (Tbl_ProductBatch oPro in list)
                    {
                        proCount += oPro.Count;
                    }
                    Tbl_Materies oMa = en.Tbl_Materies.Where(a => a.PlanID == oStorage.PlanID).FirstOrDefault(); //最后如果确认完成对加工主管状态改变
                    if (oMa.TotalNum == proCount)
                    {
                        var oPlan = en.Tbl_Plan.Where(a => a.PlanID == oStorage.PlanID).FirstOrDefault();
                        oPlan.ProductAdmStatus = 128;
                        en.SaveChanges();
                    }
                    msg = Msg.Default;
                }
            }
            catch (Exception ex)
            {
                msg = new Msg()
                {
                    Status = false, Message = ex.Message
                };
            }


            return(msg);
        }