示例#1
0
 public static void Update(BudTemplateType budTempType)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_TemplateType type = (from m in entities.Bud_TemplateType
                                  where m.TypeId == budTempType.Id
                                  select m).FirstOrDefault <Bud_TemplateType>();
         type.TypeCode = budTempType.Code;
         type.TypeName = budTempType.Name;
         entities.SaveChanges();
     }
 }
示例#2
0
        private static void Delete(string id, pm2Entities context)
        {
            Bud_TemplateType entity = (from m in context.Bud_TemplateType
                                       where m.TypeId == id
                                       select m).FirstOrDefault <Bud_TemplateType>();

            if (entity == null)
            {
                throw new Exception("找不到需要删除的模板类型");
            }
            if (context.Bud_Template.Count <Bud_Template>(c => (c.Bud_TemplateType.TypeId == id)) > 0)
            {
                throw new Exception("当前模板类型不是最底层的模板类型");
            }
            context.DeleteObject(entity);
        }
示例#3
0
 public static void Add(BudTemplateType budTempType)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         Bud_TemplateType type = new Bud_TemplateType {
             TypeId    = budTempType.Id,
             TypeCode  = budTempType.Code,
             TypeName  = budTempType.Name,
             InputUser = budTempType.InputUser
         };
         if (budTempType.InputDate.HasValue)
         {
             type.InputDate = Convert.ToDateTime(budTempType.InputDate);
         }
         entities.AddToBud_TemplateType(type);
         entities.SaveChanges();
     }
 }
示例#4
0
        public static List <Bud_TemplateType> GetBud_TemplateType(List <string> idList, pm2Entities contxt)
        {
            List <Bud_TemplateType> list = new List <Bud_TemplateType>();

            using (List <string> .Enumerator enumerator = idList.GetEnumerator())
            {
                string id;
                while (enumerator.MoveNext())
                {
                    id = enumerator.Current;
                    Bud_TemplateType item = contxt.Bud_TemplateType.FirstOrDefault <Bud_TemplateType>(c => c.TypeId == id);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }