Beispiel #1
0
        //写入数据库
        private void writeToDB()
        {
            string user_name = textBox1.Text.Trim();
            string user_pass = textBox2.Text.Trim();
            ToMD5  md5       = new ToMD5();//将密码加密为md5

            user_pass = md5.Encrypt(user_pass);
            string user_realname    = textBox4.Text.Trim();
            string user_bankAccount = bankAccount.Text.Trim();
            string user_id          = textBox5.Text.Trim();
            string user_phone       = textBox9.Text.Trim();
            string user_qq          = textBox10.Text.Trim();
            string user_province    = "";
            string province         = textBox7.Text.Trim();
            string city             = textBox6.Text.Trim();

            if (province.Contains("省"))
            {
                province = province.Substring(0, province.IndexOf("省"));
            }
            if (city.Contains("市"))
            {
                city = city.Substring(0, city.IndexOf("市"));
            }
            user_province = province + "省" + city + "市";
            if (textBox7.Text.Trim().Equals("") && textBox6.Text.Trim() != "")
            {
                user_province = textBox6.Text.Trim() + "市";
            }
            if (user_province.Equals("省市"))
            {
                user_province = "暂无";
            }
            if (user_province.IndexOf("市") - user_province.IndexOf("省") == 1)
            {
                user_province = user_province.Substring(0, user_province.IndexOf("省") + 1);
            }
            string machinecode = textBox8.Text.Trim();
            string registtime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            try
            {
                DataTable dtMCode = LinkMySql.MySqlQuery("select * from " + Global.sqlUserTable + " where user_name='" + user_name + "'");

                if (dtMCode.Rows.Count == 0)
                {
                    LinkMySql.MySqlExcute("insert into " + Global.sqlUserTable + "(user_name,user_pass,user_realname,user_bankAccount,user_id,user_phone,user_qq,user_province,machinecode,registtime,registplace) values('" + user_name + "','" + user_pass + "','" + user_realname + "','" + user_bankAccount + "','" + user_id + "','" + user_phone + "','" + user_qq + "','" + user_province + "','" + machinecode + "','" + registtime + "','" + getIP.GetWebCity() + "')");
                    MessageBox.Show("申请成功,请联系管理等待开通。", "恭喜");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("用户名已存在,请换一个用户名再试!", "温馨提示");
                }
            }
            catch
            {
                MessageBox.Show("申请失败,请稍后重试!", "温馨提示");
            }
        }
Beispiel #2
0
        private Boolean userPassVali()
        {
            bool      tf      = false;
            DataSet   ds1     = lms.conn("select * from " + Global.sqlUserTable + " where user_name='" + Global.user_name + "'");
            DataTable dt1     = ds1.Tables[0];
            DataRow   dr1     = dt1.Rows[0];
            string    oldPass = textBox2.Text;
            string    newPass = textBox3.Text;
            ToMD5     md5     = new ToMD5();

            oldPass = md5.Encrypt(oldPass);
            newPass = md5.Encrypt(newPass);
            if (oldPass.Equals(dr1["user_pass"].ToString()))
            {
                label5.Text = "";
                if (label5.Text.Equals("") && label6.Text.Equals("") && label7.Text.Equals(""))
                {
                    DataSet dsNewPass = lms.conn("update " + Global.sqlUserTable + " set user_pass='******' where user_name='" + Global.user_name + "'");
                    tf = true;
                }
            }
            else
            {
                label5.ForeColor = Color.Red;
                label5.Text      = "原密码输入有误,请检查!";
            }
            return(tf);
        }
