Exemple #1
0
        public frmMain()
        {
            InitializeComponent();

            clsAutUserBO bo = new clsAutUserBO();
            DataTable dt = bo.GetCommonMenu();
            mnuMain = BuildMenu(dt);
            this.Menu = mnuMain;

            try
            {
                string filename = clsSystemConfig.ImageFolder + ConfigurationManager.AppSettings["Background"];
                if(File.Exists(filename))
                {
                    this.BackgroundImage = Image.FromFile(clsSystemConfig.ImageFolder + ConfigurationManager.AppSettings["Background"]);
                    this.BackgroundImageLayout = ImageLayout.Stretch;
                }
            }
            catch(Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Open login form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Author:			Le Tien Phat. 
        /// Created date:	14/05/2011
        /// </remarks>
        private void mnuLogin_Click(object sender, System.EventArgs e)
        {
            int LoginResult = clsConstants.PASSWORD_WRONG;
            frmLogin frm = new frmLogin();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                LoginResult = frm.LoginResult;
            }

            if (LoginResult == clsConstants.LOGIN_SUCCESS)
            {
                //SingleInstance.SingleApplication.Run(new frmMain());
                clsAutUserBO bo = new clsAutUserBO();
                DataTable dt = bo.GetAuthority();
                this.Menu = BuildMenu(dt);
                CreateToolBar(dt);
                bo.ClearAuthority();
                this.Text = clsResources.GetTitle("frmMain.Title") + " - " + clsResources.GetMessage("messages.username.title", clsSystemConfig.UserName);
                clsFormManager.MainForm = this;
            }
        }
Exemple #3
0
 /// <summary>
 /// Login
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <remarks>
 /// Author:			Le Tien Phat. 
 /// Created date:	14/05/2011
 /// </remarks>
 private void btnLogIn_Click(object sender, System.EventArgs e)
 {
     ep.SetError(txtUserName, "");
     if(txtUserName.Text.Trim().Length == 0)
     {
         ep.SetError(txtUserName, clsResources.GetMessage("errors.required", "User name"));
         return;
     }
     clsAutUserBO login = new clsAutUserBO();
     string userName = txtUserName.Text.Trim();
     string password = txtPassword.Text;
     m_iLoginResult = login.Login(userName, password);
     switch(m_iLoginResult)
     {
         case clsConstants.ACCOUNT_NOT_EXIST://-2
             MessageBox.Show(clsResources.GetMessage("errors.login.ACCOUNT_NOT_EXIST"), clsResources.GetMessage("errors.general"), MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtPassword.Clear();
             txtUserName.Focus();
             txtUserName.SelectAll();
             break;
         case clsConstants.PASSWORD_WRONG://-3:
             MessageBox.Show("Password is wrong", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
             //txtPassword.Clear();
             txtPassword.Focus();
             txtPassword.SelectAll();
             break;
         case clsConstants.ACCOUNT_INACTIVE://-4:
             MessageBox.Show("Account is not active", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
             //txtPassword.Clear();
             txtUserName.Focus();
             txtUserName.SelectAll();
             break;
         case clsConstants.ACCOUNT_EXPIRED://-5:
             MessageBox.Show("Account expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
             txtPassword.Clear();
             txtUserName.Focus();
             txtUserName.SelectAll();
             break;
         case clsConstants.PASSWORD_EXPIRED://-6:
             MessageBox.Show("Password expired", "Invalid LogIn", MessageBoxButtons.OK, MessageBoxIcon.Error);
             clsSystemConfig.UserName = userName;
             frmChangePWD frm = new frmChangePWD();
             this.Hide();
             frm.ShowDialog();
             this.Show();
             txtPassword.Clear();
             txtUserName.Focus();
             txtUserName.SelectAll();
             break;
         case clsConstants.LOGIN_SUCCESS:
             clsSystemConfig.UserName = userName;
             this.Close();
             break;
     }
 }