Example #1
0
        private void xml_ChangedChek(object sender, EventArgs p1, string filename)
        {
            if (comboBox1.SelectedIndex != -1 && comboBox3.SelectedIndex != -1 && listBox1.Items.Count != 0)
            {
                XmlTextWriter check = null;
                try
                {
                    check            = new XmlTextWriter(filename, System.Text.Encoding.Unicode);
                    check.Formatting = Formatting.Indented;
                    check.WriteStartDocument();
                    check.WriteStartElement("CheckList");

                    check.WriteStartElement($"date");
                    check.WriteElementString($"date", Convert.ToString(DateTime.Now));
                    check.WriteEndElement();

                    b = (buyer)comboBox3.Items[comboBox3.SelectedIndex];
                    //buyer b2 = new buyer(b);
                    check.WriteStartElement($"buyer");
                    check.WriteElementString($"buyer", Convert.ToString(b));
                    check.WriteEndElement();

                    u = (user)comboBox1.Items[comboBox1.SelectedIndex];
                    check.WriteStartElement($"user");
                    check.WriteElementString($"user", Convert.ToString(u));
                    check.WriteEndElement();

                    for (var i = 0; i < listBox1.Items.Count; i++)
                    {
                        t = (Tovar)listBox1.Items[i];
                        check.WriteStartElement($"tovar");
                        check.WriteElementString($"tovar{i}", t.ToString());
                        check.WriteEndElement();
                    }
                    check.WriteEndElement();
                }
                finally
                {
                    if (check != null)
                    {
                        check.Close();
                    }
                    MessageBox.Show("Данные внесены в файл", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (listBox1.Items.Count == 0)
                {
                    MessageBox.Show("список покупок пуст, чек не оформлен", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("combobox продавца или покупателя пуст, чек не оформлен", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            b = new buyer();
            Form4 addform = new Form4(b, true);

            if (addform.ShowDialog() == DialogResult.OK)
            {
                comboBox3.Items.Add(b);
            }
        }
Example #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "")
     {
         MessageBox.Show("Заполните поле");
         return;
     }
     if (b == null)
     {
         b = new buyer();
     }
     b.Name            = textBox1.Text;
     this.DialogResult = DialogResult.OK;
 }
Example #4
0
        private void button8_Click(object sender, EventArgs e)
        {
            if (comboBox3.SelectedIndex == -1)
            {
                MessageBox.Show("Вы не выбрали покупателя"); return;
            }
            int n = comboBox3.SelectedIndex;

            b = (buyer)comboBox3.Items[n];
            Form4 editform = new Form4(b, false);

            editform.ShowDialog();
            comboBox3.Items.RemoveAt(n);
            comboBox3.Items.Insert(n, b);
            comboBox3.SelectedIndex = n;
        }
Example #5
0
        public Form4(buyer b, bool addnew)
        {
            InitializeComponent();
            this.addnew = addnew;

            this.b = b;
            if (addnew == false)
            {
                textBox1.Text     = b.Name;
                this.Text         = "Редактирование покупателя";
                this.button2.Text = "Обновить";
            }
            else
            {
                this.Text = "Добавление покупателя";
            }
        }
Example #6
0
 public buyer(buyer t)
 {
     Name = t.Name;
 }
Example #7
0
        private void button4_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox2.Items.Clear();
            comboBox3.Items.Clear();


            if (!File.Exists(TovarFileXml))
            {
                MessageBox.Show("Файла товаров не существует", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                using (StreamReader sr = File.OpenText(TovarFileXml))
                {
                    var i  = 0;
                    var fi = new FileInfo(TovarFileXml);
                    if (fi.Length == 0)
                    {
                        MessageBox.Show("Файл товаров пуст.", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XPathDocument     doc      = new XPathDocument(TovarFileXml);
                        XPathNavigator    nav      = doc.CreateNavigator();
                        XPathNodeIterator iterator = nav.Select("/tovarList/tovar");
                        int x = iterator.Count;

                        while (iterator.MoveNext())
                        {
                            XPathNodeIterator it = iterator.Current.Select($"tovar{i}");
                            i++;
                            it.MoveNext();
                            t      = new Tovar();
                            t.Name = it.Current.Value;
                            comboBox2.Items.Add(t);
                        }
                    }
                }
            }
            if (!File.Exists(userFileXml))
            {
                MessageBox.Show("Файла продавцов не существует", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                using (StreamReader sr = File.OpenText(userFileXml))
                {
                    var i  = 0;
                    var fi = new FileInfo(userFileXml);
                    if (fi.Length == 0)
                    {
                        MessageBox.Show("Файл продавцов пуст.", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XPathDocument     doc      = new XPathDocument(userFileXml);
                        XPathNavigator    nav      = doc.CreateNavigator();
                        XPathNodeIterator iterator = nav.Select("/userList/user");
                        int x = iterator.Count;

                        while (iterator.MoveNext())
                        {
                            XPathNodeIterator it = iterator.Current.Select($"user{i}");
                            i++;
                            it.MoveNext();
                            u      = new user();
                            u.Name = it.Current.Value;
                            comboBox1.Items.Add(u);
                        }
                    }
                }
            }
            if (!File.Exists(buyerFileXml))
            {
                MessageBox.Show("Файла покупателей не существует", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                using (StreamReader sr = File.OpenText(buyerFileXml))
                {
                    var i  = 0;
                    var fi = new FileInfo(buyerFileXml);
                    if (fi.Length == 0)
                    {
                        MessageBox.Show("Файл покупателей пуст.", "Инфо", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        XPathDocument     doc      = new XPathDocument(buyerFileXml);
                        XPathNavigator    nav      = doc.CreateNavigator();
                        XPathNodeIterator iterator = nav.Select("/buyerList/buyer");
                        int x = iterator.Count;

                        while (iterator.MoveNext())
                        {
                            XPathNodeIterator it = iterator.Current.Select($"buyer{i}");
                            i++;
                            it.MoveNext();
                            b      = new buyer();
                            b.Name = it.Current.Value;
                            comboBox3.Items.Add(b);
                        }
                    }
                }
            }
        }