Exemplo n.º 1
0
        public IHttpActionResult GetProofNo()
        {
            string newProofOrderId = KeyMange.GetKey("ProofOrder");
            string newProofStyleId = KeyMange.GetKey("ProofStyle");

            return(Ok(new { newProofOrderId, newProofStyleId }));
        }
Exemplo n.º 2
0
        public object CreateSample()
        {
            var newsample = SessionManage.CurrentSample;

            if (newsample == null || !newsample.IsNewSample)
            {
                string id = KeyMange.GetKey("SampleInfo");
                newsample = new SampleInfo(SessionManage.CurrentUser);
                newsample.BaseInfo.StyleId  = id;
                newsample.BaseInfo.State    = SampleState.草拟;
                SessionManage.CurrentSample = newsample;
            }
            return(Ok(new { newsample.StyleId }));
        }
Exemplo n.º 3
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);
        }