Exemple #1
0
        public static void findbypubl(string value, bool ispart, DataGridView datagrid, data dat, E_library main)
        {
            Regex regexp   = new Regex(@"\w*" + value + @"\w*");
            data  finddata = new data();

            if (ispart == false)
            {
                foreach (Library lb in dat.lbr)
                {
                    if (lb.publ == value)
                    {
                        ObjArr.Add(lb, datagrid, finddata);
                    }
                }
            }
            else
            {
                foreach (Library lb in dat.lbr)
                {
                    if (/*Regex.IsMatch(lb.publ, value)*/ regexp.Matches(lb.publ).Count != 0)
                    {
                        ObjArr.Add(lb, datagrid, finddata);
                    }
                }
            }
            main.findresult = finddata;
        }
Exemple #2
0
        public static void findbydiappages(int firstpos, int secpos, DataGridView datagrid, data dat, E_library main)//complete
        {
            data finddata = new data();
            int  start;
            int  stop;

            if (firstpos > secpos)
            {
                start = secpos;
                stop  = firstpos;
            }
            else
            {
                start = firstpos;
                stop  = secpos;
            }
            foreach (Library lb in dat.lbr)
            {
                if (lb.count_of_pages >= start && lb.count_of_pages <= stop)
                {
                    ObjArr.Add(lb, datagrid, finddata);
                }
            }
            main.findresult = finddata;
        }
Exemple #3
0
        private void датеЗагрузкиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            XDocument xdoc = XDocument.Load(@"C:\Users\илья\Desktop\OOP\labs\lab3\data.xml");
            Dictionary <int, double> sortarr = new Dictionary <int, double>();
            data sorteddata = new data();
            int  i          = 0;

            foreach (XElement elem in xdoc.Element("ArrayOfLibrary").Elements("Library"))
            {
                string dat    = elem.Element("dataLoad").Value;
                string datcut = "";
                for (int l = 0; l < 10; l++)
                {
                    datcut += dat[l];
                }
                string[] datarr = datcut.Split('-');
                int      y;
                int      m;
                int      d;
                Int32.TryParse(datarr[0], out y);
                Int32.TryParse(datarr[1], out m);
                Int32.TryParse(datarr[2], out d);
                DateTime dt0     = new DateTime();
                DateTime dtt     = new DateTime(y, m, d);
                TimeSpan ts      = dtt.Subtract(dt0);
                double   seconds = ts.TotalSeconds;
                sortarr.Add(i, seconds);
                i++;
            }
            sortarr = sortarr.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
            XElement element = xdoc.Element("ArrayOfLibrary");
            int      index;

            dataGridView3.Rows.Clear();
            for (int l = 0; l < sortarr.Count; l++)
            {
                index = sortarr.ElementAt(l).Key;
                XElement elements     = element.Elements("Library").ElementAt(index);
                XElement formatement  = elements.Element("format");
                XElement flsizeement  = elements.Element("file_size");
                XElement nameement    = elements.Element("name");
                XElement udkement     = elements.Element("uDK");
                XElement copement     = elements.Element("count_of_pages");
                XElement publement    = elements.Element("publ");
                XElement yearelement  = elements.Element("year");
                XElement dtloadement  = elements.Element("dataLoad");
                XElement idement      = elements.Element("author").Element("id");
                XElement fioement     = elements.Element("author").Element("FIO");
                XElement countryement = elements.Element("author").Element("country");
                DateTime dtt;
                DateTime.TryParse(dtloadement.ToString(), out dtt);
                Library lbr = new Library(formatement.Value, (int)flsizeement, nameement.Value, udkement.Value, (int)copement, publement.Value, (int)yearelement, dtt, (int)idement, fioement.Value, countryement.Value);
                ObjArr.Add(lbr, dataGridView3, sorteddata);
            }
            sortresult = sorteddata;
        }
Exemple #4
0
 private void delete_book_Click(object sender, EventArgs e)
 {
     if (dataGridView1.Rows.Count != 0)
     {
         int selectedRow = dataGridView1.CurrentRow.Index;
         dataGridView1.Rows.RemoveAt(selectedRow);
         ObjArr.delete(selectedRow, dat);
     }
     else
     {
         MessageBox.Show("Таблица пуста");
     }
 }
Exemple #5
0
        private void load_Click(object sender, EventArgs e)
        {
            try
            {
                ObjArr.clear(dat, dataGridView1);
                XmlSerializer xs = new XmlSerializer(typeof(List <Library>));

                StreamReader sr = new StreamReader(@"C:\Users\илья\Desktop\OOP\labs\lab3\data.xml");
                dat.lbr = (List <Library>)xs.Deserialize(sr);
                ObjArr.print(dataGridView1, dat.lbr);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Deserialisation Error: " + ex.Message);
            }
        }
Exemple #6
0
        //сортировка
        private void годуИзданияToolStripMenuItem_Click(object sender, EventArgs e)
        {
            XDocument             xdoc    = XDocument.Load(@"C:\Users\илья\Desktop\OOP\labs\lab3\data.xml");
            Dictionary <int, int> sortarr = new Dictionary <int, int>();
            data sorteddata = new data();
            int  i          = 0;

            foreach (XElement element in xdoc.Element("ArrayOfLibrary").Elements("Library"))
            {
                XElement yearelement = element.Element("year");
                sortarr.Add(i, (int)yearelement);
                i++;
            }
            sortarr = sortarr.OrderBy(pair => pair.Value).ToDictionary(pair => pair.Key, pair => pair.Value);
            int      index;
            XElement selement = xdoc.Element("ArrayOfLibrary");

            dataGridView3.Rows.Clear();
            for (int l = 0; l < sortarr.Count; l++)
            {
                index = sortarr.ElementAt(l).Key;
                XElement elements     = selement.Elements("Library").ElementAt(index);
                XElement formatement  = elements.Element("format");
                XElement flsizeement  = elements.Element("file_size");
                XElement nameement    = elements.Element("name");
                XElement udkement     = elements.Element("uDK");
                XElement copement     = elements.Element("count_of_pages");
                XElement publement    = elements.Element("publ");
                XElement yearelement  = elements.Element("year");
                XElement dtloadement  = elements.Element("dataLoad");
                XElement idement      = elements.Element("author").Element("id");
                XElement fioement     = elements.Element("author").Element("FIO");
                XElement countryement = elements.Element("author").Element("country");
                DateTime dtt;
                DateTime.TryParse(dtloadement.ToString(), out dtt);
                Library lbr = new Library(formatement.Value, (int)flsizeement, nameement.Value, udkement.Value, (int)copement, publement.Value, (int)yearelement, dtt, (int)idement, fioement.Value, countryement.Value);

                ObjArr.Add(lbr, dataGridView3, sorteddata);
            }
            sortresult = sorteddata;
        }
Exemple #7
0
        public static void findbyyear(string value, DataGridView datagrid, data dat, E_library main)
        {
            int  val;
            data finddata = new data();

            if (Int32.TryParse(value, out val) == true && val > 0)
            {
                foreach (Library lb in dat.lbr)
                {
                    if (lb.year == val)
                    {
                        ObjArr.Add(lb, datagrid, finddata);
                    }
                }
                main.findresult = finddata;
            }
            else
            {
                MessageBox.Show("Ошибка. Введено не число");
            }
        }
Exemple #8
0
 private void ADD_Click(object sender, EventArgs e)
 {
     try
     {
         string   format  = fileFormatBox.Text;
         int      fl_sz   = Convert.ToInt32(sizebookBox.Text);
         string   name    = namebookBox.Text;
         string   udk     = UDKBox.Text;
         int      c_o_p   = Convert.ToInt32(pagescountBox.Text);
         string   publ    = publBox.Text;
         int      year    = Convert.ToInt32(yearBox.Value);
         DateTime dt      = dateTimePickerBox.Value.Date;
         string   fio     = FIOBox.Text;
         string   country = CountryBox.Text;
         int      id      = (int)idBox.Value;
         Library  lib     = new Library(format, fl_sz, name, udk, c_o_p, publ, year, dt, id, fio, country);
         ObjArr.Add(lib, dataGridView1, dat);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка во введенных данных. " + ex.Message);
     }
 }