Example #1
0
File: Finder.cs Project: NKhol/Labs
 private static Emploee GetDataAboutEmploee(XmlNode em)
 {
     Emploee e = new Emploee();
     XmlAttributeCollection at = em.Attributes;
     e.Department = em.ParentNode.Attributes[1].Value;
     e.Name = at[1].Value;
     e.Position = at[2].Value;
     e.Degree = at[3].Value;
     e.SetAudience(Emploee.GetOnlyNumbersFromPhone(at[4].Value), CutNumbers(at[4].Value));
     e.SetPhone(at[5].Value);
     e.Interests = at[6].Value;
     XmlNodeList r = em.ChildNodes;
     foreach (XmlNode v in r)
     {
         e.rank.Add(v.Attributes[0].Value);
     }
     return e;
 }
Example #2
0
File: Form1.cs Project: NKhol/Labs
        private Emploee ReadParameters()
        {
            Emploee empl = new Emploee();
            if (departmentCheckBox.Checked)
            {
                if (comboBox1.SelectedItem != null)
                {
                    empl.Department = comboBox1.SelectedItem.ToString();
                }
            }
            if (nameCheckBox.Checked) { empl.Name = nameTextBox1.Text; }
            if (degreeCheckBox1.Checked) { empl.Degree = degreeTextBox1.Text; }
            if (positionCheckBox.Checked) { empl.Position = positionTextBox2.Text; }
            if (rankCheckBox1.Checked)
            {
                string[]ranks = rankTextBox1.Text.Split(new Char[]{',','.',';'});
                if(ranks!=null)
                {
                    foreach(string s in ranks)
                    {
                        empl.rank.Add(s);
                    }
                }
                else
                {
                    empl.rank.Add(String.Empty);
                }
            }
            if (audienceCheckBox1.Checked)
            {
                empl.SetAudience(audienceNumericUpDown1.Value.ToString(), null);
                if (letterCheckBox1.Checked)
                {
                    empl.SetAudience(audienceNumericUpDown1.Value.ToString(), letterTextBox2.Text);
                }
            }
            if (phoneCheckBox1.Checked)
            {
                empl.SetPhone(phoneTextBox2.Text);
            }
            if (interestsCheckBox1.Checked)
            {
                empl.Interests = interestsTextBox1.Text;
            }

            return empl;
        }
Example #3
0
File: Finder.cs Project: NKhol/Labs
        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;
        }