public ClarityAdmin LoginToApplication(String UN, String PASS)
 {
     UserNameTB.SendKeys(UN);
     passwordTB.SendKeys(PASS);
     click.Submit();
     return(new ClarityAdmin(driver));
 }
示例#2
0
 private void UserNameTB_Leave(object sender, EventArgs e)
 {
     if (UserNameTB.Text == "")
     {
         UserNameTB.Text = "username";
     }
     UserNameTB.DeselectAll();
 }
示例#3
0
        public LoginWindow(MainWindow mainWRef, Logic logicRef)
        {
            InitializeComponent();
            this.mainWRef = mainWRef;
            this.logicRef = logicRef;

            UserNameTB.Focus();
            UserNameTB.SelectAll();
        }
        private void UserLogin(object sender, EventArgs e)
        {
            var hashedPass = GenerateHash(PasswordTB.Text);


            //MessageBox.Show(LibraryDBCon.ServerVersion);
            // Open DataBase
            if (LibraryDBCon.State == ConnectionState.Closed)
            {
                LibraryDBCon.Open();
            }

            // Create Connection With DataBase
            sqlcom.Connection  = LibraryDBCon;
            sqlcom.CommandType = CommandType.Text;
            sqlcom.CommandText = $"SELECT FullName FROM Librarians WHERE UserName = '******' AND PassHash = '{hashedPass}'";

            SqlDataReader DR = sqlcom.ExecuteReader();


            if (DR.Read())
            {
                // Set The Id To Static To Be Avilabile To The Other Forms
                UserName = DR[0].ToString();

                DashBoard Admin = new DashBoard();
                this.Hide();
                // Reset User Name And Password Field
                UserNameTB.ResetText();
                PasswordTB.ResetText();

                if (Admin.ShowDialog() == DialogResult.OK)
                {
                    this.Show();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "Worng Name or Password.", "Error Message", 100);
            }

            // Close Data Reader
            DR.Close();

            // Close DataBase Connection
            if (LibraryDBCon.State == ConnectionState.Open)
            {
                LibraryDBCon.Close();
            }
        }
示例#5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.Url.Query == "?Reason=UserNotAuthenticated")
     {
         ErrorLBL.InnerText = "יש להתחבר לפני כניסה למערכת";
     }
     else if (Request.Url.Query == "?Reason=UserNotAllowed")
     {
         ErrorLBL.InnerText = "אינך מורשה להיכנס למערכת";
     }
     UserNameTB.Focus();
 }
示例#6
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                AccountTypecomboBox.Visible = true;
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                AccountTypecomboBox.Visible = false;
            }

            String Value = comboBox1.Text;

            label5.Text = Value += " Login Panel"; UserNameTB.Focus();
        }
示例#7
0
        private void UserNameTB_Enter(object sender, EventArgs e)
        {
            if (UserNameTB.Text == "username")
            {
                UserNameTB.Clear();
            }
            UserNameTB.SelectAll();
            UserNameTB.Focus();
            userPic.BackgroundImage = Properties.Resources.userLogin2;
            UserNameLn.BackColor    = Color.White;
            UserNameTB.ForeColor    = Color.White;

            passPic.BackgroundImage = Properties.Resources.userPassword;
            PasswordLn.BackColor    = Color.Black;
            PasswordTB.ForeColor    = Color.Black;

            //wrongTB.Visible = false;
        }
示例#8
0
 private void LoginBtn_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 5; i++)
     {
         if (dllfile.userN[i] == UserNameTB.Text)
         {
             if (dllfile.password[i] == dllfile.Decrypt(PasswordTB.Text))
             {
                 MessageBox.Show("Login Successfull");
                 Purchase pur = new Purchase();
                 pur.Show();
                 UserNameTB.Clear();
                 PasswordTB.Clear();
                 break;
             }
             else
             {
                 MessageBox.Show("Login Failed");
                 break;
             }
         }
     }
 }
