Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        public void SaveToNode(XmlNode projectNode)
        {
            XmlNodeHelper.SetNodeAttributeI(projectNode, XMLNodeAttributeID, this.ProjectID);
            XmlNodeHelper.SetNodeAttribute(projectNode, XMLProjectAttributeName, this.Name);
            XmlNodeHelper.SetNodeAttribute(projectNode, XMLProjectAttributeDateAgreement, this.DateAgreement.ToString(DateFormat));
            XmlNodeHelper.SetNodeAttributeF(projectNode, XMLProjectAttributeCost, this.Cost);
            XmlNodeHelper.SetNodeAttribute(projectNode, XMLProjectAttributeStatus, this.Status.ToString());
            XmlNodeHelper.SetNodeAttribute(projectNode, XMLProjectAttributeCustomer, this.CustomerID.ToString());

            for (int i = 0; i < this.EmployeesID.Count; i++)
            {
                XmlNode projectEmployeeNode = XmlNodeHelper.RequiredNode(projectNode, Project.XMLNodeEmployee,
                                                                         Project.XmlAttributeEmployeeID, this.EmployeesID[i].ToString());
            }

            XmlNodeList xmlProjectList = projectNode.SelectNodes(Project.XMLNodeEmployee);

            foreach (XmlNode node in xmlProjectList)
            {
                int employeeInProjectId = XmlNodeHelper.GetNodeAttributeI(node, Project.XmlAttributeEmployeeID);
                if (this.EmployeesID.IndexOf(employeeInProjectId) < 0)
                {
                    node.ParentNode.RemoveChild(node);
                }
            }
        }
Esempio 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);
                }
            }
        }
Esempio n. 4
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;
            }
        }
Esempio 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;
            }
        }
Esempio n. 6
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);
                }
            }
        }
Esempio n. 7
0
        internal void SaveAllToFile()
        {
            XmlDocument Doc = new XmlDocument();

            Doc.Load(PathToFile);
            manager.SaveToNode(XmlNodeHelper.RequiredNode(Doc, XMLNodeManager));
            Doc.Save(PathToFile);
        }
Esempio n. 8
0
 public void SaveToNode(XmlNode customerNode)
 {
     XmlNodeHelper.SetNodeAttributeI(customerNode, XMLCustomerAttributeID, this.CustomerID);
     XmlNodeHelper.SetNodeAttribute(customerNode, XMLCustomerAttributeName, this.Name);
     XmlNodeHelper.SetNodeAttribute(customerNode, XMLCustomerAttributeSurname, this.Surname);
     XmlNodeHelper.SetNodeAttribute(customerNode, XMLCustomerAttributeCountry, this.Country);
     XmlNodeHelper.SetNodeAttribute(customerNode, XMLCustomerAttributeDateAgreement, this.DateOfAgreement.ToString(DateFormat));
 }
Esempio n. 9
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);
 }
Esempio n. 10
0
 public void SaveToNode(XmlNode employeeNode)
 {
     XmlNodeHelper.SetNodeAttributeI(employeeNode, XMLEmployeeAttributeID, this.EmployeeID);
     XmlNodeHelper.SetNodeAttribute(employeeNode, XMLEmployeeAttributeName, this.Name);
     XmlNodeHelper.SetNodeAttribute(employeeNode, XMLEmployeeAttributeSurname, this.Surname);
     XmlNodeHelper.SetNodeAttribute(employeeNode, XMLEmployeeAttributeDateOfEmployeement, this.DateOfEmployment.ToString(DateFormat));
     XmlNodeHelper.SetNodeAttributeF(employeeNode, XMLEmployeeAttributeSalary, this.Salary);
 }
Esempio n. 11
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);
 }
Esempio n. 12
0
        internal void LoadToManager()
        {
            XmlDocument Doc = new XmlDocument();

            Doc.Load(PathToFile);
            manager.LoadFromNode(XmlNodeHelper.RequiredNode(Doc, XMLNodeManager));
            RefreshTabEmployee();
            RefreshTabProject();
            RefreshTabCustomer();
        }
Esempio n. 13
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));
     }
 }
Esempio n. 14
0
        public void SaveToNode(XmlNode managerNode)
        {
            XmlNode employeesNode = XmlNodeHelper.RequiredNode(managerNode, Employees.XMLNodeEmployees);

            Employees.SaveToNode(employeesNode);

            XmlNode customersNode = XmlNodeHelper.RequiredNode(managerNode, Customers.XMLNodeCustomers);

            Customers.SaveToNode(customersNode);

            XmlNode projectsNode = XmlNodeHelper.RequiredNode(managerNode, Projects.XMLNodeProjects);

            Projects.SaveToNode(projectsNode);
        }
Esempio n. 15
0
        internal void SaveToNode(XmlNode employeesNode)
        {
            XmlNodeList xmlEmployeesList = employeesNode.SelectNodes(Employee.XMLNodeEmployee);

            foreach (XmlNode node in xmlEmployeesList)
            {
                int employeeID = XmlNodeHelper.GetNodeAttributeI(node, Employee.XMLEmployeeAttributeID);
                if (this.ListEmployees.IndexOf(this.GetEmployeeByID(employeeID)) < 0)
                {
                    node.ParentNode.RemoveChild(node);
                }
            }

            for (var i = 0; i < this.Count; i++)
            {
                Employee employee     = this[i];
                XmlNode  employeeNode = XmlNodeHelper.RequiredNode(employeesNode, Employee.XMLNodeEmployee,
                                                                   Employee.XMLEmployeeAttributeID, employee.EmployeeID.ToString());
                employee.SaveToNode(employeeNode);
            }
        }