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