示例#1
0
    /// <summary>
    /// Add new user id field will be ignored
    /// </summary>
    private static void AddNewUser(string name, string pass, int admin, string desc, string uOptions, string aOptions)
    {
        try
        {
            db_config_users dcu = new db_config_users();
            dcu.Open(); // open connection

            // user with name or pass empty
            if (name == string.Empty || pass == string.Empty) { Generic.JavaScriptInjector("NewUserError", "alert('name or pass are empty');"); return; }

            Users user = new Users
            {
                Name = name,
                Pass = pass,
                AdMIn = admin,
                Description = desc,
                UserOptions = uOptions,
                AdMInOptions = aOptions
            };

            dcu.AddUser(user);

            dcu.Close(); // close connection

            Generic.JavaScriptInjector("alert('New user added'); window.location.reload();");
        }
        catch (Exception ex)
        {
            Generic.JavaScriptInjector("alert('" + ex.Message + "');");
        }
    }