partial void Deleteuser(user instance);
partial void Insertuser(user instance);
partial void Updateuser(user instance);
public void Register(string _username, string _password, byte[] _avarta) { //ChatDBDataContext DB = new ChatDBDataContext(); var Users = from U in DB.users where U.username == _username select U; foreach (user user in Users) { throw new Exception("Tên đăng nhập đã tồn tại. Mời bạn nhập lại!"); } user newUser = new user {username = _username, password = _password, avarta = _avarta}; DB.users.InsertOnSubmit(newUser); DB.SubmitChanges(); }
public int Register(string Username, string Password) { //ChatDBDataContext DB = new ChatDBDataContext(); var Users = from U in DB.users where U.username == Username && U.password == Password select U; foreach (user user in Users) { return 0; } user NewUser = new user(); NewUser.username = Username; NewUser.password = Password; DB.users.InsertOnSubmit(NewUser); DB.SubmitChanges(); return 1; }