Example #1
0
        private void btn_Login_Click(object sender, EventArgs e)
        {
            string loginName     = txt_loginName.Text.Trim();
            string loginPassword = txt_loginPassword.Text.Trim();

            if (!string.IsNullOrEmpty(loginName) && !string.IsNullOrEmpty(loginPassword))
            {
                UserLogin userLogin = new UserLogin();
                bool      result    = userLogin.IsExist(new User(loginName, loginPassword));
                if (result)
                {
                    OperateIniFile.GetInstance().WriteIniData("LoginLocal", "UserName", loginName);
                    OperateIniFile.GetInstance().WriteIniData("LoginLocal", "PassWord", loginPassword);
                    User user = userLogin.GetUser(loginName, loginPassword);
                    UserHelper.SetUser(user);
                    UserHelper.SetLogin(true);
                    Hide();
                    Frm_FirstPage frm = GetFormHelper.GetFirstPage(this, true);
                    frm.Show();
                    frm.Activate();
                }
                else
                {
                    XtraMessageBox.Show("用户名或密码错误。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                XtraMessageBox.Show("用户名和密码不能为空。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
 public static OperateIniFile GetInstance()
 {
     if (_operateIniFile == null)
     {
         _operateIniFile = new OperateIniFile();
     }
     return(_operateIniFile);
 }
Example #3
0
        private void Frm_Login_Load(object sender, EventArgs e)
        {
            OperateIniFile oper     = OperateIniFile.GetInstance();
            string         username = oper.ReadIniData("LoginLocal", "UserName", null);
            string         password = oper.ReadIniData("LoginLocal", "PassWord", null);

            if (!string.IsNullOrEmpty(username))
            {
                txt_loginName.Text = username;
            }
            if (!string.IsNullOrEmpty(password))
            {
                txt_loginPassword.Text = password;
            }
        }