Exemple #1
0
        private void adddata_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();                         //建立个数据表

            dt.Columns.Add(new DataColumn("id", typeof(int)));      //在表中添加int类型的列

            dt.Columns.Add(new DataColumn("Name", typeof(string))); //在表中添加string类型的Name列
            XmlDocument doc = new XmlDocument();

            doc.Load(xmlConnection.str);
            XmlNodeList all_user = doc.SelectSingleNode("userInfo").ChildNodes;
            int         id       = 0;

            foreach (XmlNode Seted_user in all_user)
            {
                id++;
                XmlNode user_name = Seted_user.SelectSingleNode("user_name");
                DataRow dr;//行

                dr       = dt.NewRow();
                dr["id"] = id;
                string name_ = user_name.InnerText;
                dr["Name"] = name_;
                dt.Rows.Add(dr);//在表的对象的行里添加此行
            }
            dataGridView1.DataSource            = dt;
            dataGridView1.Columns[0].HeaderText = "编号";
            dataGridView1.Columns[1].HeaderText = "用户名";
        }
Exemple #2
0
        public int check()
        {
            int         response_num = 1;
            XmlDocument doc          = new XmlDocument();

            doc.Load("userInfo.xml");
            XmlNodeList all_user = doc.SelectSingleNode("userInfo").ChildNodes;

            foreach (XmlNode Seted_user in all_user)
            {
                XmlNode user_name = Seted_user.SelectSingleNode("user_name");
                if (textBox1.Text == user_name.InnerText)
                {
                    XmlNode user_password = Seted_user.SelectSingleNode("password");
                    if (user_password.InnerText == textBox2.Text)
                    {
                        response_num = 3;   //登录成功
                    }
                    else
                    {
                        response_num = 2;   //密码错误
                    }
                }
                else
                {
                    response_num = 1;       //无此用户
                }
            }
            return(response_num);
        }
Exemple #3
0
        public int check()
        {
            //首先验证是不是最高管理员
            if (textBox1.Text == "Admin" && textBox2.Text == "root")
            {
                GuanLiYuan.ma = true;
                return(3);
            }

            int         response_num = 0;
            XmlDocument doc          = new XmlDocument();

            doc.Load(xmlConnection.str);
            XmlNodeList all_user = doc.SelectSingleNode("userInfo").ChildNodes;

            foreach (XmlNode Seted_user in all_user)
            {
                XmlNode user_name = Seted_user.SelectSingleNode("user_name");
                if (textBox1.Text == user_name.InnerText)
                {
                    XmlNode user_password = Seted_user.SelectSingleNode("password");
                    if (user_password.InnerText == textBox2.Text)
                    {
                        response_num = 3;   //登录成功
                        break;
                    }
                    else
                    {
                        response_num = 2;   //密码错误
                        break;
                    }
                }
                else
                {
                    response_num = 1;       //无此用户
                }
            }
            return(response_num);
        }