Beispiel #1
0
        public bool addMember(string username, string password)
        {
            bool    result      = false;
            string  encryptPass = DllCrypto.Class1.Encrypt(password);
            Accound addMember   = new Accound();

            addMember.UserName = username;
            addMember.Password = encryptPass;
            string      addData = HttpRuntime.AppDomainAppPath + "App_Data/Member.xml";
            XmlDocument xd      = new XmlDocument();

            xd.Load(addData);
            try
            {
                XElement xml = XElement.Load(addData);
                xml.Add(new XElement("Member",
                                     new XElement("user_name", addMember.UserName),
                                     new XElement("password", addMember.Password)
                                     ));
                result = true;
                xml.Save(addData);
            }
            catch (Exception ex)
            {
                result = false;
            }



            return(result);
        }
Beispiel #2
0
        public string addAcoundt(string username, string password, int role)
        {
            string result = "";
            string xmlFile = null;
            string PaM = "", pa = "";

            if (role == 1)
            {
                xmlFile = "Member.xml";
                PaM     = "Members/Member/";
                pa      = "Member";
            }
            else if (role == 2)
            {
                xmlFile = "Staff.xml";
                PaM     = "Staffs/Staff/";
                pa      = "Staff";
            }

            string  encryptPass = DllCrypto.Class1.Encrypt(password);
            Accound addMember   = new Accound();

            addMember.UserName = username;
            addMember.Password = encryptPass;
            string      addData = HttpRuntime.AppDomainAppPath + "App_Data/" + xmlFile;
            XmlDocument xd      = new XmlDocument();

            xd.Load(addData);
            //XmlNode user_node = xd.CreateElement()
            XmlNodeList userList = xd.SelectNodes(PaM + "user_name");

            foreach (XmlNode user in userList)
            {
                if (user.InnerText == username)
                {
                    return(result = "exist");
                }
            }

            try
            {
                XElement xml = XElement.Load(addData);
                xml.Add(new XElement(pa,
                                     new XElement("user_name", addMember.UserName),
                                     new XElement("password", addMember.Password)
                                     ));

                xml.Save(addData);
                return(result = "success");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
            //return result;
        }