Beispiel #1
0
        public static dynamic GetReturnObj(ISampleBaseInfo baseinfo)
        {
            using (SunginDataContext sc = new SunginDataContext())
            {
                IProofing pr = sc.Proofings.SingleOrDefault(p => p.StyleId == baseinfo.StyleId);
                if (pr == null)
                {
                    pr = new Proofing();
                }
                IProductionRecord pd = sc.ProductionRecords.SingleOrDefault(p => p.StyleId == baseinfo.StyleId);
                if (pd == null)
                {
                    pd = new ProductionRecord();
                }
                var    Files     = sc.StyleFiles.Where(p => !p.IsDelete && p.StyleId == baseinfo.StyleId).Select(p => new { p.DisplayName, p.FileName, p.FileType }).ToList();
                var    FirstPic  = Files.FirstOrDefault(p => p.FileType == FileType.Pic);
                var    StockData = sc.GarmentStocks.Where(p => !p.IsDelete && p.StyleId == baseinfo.StyleId).Select(p => new { size = p.Size, color = p.Color, num = p.Num }).ToList();
                string Pic       = FirstPic != null ? FirstPic.FileName : "";

                return(new
                {
                    baseinfo.Id,
                    baseinfo.StyleId,
                    baseinfo.StyleNo,
                    baseinfo.Color,
                    baseinfo.Weight,
                    baseinfo.Gauge,
                    baseinfo.Size,
                    baseinfo.Kinds,
                    baseinfo.CanLendOut,
                    baseinfo.HaveStock,
                    User = baseinfo.CreateUser,
                    baseinfo.State,
                    baseinfo.CostPrice,
                    baseinfo.FactoryPrice,
                    baseinfo.SalePrice,
                    baseinfo.DiscountPrice,
                    baseinfo.Counts,
                    StateText = baseinfo.State.ToString(),
                    StyleTag = JsonHelper.ToObj(baseinfo.StyleTag),
                    Material = JsonHelper.ToObj(baseinfo.Material),
                    CreateDate = baseinfo.CreateDate != null?baseinfo.CreateDate.Value.Date.ToShortDateString() : "",
                                     pr.ProofingCompany,
                                     pr.ProgamPeople,
                                     pr.TechnologyPeople,
                                     baseinfo.DeptName,
                                     pr.WeaveTime,
                                     pr.LinkTime,
                                     ProofingDate = pr.ProofingDate != null?pr.ProofingDate.Value.Date.ToShortDateString() : "",
                                                        pd.ClientName,
                                                        pd.ProductFactory,
                                                        pd.ProductNum,
                                                        pd.Price,
                                                        ProductDate = pd.ProductDate != null?pd.ProductDate.Value.ToShortDateString() : "",
                                                                          StockData,
                                                                          Pic,
                                                                          Files
                });
            }
        }
Beispiel #2
0
 public bool LoadSampleById(string styleId)
 {
     try
     {
         using (SunginDataContext sc = new SunginDataContext())
         {
             BaseInfo     = sc.SampleBaseInfos.SingleOrDefault(p => p.StyleId == styleId);
             ProofingInfo = sc.Proofings.SingleOrDefault(p => p.StyleId == styleId);
             if (ProofingInfo == null)
             {
                 ProofingInfo = new Proofing();
             }
             ProductInfo = sc.ProductionRecords.SingleOrDefault(p => p.StyleId == styleId);
             if (ProductInfo == null)
             {
                 ProductInfo = new ProductionRecord();
             }
             StockList   = sc.GarmentStocks.Where(p => p.StyleId == styleId).ToList();
             Files       = sc.StyleFiles.Where(p => p.StyleId == BaseInfo.StyleId).ToList();
             IsNewSample = false;
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }