Exemplo n.º 1
0
        internal void SaveToNode(XmlNode projectsNode)
        {
            XmlNodeList xmlProjectList = projectsNode.SelectNodes(Project.XMLNodeProject);

            foreach (XmlNode node in xmlProjectList)
            {
                int projectID = int.Parse(XmlNodeHelper.GetNodeAttribute(node, Project.XMLNodeAttributeID));
                if (this.ListProjects.IndexOf(this.GetProjectByID(projectID)) < 0)
                {
                    node.ParentNode.RemoveChild(node);
                }
            }

            if (this.Count != 0)
            {
                for (var i = 0; i < this.Count; i++)
                {
                    Project project     = this[i];
                    XmlNode projectNode = XmlNodeHelper.RequiredNode(projectsNode, Project.XMLNodeProject,
                                                                     Project.XMLNodeAttributeID, project.ProjectID.ToString());
                    project.SaveToNode(projectNode);
                }
            }
            else
            {
                projectsNode = null;
            }
        }
Exemplo n.º 2
0
        internal void LoadFromNode(XmlNode employeesNode)
        {
            XmlNodeList xmlEmployeeList = employeesNode.SelectNodes(Employee.XMLNodeEmployee);

            foreach (XmlNode employeeNode in xmlEmployeeList)
            {
                var      attributeID = XmlNodeHelper.GetNodeAttribute(employeeNode, Employee.XMLEmployeeAttributeID);
                Employee employee    = this.GetEmployeeByID(int.Parse(attributeID));
                if (employee == null)
                {
                    employee = new Employee(this.Manager);
                    this.Add(employee);
                }
                employee.LoadFromNode(employeeNode);
            }

            for (int i = this.Count - 1; i >= 0; i--)
            {
                var    employee = this[i];
                string xPath    = Employee.XMLNodeEmployee + String.Format("[@{0}='{1}']", Employee.XMLEmployeeAttributeID, employee.EmployeeID.ToString());
                var    res      = employeesNode.SelectSingleNode(xPath);
                if (res == null)
                {
                    this.Remove(employee);
                }
            }
        }
Exemplo n.º 3
0
        internal void LoadFromNode(XmlNode projectsNode)
        {
            XmlNodeList xmlProjectList = projectsNode.SelectNodes(Project.XMLNodeProject);

            foreach (XmlNode projectNode in xmlProjectList)
            {
                var     attributeID = XmlNodeHelper.GetNodeAttribute(projectNode, Project.XMLNodeAttributeID);
                Project project     = this.GetProjectByID(int.Parse(attributeID));
                if (project == null)
                {
                    project = new Project(this.Manager);
                    this.Add(project);
                }
                project.LoadFromNode(projectNode);
            }

            for (int i = this.Count - 1; i >= 0; i--)
            {
                var    project = this[i];
                string xPath   = Project.XMLNodeProject + String.Format("[@{0}='{1}']", Project.XMLNodeAttributeID, project.ProjectID.ToString());
                var    res     = projectsNode.SelectSingleNode(xPath);
                if (res == null)
                {
                    this.Remove(project);
                }
            }
        }
Exemplo n.º 4
0
        internal void LoadFromNode(XmlNode customersNode)
        {
            XmlNodeList xmlCustomerList = customersNode.SelectNodes(Customer.XMLNodeCustomer);

            foreach (XmlNode customerNode in xmlCustomerList)
            {
                var      attributeID = XmlNodeHelper.GetNodeAttribute(customerNode, Customer.XMLCustomerAttributeID);
                Customer customer    = this.GetCustomerByID(int.Parse(attributeID));
                if (customer == null)
                {
                    customer = new Customer(this.Manager);
                    this.Add(customer);
                }
                customer.LoadFromNode(customerNode);
            }

            for (int i = this.Count - 1; i >= 0; i--)
            {
                var    customer = this[i];
                string xPath    = Customer.XMLNodeCustomer + String.Format("[@{0}='{1}']", Customer.XMLCustomerAttributeID, customer.CustomerID.ToString());
                var    res      = customersNode.SelectSingleNode(xPath);
                if (res == null)
                {
                    this.Remove(customer);
                }
            }
        }
