Exemplo n.º 1
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);
        }
Exemplo n.º 2
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_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
            {
                DataSet   dsMCode = lms.conn("select * from " + Global.sqlUserTable + " where user_name='" + user_name + "'");
                DataTable dtMCode = dsMCode.Tables[0];

                if (dtMCode.Rows.Count == 0)
                {
                    lms.conn("insert into " + Global.sqlUserTable + "(user_name,user_pass,user_realname,user_id,user_phone,user_qq,user_province,machinecode,registtime,registplace) values('" + user_name + "','" + user_pass + "','" + user_realname + "','" + user_id + "','" + user_phone + "','" + user_qq + "','" + user_province + "','" + machinecode + "','" + registtime + "','" + getIP.GetWebCity() + "')");
                    MessageBox.Show("申请成功,请联系管理等待开通。", "恭喜");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("用户名已存在,请换一个用户名再试!", "温馨提示");
                }
            }
            catch
            {
                MessageBox.Show("申请失败,请稍后重试!", "温馨提示");
            }
        }
Exemplo n.º 3
0
        //启动下线机制
        private void offlineUserTimer_Tick(object sender, EventArgs e)
        {
            DataSet   ds = lms.conn("select allowlogin,`online`,isdel from " + Global.sqlUserTable + " where user_name='" + Global.user_name + "'");
            DataTable tb = ds.Tables[0];

            if (tb != null && tb.Rows.Count > 0)
            {
                DataRow dr         = tb.Rows[0];
                string  allowlogin = dr["allowlogin"].ToString();
                string  online     = dr["online"].ToString();
                string  isdel      = dr["isdel"].ToString();

                //如果是用户名密码登录但是发现数据库有机器码登录史,则下线

                /*if ((online.Equals("2") && Global.loginType.Equals("1")))
                 * {
                 *  MessageBox.Show("已使用机器码登录,软件即将关闭。");
                 *  this.DialogResult = DialogResult.Cancel;
                 *  return;
                 * }*/

                if (allowlogin.Equals("0")
                    ||
                    isdel.Equals("-1")
                    ||
                    online.Equals("0"))
                {
                    MessageBox.Show("软件即将关闭,请联系管理员。");
                    this.Dispose();
                    this.Close();
                }
            }
        }
