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; } }
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); } } }
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; } }
internal void SaveAllToFile() { XmlDocument Doc = new XmlDocument(); Doc.Load(PathToFile); manager.SaveToNode(XmlNodeHelper.RequiredNode(Doc, XMLNodeManager)); Doc.Save(PathToFile); }
internal void LoadToManager() { XmlDocument Doc = new XmlDocument(); Doc.Load(PathToFile); manager.LoadFromNode(XmlNodeHelper.RequiredNode(Doc, XMLNodeManager)); RefreshTabEmployee(); RefreshTabProject(); RefreshTabCustomer(); }
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); }
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); } }