Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (tbOld.Text == "")
            {
                MessageBox.Show("旧密码不能为空!");
                return;
            }
            if (tbNew.Text == "")
            {
                MessageBox.Show("新密码不能为空!");
                return;
            }
            if (tbNew2.Text == "")
            {
                MessageBox.Show("确认新密码不能为空!");
                return;
            }
            if (tbNew.Text != tbNew2.Text)
            {
                MessageBox.Show("两次输入的密码不一致!");
                return;
            }
            if (tbNew.Text.Length < 6)
            {
                MessageBox.Show("密码最小长度为6!");
                return;
            }
            String oldpwd        = EDncryptHelper.MD5Encrypt16(tbOld.Text);
            String newpwd        = EDncryptHelper.MD5Encrypt16(tbNew.Text);
            string data          = String.Format("cardnum={0}&oldpsw={1}&newpsw={2}", MainStaticData.USERCARD, oldpwd, newpwd);
            String ReturnDatastr = HttpUtil.RequestData(MainStaticData.ServerAddr + MainStaticData.INTE_EMPLOYEECHANGEPSW, data);

            if (ReturnDatastr == "errorPassword")
            {
                MessageBox.Show("旧密码错误!");
                return;
            }
            if (ReturnDatastr == "changeSuccess")
            {
                db_EmployeeLoginDao.logout(MainStaticData.USERCARD);
                MessageBox.Show("密码修改成功,请重新登录!");
                Application.ExitThread();
                MainStaticData.Restart();
                return;
            }
            MessageBox.Show(ReturnDatastr);//
        }
Beispiel #2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pw"></param>
        internal static string UserLogin(string card, string pw, int isMember)
        {
            String ReturnDatastr = null;

            try
            {
                string data = String.Format("cardnum={0}&psw={1}", card, EDncryptHelper.MD5Encrypt16(pw));
                ReturnDatastr = HttpUtil.RequestData(MainStaticData.ServerAddr + MainStaticData.INTE_EMPLOYEELOGIN, data);
                if (ReturnDatastr == null)
                {
                    return("服务器连接失败!");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(typeof(LoginWindow), ex);
                return("服务器连接失败!");
            }
            LogHelper.WriteInfo(typeof(LoginWindow), "登录结果: " + ReturnDatastr);
            if (ReturnDatastr == MainStaticData.loginSuccess)
            {
                MainStaticData.USERCARD = card;
                if (db_EmployeeLoginDao.existsByCard(card)) //如果存在记录则修改
                {
                    db_EmployeeLoginDao.update(card, pw, isMember);
                }
                else
                {
                    db_EmployeeLoginDao.addIfNoExist(card, pw, isMember);
                }
                return(ReturnDatastr);
            }
            else
            {
                return(ReturnDatastr);
            }
        }