Beispiel #3
0
        //点击“登录”按钮以后的文本框输入验证操作
        private Boolean loginValidate(string user_name, string user_pass)
        {
            ToMD5 md5 = new ToMD5();

            if (string.IsNullOrEmpty(user_name))
            {
                setLabel3Text("请输入用户名!");
                setLoginResult("请输入用户名!");
                return(false);
            }
            if (string.IsNullOrEmpty(user_pass))
            {
                setLabel4Text("请输入密码!");
                setLoginResult("请输入密码!");
                return(false);
            }
            user_pass = md5.Encrypt(user_pass);

            DataTable dt1 = LinkMySql.MySqlQuery("select * from " + Global.sqlUserTable + " where user_name='" + user_name + "' and isdel='1'");

            if (dt1 == null || dt1.Rows.Count == 0)//如果没有返回来数据,证明用户名错了
            {
                setLabel3Text("用户名错误或者该用户未找到,请检查!");
                setLoginResult("用户名错误或者该用户未找到,请检查!");
                return(false);
            }

            setLabel3Text("");
            DataRow dr1 = dt1.Rows[0];

            if (!dr1["user_pass"].Equals(user_pass))
            {
                setLabel4Text("密码不正确,请检查!");
                setLoginResult("密码不正确,请检查!");
                return(false);
            }

            setLabel4Text("");
            if (dr1["allowlogin"].Equals("0"))
            {
                setLabel3Text("您没有使用权限!");
                setLoginResult("您没有使用权限!");
                return(false);
            }

            if (dr1["online"].Equals("1") || dr1["online"].Equals("2"))
            {
                setLabel3Text("该账号已在别处登录!");
                setLoginResult("该账号已在别处登录!");
                return(false);
            }

            Global.user_name     = dr1["user_name"].ToString();
            Global.user_realname = dr1["user_realname"].ToString();
            Global.user_province = dr1["user_province"].ToString();
            Global.user_vali     = dr1["user_vali"].ToString();
            Global.allowlogin    = dr1["allowlogin"].ToString();
            Global.loginType     = "1";
            return(true);
        }
Beispiel #4
0
        //点击“用户名登录”按钮以后的文本框输入验证操作
        private Boolean lValidate(string user_name, string user_pass)
        {
            ToMD5 md5 = new ToMD5();

            if (string.IsNullOrEmpty(user_name))
            {
                setLabel3Text("请输入用户名!");
                setLoginResult("请输入用户名!");
                return(false);
            }


            if (string.IsNullOrEmpty(user_pass))
            {
                setLabel4Text("请输入密码!");
                setLoginResult("请输入密码!");
                return(false);
            }

            DataSet   ds1 = lms.conn("select * from " + Global.sqlUserTable + " where user_name='" + user_name + "' and isdel='1'");
            DataTable dt1 = ds1.Tables[0];

            if (dt1 == null || dt1.Rows.Count == 0)
            {
                setLabel3Text("用户名不正确,请检查!");
                setLoginResult("用户名不正确,请检查!");
                return(false);
            }

            setLabel3Text("");
            DataRow dr1 = dt1.Rows[0];

            user_pass = md5.Encrypt(user_pass);
            if (!dr1["user_pass"].Equals(user_pass))
            {
                setLabel4Text("密码不正确,请检查!");
                setLoginResult("密码不正确,请检查!");
                return(false);
            }

            setLabel4Text("");
            if (dr1["allowlogin"].Equals("0"))
            {
                MessageBox.Show("您没有使用权限!");
                setLoginResult("您没有使用权限!");
                return(false);
            }

            Global.user_name     = dr1["user_name"].ToString();
            Global.user_realname = dr1["user_realname"].ToString();
            Global.user_province = dr1["user_province"].ToString();
            Global.user_vali     = dr1["user_vali"].ToString();
            Global.allowlogin    = dr1["allowlogin"].ToString();
            return(true);
        }