Exemplo n.º 5
0
        internal void SaveToNode(XmlNode customersNode)
        {
            XmlNodeList xmlCustomerList = customersNode.SelectNodes(Customer.XMLNodeCustomer);

            foreach (XmlNode node in xmlCustomerList)
            {
                int customerID = int.Parse(XmlNodeHelper.GetNodeAttribute(node, Customer.XMLCustomerAttributeID));
                if (this.ListCustomers.IndexOf(this.GetCustomerByID(customerID)) < 0)
                {
                    node.ParentNode.RemoveChild(node);
                }
            }

            if (this.Count != 0)
            {
                for (var i = 0; i < this.Count; i++)
                {
                    Customer customer     = this[i];
                    XmlNode  customerNode = XmlNodeHelper.RequiredNode(customersNode, Customer.XMLNodeCustomer,
                                                                       Customer.XMLCustomerAttributeID, customer.CustomerID.ToString());
                    customer.SaveToNode(customerNode);
                }
            }
            else
            {
                customersNode = null;
            }
        }
Exemplo n.º 6
0
 public void LoadFromNode(XmlNode customerNode)
 {
     this.CustomerID      = XmlNodeHelper.GetNodeAttributeI(customerNode, XMLCustomerAttributeID);
     this.Name            = XmlNodeHelper.GetNodeAttribute(customerNode, XMLCustomerAttributeName);
     this.Surname         = XmlNodeHelper.GetNodeAttribute(customerNode, XMLCustomerAttributeSurname);
     this.Country         = XmlNodeHelper.GetNodeAttribute(customerNode, XMLCustomerAttributeCountry);
     this.DateOfAgreement = XmlNodeHelper.GetNodeAttributeDT(customerNode, XMLCustomerAttributeDateAgreement, DateFormat);
 }
Exemplo n.º 7
0
 public void LoadFromNode(XmlNode employeeNode)
 {
     this.EmployeeID       = XmlNodeHelper.GetNodeAttributeI(employeeNode, XMLEmployeeAttributeID);
     this.Name             = XmlNodeHelper.GetNodeAttribute(employeeNode, XMLEmployeeAttributeName);
     this.Surname          = XmlNodeHelper.GetNodeAttribute(employeeNode, XMLEmployeeAttributeSurname);
     this.DateOfEmployment = XmlNodeHelper.GetNodeAttributeDT(employeeNode, XMLEmployeeAttributeDateOfEmployeement, DateFormat);
     this.Salary           = XmlNodeHelper.GetNodeAttributeF(employeeNode, XMLEmployeeAttributeSalary);
 }
Exemplo n.º 8
0
 public void LoadFromNode(XmlNode projectNode)
 {
     this.ProjectID     = XmlNodeHelper.GetNodeAttributeI(projectNode, XMLNodeAttributeID);
     this.Name          = XmlNodeHelper.GetNodeAttribute(projectNode, XMLProjectAttributeName);
     this.DateAgreement = XmlNodeHelper.GetNodeAttributeDT(projectNode, XMLProjectAttributeDateAgreement, DateFormat);
     this.Cost          = XmlNodeHelper.GetNodeAttributeF(projectNode, XMLProjectAttributeCost);
     this.Status        = (ProjestStatus)Enum.Parse(typeof(ProjestStatus), XmlNodeHelper.GetNodeAttribute(projectNode, XMLProjectAttributeStatus).ToString());
     this.CustomerID    = XmlNodeHelper.GetNodeAttributeI(projectNode, XMLProjectAttributeCustomer);
     for (XmlNode node = projectNode.FirstChild; node != null; node = node.NextSibling)
     {
         this.EmployeesID.Add(XmlNodeHelper.GetNodeAttributeI(node, XmlAttributeEmployeeID));
     }
 }