Пример #1
0
 private void ShowEmploee(Emploee empl)
 {
     List<string> data = new List<string>();
     string s = String.Empty;
     string t = String.Empty;
     //department
     s = "Department: ";
     t = empl.Department;
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //name
     s = "Name: ";
     t = empl.Name;
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //position
     t = empl.Position;
     s = "Position: ";
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //degree
     s = "Degree: ";
     t = empl.Degree;
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //rank
     s = "Rank(s): ";
     t = String.Empty;
     string[] ar = empl.rank.ToArray();
     if(ar!=null)
     {
         foreach(string st in ar)
         {
             if (t != String.Empty) { t = t + ", "; }
             t = t + st;
         }
     }
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //audience
     s = "Audience: ";
     t = empl.GetNumberOfAudience();
     if (empl.GetLetterOfAudience() != String.Empty)
     {
         t = t + " (" + empl.GetLetterOfAudience() + ")";
     }
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //phone
     s = "Phone: ";
     t = empl.GetPhone();
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     //interests
     s = "Interests: ";
     t = empl.Interests;
     if (t == String.Empty) { t = "-"; }
     s = s + t;
     data.Add(s);
     // data is seted
     string[] str = data.ToArray();
     foreach(string h in str)
     {
         resultRichTextBox1.AppendText(h+'\n');
     }
     resultRichTextBox1.AppendText("---------------------------------------------------------------------------\n");
 }
Пример #2
0
        static List<Emploee> FiltrByEmployee(List<Emploee> allEmpl, Emploee param)
        {
            List<Emploee> result = new List<Emploee>();
            if(allEmpl!=null)
            {
                foreach(Emploee e in allEmpl)
                {
                    try
                    {
                        if ((e.Name == param.Name || param.Name == String.Empty) &&
                            (e.Interests == param.Interests || param.Interests == String.Empty) &&
                            (e.Position == param.Position || param.Position == String.Empty) &&
                            (e.Department == param.Department || param.Department == String.Empty) &&
                            (e.Degree == param.Degree || param.Degree == String.Empty) &&
                            (e.GetPhone() == param.GetPhone() || param.GetPhone() == String.Empty) &&
                            ((e.GetLetterOfAudience() == param.GetLetterOfAudience() && e.GetNumberOfAudience() == param.GetNumberOfAudience()) || (param.GetNumberOfAudience() == String.Empty))

                            )
                        {
                            if (e.rank.Count <= 0 || param.rank.Count <=0)
                            {
                                result.Add(e);
                            }
                            else
                            {
                                if(e.rank.Contains(param.rank[0]))
                                    result.Add(e);
                            }
                        }
                    }
                    catch { }
                }
            }
            return result;
        }
Пример #3
0
 //DOM
 public static List<Emploee> SearchByDOM(Emploee empl)
 {
     List<List<Emploee>> allResults = new List<List<Emploee>>();
      try
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(@"C:\Users\nazar\Documents\Visual Studio 2013\Projects\Laba3\Base.xml");
         allResults.Add(SearchByDomDepartment(empl.Department, xmlDoc));
         allResults.Add(SearchByDomName(empl.Name, xmlDoc));
         allResults.Add(SearchByDomPosition(empl.Position, xmlDoc));
         allResults.Add(SearchByDomDegree(empl.Degree, xmlDoc));
         allResults.Add(SearchByDomAudience(empl.GetNumberOfAudience(), empl.GetLetterOfAudience(), xmlDoc));
         allResults.Add(SearchByDomPhone(empl.GetPhone(), xmlDoc));
         allResults.Add(SearchByDomInterests(empl.Interests, xmlDoc));
         if (empl.rank.Count > 0) { allResults.Add(SearchByDomRank((empl.rank.ToArray())[0], xmlDoc)); }
         else
         {
             allResults.Add(SearchByDomRank(String.Empty, xmlDoc));
         }
     }
     catch { }
     return CrossingOfResults(allResults);
 }
Пример #4
0
        public static List<Emploee> SearchByLINQ(Emploee empl)
        {
            List<Emploee> results = new List<Emploee>();
            XDocument docXML = XDocument.Load(@"C:\Users\nazar\Documents\Visual Studio 2013\Projects\Laba3\Base.xml");
            var result = (from obj in docXML.Descendants("employee")
                          where (

                          (empl.Name == String.Empty || empl.Name == obj.Attribute("NAME").Value) &&
                          (empl.Position == String.Empty || empl.Position == obj.Attribute("POSITION").Value) &&
                          (empl.Degree == String.Empty || empl.Degree == obj.Attribute("DEGREE").Value) &&
                          ((empl.GetLetterOfAudience() == CutNumbers(obj.Attribute("AUDIENCE").Value) &&
                          empl.GetNumberOfAudience() == Emploee.GetOnlyNumbersFromPhone(obj.Attribute("AUDIENCE").Value)) ||
                          empl.GetNumberOfAudience() == String.Empty) &&
                          (empl.GetPhone() == String.Empty || empl.GetPhone() == Emploee.GetOnlyNumbersFromPhone( obj.Attribute("PHONE").Value)) &&
                          (empl.Interests == String.Empty || empl.Interests == obj.Attribute("INTERESTS").Value) &&
                          (empl.Department == String.Empty || empl.Department == obj.Parent.Attribute("NANE").Value) &&
                          (empl.rank.Count <= 0 || obj.Descendants().Any(elem => (elem.Attribute("RANK").Value == empl.rank[0])))

                          )

                          select obj
                                      ).ToList();

            foreach(var r in result)
            {
                Emploee e = new Emploee();
                e.Name = r.Attribute("NAME").Value;
                e.Position = r.Attribute("POSITION").Value;
                e.Degree = r.Attribute("DEGREE").Value;
                e.Department = r.Parent.Attribute("NANE").Value;
                e.SetAudience(Emploee.GetOnlyNumbersFromPhone(r.Attribute("AUDIENCE").Value), CutNumbers(r.Attribute("AUDIENCE").Value));
                e.SetPhone(r.Attribute("PHONE").Value);
                e.Interests = r.Attribute("INTERESTS").Value;
                var ranks = r.Descendants();
                foreach(var rank in ranks)
                {
                    e.rank.Add(rank.Attribute("RANK").Value);
                }
                results.Add(e);
            }

            return results;
        }