コード例 #1
0
 public void AddNew(string user_ID, string name, string password, string account_type)
 {
     using (MyContext ctx = new MyContext())
     {
         account s = new account();
         s.user_ID      = user_ID;
         s.name         = name;
         s.password     = password;
         s.account_type = account_type;
         ctx.accounts.Add(s);
         ctx.SaveChanges();
     }
 }
コード例 #2
0
 //添加账号函数
 public bool AddNew1(string userID, string password, string name, string type)
 {
     using (MyContext ctx = new MyContext())
     {
         var s = ctx.accounts.AsNoTracking().SingleOrDefault(e => e.user_ID == userID);
         if (s != null || userID == null || name == null || password == null)
         {
             return(false);
         }
         account  account  = new account();
         Register register = new Register();
         register.ID          = userID;
         register.login_time  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
         account.user_ID      = userID;
         account.password     = password;
         account.name         = name;
         account.account_type = type;
         ctx.accounts.Add(account);
         ctx.SaveChanges();
         ctx.Registers.Add(register);
         ctx.SaveChanges();
         return(true);
     }
 }