예제 #1
0
        /// <summary>
        /// method wich works when the user press on "log in" button
        /// the method will check the user name and password and open the right control panel (user / admin)
        /// </summary>
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == string.Empty || txtPassword.Text == string.Empty)
            {
                MessageBox.Show("שם משתמש וסיסמא ריקים נסה שנית !! ", " הודעת מערכת ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword.Text = string.Empty;
            }
            else
            {
                string pass = Eramake.eCryptography.Encrypt(txtPassword.Text);
                User   user = db.CheckLogin(txtUserName.Text, pass);

                if (user != null)
                {
                    checkMonthAndYearForStock();
                    if (user.Permission == "מנהל")
                    {
                        AdminHomePage adminHomePage = new AdminHomePage(this);
                        adminHomePage.Show();
                    }
                    else
                    {
                        UserHomePage userHomePage = new UserHomePage(this);
                        userHomePage.Show();
                    }
                    this.Hide();
                    txtUserName.Text = string.Empty;
                    txtPassword.Text = string.Empty;
                }
                else
                {
                    MessageBox.Show("שם משתמש או סיסמא שגויים נסה שנית ", "הודעת מערכת", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtPassword.Text = string.Empty;
                }
            }
        }