Exemplo n.º 1
0
        //登陆事件
        private void btn_Login_Click(object sender, EventArgs e)
        {
            string tel             = txt_Phone.Text.ToString().Trim();
            string checkCode       = txt_ValiCode.Text.ToString().Trim();
            string password        = txt_ReSetPwd.Text.ToString().Trim();
            string confirmPassword = txt_SurePwd.Text.ToString().Trim();
            //MessageBox.Show(tel+ checkCode+password + confirmPassword);
            string par  = "mobile=" + tel + "&checkCode=" + checkCode + "&password="******"&confirmPassword="******"web/login/forget.do", par);
            Result objs = JsonHelper.Json2Object <Result>(data);

            currentUser          = new User();
            currentUser.Tel      = tel;
            currentUser.Password = password;
            // MessageBox.Show(objs.description);
            if (objs.isSuccess == "True")
            {
                FloatWin fw = new FloatWin(this, currentUser);
                fw.Show();
                this.Hide();
            }
            else
            {
                TipFrm       tipFrm = new TipFrm(objs.description);
                DialogResult result = tipFrm.ShowDialog();
                //DialogResult result = Messagebox.Show(objs.description, "提示", Messagebox.MyButtons.OK, Messagebox.MyIcon.Information);
            }
        }
Exemplo n.º 2
0
        //获取验证码事件
        private void btn_AcquireValiCode_Click(object sender, EventArgs e)
        {
            string tel = txt_Phone.Text.ToString().Trim();
            Button btn = (Button)sender;

            if (tel == "" || tel == "请输入手机号码" || tel.Length != 11)
            {
                new TipFrm("请输入正确的手机号码").ShowDialog();
            }
            else if (btn.Text == "获取验证码")
            {
                string par  = "mobile=" + tel;
                String data = CommonService.remote("web/login/sendcheckcode.do", par, "login");
                Result objs = JsonHelper.Json2Object <Result>(data);
                if (objs.isSuccess == "False")
                {
                    TipFrm       tipFrm = new TipFrm("短信发送失败!");
                    DialogResult result = tipFrm.ShowDialog();
                }
                else if (objs.isSuccess == "True")
                {
                    btn_AcquireValiCode.BackColor = Color.DarkGray;
                    btn_AcquireValiCode.Text      = "60S";
                    timer_ValiCode.Enabled        = true;
                    TipFrm       tipFrm = new TipFrm("短信已发送!");
                    DialogResult result = tipFrm.ShowDialog();
                }
                //Messagebox.Show(objs.description, "提示", Messagebox.MyButtons.OK, Messagebox.MyIcon.Information);
            }
            //
        }
Exemplo n.º 3
0
        /// <summary>
        /// 手机动态码登录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btn_DyLogin_Click(object sender, EventArgs e)
        {
            btn_AcquireValiCode.Text      = "获取验证码";
            btn_AcquireValiCode.BackColor = Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(122)))), ((int)(((byte)(195)))));
            string  tel        = txt_Phone.Text.ToString().Trim();
            Boolean isRemember = false;
            // MessageBox.Show(tel);
            string password = txt_ValiCode.Text.ToString().Trim();
            string para     = "mobile=" + tel + "&dynamicPassword="******"&isRemember=" + isRemember;
            string data     = CommonService.remote("web/login/dynamic.do", para, "login");
            Result objs     = JsonHelper.Json2Object <Result>(data);

            currentUser          = new User();
            currentUser.Tel      = tel;
            currentUser.Password = password;
            //MessageBox.Show(data);
            if (objs.isSuccess == "True")
            {
                FloatWin fw = new FloatWin(this, currentUser);
                fw.Show();
                this.Hide();
            }

            else
            {
                TipFrm       tipFrm = new TipFrm(objs.description);
                DialogResult result = tipFrm.ShowDialog();
                //Messagebox.Show(objs.description, "提示", Messagebox.MyButtons.OK, Messagebox.MyIcon.Information);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 登录方法
        /// </summary>
        /// <param name="user">User的一个实例化对象</param>
        private void Login(User user, int isAutoLogin = 0)
        {
            Boolean isRemember = false;
            string  para       = "mobile=" + user.Tel + "&password="******"&isRemember=" + isRemember;
            string  data       = CommonService.remote("web/login/normal.do", para, "login");
            Result  objs       = JsonHelper.Json2Object <Result>(data);

            //MessageBox.Show(data);
            if (objs.isSuccess == "True")
            {
                try
                {  //登录成功记住账号 appPath + "\\data.bin"
                    //string appPath = System.Windows.Forms.Application.StartupPath;
                    FileStream      fs = new FileStream(@"D:\data.bin", FileMode.OpenOrCreate);
                    BinaryFormatter bf = new BinaryFormatter();
                    if (this.AutoLogin.Checked) //如果单击自动登录
                    {
                        user.IsAutoLogin = 1;
                    }
                    else
                    {
                        user.IsAutoLogin = 0;
                    }
                    if (this.RememberPassword.Checked) //如果单击了记住密码的功能
                    {                                  //  在文件中保存密码
                        user.Password = user.Password;
                    }
                    else
                    {   //  不在文件中保存密码
                        user.Password = "";
                    }
                    //判断用户是否存在,不存在则把用户保存在集合users中
                    //if (!users.ContainsKey(user.Tel))
                    //{
                    //    users[user.Tel] = user;
                    //}
                    if (users.ContainsKey(user.Tel))
                    {
                        users.Remove(user.Tel);
                    }
                    //user.IsExist = 1;   //用户已经登录为1,未登录为0
                    users.Add(user.Tel, user);
                    storeLastLoginInfo(user.Tel);
                    //要先将User类先设为可以序列化(即在类的前面加[Serializable])
                    bf.Serialize(fs, users);
                    fs.Close();
                    createFloatWin(isAutoLogin);
                }
                catch
                {
                }
            }

            else
            {
                TipFrm       tipFrm = new TipFrm(objs.description);
                DialogResult result = tipFrm.ShowDialog();
                //Messagebox.Show(objs.description, "提示", Messagebox.MyButtons.OK, Messagebox.MyIcon.Information);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 首次登录方法
        /// </summary>
        private void btn_Login_Click(object sender, EventArgs e)
        {
            User user = new User();

            btn_AcquireValiCode.Text      = "获取验证码";
            btn_AcquireValiCode.BackColor = Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(122)))), ((int)(((byte)(195)))));
            string tel             = txt_Phone.Text.ToString().Trim();
            string checkCode       = txt_ValiCode.Text.ToString().Trim();
            string password        = txt_SetPwd.Text.ToString().Trim();
            string confirmPassword = txt_SurePwd.Text.ToString().Trim();
            //MessageBox.Show(tel+ checkCode+password + confirmPassword);
            string par  = "mobile=" + tel + "&checkCode=" + checkCode + "&password="******"&confirmPassword="******"web/login/first.do", par);
            Result objs = JsonHelper.Json2Object <Result>(data);

            // MessageBox.Show(objs.isSuccess);
            user.Tel      = tel;
            user.Password = password;
            if (objs.isSuccess == "True")
            {
                new FloatWin(this, user).Show();
                this.Hide();
            }
            else
            {
                TipFrm       tipFrm = new TipFrm(objs.description);
                DialogResult result = tipFrm.ShowDialog();
                //Messagebox.Show(objs.description, "提示", Messagebox.MyButtons.OK, Messagebox.MyIcon.Information);
            }
        }