Exemple #1
0
        public static IList <ResTemplateItem> GetAll()
        {
            List <ResTemplateItem> list = new List <ResTemplateItem>();

            using (pm2Entities entities = new pm2Entities())
            {
                var list2 = (from m in entities.Res_TemplateItem select new { ItemId = m.ItemId, ExcelColumn = m.ExcelColumn, ExcelRealCoumn = m.ExcelRealCoumn, DbColumn = m.DbColumn, TemplateId = m.Res_Template.TemplateId }).ToList();
                if (list2.Count == 0)
                {
                    return(list);
                }
                foreach (var type in list2)
                {
                    ResTemplateItem item = new ResTemplateItem {
                        ItemId         = type.ItemId,
                        ExcelColumn    = type.ExcelColumn,
                        ExcelRealCoumn = type.ExcelRealCoumn,
                        DbColumn       = type.DbColumn,
                        Template       = ResTemplate.GetById(type.TemplateId)
                    };
                    list.Add(item);
                }
            }
            return(list);
        }
Exemple #2
0
 public static void Add(ResTemplateItem restemplateitem)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Res_TemplateItem entity   = bindEntity(restemplateitem);
         Res_Template     template = (from m in entities.Res_Template
                                      where m.TemplateId == restemplateitem.Template.Id
                                      select m).FirstOrDefault <Res_Template>();
         entity.Res_Template = template;
         template.Res_TemplateItem.Add(entity);
         entities.SaveChanges();
     }
 }
Exemple #3
0
        public static ResTemplateItem GetById(string id)
        {
            ResTemplateItem item = new ResTemplateItem();

            using (pm2Entities entities = new pm2Entities())
            {
                var type = (from m in entities.Res_TemplateItem
                            where m.ItemId == id
                            select new { ItemId = m.ItemId, ExcelColumn = m.ExcelColumn, ExcelRealCoumn = m.ExcelRealCoumn, DbColumn = m.DbColumn, TemplateId = m.Res_Template.TemplateId }).FirstOrDefault();
                if (type != null)
                {
                    item.ItemId         = type.ItemId;
                    item.ExcelColumn    = type.ExcelColumn;
                    item.ExcelRealCoumn = type.ExcelRealCoumn;
                    item.DbColumn       = type.DbColumn;
                    item.Template       = ResTemplate.GetById(type.TemplateId);
                    return(item);
                }
                return(null);
            }
        }
Exemple #4
0
 private static Res_TemplateItem bindEntity(ResTemplateItem restemplateitem)
 {
     return(new Res_TemplateItem {
         ItemId = restemplateitem.ItemId, ExcelColumn = restemplateitem.ExcelColumn, ExcelRealCoumn = restemplateitem.ExcelRealCoumn, DbColumn = restemplateitem.DbColumn
     });
 }