Ejemplo n.º 1
0
        private void btSure_Click(object sender, EventArgs e)
        {
            //检查密码是否填写
            if ((txtPswd.Text == null || txtPswd.Text.Equals("")) ||
                txtPswd2.Text == null || txtPswd2.Text.Equals(""))
            {
                MessageBox.Show("please input the password !", "error");
                return;
            }

            //检查两次密码是否一致
            if (!txtPswd.Text.Trim().Equals(txtPswd2.Text.Trim()))
            {
                MessageBox.Show("two password not equal!", "error");
            }
            else
            {
                string pswd = MyMd5.getMd5EncryptedStr(txtPswd2.Text.Trim());
                try
                {
                    service.chgPswd(curUser.UserId, pswd);
                    MessageBox.Show("change password success!", "message");
                    this.Dispose();
                }catch (Exception ex)
                {
                    MyLogger.WriteLine("change password failed!");
                    MessageBox.Show("change password failed!\r\n" + ex.Message, "error");
                }
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (combTeam.Text.Equals("") || combLevel.Text.Equals("") ||
         txtName.Text.Equals("") || txtUid.Text.Equals("") ||
         txtTel.Text.Equals(""))
     {
         MessageBox.Show("Please complete the blank space !", "warning");
         return;
     }
     else
     {
         Dictionary <string, string> dict = new Dictionary <string, string>();
         dict.Add("userid", txtUid.Text);
         dict.Add("username", txtName.Text);
         dict.Add("teamname", combTeam.Text);
         dict.Add("usertel", txtTel.Text);
         dict.Add("userlevel", combLevel.Text);
         dict.Add("userimgpath", null);
         dict.Add("userinfo", txtInfo.Text);
         dict.Add("userpass", MyMd5.getMd5EncryptedStr(txtUid.Text));
         if (service.add(dict, "tabusers"))
         {
             MessageBox.Show("Save record ok !", "Add User");
             parent.resetUserList();
             this.Close();
         }
         else
         {
             MessageBox.Show("Save record failed !", "Add User");
         }
     }
 }
Ejemplo n.º 3
0
        private void judgeLogin()
        {
            //验证用户
            string userId   = txtName.Text.Trim();
            string userPass = txtPass.Text.Trim();

            //输入合法
            if (userId != "" && userPass != "")
            {
                string encryptedPass = null;
                if (isAuto)
                {
                    encryptedPass = autoPas;
                }
                else
                {
                    encryptedPass = MyMd5.getMd5EncryptedStr(userPass);
                }

                string userLevel = "";

                //用户身份合法
                if (service.checkUser(userId, encryptedPass, ref userLevel))
                {
                    if (userLevel.Equals("normallv"))
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                    else if (userLevel.Equals("lowlv"))
                    {
                        this.DialogResult = DialogResult.Yes;
                    }

                    //保持用户id 到cache
                    Cache.userId = userId;


                    //写入文件
                    string cache = Environment.CurrentDirectory + "//.user.cache";
                    //记住用户
                    if (chkBoxCache.Checked)
                    {
                        using (FileStream fs = new FileStream(cache, FileMode.Create))
                        {
                            using (StreamWriter sw = new StreamWriter(fs))
                            {
                                sw.WriteLine(userId + "%" + PsEnDecode.encode(encryptedPass) + "%");
                            }
                        }
                    }
                    else //不记住用户
                    {
                        if (File.Exists(cache))
                        {
                            try
                            {
                                File.Delete(cache);
                            }
                            catch { }
                        }
                    }

                    Close();
                }
                //用户身份不合法
                else
                {
                    labLoginStatus.Visible = true;
                    labLoginStatus.Text    = "用户名或密码错误!";
                    txtName.Focus();
                }
            }
            //输入不合法
            else
            {
                labLoginStatus.Visible = true;
                labLoginStatus.Text    = "请输入用户名和密码!";
                txtName.Focus();
            }
        }