Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                foreach (One_person item in F1.persons)
                {
                    if (item.Name == textBox1.Text)
                    {
                        MessageBox.Show(
                          "Такое имя уже существует",
                          "Обратите внимание",
                           MessageBoxButtons.OK,
                           MessageBoxIcon.Information,
                           MessageBoxDefaultButton.Button1);
                        return;
                    }
                }

                One_person pers = new One_person();
                pers.Name = textBox1.Text;
                pers.Notion = textBox2.Text;
                comboBox1.Items.Add(textBox1.Text);
                F1.Add_person(pers);
            }            
        }
Ejemplo n.º 2
0
        public Form1()
        {
            One_person           first            = new One_person();
            One_spend_categories first_categories = new One_spend_categories();

            first_categories.Name   = "General";
            first_categories.Notion = "Default categories spends";
            first.Name   = "Owner";
            first.Notion = "Default Owner";

            persons.Add(first);
            categories.Add(first_categories);

            InitializeComponent();
            comboBox1.Items.Add(first.Name);
            comboBox2.Items.Add(first_categories.Name);
        }
Ejemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text != "")
            {
                //foreach (One_person item in F1.persons)
                //{
                //    if (item.Name == comboBox1.Text)
                //    {
                //        MessageBox.Show(
                //          "Такое имя уже существует",
                //          "Обратите внимание",
                //           MessageBoxButtons.OK,
                //           MessageBoxIcon.Information,
                //           MessageBoxDefaultButton.Button1,
                //           MessageBoxOptions.DefaultDesktopOnly);
                //        return;
                //    }
                //}

                string chname = F1.persons[last_selected_index].Name;

                

                One_person pers = new One_person();
                pers.Name = comboBox1.Text;
                pers.Notion = textBox2.Text;

                F1.persons.RemoveAt(last_selected_index);
                F1.Dell_person(last_selected_index);
                comboBox1.Items.RemoveAt(last_selected_index);
                comboBox1.Text = pers.Name;
                comboBox1.Items.Add(pers.Name);
                F1.Add_person(pers);

                for (int i = 0; i < F1.spends.Count; i++)
                {                    
                    if (F1.spends[i].Person == chname)
                    {
                        F1.spends[i].Person = comboBox1.Text;
                    }
                    
                }//заменить ответственных на новых
                F1.refresh();
            }
        }//изменить Имя
Ejemplo n.º 4
0
        }//сохранение

        private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            string         path = "";

            if (open.ShowDialog() == DialogResult.OK)
            {
                path = open.FileName;
            }
            else
            {
                return;
            }

            XmlReader reader;

            categories.Clear();
            persons.Clear();
            spends.Clear();

            // открытие существующего файла
            reader = XmlReader.Create(path);
            {
                One_person           pers  = new One_person();
                One_spend            spend = new One_spend();
                One_spend_categories categ = new One_spend_categories();
                short pass = 0;
                int   i    = 0;

                while (reader.Read())
                {
                    pers  = new One_person();
                    spend = new One_spend();
                    categ = new One_spend_categories();


                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "Spend")
                    {
                        while (reader.Read() || pass == 0)
                        {
                            if (pass > 0)
                            {
                                break;
                            }

                            if (reader.NodeType == XmlNodeType.Element && reader.Name == "_person")
                            {
                                pass = 1;
                                break;
                            }

                            if (i > 6)
                            {
                                i = 0;
                                Add_spends(spend);
                                spends.Add(spend);

                                spend = new One_spend();
                            }

                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                if (reader.Value != "" && reader.Value != " ")
                                {
                                    switch (i)
                                    {
                                    case 0:
                                        spend.ID = int.Parse(reader.Value);
                                        i++;
                                        break;

                                    case 1:
                                        spend.Name = reader.Value;
                                        i++;
                                        break;

                                    case 2:
                                        spend.Categories = reader.Value;
                                        i++;
                                        break;

                                    case 3:
                                        spend.Person = reader.Value;
                                        i++;
                                        break;

                                    case 4:
                                        DateTime dateTimeStart = DateTime.Parse(reader.Value);
                                        spend.Date = dateTimeStart;
                                        i++;
                                        break;

                                    case 5:
                                        spend.Notion = reader.Value;
                                        i++;
                                        break;

                                    case 6:
                                        spend.Price = int.Parse(reader.Value);
                                        i++;
                                        break;
                                    }
                                }
                            }
                        }
                    }//добавление спендов


                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "_person")// не читает первую
                    {
                        int count = 0;
                        while (reader.Read() || pass == 1)
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Name == "_category")
                            {
                                pass = 2;
                                break;
                            }
                            if (i > 1)
                            {
                                i = 0;
                                Add_person(pers);
                                pers = new One_person();
                            }
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                if (reader.Value != "" && reader.Value != " ")
                                {
                                    switch (i)
                                    {
                                    case 0:
                                        pers.Name = reader.Value;
                                        i++;
                                        break;

                                    case 1:
                                        pers.Notion = reader.Value;
                                        i++;
                                        count++;
                                        label5.Text = count.ToString();
                                        break;
                                    }
                                }
                            }
                        }
                        ;
                    }//добавление персон

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "_category")
                    {
                        while (reader.Read() || pass == 2)
                        {
                            if (reader.Value == "1488_8841")
                            {
                                pass = 3;
                                break;
                            }

                            if (i > 1)
                            {
                                i = 0;
                                Add_category(categ);
                                categ = new One_spend_categories();
                            }
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                if (reader.Value != "" && reader.Value != " ")
                                {
                                    switch (i)
                                    {
                                    case 0:
                                        categ.Name = reader.Value;
                                        i++;
                                        break;

                                    case 1:
                                        categ.Notion = reader.Value;
                                        i++;
                                        break;
                                    }
                                }
                            }
                        }
                    }//добавление категорий
                }
            }
            new_id = spends.Count();
            reader.Close();
            // search_categ();
            refresh();
        }
Ejemplo n.º 5
0
 public void Add_person(One_person pers)
 {
     comboBox1.Items.Add(pers.Name);
     persons.Add(pers);
 }