示例#1
0
        private void menuItem3_Click(object sender, EventArgs e)
        {
            //Create user...
            frmCreateUser f = new frmCreateUser();

            f.ShowDialog();
        }
示例#2
0
 /// <summary>
 /// Auteur : Alexandre Pouliot
 /// Description : Allows the creation of a new user.
 /// Date : 2019/10/27
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void mnuCreateNewUser_Click(object sender, EventArgs e)
 {
     using (frmCreateUser createUser = new frmCreateUser())
     {
         createUser.ShowDialog();
     }
 }
示例#3
0
        private void frmLogin_Activated(object sender, EventArgs e)
        {
            try
            {
                if (blnBeenHere == true)
                {
                    return;
                }

                blnBeenHere = true;

                if (DB.CoreUsers.Count() <= 0)
                {
                    MessageBox.Show("Currently there is no user created. You need to create a user to login into the application.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmCreateUser createUserForm = new frmCreateUser();
                    this.Hide();
                    createUserForm.ShowDialog();
                    blnBeenHere = false;
                    this.Show();
                }
                else
                {
                    txtUsername.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Login Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtUsername.Text))
            {
                txtUsername.Focus();
                MessageBox.Show("Please enter Username.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                txtPassword.Focus();
                MessageBox.Show("Please enter Password.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["LicenseExpiry"]))
            {
                if (DateTime.Today > DateTime.Parse(ConfigurationManager.AppSettings["LicenseExpiry"].ToString()))
                {
                    MessageBox.Show("Software License Expired, Please contact software administrator.");
                    return;
                }
            }

            this.btnLogin.Enabled  = false;
            this.btnCancel.Enabled = false;
            this.Cursor            = System.Windows.Forms.Cursors.WaitCursor;

            string username = txtUsername.Text.ToUpper();

            CoreUser coreUser = DB.CoreUsers.Where(cu => cu.UserName.ToUpper() == txtUsername.Text.ToUpper() && cu.UserPassword == txtPassword.Text).FirstOrDefault();

            if (coreUser != null)
            {
                GlobalClass.LoggedInUserID = coreUser.CoreUserID;
                GlobalClass.EmployeeName   = coreUser.FirstName + " " + coreUser.LastName;

                NSGEmployee nsgEmp = DB.NSGEmployees.Where(em => em.NSGEmployeeCode == coreUser.EmployeeID).FirstOrDefault();

                if (coreUser.UserName.ToUpper() == "NSGADMIN")
                {
                    if (MessageBox.Show("Do you want to create user?", "Login", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        frmCreateUser createUserForm = new frmCreateUser();
                        this.Hide();
                        createUserForm.ShowDialog();
                        this.txtPassword.Text  = string.Empty;
                        this.txtUsername.Text  = string.Empty;
                        this.btnLogin.Enabled  = true;
                        this.btnCancel.Enabled = true;
                        this.txtUsername.Focus();
                        this.Cursor = System.Windows.Forms.Cursors.Default;
                        this.Show();
                    }
                    else
                    {
                        //GlobalClass.LoggedInUserRank = DB.CoreRanks.Where(cr => cr.RankID == nsgEmp.RankID).FirstOrDefault().RankName;
                        //GlobalClass.LoggedInUserUnit = DB.CoreUnits.Where(cu => cu.UnitID == nsgEmp.UnitID).FirstOrDefault().UnitName;

                        this.btnLogin.Enabled  = true;
                        this.btnCancel.Enabled = true;
                        this.Cursor            = System.Windows.Forms.Cursors.Default;
                        this.Hide();
                        frmMainPage frmMainPage = new frmMainPage();
                        frmMainPage.ShowDialog();
                        this.Close();
                    }
                }
                else
                {
                    GlobalClass.LoggedInUserRank = DB.CoreRanks.Where(cr => cr.RankID == nsgEmp.RankID).FirstOrDefault().RankName;
                    GlobalClass.LoggedInUserUnit = DB.CoreUnits.Where(cu => cu.UnitID == nsgEmp.UnitID).FirstOrDefault().UnitName;

                    this.btnLogin.Enabled  = true;
                    this.btnCancel.Enabled = true;
                    this.Cursor            = System.Windows.Forms.Cursors.Default;
                    this.Hide();
                    frmMainPage frmMainPage = new frmMainPage();
                    frmMainPage.ShowDialog();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Invalid username or password!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtPassword.Text = string.Empty;
                txtUsername.Text = string.Empty;
                txtUsername.Focus();
                this.btnLogin.Enabled  = true;
                this.btnCancel.Enabled = true;
                this.Cursor            = System.Windows.Forms.Cursors.Default;
                return;
            }
        }
        private void newUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCreateUser user = new frmCreateUser();

            user.ShowDialog();
        }