Пример #1
0
 public int Add(string Name, string ID, string Address, string Telephone, string Remark)
 {
     try
     {
         var i     = new InformationAnal();
         var Infor = i.Analysis(ID); //分析ID
         if (Infor.Check == true)    //校验通过
         {
             var DAL = new AddDAL();
             if (DAL.Access(Name, ID, Infor, Address, Telephone, Remark) == true)
             {
                 return(0);  //成功
             }
             else
             {
                 return(2);  //ID已存在
             }
         }
         else
         {
             return(1);  //校验不通过
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #2
0
 public bool Update(string name, string ID, string address, string phone, string remark)
 {
     try
     {
         var Anal        = new InformationAnal();
         var Information = Anal.Analysis(ID);
         if (Information.Check == false)  //校验不过
         {
             return(false);
         }
         else
         {
             var DAL = new UpdateDAL();
             DAL.Access(name, ID, Information, address, phone, remark);
             return(true);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Пример #3
0
 public List <Data> Refresh()
 {
     try
     {
         using (var db = new DataContext())
         {
             var result = db.Datas.Where(a => a.Age > 150); //删除大于150岁
             if (result != null)
             {
                 db.Datas.RemoveRange(result);
             }
             var i     = new InformationAnal();
             var IDSet = db.Datas.Select(a => a.ID);
             foreach (var ID in IDSet)
             {
                 var Infor    = i.Analysis(ID);                                        //身份证号分析
                 var IDResult = db.Datas.Where(a => a.ID.Equals(ID)).FirstOrDefault(); //更新年龄
                 if (Infor.Check == true)
                 {
                     if (IDResult != null)
                     {
                         IDResult.Age = Infor.Age;
                     }
                 }
                 else
                 {
                     db.Datas.Remove(IDResult);
                 }
             }
             db.SaveChanges();
             return(db.Datas.Select(a => a).ToList());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }