예제 #1
0
    public static bool SaveUser(string username, string fullnames, string password, string secque, string answer, string email, string telephone)
    {
        try
        {
            SkypensionCryptoEngine _SkypensionCryptoEngine = new SkypensionCryptoEngine();
            var _User = new User();
            _User.UserName = username;

            _User.FullNames = fullnames;
            _User.Password  = SkypensionCryptoEngine.Encrypt(password, true);

            _User.Question = secque;
            _User.Answer   = answer;

            _User.Email     = email;
            _User.Telephone = telephone;

            if (_User.SaveUser())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (Exception ex)
        {
            var _Security = new Security();
            _Security.ErrorDesscription = ex.Message;
            _Security.ErrorModule       = "Intializing saving user";
            _Security.SaveError();
            return(false);
        }
    }
예제 #2
0
 private void saveToolStripButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.ValidateRight("Add", AppConstant.UserID))
         {
             var password        = PasswordTextEdit.Text.ToString();
             var ConfirmPassword = ConfirmPasswordTextEdit.Text.ToString();
             if (password == ConfirmPassword)
             {
                 this.spSelectUsersTableAdapter.spSaveUsers(
                     AppConstant.CompCode,
                     UserNameTextEdit.Text.ToString(),
                     FullNamesTextEdit.Text.ToString(),
                     SkypensionCryptoEngine.Encrypt(password, true),
                     SkypensionCryptoEngine.Encrypt(ConfirmPassword, true),
                     EmailTextEdit.Text.ToString(),
                     TelephoneTextEdit.Text.ToString(),
                     ExpiryDateDateEdit.DateTime,
                     IsActiveCheckEdit.Checked,
                     SuperUserCheckEdit.Checked,
                     CCCodeTextEdit.EditValue.ToString(),
                     NarrationTextEdit.Text.ToString(),
                     Environment.MachineName,
                     AppConstant.UserID
                     );
                 MessageBox.Show("User saved successfully");
                 this.spSelectAllUsersTableAdapter.Fill(this.dsUsers.spSelectAllUsers, AppConstant.CompCode, AppConstant.UserID, Environment.MachineName);
             }
             else
             {
                 MessageBox.Show("Sorry, your passwords don't match");
             }
         }
         else
         {
             MessageBox.Show("Privilege Violation.You have insufficient right to add Users", "Privilege Violation", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }