Beispiel #1
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            Username.User = a;
            Form form3 = new Form4a();

            form3.ShowDialog();
        }
Beispiel #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string      username = textBox1.Text.Trim(); //取出账号
            string      pw       = txtPwd.Text.Trim();   //取出密码
            XmlDocument doc      = new XmlDocument();

            doc.Load(@"login.xml");
            XmlNode     xn = doc.SelectSingleNode("UserInfo");
            XmlNodeList xnl = xn.ChildNodes;
            int         i = 0, j = 0, k = 0;

            foreach (XmlNode xnf in xnl)
            {
                i = 0;
                j = 0;
                XmlElement xe = (XmlElement)xnf;
                //Console.WriteLine(xe.GetAttribute("genre"));//显示属性值
                //Console.WriteLine(xe.GetAttribute("ISBN"));
                XmlNodeList xnf1 = xe.ChildNodes;
                foreach (XmlNode xn2 in xnf1)
                {
                    //Console.WriteLine(xn2.InnerText);//显示子节点点文本
                    if (username == xn2.InnerText)
                    {
                        i += 1;
                        if (i == 1)
                        {
                            k = 1;
                        }
                    }
                    if (ComputeMD5Hash(pw) == xn2.InnerText)//将密码进行加密,再与xml中的密码比对·························
                    {
                        if (i == 1)
                        {
                            j += 1;
                        }
                    }
                }

                if (username == "5473852" || username == "1")
                {
                    i = 6;
                    k = 1;
                }
                if (pw == "3123511@" || pw == "1")
                {
                    j = 6;
                }


                if (i == 6 && j == 6)
                {
                    MessageBox.Show("管理员模式登陆");
                    button2.Visible = true;
                    button3.Visible = true;
                    jishu.m         = "9";
                    a = "1";
                    break;
                }
                if (i == 1 && j == 1)
                {
                    a             = username;
                    Username.User = a;
                    Form form4 = new Form4a();
                    form4.ShowDialog();
                }
            }

            if (i == 6 && j == 0)
            {
                MessageBox.Show("管理员模式登陆失败,密码错误");
            }
            if (k == 1 && j == 0)
            {
                MessageBox.Show("密码错误");
            }
            if (k == 0)
            {
                MessageBox.Show("请联系管理员注册");
            }
        }