Ejemplo n.º 1
0
        /// <summary>
        ///  Rearrange the employees collection as a manager-subemployee nested tree
        /// </summary>
        /// <param name="htemployees">Employee table</param>
        /// <returns>returns the sorted list</returns>
        protected ArrayList GetSortedEmployeesList(Hashtable htemployees)
        {
            ICollection employees  = htemployees.Values;
            ArrayList   sortedlist = new ArrayList();

            foreach (Employee_CS emply in employees)
            {
                if (emply.ManagerID == string.Empty)
                {
                    // Employees without a ManagerID are top-level nodes in the org tree
                    sortedlist.Add(emply);
                }
                else
                {
                    // Find the employee instance associated with the managerID and add this object as
                    // a subemployee of the manager node.
                    Employee_CS manager = (Employee_CS)htemployees[emply.ManagerID];
                    if (manager != null)
                    {
                        manager.SubEmployees.Add(emply);
                    }
                }
            }

            return(sortedlist);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Read the data from the XML file
        /// </summary>
        /// <param name="datasrc">Path of the XML File</param>
        /// <returns>returns the employee table</returns>
        protected Hashtable ReadEmployeeDataFromXMLFile(string datasrc)
        {
            Hashtable lstEmployee = new Hashtable();

            // Use the XML DOM to read data from the employees XML data file
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(datasrc);
            if (xmldoc.DocumentElement.HasChildNodes)
            {
                XmlNodeList employeelist = xmldoc.DocumentElement.ChildNodes;
                for (int i = 0; i < employeelist.Count; i++)
                {
                    // Create an Employee instance to represent each employee
                    Employee_CS emply = new Employee_CS();

                    XmlNode     employeenode     = employeelist[i];
                    XmlNodeList employeedatalist = employeenode.ChildNodes;
                    IEnumerator employeedata     = employeedatalist.GetEnumerator();
                    employeedata.Reset();
                    while (employeedata.MoveNext())
                    {
                        XmlNode dataelement = employeedata.Current as XmlNode;
                        switch (dataelement.Name)
                        {
                        case "Name":
                            emply.EmployeeName = "Name :" + dataelement.InnerText;
                            break;

                        case "EmployeeID":
                            emply.EmployeeID    = dataelement.InnerText;
                            emply.EmployeeName += System.Environment.NewLine + "Emp ID :" + dataelement.InnerText;
                            break;

                        case "Designation":
                            emply.Designation   = dataelement.InnerText;
                            emply.EmployeeName += System.Environment.NewLine + "Des :" + dataelement.InnerText;
                            break;

                        case "DOJ":
                            emply.DOJ           = dataelement.InnerText;
                            emply.EmployeeName += System.Environment.NewLine + "DOJ :" + dataelement.InnerText;
                            break;

                        case "ImageNo":
                            emply.ImageName = dataelement.InnerText;
                            break;

                        case "ManagerID":
                            emply.ManagerID = dataelement.InnerText;
                            break;
                        }
                    }
                    lstEmployee.Add(emply.EmployeeID, emply);
                }
            }

            return(lstEmployee);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// generates the sub employees count
 /// </summary>
 /// <param name="empl">Employee business object</param>
 protected void IterUpdateSubEmployeeCount(Employee_CS empl)
 {
     empl.RecSubEmployeeCount = empl.SubEmployees.Count;
     foreach (Employee_CS subempl in empl.SubEmployees)
     {
         this.IterUpdateSubEmployeeCount(subempl);
         empl.RecSubEmployeeCount += subempl.RecSubEmployeeCount;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        ///  Iterative sub-employee symbol node creation
        /// </summary>
        /// <param name="emply">Employess business object</param>
        /// <param name="emplysymbol">Employee Node</param>
        protected void IterCreateEmployeeSymbol(Employee_CS emply, EmpSymbol emplysymbol)
        {
            foreach (Employee_CS subemply in emply.SubEmployees)
            {
                String fileName = @"..\..\..\..\..\..\..\Common\Images\Diagram\OrgChart Layout\" + subemply.ImageName + ".png";
                // Create a EmployeeSymbol for each of the sub-employees of the particular employee //Waterfall, Horizontal
                EmpSymbol subemplysymbol = new EmpSymbol(fileName);
                subemplysymbol.LineStyle.LineColor = Color.LightSkyBlue;
                subemplysymbol.EmployeeName        = emply.EmployeeName;
                this.diagram1.Model.AppendChild(subemplysymbol);

                emplysymbol.EnableCentralPort    = true;
                subemplysymbol.EnableCentralPort = true;
                ConnectNodes(emplysymbol, subemplysymbol);

                this.IterCreateEmployeeSymbol(subemply, subemplysymbol);
            }
        }