/// <summary> /// Создает нового пользователя /// </summary> private void New_User_Button_Sign_Up_Click(object sender, EventArgs e) { using (db = new UsersDBEntities()) { user = new User() { Login_Name = NewUserTextBoxLoginName.Text, Password = NewUserTextBoxPassword.Text, Last_Name = NewUserTextBoxLastName.Text, First_Name = NewUserTextBoxFirstName.Text, Phone = NewUserTextBoxPhone.Text, Email = NewUserTextBoxEmail.Text }; db.Users.Add(user); db.SaveChanges(); } ClearTextBoxs.Clear(newUserTextBoxsArr); Get_All_Data(); }
/// <summary> /// Обнавляет данные Пользователя по User_Id /// </summary> private void Update_User_Data_Button_Click(object sender, EventArgs e) { using (db = new UsersDBEntities()) { int userID = Convert.ToInt32(UpdateUserDataTextBoxID.Text); user = db.Users .Where(us => us.User_Id == userID) .FirstOrDefault(); user.Login_Name = UpdateUserDataTextBoxLoginName.Text; user.Password = UpdateUserDataTextBoxPassword.Text; user.Last_Name = UpdateUserDataTextBoxLastName.Text; user.First_Name = UpdateUserDataTextBoxFirstName.Text; user.Phone = UpdateUserDataTextBoxPhone.Text; user.Email = UpdateUserDataTextBoxEmail.Text; db.SaveChanges(); } ClearTextBoxs.Clear(updateUserDataTextBoxArr); Get_All_Data(); }