Beispiel #1
0
        /// Обновляет данные Пользователя по User_Id
        private void Update_User_Data_Button_Click(object sender, EventArgs e)
        {
            using (connect = new SqlConnection(connectionString))
            {
                connect.Open();

                command = new SqlCommand($"UPDATE [Users] SET [Login_Name] = @LoginName , " +
                                         "[Password] = @Password , " +
                                         "[First_Name] = @FirstName , " +
                                         "[Last_Name] = @LastName , " +
                                         "[Email] = @Email , " +
                                         "[Phone] = @Phone " +
                                         "WHERE [User_Id] = @User_ID", connect);

                command.Parameters.Add(new SqlParameter("@LoginName", UpdateUserDataTextBoxLoginName.Text));
                command.Parameters.Add(new SqlParameter("@Password", UpdateUserDataTextBoxPassword.Text));
                command.Parameters.Add(new SqlParameter("@FirstName", UpdateUserDataTextBoxFirstName.Text));
                command.Parameters.Add(new SqlParameter("@LastName", UpdateUserDataTextBoxLastName.Text));
                command.Parameters.Add(new SqlParameter("@Email", UpdateUserDataTextBoxEmail.Text));
                command.Parameters.Add(new SqlParameter("@Phone", UpdateUserDataTextBoxPhone.Text));
                command.Parameters.Add(new SqlParameter("@User_ID", UpdateUserDataTextBoxID.Text));

                command.ExecuteNonQuery();
            }

            ClearTextBoxs.Clear(updateUserDataTextBoxArr);
            Get_All_Users_Data();
        }
Beispiel #2
0
        /// Создает нового пользователя
        private void New_User_Button_Sign_Up_Click(object sender, EventArgs e)
        {
            using (connect = new SqlConnection(connectionString))
            {
                connect.Open();

                command = new SqlCommand("INSERT INTO [Users] Values (@LoginName , @Password ," +
                                         " @FirstName , @LastName ," +
                                         " @Email , @Phone)", connect);

                command.Parameters.Add(new SqlParameter("@LoginName", NewUserTextBoxLoginName.Text));
                command.Parameters.Add(new SqlParameter("@Password", NewUserTextBoxPassword.Text));
                command.Parameters.Add(new SqlParameter("@FirstName", NewUserTextBoxFirstName.Text));
                command.Parameters.Add(new SqlParameter("@LastName", NewUserTextBoxLastName.Text));
                command.Parameters.Add(new SqlParameter("@Email", NewUserTextBoxEmail.Text));
                command.Parameters.Add(new SqlParameter("@Phone", NewUserTextBoxPhone.Text));

                command.ExecuteNonQuery();
            }

            ClearTextBoxs.Clear(newUserTextBoxsArr);
            Get_All_Users_Data();
        }