示例#1
0
 public finalproject.User.Users GetUsersDetails(string userId)
 {
     try
     {
         XElement outPut = null;
         if (File.Exists(USER_DATA))
         {
             XElement doc = XElement.Load(USER_DATA);
             IEnumerable <XElement> childList =
                 from el in doc.Descendants("user")
                 where (string)el.Element("userId") == userId
                 select el;
             foreach (XElement e in childList)
             {
                 outPut = e;
             }
             finalproject.User.Users userObject = new finalproject.User.Users(outPut.Element("firstName").Value, outPut.Element("lastName").Value, outPut.Element("phone").Value, outPut.Element("email").Value, outPut.Element("password").Value, outPut.Element("education").Value, outPut.Element("address1").Value, outPut.Element("address2").Value, outPut.Element("city").Value, outPut.Element("province").Value, outPut.Element("zipCode").Value, outPut.Element("jobType").Value);
             return(userObject);
         }
         else
         {
             throw new System.ArgumentException("Configuration error!", "original");
         }
     }
     catch (Exception ex)
     {
         throw new System.ArgumentException(ex.ToString(), "original");
     }
 }
 private Users UserData()
 {
     try
     {
         XElement outPut = null;
         if (File.Exists(USER_SESSION))
         {
             XElement doc = XElement.Load(USER_SESSION);
             outPut = doc.Element("user");
             finalproject.User.Users userObject = new finalproject.User.Users(outPut.Element("firstName").Value, outPut.Element("lastName").Value, outPut.Element("phone").Value, outPut.Element("email").Value, outPut.Element("password").Value, outPut.Element("education").Value, outPut.Element("address1").Value, outPut.Element("address2").Value, outPut.Element("city").Value, outPut.Element("province").Value, outPut.Element("zipCode").Value, outPut.Element("jobType").Value);
             //this.userObject =  userObject;
             MessageBox.Show(userObject.FirstName);
             return(userObject);
         }
         else
         {
             MessageBox.Show("File does not exuxts");
             return(userObject);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(userObject);
     }
 }