Exemplo n.º 1
0
        public static string GetLastLoginUser()
        {
            string UserNo   = "";
            string fileName = "ipConfig.xml";

            if (!System.IO.File.Exists(fileName))
            {
                UserNo = "";
            }
            else
            {
                xmlDoc xmldoc = new xmlDoc();
                if (xmldoc.LoadXmlFile(fileName))
                {
                    UserNo = xmldoc.readByNodeName("UserNo");
                }
            }
            return(UserNo);
        }
Exemplo n.º 2
0
        private void saveLocal()
        {
            string key    = md5Cls.GenerateKey();
            string xmlstr = "";

            xmlstr += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
            xmlstr += "<setting>\r\n";

            if (this.textBox1.Text.Trim() != "")
            {
                xmlstr += "<User_Num>" + this.textBox1.Text.Trim() + "</User_Num>\r\n";
            }
            //else
            //{
            //    xmlstr += "<User_Num></User_Num>\r\n";
            //}

            if (this.textBox2.Text.Trim() != "" && checkBox1.Checked)
            {
                xmlstr += "<User_Pwd>" + md5Cls.MD5Encrypt(this.textBox2.Text.Trim(), key) + "</User_Pwd>\r\n";
            }
            else
            {
                xmlstr += "<User_Pwd></User_Pwd>\r\n";
            }
            //else
            //{
            //    xmlstr += "<User_Pwd></User_Pwd>\r\n";
            //}
            xmlstr += "<Key>" + key + "</Key>\r\n";
            xmlstr += "</setting>";
            try
            {
                xmlDoc xmldoc2 = new xmlDoc();
                xmldoc2.LoadXmlString(xmlstr);
                var b = xmldoc2.SaveXmlFile("user.xml");
            }
            catch
            {
            }
        }
Exemplo n.º 3
0
        public static string GetSettingUser()
        {
            string fileName = "ipConfig.xml";

            if (!System.IO.File.Exists(fileName))
            {
                return("");
            }
            else
            {
                xmlDoc xmldoc = new xmlDoc();
                if (xmldoc.LoadXmlFile(fileName))
                {
                    return(xmldoc.readByNodeName("User_ID"));
                }
                else
                {
                    return("");
                }
            }
        }
Exemplo n.º 4
0
        public static void GetServerInfo()
        {
            MD5Cls md5Cls   = new MD5Cls();
            string fileName = "ipConfig.xml";

            if (!System.IO.File.Exists(fileName))
            {
                return;
            }
            else
            {
                xmlDoc xmldoc = new xmlDoc();
                if (xmldoc.LoadXmlFile(fileName))
                {
                    ServerIP = xmldoc.readByNodeName("ServerIP");
                    User_ID  = xmldoc.readByNodeName("User_ID");
                    User_Pwd = md5Cls.MD5Decrypt(xmldoc.readByNodeName("User_Pwd"), xmldoc.readByNodeName("Key"));
                    //md5Cls.MD5Decrypt(xmldoc.readByNodeName("User_Pwd"), xmldoc.readByNodeName("Key"))
                }
            }
        }
Exemplo n.º 5
0
        public static void SaveLastLoginUser()
        {
            string xmlstr = "";

            xmlstr += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
            xmlstr += "<setting>\r\n";
            xmlstr += "<注释>数据库配置信息</注释>\r\n";
            xmlstr += "<ServerIP>" + ServerIP + "</ServerIP>\r\n";
            xmlstr += "<User_ID>" + User_ID + "</User_ID>\r\n";
            xmlstr += "<User_Pwd>" + User_Pwd + "</User_Pwd>\r\n";
            xmlstr += "</setting>";

            try
            {
                xmlDoc xmldoc = new xmlDoc();
                xmldoc.LoadXmlString(xmlstr);
                xmldoc.SaveXmlFile("ipConfig.xml");
            }
            catch
            {
            }
        }
Exemplo n.º 6
0
        private void Login_Load(object sender, EventArgs e)
        {
            ServerInfo.GetServerInfo();
            string fileName = "user.xml";

            if (!System.IO.File.Exists(fileName))
            {
                return;
            }
            else
            {
                xmlDoc xmldoc = new xmlDoc();
                if (xmldoc.LoadXmlFile(fileName))
                {
                    this.textBox1.Text = xmldoc.readByNodeName("User_Num");
                    if (xmldoc.readByNodeName("User_Pwd") != "")
                    {
                        this.textBox2.Text     = md5Cls.MD5Decrypt(xmldoc.readByNodeName("User_Pwd"), xmldoc.readByNodeName("Key"));
                        this.checkBox1.Checked = true;
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text.Trim() == "")
            {
                MessageBox.Show("请输入服务器IP地址!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.textBox1.Focus();
                this.textBox1.SelectAll();
            }
            else if (this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("请输入数据库登录名!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.textBox2.Focus();
                this.textBox2.SelectAll();
            }
            else if (this.textBox3.Text.Trim() == "")
            {
                MessageBox.Show("请输入数据库密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.textBox3.Focus();
                this.textBox3.SelectAll();
            }

            else
            {
                string key    = md5cls.GenerateKey();
                string xmlstr = "";
                xmlstr += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
                xmlstr += "<setting>\r\n";
                if (this.textBox1.Text.Trim() != "")
                {
                    xmlstr += "<ServerIP>" + this.textBox1.Text.Trim() + "</ServerIP>\r\n";
                }
                else
                {
                    xmlstr += "<ServerIP>127.0.0.1</ServerIP>\r\n";
                }

                if (this.textBox2.Text.Trim() != "")
                {
                    xmlstr += "<User_ID>" + this.textBox2.Text.Trim() + "</User_ID>\r\n";
                }
                else
                {
                    xmlstr += "<User_ID></User_ID>\r\n";
                }

                if (this.textBox3.Text.Trim() != "")
                {
                    xmlstr += "<User_Pwd>" + md5cls.MD5Encrypt(this.textBox3.Text.Trim(), key) + "</User_Pwd>\r\n";//
                }
                else
                {
                    xmlstr += "<User_Pwd></User_Pwd>\r\n";
                }
                xmlstr += "<Key>" + key + "</Key>\r\n";


                xmlstr += "</setting>";
                //MessageBox.Show(key);
                try
                {
                    xmlDoc xmldoc = new xmlDoc();
                    xmldoc.LoadXmlString(xmlstr);
                    //var b = xmldoc.SaveXmlFile(@"~/ipConfig.xml");//"\\ipConfig.xml"
                    var b = xmldoc.SaveXmlFile("ipConfig.xml");

                    if (this.Text.Trim() == "")
                    {
                        ServerInfo.ServerIP = "127.0.0.1";
                    }
                    else
                    {
                        ServerInfo.ServerIP = this.textBox1.Text.Trim();
                    }
                    if (b)
                    {
                        MessageBox.Show("IP配置成功!");
                    }
                    else
                    {
                        MessageBox.Show("IP配置失败!");
                    }
                    ServerInfo.User_ID  = this.textBox2.Text.Trim();
                    ServerInfo.User_Pwd = this.textBox3.Text.Trim();
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("IP配置失败\r\n请检查网络或联系管理人员");
                }
            }
        }