Exemplo n.º 4
0
        //启动下线机制
        private void offlineUserTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                //刷新自己在线的时间状态
                refreshMyOnlineTime_Tick();
                DataTable tb = lms.conn("select allowlogin,`online`,isdel from " + Global.sqlUserTable + " where user_name='" + Global.user_name + "'");
                if (tb != null && tb.Rows.Count > 0)
                {
                    DataRow dr         = tb.Rows[0];
                    string  allowlogin = dr["allowlogin"].ToString();
                    string  online     = dr["online"].ToString();
                    string  isdel      = dr["isdel"].ToString();

                    //如果是用户名密码登录但是发现数据库有机器码登录史,则下线

                    /*if ((online.Equals("2") && Global.loginType.Equals("1")))
                     * {
                     *  MessageBox.Show("已使用机器码登录,软件即将关闭。");
                     *  this.DialogResult = DialogResult.Cancel;
                     *  return;
                     * }*/

                    if (allowlogin.Equals("0")
                        ||
                        isdel.Equals("-1")
                        ||
                        online.Equals("0")
                        ||
                        (online.Equals("2") && Global.loginType.Equals("1")))
                    {
                        Global.isNormalStatus         = false;// 设置为非正常关闭
                        this.offlineUserTimer.Enabled = false;
                        MessageBox.Show("账号与服务器失去连接或者异地登录,软件即将关闭\r\n请重新登录或者检查账号安全");
                        this.Dispose();
                        this.Close();
                    }
                }
            }
            catch (Exception err)
            {
                //throw err;
            }
            finally
            {
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 刷新datagridview时执行的sql
        /// 参数where是查询条件
        /// </summary>
        private void dgvGetInfoSqlExecute(string where)
        {
            //设定给datagridview的select列名
            string displaySqlSelect = "user_name as '用户名',user_realname as '姓名',user_phone as '手机/电话',user_qq as 'QQ/MSN'," +
                                      "CASE allowlogin when '1' then'是' ELSE'否' end AS '允许登录',case online when '1' then '在线' when '2' then '在线' else '离线' end as '当前是否在线'," +
                                      "soft_version as '软件版本' ";

            DataTable tb = lms.conn("select " + displaySqlSelect + " from " + Global.sqlUserTable + " " + where);

            dataGridView1.DataSource = tb;
            dataGridView1.DataMember = tb.TableName;

            DataTable cu = lms.conn("select count(user_id) as 总计 from " + Global.sqlUserTable + " " + where);
            DataRow   dr = cu.Rows[0];

            this.sumUserLabel.Text = "共有 " + dr[0].ToString() + " 位用户";
        }
Exemplo n.º 6
0
        private void loginStart()
        {
            try
            {
                setLoginResult("正在登录中...请稍后");
                disabledControls();

                string user_name = textBox1.Text.Trim();//textBox1.Text.Trim();
                string user_pass = textBox2.Text.Trim();
                if (loginValidate(user_name, user_pass) == true)
                {
                    lms.conn("UPDATE " + Global.sqlUserTable +
                             " SET `online`='1',lastloginip='" + getIP.GetWebIP() + "',lastlogintime=now(),lastloginplace='" + getIP.GetWebCity() + "',soft_version='" + Global.version + "',onlinetime=now() " +
                             " where user_name='" + user_name + "'");

                    writeToUserXML(user_name, user_pass);//写入到用户配置文件
                    loginToMain();
                    return;
                }
                enabledControls();
            }
            catch (Exception err)
            {
                MessageBox.Show("登录失败,请检查网络连接或者稍后重试。", "友情提示");
                //throw err;
            }
            finally {
                threadLogin.Abort();
            }
        }
Exemplo n.º 7
0
        //第一个选项卡中Datagridview窗体的信息获取
        private void dgvGetInfo()
        {
            string us = "";//

            if (Global.user_province.IndexOf("省") >= 0)
            {
                us = Global.user_province.Substring(0, Global.user_province.IndexOf("省") + 1);
            }
            else
            {
                us = Global.user_province.Substring(0, Global.user_province.IndexOf("市") + 1);
            }

            try
            {
                string prov = provinceCbx.Text;
                string ol   = onlineCbx.Text;
                if (prov.Equals("显示全部"))
                {
                    DataSet   ds = lms.conn("select user_name as '用户名',user_realname as '姓名',user_phone as '手机/电话',user_qq as 'QQ/MSN',CASE allowlogin when '1' then'是' ELSE'否' end AS '允许登录',case online when '1' then '在线' else '离线' end as '当前是否在线' from user_login where user_province like '%" + us + "%' and user_vali!='1' and user_vali!='3' and user_vali!='4'");
                    DataTable tb = ds.Tables[0];

                    dataGridView1.DataSource = ds;
                    dataGridView1.DataMember = ds.Tables[0].TableName;

                    DataSet   countUser = lms.conn("SELECT count(user_id) as 总计 FROM user_login where user_province like '%" + us + "%' and user_vali!='1' and user_vali!='3' and user_vali!='4'");
                    DataTable cu        = countUser.Tables[0];
                    DataRow   dr        = cu.Rows[0];
                    this.sumUserLabel.Text = "共有 " + dr[0].ToString() + " 位用户";
                }
                if (prov.Equals("在线状态"))
                {
                    if (ol.Equals("在线"))
                    {
                        ol = "1";
                    }
                    else
                    {
                        ol = "0";
                    }

                    DataSet   ds = lms.conn("select user_name as '用户名',user_realname as '姓名',user_phone as '手机/电话',user_qq as 'QQ/MSN',CASE allowlogin when '1' then'是' ELSE'否' end AS '允许登录',case online when '1' then '在线' else '离线' end as '当前是否在线' from user_login where online='" + ol + "' and user_province like '%" + us + "%' and user_vali!='1' and user_vali!='3' and user_vali!='4'");
                    DataTable tb = ds.Tables[0];

                    dataGridView1.DataSource = ds;
                    dataGridView1.DataMember = ds.Tables[0].TableName;

                    DataSet   countUser = lms.conn("SELECT count(user_id) as 总计 FROM user_login where online='" + ol + "' and user_province like '%" + us + "%' and user_vali!='1' and user_vali!='3' and user_vali!='4'");
                    DataTable cu        = countUser.Tables[0];
                    DataRow   dr        = cu.Rows[0];
                    this.sumUserLabel.Text = "共有 " + dr[0].ToString() + " 位用户";
                }
            }
            catch
            {
            }
        }
Exemplo n.º 8
0
        //写入数据库
        private void writeToDB()
        {
            string user_realname = textBox4.Text;
            string user_id       = textBox5.Text;
            string user_phone    = textBox9.Text;
            string user_qq       = textBox10.Text;
            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
            {
                lms.conn("update " + Global.sqlUserTable + " set user_realname='" + user_realname + "',user_province='" + user_province + "',user_id='" + user_id + "',user_phone='" + user_phone + "',user_qq='" + user_qq + "' where user_name='" + Global.user_name + "'");
                MessageBox.Show("修改成功", "恭喜");
                this.Close();
            }
            catch {
                MessageBox.Show("修改失败,请稍后重试", "提示");
            }
        }
Exemplo n.º 9
0
        //关闭程序时写注册表离线
        static void quitWriteSql()
        {
            LinkMySql lms = new LinkMySql();

            try
            {
                lms.conn("update " + Global.sqlUserTable + " set `online`='0' where user_name='" + Global.user_name + "'");
            }
            catch
            {
                DialogResult drr = MessageBox.Show("程序关闭时遇到问题,如果无法再次登录软件,请联系售后", "温馨提示", MessageBoxButtons.OKCancel);
                if (drr == DialogResult.OK)
                {
                    Global.user_name = "";
                    Environment.Exit(0);
                }
                if (drr == DialogResult.Cancel)
                {
                    Application.Run(new main());
                }
            }
        }
Exemplo n.º 10
0
        //关闭程序时写注册表离线
        static void quitWriteSql()
        {
            if (Global.isNormalStatus == false)
            {
                return;
            }

            LinkMySql lms = new LinkMySql();

            try
            {
                lms.conn("update " + Global.sqlUserTable + " set `online`='0' where user_name='" + Global.user_name + "'");
            }
            catch
            {
                DialogResult drr = MessageBox.Show("程序关闭时遇到问题,如果无法再次登录软件,请联系售后", "温馨提示", MessageBoxButtons.OKCancel);
                if (drr == DialogResult.OK)
                {
                    Global.user_name = "";
                    Environment.Exit(0);
                }
                if (drr == DialogResult.Cancel)
                {
                    return;
                }
            }

            //try
            //{
            //WebConnect wc = new WebConnect();
            // string result = wc.sendStringMessage("http://eztx.cn/eztx/eztx_offline.php?username="******"");
            // Application.Exit();
            //}
            //catch
            //{
            //    MessageBox.Show("程序关闭时遇到问题,如果无法再次登录软件,请联系售后", "温馨提示");
            //}
        }
Exemplo n.º 11
0
        private void loginStart()
        {
            setLoginResult("正在登录中...请稍后");

            string user_name = textBox1.Text.Trim();
            string user_pass = textBox2.Text.Trim();

            try
            {
                if (loginValidate(user_name, user_pass) == true)
                {
                    lms.conn("UPDATE " + Global.sqlUserTable + " SET `online`='1',lastloginip='" + getIP.GetWebIP() + "',lastlogintime=now(),lastloginplace='" + getIP.GetWebCity() + "' where user_name='" + user_name + "'");

                    string url = Application.StartupPath;
                    if (savePass.Checked == true)
                    {
                        if (!File.Exists(url + "\\UserProfile.xml"))
                        {
                            XmlDocument    doc = new XmlDocument();
                            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

                            doc.AppendChild(dec);
                            //创建一个根节点(一级)
                            //创建节点(二级)
                            XmlNode node = doc.CreateElement("UserProfile");
                            //创建节点(三级)
                            XmlElement element1 = doc.CreateElement("UserName");
                            element1.InnerText = user_name;
                            node.AppendChild(element1);

                            XmlElement element2 = doc.CreateElement("UserPass");
                            element2.InnerText = user_pass;
                            node.AppendChild(element2);
                            doc.AppendChild(node);

                            doc.Save(url + "\\UserProfile.xml");
                        }

                        if (File.Exists(url + "\\UserProfile.xml"))
                        {
                            XmlDocument doc = new XmlDocument();
                            doc.Load(url + "\\UserProfile.xml");
                            XmlNode xmlNode  = doc.SelectSingleNode("UserProfile/UserName"); //得到根节点
                            XmlNode xmlNode2 = doc.SelectSingleNode("UserProfile/UserPass"); //得到根节点
                            xmlNode.InnerText  = user_name;
                            xmlNode2.InnerText = user_pass;
                            doc.Save(url + "\\UserProfile.xml");
                        }
                    }

                    while (Global.main_msg.Length > 0)//确保main界面上方滚动条的文字已经读入
                    {
                        this.DialogResult = DialogResult.OK;
                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show("登录失败,请检查网络连接或者稍后重试,如果还不可以请联系管理员。", "友情提示");
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 绑定区域代理的combobox数据
        /// </summary>
        private void bindQuYuCbx()
        {
            qyCbx.DataSource = null;
            DataTable tb = lms.conn("select user_name,user_realname from " + Global.sqlUserTable + " where user_vali='5' and isdel='1'");

            qyCbx.DataSource    = tb;
            qyCbx.DisplayMember = "user_realname";
            qyCbx.ValueMember   = "user_name";
        }
Exemplo n.º 13
0
        private void ModifyInfoByAdmin_Load(object sender, EventArgs e)
        {
            DataSet   ds1           = lms.conn("select * from " + Global.sqlUserTable + " where user_name='" + un + "'");
            DataTable dt1           = ds1.Tables[0];
            DataRow   dr1           = dt1.Rows[0];
            string    user_realname = dr1["user_realname"].ToString();

            if (user_realname == null || user_realname.Equals(""))
            {
                user_realname = "";
            }

            string user_id = dr1["user_id"].ToString();

            if (user_id == null || user_id.Equals(""))
            {
                user_id = "";
            }

            string user_phone = dr1["user_phone"].ToString();

            if (user_phone == null || user_phone.Equals(""))
            {
                user_phone = "";
            }

            string user_qq = dr1["user_qq"].ToString();

            if (user_qq == null || user_qq.Equals(""))
            {
                user_qq = "";
            }

            string user_province = dr1["user_province"].ToString();

            if (user_province.Equals("暂无"))
            {
                user_province = "";
            }
            if (user_province != "暂无" && user_province.IndexOf("省") > 0 && user_province.IndexOf("市") > 0)
            {
                this.textBox7.Text = (user_province.Substring(0, user_province.IndexOf("省")));
                this.textBox6.Text = (user_province.Substring(user_province.IndexOf("省") + 1, user_province.IndexOf("市") - user_province.IndexOf("省") - 1));
            }
            if (user_province != "暂无" && user_province.IndexOf("省") < 0 && user_province.IndexOf("市") > 0)
            {
                this.textBox6.Text = (user_province.Substring(0, user_province.IndexOf("市")));
            }
            if (user_province != "暂无" && user_province.IndexOf("省") > 0 && user_province.IndexOf("市") < 0)
            {
                this.textBox7.Text = (user_province.Substring(0, user_province.IndexOf("省")));
            }

            this.textBox4.Text  = user_realname;
            this.textBox5.Text  = user_id;
            this.textBox9.Text  = dr1["user_phone"].ToString();
            this.textBox10.Text = dr1["user_qq"].ToString();

            string allowlogin = dr1["allowlogin"].ToString();

            if (allowlogin.Equals("1"))
            {
                this.radioButton1.Checked = true;
            }
            if (allowlogin.Equals("0"))
            {
                this.radioButton2.Checked = true;
            }
        }