Beispiel #1
0
        public static IList <BudTemplate> GetAll(string templateTypeId)
        {
            var predicate            = null;
            IList <BudTemplate> list = new List <BudTemplate>();

            using (pm2Entities entities = new pm2Entities())
            {
                var source = (from bt in entities.Bud_Template
                              orderby bt.InputDate descending
                              select new { TemplateId = bt.TemplateId, TemplateCode = bt.TemplateCode, TemplateName = bt.TemplateName, InputUser = bt.InputUser, InputDate = bt.InputDate, TypeId = bt.Bud_TemplateType.TypeId }).ToList();
                if (!string.IsNullOrEmpty(templateTypeId))
                {
                    if (predicate == null)
                    {
                        predicate = m => m.TypeId == templateTypeId;
                    }
                    source = source.Where(predicate).ToList();
                }
                foreach (var typea in source)
                {
                    BudTemplate item = new BudTemplate {
                        Id          = typea.TemplateId,
                        Code        = typea.TemplateCode,
                        Name        = typea.TemplateName,
                        InputUser   = typea.InputUser,
                        InputDate   = new DateTime?(typea.InputDate),
                        BudTempType = BudTemplateType.GetById(typea.TypeId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #2
0
        public static IList <BudTemplate> Select(int pagesize, int pageIndex, string tempTypeId)
        {
            IList <BudTemplate> list = new List <BudTemplate>();

            using (pm2Entities entities = new pm2Entities())
            {
                var queryable = (from temp in entities.Bud_Template
                                 where temp.Bud_TemplateType.TypeId == tempTypeId
                                 orderby temp.InputDate descending
                                 select new { TemplateId = temp.TemplateId, TemplateName = temp.TemplateName, TypeId = temp.Bud_TemplateType.TypeId }).Skip((pageIndex * pagesize)).Take(pagesize);
                if ((tempTypeId == "") || (tempTypeId == "0"))
                {
                    queryable = (from temp in entities.Bud_Template
                                 orderby temp.InputDate descending
                                 select new { TemplateId = temp.TemplateId, TemplateName = temp.TemplateName, TypeId = temp.Bud_TemplateType.TypeId }).Skip((pageIndex * pagesize)).Take(pagesize);
                }
                foreach (var typeb in queryable)
                {
                    BudTemplate item = new BudTemplate {
                        Id          = typeb.TemplateId,
                        Name        = typeb.TemplateName,
                        BudTempType = BudTemplateType.GetById(typeb.TypeId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #3
0
        public static IList <BudTemplate> Select(string tempTypeId)
        {
            IList <BudTemplate> list = new List <BudTemplate>();

            using (pm2Entities entities = new pm2Entities())
            {
                foreach (var typeb in (from temp in entities.Bud_Template
                                       where temp.Bud_TemplateType.TypeId == tempTypeId
                                       orderby temp.InputDate descending
                                       select new { TemplateId = temp.TemplateId, TemplateName = temp.TemplateName, TypeId = temp.Bud_TemplateType.TypeId }).ToList())
                {
                    BudTemplate item = new BudTemplate {
                        Id          = typeb.TemplateId,
                        Name        = typeb.TemplateName,
                        BudTempType = BudTemplateType.GetById(typeb.TypeId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #4
0
        public static IList <BudTemplate> GetByName(string name)
        {
            IList <BudTemplate> list = new List <BudTemplate>();

            using (pm2Entities entities = new pm2Entities())
            {
                foreach (var typea in (from bt in entities.Bud_Template
                                       where bt.TemplateName == name
                                       select new { TemplateId = bt.TemplateId, TemplateCode = bt.TemplateCode, TemplateName = bt.TemplateName, InputUser = bt.InputUser, InputDate = bt.InputDate, TypeId = bt.Bud_TemplateType.TypeId }).ToList())
                {
                    BudTemplate item = new BudTemplate {
                        Id          = typea.TemplateId,
                        Code        = typea.TemplateCode,
                        Name        = typea.TemplateName,
                        InputUser   = typea.InputUser,
                        InputDate   = new DateTime?(typea.InputDate),
                        BudTempType = BudTemplateType.GetById(typea.TypeId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Beispiel #5
0
        public static BudTemplate GetById(string id)
        {
            BudTemplate template = new BudTemplate();

            using (pm2Entities entities = new pm2Entities())
            {
                var typea = (from bt in entities.Bud_Template
                             where bt.TemplateId == id
                             select new { TemplateId = bt.TemplateId, TemplateCode = bt.TemplateCode, TemplateName = bt.TemplateName, InputUser = bt.InputUser, InputDate = bt.InputDate, TypeId = bt.Bud_TemplateType.TypeId }).FirstOrDefault();
                if (typea != null)
                {
                    template.Id        = id;
                    template.Code      = typea.TemplateCode;
                    template.Name      = typea.TemplateName;
                    template.InputUser = typea.InputUser;
                    template.InputDate = new DateTime?(typea.InputDate);
                    BudTemplateType byId = BudTemplateType.GetById(typea.TypeId);
                    template.BudTempType = byId;
                    return(template);
                }
                return(null);
            }
        }