Esempio n. 1
0
 /// <summary>
 /// 执行借出申请
 /// </summary>
 /// <param name="_lendOutNo"></param>
 /// <returns></returns>
 public static bool ApplyLendOut(int LendId, User _user)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         var            lr = sc.LendRecords.SingleOrDefault(p => p.Id == LendId);
         SampleBaseInfo sb = sc.SampleBaseInfos.SingleOrDefault(s => s.StyleId == lr.StyleId);
         if (sb != null && sb.State == SampleState.在库)
         {
             lr.State           = LendRecordStats.借出审批;
             sb.State           = SampleState.待借出;
             lr.LendOutNo       = "";
             sc.Entry(lr).State = System.Data.Entity.EntityState.Modified;
             sc.Entry(sb).State = System.Data.Entity.EntityState.Modified;
             //ishavelend = true;
         }
         //else sc.Entry(lr).State = System.Data.Entity.EntityState.Deleted;  //不在库中从借出审批中删除
         sc.SaveChanges();
     }
     return(true);
 }
Esempio n. 2
0
 public static void ClearRoleBeforDate()
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         var list = sc.Users.Where(p => p.Role != UserRoleU.一般用户).ToList();
         list.ForEach(p =>
         {
             p.Role            = UserRoleU.一般用户;
             sc.Entry(p).State = System.Data.Entity.EntityState.Modified;
         });
         sc.SaveChanges();
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 删除指定待借样衣
 /// </summary>
 /// <param name="styleId"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool DoDelete(int LendId, User _user)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         LendRecord lr = sc.LendRecords.SingleOrDefault(p => p.Id == LendId);
         if (lr != null)
         {
             sc.Entry(lr).State = System.Data.Entity.EntityState.Deleted;
         }
         else
         {
             return(false);
         }
         sc.SaveChanges();
     }
     return(true);
 }
Esempio n. 4
0
 /// <summary>
 /// 取消借用审批中的样衣借用
 /// </summary>
 /// <param name="StyleId"></param>
 /// <param name="user">借用者</param>
 /// <returns></returns>
 public static bool CancelLend(string StyleId, User _user)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         var lr = sc.LendRecords.SingleOrDefault(p => p.StyleId == StyleId && p.DdId == _user.DdId && p.State == LendRecordStats.借出审批);
         if (lr != null)
         {
             sc.Entry(lr).State = System.Data.Entity.EntityState.Deleted;
             sc.SampleBaseInfos.SingleOrDefault(p => p.StyleId == StyleId).State = SampleState.在库;
             sc.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 5
0
 public static bool SetUserRole(string Ddid, UserRoleU ur)
 {
     using (SunginDataContext sc = new SunginDataContext())
     {
         var u = GetUser(Ddid);
         if (u != null)
         {
             u.Role = ur;
             u.SetEditUser("system");
             sc.Entry(u).State = System.Data.Entity.EntityState.Modified;
             sc.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Esempio n. 6
0
        public bool SaveSample(SampleFullInfoModel sample)
        {
            using (SunginDataContext sc = new SunginDataContext())
            {
                //基本信息
                //BaseInfo.StyleId = (string)sample.styleId;
                BaseInfo.StyleNo    = sample.StyleNo;
                BaseInfo.DeptName   = sample.DeptName;
                BaseInfo.Color      = sample.Color;
                BaseInfo.Size       = sample.Size;
                BaseInfo.Gauge      = sample.Gauge;
                BaseInfo.Weight     = sample.Weight;
                BaseInfo.CanLendOut = sample.CanLendOut;
                BaseInfo.Kinds      = sample.Kinds;
                BaseInfo.Counts     = sample.Counts;
                BaseInfo.Material   = JsonHelper.ToJson(sample.MaterialItems);
                BaseInfo.StyleTag   = JsonHelper.ToJson(sample.StyleTagItems);
                if (IsNewSample)
                {
                    BaseInfo.DdId = currentUser.DdId;
                }
                BaseInfo.HaveStock     = sample.HaveStock;
                BaseInfo.CostPrice     = sample.CostPrice;
                BaseInfo.FactoryPrice  = sample.FactoryPrice;
                BaseInfo.SalePrice     = sample.SalePrice;
                BaseInfo.DiscountPrice = sample.DiscountPrice;
                //大货信息
                ProductInfo.StyleId        = BaseInfo.StyleId;
                ProductInfo.ClientName     = sample.ClientName;
                ProductInfo.ProductFactory = sample.ProductFactory;
                ProductInfo.ProductNum     = sample.ProductNum;
                ProductInfo.Price          = sample.Price;
                if (sample.ProductDate != "")
                {
                    ProductInfo.ProductDate = DateTime.Parse(sample.ProductDate);
                }


                //打样信息
                ProofingInfo.StyleId          = BaseInfo.StyleId;
                ProofingInfo.ProofingCompany  = (string)sample.ProofingCompany;
                ProofingInfo.TechnologyPeople = (string)sample.TechnologyPeople;
                ProofingInfo.ProgamPeople     = (string)sample.ProgamPeople;
                ProofingInfo.WeaveTime        = sample.WeaveTime;
                ProofingInfo.LinkTime         = sample.LinkTime;
                if (sample.ProofingDate != "")
                {
                    ProofingInfo.ProofingDate = DateTime.Parse(sample.ProofingDate);
                }

                //开始保存
                //库存信息

                if (BaseInfo.HaveStock && sample.StockDataItems.Count > 0)
                {
                    //如已有数据,则更新,如无则删除
                    StockList.ForEach(p =>
                    {
                        var re = sample.StockDataItems.SingleOrDefault(w => w.Size == p.Size && w.Color == p.Color);
                        if (re != null)
                        {
                            p.Num = re.Num;
                        }
                        else
                        {
                            p.IsDelete = true;
                        }
                        sc.Entry(p).State = System.Data.Entity.EntityState.Modified;
                        sample.StockDataItems.Remove(re);
                    });

                    //新增数据
                    sample.StockDataItems.ForEach(p =>
                    {
                        sc.GarmentStocks.Add(new GarmentStock
                        {
                            Color   = p.Color,
                            Size    = p.Size,
                            Num     = p.Num,
                            StyleId = BaseInfo.StyleId,
                            StockId = KeyMange.GetKey("Stock")
                        });
                    });
                }

                if (IsNewSample)
                {
                    Files.ForEach(p =>
                    {
                        if (p.IsDelete)
                        {
                            File.Delete(p.FileUrl);
                        }
                    });
                    Files.RemoveAll(p => p.IsDelete);
                    BaseInfo.SetCreateUser(currentUser.UserName);
                    sc.SampleBaseInfos.Add(BaseInfo);
                    //写入打样信息
                    ProofingInfo.SetCreateUser(currentUser.UserName);
                    sc.Proofings.Add(ProofingInfo);
                    //写入文件信息
                    sc.StyleFiles.AddRange(Files);
                    //写入大货信息
                    ProductInfo.SetCreateUser(currentUser.UserName);
                    sc.ProductionRecords.Add(ProductInfo);
                }
                else
                {
                    Files.ForEach(p =>
                    {
                        if (p.Id == 0)
                        {
                            sc.StyleFiles.Add(p);
                        }
                        else if (p.IsDelete == true)
                        {
                            sc.Entry(p).State = System.Data.Entity.EntityState.Modified;
                        }
                    });

                    BaseInfo.SetEditUser(currentUser.UserName);
                    ProofingInfo.SetEditUser(currentUser.UserName);
                    ProductInfo.SetEditUser(currentUser.UserName);
                    sc.Entry(BaseInfo).State = System.Data.Entity.EntityState.Modified;
                    if (ProofingInfo.Id > 0)
                    {
                        sc.Entry(ProofingInfo).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        sc.Entry(ProofingInfo).State = System.Data.Entity.EntityState.Added;
                    }
                    if (ProductInfo.Id > 0)
                    {
                        sc.Entry(ProductInfo).State = System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        sc.Entry(ProductInfo).State = System.Data.Entity.EntityState.Added;
                    }
                };
                SetSeachStr();
                sc.SaveChanges();
            }
            return(true);
        }