/// <summary>
 /// Create a new user
 /// </summary>
 /// <param name="firstname">The users firstname</param>
 /// <param name="lastname">The users lastname</param>
 /// <param name="phone">The users phone</param>
 /// <param name="mail">The users mail</param>
 /// <param name="cpr">The users CPR number.</param>
 /// <param name="address">The users address</param>
 /// <param name="zip">The users zip code</param>
 /// <param name="city">The users city</param>
 /// <param name="username">The users username</param>
 /// <param name="password">The users password</param>
 /// <param name="picture">The url to the users picture</param>
 /// <param name="signature">The url to the users signature</param>
 /// <param name="sysmin">wether the user is a sysmin or not</param>
 /// <param name="classname">An optional class the user is enrolled in</param>
 /// <param name="usertable">Optional* the table to change the user in</param>
 /// <returns>boolean, wether the db executed the command or not</returns>
 public static bool AddUser(string firstname, string lastname, string phone, string mail, string cpr,
                            string address,
                            string zip, string city, string username, string password, string picture = null, string signature = "",
                            string sysmin = "false", string classname = "", string usertable = UserTable)
 {
     return(MySql.AddUser(firstname, lastname, phone, mail, cpr, address, zip, city, username, password, picture,
                          signature, sysmin, classname, usertable));
 }
Ejemplo n.º 2
0
        private void AddUserBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (FirstName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (LastName.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (Password.Text.Length <= 0)
                {
                    throw new Exception();
                }

                if (AdminPrivilege.SelectedIndex == -1)
                {
                    throw new Exception();
                }

                if (EmailText.Text.Length <= 0)
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please Complete all the information");
                return;
            }

            bool admin = AdminPrivilege.SelectedItem.ToString().Equals("Yes");

            MySql sql = new MySql();

            sql.OpenConnection();

            if (sql.AddUser(FirstName.Text, LastName.Text, Password.Text, admin, EmailText.Text))
            {
                MessageBox.Show("User Successfully Added");
                sql.CloseConnection();
                DialogResult = DialogResult.OK;
                Close();
            }
        }
 public void CreateUser_Succesfull(string firstname, string lastname, string phone, string mail, string cpr, string address,
                                   string zip, string city, string username, string password, string picture = null)
 {
     Assert.IsTrue(MySql.AddUser(firstname, lastname, phone, mail, cpr, address, zip, city, username, password, picture, usertable: "usertest"));
 }