/// <summary>
 /// describes button that creates new user
 /// </summary>
 /// <param name="sender">sender of event</param>
 /// <param name="e">event data</param>
 private void NewUser_Click(object sender, EventArgs e)
 {
     if ((login.Text.Length < 5) || UserControls.WrongSymbols(login.Text) || (password.Text.Length < 5) || UserControls.WrongSymbols(password.Text))
     {
         MessageBox.Show("Wrong login or password. Not enought or wrong symbols");
     }
     else
     {
         UserControls.AddNewUser(login.Text, password.Text);
         MessageBox.Show("User Created");
     }
 }
Example #2
0
        /// <summary>
        /// Adding of new user
        /// </summary>
        private static void AddNewUser()
        {
            string login;
            string password;

            Console.WriteLine("Write login for new user:"******"Password: "******"Enter 0 to stop adding 1 to add new role to user any other symbol to show available roles");
                int c = Console.Read();
                switch (c)
                {
                case 0:
                {
                    adding = false;
                    break;
                }

                case 1:
                {
                    Console.WriteLine("Enter roles id:");
                    int roleid = Convert.ToInt32(Console.ReadLine());
                    if (UserControls.AddUsersRole(user.Id, roleid))
                    {
                        Console.WriteLine("Role added successfully");
                    }
                    else
                    {
                        Console.WriteLine("Something went wrong maybe id is incorrect");
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }