コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            DatManage  datManage  = new DatManage();
            PersonList personList = new PersonList();

            personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
            ListBooks listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");

            if (personList.People.Count > 0)
            {
                foreach (var el in personList.People)
                {
                    if (el.HaveBook.Count > 0)
                    {
                        Authorization authorization = new Authorization();
                        authorization.comboBox1.Visible = true;
                        authorization.listView1.Visible = true;
                        authorization.label1.Text       = "Выберите читателя: ";
                        authorization.TakeOrGetBtn.Text = "Сдать";

                        authorization.textNamePersonFields.Visible = false;

                        foreach (var ell in personList.People)
                        {
                            authorization.comboBox1.Items.Add(ell.Name);
                        }

                        if (authorization.ShowDialog() == DialogResult.OK)
                        {
                            Book book = personList.People[authorization.ind1].HaveBook[authorization.ind2];
                            listBooks.Books.Add(book);
                            personList.People[authorization.ind1].HaveBook.RemoveAt(authorization.ind2);



                            datManage.SerializeXML(personList, "PERSONS.xml");
                            datManage.SerializeXML(listBooks, "LISTBOOKS.xml");
                            authorization.comboBox1.Visible = false;
                            authorization.listView1.Visible = false;
                        }
                        authorization.label1.Text       = "Введите имя: ";
                        authorization.TakeOrGetBtn.Text = "Взять";
                        UpdateListViev();
                        UpdateCombobox();
                        break;
                    }
                    else
                    {
                        MessageBox.Show("Нет персон, которие не здалы книги!", "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Нет персон!", "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            try
            {
                if (listView1.FocusedItem.Index <= 0)
                {
                }
                if (DialogResult.OK == form2.ShowDialog())
                {
                    DatManage datManage = new DatManage();
                    ListMusic listMusic = new ListMusic();

                    listMusic = datManage.DeserializeXML <ListMusic>("MusicL.xml");
                    File.Delete("MusicL.xml");
                    listMusic.Musics[listView1.FocusedItem.Index].Category = form2.text;
                    datManage.SerializeXML(listMusic, "MusicL.xml");
                    LoadFile();
                }
            }
            catch (Exception eror)
            {
                MessageBox.Show(eror.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        private void UpdateCombobox()
        {
            ListBooks listBooks = new ListBooks();
            DatManage datManage = new DatManage();

            listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
            comboBox1.Items.Clear();
            comboBox1.Items.Add("Все категории");
            foreach (var elem in listBooks.Books)
            {
                if (!comboBox1.Items.Contains(elem.TypeBook))
                {
                    comboBox1.Items.Add(elem.TypeBook);
                }
            }
            comboBox1.SelectedIndex  = 0;
            ChooseItem.SelectedIndex = 0;

            comboxChanr.Items.Clear();
            comboxChanr.Items.Add("Все жанры");
            foreach (var elem in listBooks.Books)
            {
                if (!comboxChanr.Items.Contains(elem.ChanrBook))
                {
                    comboxChanr.Items.Add(elem.ChanrBook);
                }
            }
            comboxChanr.SelectedIndex = 0;
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //try
            //{
            if (zaholovok.Text.Length == 0 || opisanna.Text.Length == 0)
            {
                //throw new Exception("Eror!");
            }
            Data data = new Data();

            data.DateTime   = DateTime.Parse(dateTimePicker1.Value.ToString("dd/MM/yyyy"));
            data.ZaholEvent = zaholovok.Text;
            data.TextEvent  = opisanna.Text;
            DataList list_tmp = new DataList();

            DatManage datManage = new DatManage();

            list_tmp = datManage.DeserializeXML <DataList>("List.xml");
            list_tmp.Datas.Add(data);

            datManage.SerializeXML(list_tmp, "List.xml");



            this.DialogResult = DialogResult.OK;
            //}
            //catch (Exception eror)
            //{
            //    MessageBox.Show(eror.Message, "Length tewfewxt=0!",MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
            //}
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (listView1.FocusedItem.Index < 0)
                {
                    throw new Exception("Eror!");
                }



                Authorization authorization = new Authorization();
                authorization.listView1.Visible = false;
                authorization.comboBox1.Visible = false;
                if (authorization.ShowDialog() == DialogResult.OK)
                {
                    DatManage  datManage  = new DatManage();
                    PersonList personList = new PersonList();
                    personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");

                    ListBooks listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
                    Person    person    = new Person()
                    {
                        Name = authorization.textNamePersonFields.Text, Id = personList.People.Count + 1, Type = ModeBoxCombo.SelectedIndex
                    };

                    person.HaveBook.Add(listBooks.Books[listView1.FocusedItem.Index]);

                    personList.People.Add(person);
                    personList.People[personList.People.Count - 1].HaveBook.Add(listBooks.Books[listView1.FocusedItem.Index]);

                    listBooks.Books.RemoveAt(listView1.FocusedItem.Index);
                    datManage.SerializeXML(personList, "PERSONS.xml");
                    datManage.SerializeXML(listBooks, "LISTBOOKS.xml");
                    UpdateListViev();
                    UpdateCombobox();
                }
            }

            catch (Exception eror)
            {
                MessageBox.Show(eror.Message, "Eror index!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
        private void LoadCategory()
        {
            comboBox1.Text = "";
            comboBox1.Items.Clear();



            ListCategory = datManage.DeserializeXML <ListCategory>(pat);
            foreach (var el in ListCategory.SiteAndCategories)
            {
                comboBox1.Items.Add(el.Name_Category);
            }
            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }
        }
コード例 #7
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            ListBooks listBooks = new ListBooks();
            DatManage datManage = new DatManage();

            DeleteListBooks.Items.Clear();

            listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
            foreach (var elem in listBooks.Books)
            {
                DeleteListBooks.Items.Add(elem.Name);
            }
        }
コード例 #8
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            DatManage  datManage  = new DatManage();
            PersonList personList = new PersonList();

            personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
            ListBooks listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");

            Authorization authorization = new Authorization();

            authorization.comboBox1.Visible = true;
            authorization.listView1.Visible = true;
            authorization.button1.Visible   = true;
            authorization.label1.Text       = "Выберите читателя: ";
            authorization.TakeOrGetBtn.Text = "Удалить";

            authorization.textNamePersonFields.Visible = false;

            foreach (var ell in personList.People)
            {
                authorization.comboBox1.Items.Add(ell.Name);
            }

            if (authorization.ShowDialog() == DialogResult.OK)
            {
                personList.People[authorization.ind1].HaveBook.RemoveAt(authorization.ind2);


                datManage.SerializeXML(personList, "PERSONS.xml");
                datManage.SerializeXML(listBooks, "LISTBOOKS.xml");
                authorization.comboBox1.Visible = false;
                authorization.listView1.Visible = false;
                authorization.button1.Visible   = false;
            }
            authorization.label1.Text       = "Введите имя: ";
            authorization.TakeOrGetBtn.Text = "Взять";
            UpdateListViev();
            UpdateCombobox();
        }
コード例 #9
0
        private void LoadEvents()
        {
            DataLists = datManage.DeserializeXML <DataList>("List.xml");
            listBox1.Items.Clear();
            foreach (var el in DataLists.Datas)
            {
                ListViewItem listViewItem = new ListViewItem(el.ZaholEvent);

                listViewItem.Tag = el.ZaholEvent;


                listBox1.Items.Add(listViewItem.Tag);
            }
        }
コード例 #10
0
        private void ChooseItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            PersonBoxList.Items.Clear();
            PersonList personList = new PersonList();
            DatManage  datManage  = new DatManage();

            personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
            foreach (var el in personList.People)
            {
                if (el.Type == ChooseItem.SelectedIndex)
                {
                    PersonBoxList.Items.Add(el.Name);
                }
            }
        }
コード例 #11
0
        void UpdateBox()
        {
            listView1.Clear();
            DatManage datManage = new DatManage();
            ListBooks listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");

            foreach (var el in listBooks.Books)
            {
                var item = listView1.Items.Add(el.Name);
                item.SubItems.Add(el.Cost.ToString());
                item.SubItems.Add(el.TypeBook.ToString());
                item.SubItems.Add(el.ChanrBook.ToString());
                item.SubItems.Add(el.Id.ToString());
            }
        }
コード例 #12
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (ModeBoxCombo.SelectedIndex == 1)
            {
                Authorization authorization = new Authorization();
                authorization.listView1.Visible = false;
                authorization.comboBox1.Visible = false;
                if (authorization.ShowDialog() == DialogResult.OK)
                {
                    DatManage  datManage  = new DatManage();
                    PersonList personList = new PersonList();
                    personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");


                    Person person = new Person()
                    {
                        Name = authorization.textNamePersonFields.Text, Id = personList.People.Count + 1, Type = ModeBoxCombo.SelectedIndex
                    };


                    if (!personList.People.Contains(person))
                    {
                        personList.People.Add(person);
                    }



                    datManage.SerializeXML(personList, "PERSONS.xml");

                    UpdateListViev();
                    UpdateCombobox();
                }
            }
            else if (ModeBoxCombo.SelectedIndex == 2)
            {
                panel1.Visible          = true;
                DeleteListBooks.Visible = false;
                Cancelbutton.Tag        = "Add";
                anotationfield.Visible  = true; namefield.Visible = true; costfield.Visible = true; typefield.Visible = true;
                labelAnotation.Visible  = true; labelCost.Visible = true; labelName.Visible = true; labelType.Visible = true;
                PersonBoxList.Visible   = false;
                textBoxChnr.Visible     = true;
                labelChanr.Visible      = true;
                UniversalButton.Text    = "Сохранить";
                UpdateListViev();
                UpdateCombobox();
            }
        }
コード例 #13
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DatManage  datManage  = new DatManage();
            PersonList personList = new PersonList();

            listView1.Items.Clear();
            personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
            foreach (var el in personList.People[comboBox1.SelectedIndex].HaveBook)
            {
                var item = listView1.Items.Add(el.Name);
                item.SubItems.Add(el.Cost.ToString());
                item.SubItems.Add(el.TypeBook.ToString());
                item.SubItems.Add(el.ChanrBook.ToString());
                item.SubItems.Add(el.Id.ToString());
            }

            ind1 = comboBox1.SelectedIndex;
        }
コード例 #14
0
        private void ReaderBook_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (ReaderBook.SelectedIndex < 0)
                {
                    throw new Exception("Eror Selected!");
                }
                DatManage datManage = new DatManage();

                ListBooks listBooks = new ListBooks();
                listBooks     = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
                InfoText.Text = listBooks.Books[ReaderBook.SelectedIndex].Anotation;
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #15
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (PersonBoxList.SelectedIndex < 0)
                {
                    throw new Exception("Eror Selected!");
                }
                DatManage datManage = new DatManage();

                PersonList personBoxList = new PersonList();
                personBoxList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
                personBoxList.People.RemoveAt(PersonBoxList.SelectedIndex);
                datManage.SerializeXML(personBoxList, "PERSONS.xml");
                UpdateListViev();
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #16
0
        private void LoadFile()
        {
            axWindowsMediaPlayer1.Ctlcontrols.stop();
            DatManage datManage = new DatManage();
            ListMusic listMusic = new ListMusic();

            listMusic = datManage.DeserializeXML <ListMusic>("MusicL.xml");

            listView1.Items.Clear();
            List <string> vs = new List <string>();

            foreach (var el in listMusic.Musics)
            {
                var item = listView1.Items.Add(el.Filename);
                item.SubItems.Add(el.Category);
                vs.Add(el.Category);
            }
            comboBox1.Items.Clear();
            comboBox1.Items.Add("All");
            List <string> res = new List <string>();

            for (int i = 0; i < vs.Count; i++)
            {
                for (int j = vs.Count - 1; j >= 0; j--)
                {
                    if (vs[i] == vs[j])
                    {
                        if (!res.Contains(vs[i]))
                        {
                            res.Add(vs[i]);
                        }
                    }
                }
            }
            foreach (var el in res)
            {
                comboBox1.Items.Add(el);
            }
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }
コード例 #17
0
        private void SaveFile(Music music)
        {
            DatManage datManage = new DatManage();
            ListMusic listMusic = new ListMusic();

            listMusic = datManage.DeserializeXML <ListMusic>("MusicL.xml");
            bool e = false;

            foreach (var el in listMusic.Musics)
            {
                if (el.Filename == music.Filename)
                {
                    e = true;
                }
            }
            if (e == false)
            {
                listMusic.Musics.Add(music);

                datManage.SerializeXML(listMusic, "MusicL.xml");
            }
        }
コード例 #18
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int ind = comboBox1.SelectedIndex;
                if (ind < 0)
                {
                    throw new Exception("Eror index selected!");
                }
                if (ind == 0)
                {
                    throw new ArgumentException();
                }

                DatManage datManage = new DatManage();
                ListMusic listMusic = new ListMusic();

                listMusic = datManage.DeserializeXML <ListMusic>("MusicL.xml");

                listView1.Items.Clear();
                foreach (var el in listMusic.Musics)
                {
                    if (el.Category == comboBox1.Text)
                    {
                        var item = listView1.Items.Add(el.Filename);
                        item.SubItems.Add(el.Category);
                    }
                }
            }
            catch (ArgumentException eror)
            {
                LoadFile();
            }
            catch (Exception eror)
            {
                MessageBox.Show(eror.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #19
0
        private void UniversalButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (anotationfield.Text.Length == 0 || namefield.Text.Length == 0 || costfield.Text.Length == 0 || typefield.Text.Length == 0 || textBoxChnr.Text.Length == 0)
                {
                    throw new Exception("Text length <0!");
                }

                if (!int.TryParse(costfield.Text, out int text))
                {
                    throw new Exception($" {text} is not a number!");
                }

                //Add
                PersonList personList = new PersonList();
                DatManage  datManage  = new DatManage();

                personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");

                personList.People[comboBox1.SelectedIndex].HaveBook.Add(new Book()
                {
                    Name = namefield.Text, Anotation = anotationfield.Text, Cost = int.Parse(costfield.Text), TypeBook = typefield.Text, Id = personList.People[comboBox1.SelectedIndex].HaveBook.Count + 1, ChanrBook = textBoxChnr.Text
                });
                datManage.SerializeXML(personList, "PERSONS.xml");

                panel1.Visible = false;



                ////////
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
            }
        }
コード例 #20
0
        private void UpdateListViev(string type = "Все категории", int ind_mode = 0)
        {
            listView1.Items.Clear();
            ReaderBook.Items.Clear();
            PersonBoxList.Items.Clear();


            ListBooks listBooks = new ListBooks();
            DatManage datManage = new DatManage();

            listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
            foreach (var el in  listBooks.Books)
            {
                ReaderBook.Items.Add(el.Name);
            }
            if (ind_mode == 1)
            {
                IsGrowing(ref listBooks);
            }
            else if (ind_mode == 2)
            {
                IsFall(ref listBooks);
            }

            if (comboxChanr.SelectedIndex == 0)
            {
                foreach (var elem in listBooks.Books)
                {
                    if (type == "Все категории")
                    {
                        WriteListBook(elem);
                    }

                    else if (elem.TypeBook == type)
                    {
                        WriteListBook(elem);
                    }
                }
            }
            else
            {
                foreach (var elem in listBooks.Books)
                {
                    if (type == "Все категории")
                    {
                        WriteListBook2(elem);
                    }

                    else if (elem.TypeBook == type)
                    {
                        WriteListBook2(elem);
                    }
                }
            }

            PersonList personList = new PersonList();

            personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");


            if (ModeBoxCombo.SelectedIndex == 1)
            {
                foreach (var el in personList.People)
                {
                    PersonBoxList.Items.Add(el.Name);
                }
            }
            else
            {
                foreach (var el in listBooks.Books)
                {
                    PersonBoxList.Items.Add(el.Name);
                }
            }
        }
コード例 #21
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (Cancelbutton.Tag == "Add")
            {
                try
                {
                    if (anotationfield.Text.Length == 0 || namefield.Text.Length == 0 || costfield.Text.Length == 0 || typefield.Text.Length == 0 || textBoxChnr.Text.Length == 0)
                    {
                        throw new Exception("Text length <0!");
                    }

                    if (!int.TryParse(costfield.Text, out int text))
                    {
                        throw new Exception($" {text} is not a number!");
                    }
                    panel1.Visible         = false;
                    PersonBoxList.Visible  = true; textBoxChnr.Visible = false; labelChanr.Visible = false;
                    anotationfield.Visible = false; namefield.Visible = false; costfield.Visible = false; typefield.Visible = false;
                    labelAnotation.Visible = false; labelCost.Visible = false; labelName.Visible = false; labelType.Visible = false;
                    //Add
                    ListBooks listBooks = new ListBooks();
                    DatManage datManage = new DatManage();

                    listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");

                    listBooks.Books.Add(new Book()
                    {
                        Name = namefield.Text, Anotation = anotationfield.Text, Cost = int.Parse(costfield.Text), TypeBook = typefield.Text, Id = listBooks.Books.Count + 1, ChanrBook = textBoxChnr.Text
                    });
                    datManage.SerializeXML(listBooks, "LISTBOOKS.xml");
                    ShowMesText("Успешно добавлено!");
                    ////////
                }
                catch (Exception er)
                {
                    MessageBox.Show(er.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (DeleteListBooks.Items.Count != 0)
                {
                    try
                    {
                        if (Convert.ToInt32(DeleteListBooks.Tag.ToString()) < 0)
                        {
                            throw new Exception("Eror index!");
                        }

                        //Delete

                        ListBooks listBooks = new ListBooks();
                        DatManage datManage = new DatManage();

                        listBooks = datManage.DeserializeXML <ListBooks>("LISTBOOKS.xml");
                        listBooks.Books.RemoveAt(DeleteListBooks.SelectedIndex + 1);
                        datManage.SerializeXML(listBooks, "LISTBOOKS.xml");
                        ShowMesText("Успешно удалено!");

                        /////

                        DeleteListBooks.Visible = false;
                        panel1.Visible          = false;
                    }
                    catch (Exception er)
                    {
                        MessageBox.Show(er.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    DeleteListBooks.Visible = false;
                    panel1.Visible          = false;
                }
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: MaxymGorn/WinForms-project
        void Init_Test()
        {
            DatManage datManage = new DatManage();

            listQueAnsw = datManage.DeserializeXML <ListQueAnsw>("AnswQuet.xml");
        }
コード例 #23
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (ModeBoxCombo.SelectedIndex == 1)
            {
                try
                {
                    if (PersonBoxList.SelectedIndex < 0)
                    {
                        throw new Exception("Eror ind!");
                    }
                    PersonList personList = new PersonList();
                    DatManage  datManage  = new DatManage();

                    personList = datManage.DeserializeXML <PersonList>("PERSONS.xml");
                    PersonList personList1 = new PersonList(); PersonList personList2 = new PersonList(); PersonList personList3 = new PersonList();


                    foreach (var el in personList.People)
                    {
                        if (el.Type == 0)
                        {
                            personList1.People.Add(el);
                        }
                        else if (el.Type == 1)
                        {
                            personList2.People.Add(el);
                        }
                        else
                        {
                            personList3.People.Add(el);
                        }
                    }

                    if (ChooseItem.SelectedIndex == 0)
                    {
                        personList1.People.RemoveAt(PersonBoxList.SelectedIndex);
                    }
                    else if (ChooseItem.SelectedIndex == 1)
                    {
                        personList2.People.RemoveAt(PersonBoxList.SelectedIndex);
                    }
                    else
                    {
                        personList3.People.RemoveAt(PersonBoxList.SelectedIndex);
                    }
                    personList = personList1;
                    foreach (var el in personList2.People)
                    {
                        personList.People.Add(el);
                    }

                    foreach (var el in personList3.People)
                    {
                        personList.People.Add(el);
                    }



                    datManage.SerializeXML(personList, "PERSONS.xml");
                    UpdateCombobox();
                    UpdateListViev();
                }
                catch (Exception eror)
                {
                    MessageBox.Show(eror.Message, "Notifications", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                }
            }
            else if (ModeBoxCombo.SelectedIndex == 2)
            {
                anotationfield.Visible = false; namefield.Visible = false; costfield.Visible = false; typefield.Visible = false; textBoxChnr.Visible = false;
                labelAnotation.Visible = false; labelCost.Visible = false; labelName.Visible = false; labelType.Visible = false; labelChanr.Visible = false;

                PersonBoxList.Visible   = false;
                panel1.Visible          = true;
                Cancelbutton.Tag        = "Del";
                DeleteListBooks.Visible = true;
                UniversalButton.Text    = "Удалить";
            }
        }