示例#9
0
 public LoginPage(string username = null)
 {
     /*
      * Thread.CurrentThread.CurrentCulture = new CultureInfo("hu-HU");
      * Thread.CurrentThread.CurrentUICulture = new CultureInfo("hu-HU");
      * LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
      *          XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
      */
     InitializeComponent();
     if (username != null)
     {
         UserNameTB.Text = username;
         PasswordTB.Focus();
         Keyboard.Focus(PasswordTB);
     }
     else
     {
         UserNameTB.Focus();
         Keyboard.Focus(UserNameTB);
     }
     viewModel = FindResource("viewModel") as ViewModels.LoginViewModel;
     viewModel.SetLoginPage(this);
     //DataContext = new LoginViewModel(this);
 }
示例#10
0
 public void clearUserName()
 {
     UserNameTB.Text = "";
     UserNameTB.Focus();
     Keyboard.Focus(UserNameTB);
 }
示例#11
0
        private void Updatebutton_Click(object sender, EventArgs e)
        {
            if (CompanyNameTB.Text == "")
            {
                CompanyNameTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Company Name Is Required", "Please Enter Company Name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CompanyNameTB.Focus();
                return;
            }

            if (SaloganTB.Text == "")
            {
                SaloganTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Salogan Is Required", "Please Enter Salogan", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                SaloganTB.Focus();
                return;
            }

            if (AddressTB.Text == "")
            {
                AddressTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Address Is Required", "Please Enter Address", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                AddressTB.Focus();
                return;
            }

            if (ContactTB.Text == "")
            {
                ContactTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Contact Number Is Required", "Please Enter Number", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ContactTB.Focus();
                return;
            }

            if (EmailTB.Text == "")
            {
                EmailTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Email Is Required", "Please Enter Email", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                EmailTB.Focus();
                return;
            }

            if (WebsiteTb.Text == "")
            {
                WebsiteTb.BackColor = Color.DodgerBlue;
                MessageBox.Show("Website Is Required", "Please Enter Website", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                WebsiteTb.Focus();
                return;
            }

            if (UserNameGetter.Text == "")
            {
                UserNameTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("UserName Is Required", "Please Enter UserName", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                UserNameTB.Focus();
                return;
            }



            UpdateMethod();
        }
示例#12
0
 private void LogIn_Load(object sender, EventArgs e)
 {
     cmd.Connection = conn;
     UserNameTB.Focus();
 }
示例#13
0
        /// <summary>
        /// Save User.
        /// </summary>
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(UserNameTB.Text))
                {
                    UserNameTB.Focus();
                    MessageBox.Show("用户名不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                var UserName = UserNameTB.Text.Trim();
                if (CurBehavior == EnmSaveBehavior.Add || (CurBehavior == EnmSaveBehavior.Edit && !CurUser.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)))
                {
                    if (MemberShipEntity.UserExists(UserName))
                    {
                        UserNameTB.Focus();
                        MessageBox.Show("用户名已存在", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (CurBehavior == EnmSaveBehavior.Add || (CurBehavior == EnmSaveBehavior.Edit && UserPasswordCB.Checked))
                {
                    if (String.IsNullOrWhiteSpace(UserPasswordTB.Text))
                    {
                        UserPasswordTB.Focus();
                        MessageBox.Show("密码不能为空", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (!UserPasswordTB.Text.Equals(UserCPasswordTB.Text))
                    {
                        UserPasswordTB.Focus();
                        MessageBox.Show("两次输入密码不一致", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }

                if (!String.IsNullOrWhiteSpace(UserMobileTB.Text) && !Regex.IsMatch(UserMobileTB.Text.Trim(), @"^1[358][0-9]{9}$", RegexOptions.IgnoreCase))
                {
                    UserMobileTB.Focus();
                    MessageBox.Show("请输入正确的手机号码", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!String.IsNullOrWhiteSpace(UserEmailTB.Text) && !Regex.IsMatch(UserEmailTB.Text.Trim(), @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$", RegexOptions.IgnoreCase))
                {
                    UserEmailTB.Focus();
                    MessageBox.Show("请输入正确的Email", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (!NeverCB.Checked && UserLimitDTP.Value <= DateTime.Now)
                {
                    UserLimitDTP.Focus();
                    MessageBox.Show("用户有效日期无效,请选择大于当前时间的有效日期。", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (CurBehavior == EnmSaveBehavior.Add)
                {
                    CurUser.Role.RoleID                = (Guid)UserRoleCB.SelectedValue;
                    CurUser.Role.RoleName              = UserRoleCB.Text;
                    CurUser.UserName                   = UserNameTB.Text.Trim();
                    CurUser.RemarkName                 = UserRemarkNameTB.Text.Trim();
                    CurUser.Password                   = MemberShipEntity.EncodePassword(UserPasswordTB.Text.Trim(), CurUser.PasswordFormat, CurUser.PasswordSalt);
                    CurUser.MobilePhone                = UserMobileTB.Text.Trim();
                    CurUser.Email                      = UserEmailTB.Text.Trim();
                    CurUser.CreateDate                 = DateTime.Now;
                    CurUser.LimitDate                  = NeverCB.Checked ? new DateTime(2099, 12, 31) : UserLimitDTP.Value;
                    CurUser.LastLoginDate              = ComUtility.DefaultDateTime;
                    CurUser.LastPasswordChangedDate    = ComUtility.DefaultDateTime;
                    CurUser.FailedPasswordAttemptCount = 0;
                    CurUser.IsLockedOut                = false;
                    CurUser.LastLockoutDate            = ComUtility.DefaultDateTime;
                    CurUser.Comment                    = UserCommentTB.Text.Trim();
                    CurUser.Enabled                    = UserStatusCB.Checked;

                    var result = Common.ShowWait(() => {
                        MemberShipEntity.CreateUser(CurUser);
                    }, default(String), "正在保存,请稍后...", default(Int32), default(Int32));

                    if (result == DialogResult.OK)
                    {
                        Common.CopyObjectValues(CurUser, OriUser);
                        Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", String.Format("新增用户:[{0}]", CurUser.UserName), null);
                        MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else if (CurBehavior == EnmSaveBehavior.Edit)
                {
                    var IsChangePwd = UserPasswordCB.Checked;
                    if (!IsChangePwd || MessageBox.Show("您确定要重置用户密码吗?", "确认对话框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
                    {
                        CurUser.Role.RoleID   = (Guid)UserRoleCB.SelectedValue;
                        CurUser.Role.RoleName = UserRoleCB.Text;
                        CurUser.UserName      = UserNameTB.Text.Trim();
                        CurUser.RemarkName    = UserRemarkNameTB.Text.Trim();
                        if (IsChangePwd)
                        {
                            CurUser.PasswordFormat          = EnmPasswordFormat.Hashed;
                            CurUser.PasswordSalt            = MemberShipEntity.GenerateSalt();
                            CurUser.Password                = MemberShipEntity.EncodePassword(UserPasswordTB.Text.Trim(), CurUser.PasswordFormat, CurUser.PasswordSalt);
                            CurUser.LastPasswordChangedDate = DateTime.Now;
                        }
                        CurUser.MobilePhone = UserMobileTB.Text.Trim();
                        CurUser.Email       = UserEmailTB.Text.Trim();
                        CurUser.LimitDate   = NeverCB.Checked ? new DateTime(2099, 12, 31) : UserLimitDTP.Value;
                        CurUser.Comment     = UserCommentTB.Text.Trim();
                        CurUser.Enabled     = UserStatusCB.Checked;

                        var result = Common.ShowWait(() => {
                            MemberShipEntity.SaveUser(CurUser);
                            if (IsChangePwd)
                            {
                                MemberShipEntity.ChangePassword(CurUser);
                            }
                        }, default(string), "正在保存,请稍后...", default(int), default(int));

                        if (result == DialogResult.OK)
                        {
                            Common.CopyObjectValues(CurUser, OriUser);
                            Common.WriteLog(DateTime.Now, EnmMsgType.Info, Common.CurUser.UserName, "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", String.Format("更新用户:[{0}]", CurUser.UserName), null);
                            MessageBox.Show("数据保存完成", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show("数据保存失败", "系统警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.SaveUserForm.SaveBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#14
0
//        Admin
//        Accountant
//        Receptionist
//        General Employee

        private void panel3_Click(object sender, EventArgs e)
        {
            if (UserNameTB.Text == "")
            {
                UserNameTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Username Is Required", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                UserNameTB.Focus();
                return;
            }
            if (PassTB.Text == "")
            {
                PassTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Password Is Required", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PassTB.Focus();
                return;
            }



            if (comboBox1.SelectedIndex == 0)
            {
                if (AccountTypecomboBox.SelectedIndex == 0)
                {
                    //if (UserNameTB.Text == "Admin" && PassTB.Text == "Admin123")
                    //{
                    if (UserNameTB.Text.ToUpper() == "ADMIN" && PassTB.Text == "Admin123")
                    {
                        this.Hide();
                        AdminPortal Ap = new AdminPortal();
                        Ap.Show();
                    }
                    else
                    {
                        LoginMethod("Sp_AdminLogin");

                        //MessageBox.Show("Wrong User Name or Password, Try again", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //UserNameTB.Focus();
                    }
                }


                else if (AccountTypecomboBox.SelectedIndex == 1)
                {
                    //Accountant

                    //if (UserNameTB.Text == "Account" && PassTB.Text == "Account123")
                    //{


                    LoginMethod("Sp_AccountantLogin");
                    //this.Hide();
                    //AccountantPortal Ap = new AccountantPortal();
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }
                else if (AccountTypecomboBox.SelectedIndex == 2)
                {
                    // Receptionist

                    //if (UserNameTB.Text == "Rec" && PassTB.Text == "Rec123")
                    //{
                    LoginMethod("Sp_ReceptionistLogin");
                    //this.Hide();
                    //ReceptionestPortal Ap = new ReceptionestPortal();
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }
                else if (AccountTypecomboBox.SelectedIndex == 3)
                {
                    //  General Employee

                    //if (UserNameTB.Text == "Emp" && PassTB.Text == "Emp123")
                    //{

                    LoginMethod("Sp_EmpLogin");
                    //this.Hide();
                    //GeneralEmployeePortal Ap = new GeneralEmployeePortal(UserNameTB.Text);
                    //Ap.Show();
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Invalid UserName Or PassWord");
                    //    UserNameTB.Focus();
                    //}
                }

                else
                {
                    MessageBox.Show("Please Select Account Type", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    AccountTypecomboBox.Focus();
                }
            }

            else if (comboBox1.SelectedIndex == 1)
            {
                try
                {
                    LoginMethod("Sp_AccountantLogin");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#15
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            String Value = AccountTypecomboBox.Text;

            label5.Text = Value += " Login Panel"; UserNameTB.Focus();
        }
示例#16
0
        private void LoginMethod(String Proc)
        {
            try
            {
                String        ConnString = ConfigurationManager.ConnectionStrings["PayrollConn"].ConnectionString;
                SqlConnection conn       = new SqlConnection(ConnString);
                SqlDataReader reader;

                using (conn)
                {
                    SqlCommand cmd1 = new SqlCommand(Proc, conn);
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.AddWithValue("@UserId", UserNameTB.Text);
                    cmd1.Parameters.AddWithValue("@Pass", PassTB.Text);
                    conn.Open();
                    reader = cmd1.ExecuteReader();
                    reader.Read();
                    if (reader.HasRows)
                    {
                        if (comboBox1.SelectedIndex == 0)
                        {
                            if (AccountTypecomboBox.SelectedIndex == 0)
                            {
                                this.Hide();
                                AdminPortal Ap = new AdminPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 1)
                            {
                                this.Hide();
                                AccountantPortal Ap = new AccountantPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 2)
                            {
                                this.Hide();
                                ReceptionestPortal Ap = new ReceptionestPortal();
                                Ap.Show();
                            }
                            else if (AccountTypecomboBox.SelectedIndex == 3)
                            {
                                this.Hide();
                                GeneralEmployeePortal Ap = new GeneralEmployeePortal(UserNameTB.Text);
                                Ap.Show();
                            }
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(Application.StartupPath + @"\inventorysystem\inventorysystem\bin\Debug\inventorysystem.exe");

                            UserNameTB.Clear();
                            PassTB.Clear();
                            UserNameTB.Focus();
                            comboBox1.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        MessageBox.Show(" Wrong User Name or Password, Try again", "Invalid User", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UserNameTB.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                UserNameTB.Focus();
            }
        }