private void BtnLogin_Click(object sender, EventArgs e)
        {
            main.SetStatus("Loging...");
            String Username = txtUsername.Text;
            String Password = TxtPassword.Text;

            if (Username == "" || Password == "")
            {
                MessageBox.Show("Username and password not empty!");
            }
            else
            {
                Password = PasswordUtils.Get(Password);

                try
                {
                    IEnumerable <USER_MANAGEMENT> userList = this.view.GetUserInfo(Username);
                    USER_MANAGEMENT user   = userList.First();
                    Boolean         isLock = Oracleview.IsLock(Username);
                    if (user.PASSWORD.Equals(Password) && !isLock)
                    {
                        this.currentUser.UserName = user.USERNAME;
                        if (user.ADMIN_OPTION != null && user.ADMIN_OPTION.Equals("Y"))
                        {
                            this.currentUser.IsAdmin = true;
                        }
                        else
                        {
                            this.currentUser.IsAdmin = false;
                        }
                        main.SetStatus(String.Join(" ", "Hello,", currentUser.UserName));
                        main.StatusAll(true);
                        Hide();
                    }
                    else
                    {
                        if (isLock)
                        {
                            MessageBox.Show("Account locked!");
                        }
                        else
                        {
                            MessageBox.Show("Incorect username or password!");
                        }
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Fail to login!");
                }
            }
        }
Example #2
0
        /// <summary>
        /// You must have the CREATE USER system privilege.
        /// When you create a user with the CREATE USER statement, the user's privilege domain is empty.
        /// To log on to Oracle Database, a user must have the CREATE SESSION system privilege.
        /// Therefore, after creating a user, you should grant the user at least the CREATE SESSION system privilege.
        /// Please refer to GRANT for more information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            Privilege privilege = new Privilege
            {
                Name = CREATE_USER
            };
            Boolean hasPermision = this.privilegeBLL.HasSystemPrivilege(this.currentUser.UserName, privilege);

            if (hasPermision)
            {
                String Username  = txtUsername.Text;
                String Password  = txtPassword.Text;
                String Password2 = txtPassword2.Text;
                String IsAdmin;
                if (CbxIsAdmin.Checked)
                {
                    IsAdmin = "y";
                }
                else
                {
                    IsAdmin = "";
                }
                if (Username == "" || Password == "" || Password2 == "")
                {
                    MessageBox.Show("Username and password not empty!");
                }
                else
                {
                    Boolean flag = false;
                    foreach (USER_MANAGEMENT ExistUser in this.view.GetAll())
                    {
                        if (ExistUser.USERNAME == Username)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag == true)
                    {
                        MessageBox.Show("Username  is realy exist!");
                    }
                    else
                    {
                        String          HashPassword = PasswordUtils.Get(Password);
                        DateTime        now          = DateTime.Now;
                        USER_MANAGEMENT user         = new USER_MANAGEMENT
                        {
                            USERNAME     = Username,
                            PASSWORD     = HashPassword,
                            CREATE_TIME  = now,
                            ADMIN_OPTION = IsAdmin
                        };

                        this.view.Add(user);
                        this.OracleView.AddOracleUser(Username, Password);
                        UpdateQoutaDromform();
                        AddProfileFromForm();
                        AddRoleFromForm();
                        AddTableSpaceFromForm();
                        CheckLockAccountFromForm();
                        ClearText();
                        MessageBox.Show("User created!");
                        Hide();
                    }
                }
            }
            else
            {
                MessageBox.Show(String.Join(" ", "You don't have", CREATE_USER, "privilege!"));
            }
        }