Beispiel #5
0
        //第二个选项卡添加用户写入数据库
        private void writeToDB()
        {
            string user_name = textBox1.Text;
            string user_pass = textBox2.Text;

            if (user_pass.Equals(""))
            {
                user_pass = "******";
            }
            ToMD5 md5 = new ToMD5();//将密码加密为md5

            user_pass = md5.Encrypt(user_pass);
            string user_realname    = textBox4.Text;
            string user_bankAccount = bankAccount.Text.Trim();
            string user_id          = textBox5.Text;
            string user_phone       = textBox9.Text;
            string user_qq          = textBox10.Text;
            string user_province    = textBox7.Text + "省" + textBox6.Text + "市";

            if (textBox7.Text.Equals("") && textBox6.Text != "")
            {
                user_province = textBox6.Text + "市";
            }
            if (user_province.Equals("省市"))
            {
                user_province = "暂无";
            }
            string machinecode = textBox3.Text;
            string registtime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string registplace = getIP.GetWebCity();
            int    i           = registplace.LastIndexOf(":") + 1;
            int    j           = registplace.IndexOf("市");

            registplace = registplace.Substring(i, j - i + 1);
            string allowlogin = "";

            if (this.radioButton1.Checked == true)
            {
                allowlogin = "******";
            }
            if (this.radioButton2.Checked == true)
            {
                allowlogin = "******";
            }

            try
            {
                DataTable dtMCode = LinkMySql.MySqlQuery("select * from " + Global.sqlUserTable + " where user_name='" + user_name + "'");
                if (dtMCode.Rows.Count == 0)
                {
                    int res = LinkMySql.MySqlExcute("insert into " + Global.sqlUserTable + "(user_name,user_pass,user_realname,user_bankAccount,user_id,user_phone,user_qq,user_province,allowlogin,machinecode,registtime,registplace) values('" + user_name + "','" + user_pass + "','" + user_realname + "','" + user_bankAccount + "','" + user_id + "','" + user_phone + "','" + user_qq + "','" + user_province + "','" + allowlogin + "','" + machinecode + "','" + registtime + "','" + registplace + "')");
                    if (res == 0)
                    {
                        MessageBox.Show("添加失败,请检查输入然后重试此操作。", "提示");
                        return;
                    }
                    MessageBox.Show("添加成功", "温馨提示");
                    clrTbx();
                }
                else
                {
                    MessageBox.Show("用户名已存在,请换一个用户名再试", "温馨提示");
                }
            }
            catch
            {
                MessageBox.Show("添加失败,请稍后重试。", "温馨提示");
            }
        }
        //写入数据库
        private void writeToDB()
        {
            string user_name     = textBox1.Text;
            string user_realname = textBox4.Text;
            string user_pass     = textBox3.Text;

            if (!user_pass.Equals(""))
            {
                ToMD5 md5 = new ToMD5();
                user_pass = md5.Encrypt(user_pass);
            }
            string user_bankAccount = bankAccount.Text.Trim();
            string user_id          = textBox5.Text;
            string user_phone       = textBox9.Text;
            string user_qq          = textBox10.Text;
            string allowlogin       = "";

            if (this.radioButton1.Checked)
            {
                allowlogin = "******";
            }
            if (this.radioButton2.Checked)
            {
                allowlogin = "******";
            }
            string user_province = "";
            string province      = textBox7.Text;
            string city          = textBox6.Text;

            if (province.Contains("省"))
            {
                province = province.Substring(0, province.IndexOf("省"));
            }
            if (city.Contains("市"))
            {
                city = city.Substring(0, city.IndexOf("市"));
            }
            user_province = province + "省" + city + "市";
            if (textBox7.Text.Equals("") && textBox6.Text != "")
            {
                user_province = textBox6.Text + "市";
            }
            if (user_province.Equals("省市"))
            {
                user_province = "暂无";
            }
            if (user_province.IndexOf("市") - user_province.IndexOf("省") == 1)
            {
                user_province = user_province.Substring(0, user_province.IndexOf("省") + 1);
            }
            try
            {
                if (!user_pass.Equals(""))
                {
                    LinkMySql.MySqlExcute("update " + Global.sqlUserTable + " set user_name='" + user_name + "',user_pass='******',user_realname='" + user_realname + "',user_province='" + user_province + "',allowlogin='******',user_bankAccount='" + user_bankAccount + "',user_id='" + user_id + "',user_phone='" + user_phone + "',user_qq='" + user_qq + "' where user_name='" + un + "'");
                    MessageBox.Show("修改成功", "恭喜");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }

                if (user_pass.Equals(""))
                {
                    LinkMySql.MySqlExcute("update " + Global.sqlUserTable + " set user_name='" + user_name + "',user_realname='" + user_realname + "',user_province='" + user_province + "',allowlogin='******',user_bankAccount='" + user_bankAccount + "',user_id='" + user_id + "',user_phone='" + user_phone + "',user_qq='" + user_qq + "' where user_name='" + un + "'");
                    MessageBox.Show("修改成功", "恭喜");
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch {
                MessageBox.Show("修改失败,请稍后重试。", "提示");
            }
        }