using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StekloMaster
{
    public partial class Form18 : Form
    {
        public Form18()
        {
            InitializeComponent();
        }

        public string edit = "";

        private void Form18_Shown(object sender, EventArgs e)
        {

            if (edit != "")
            {

                //при редактировании вызвать пересчет отверстий!
                string[] s = edit.Split('|');
                textBox1.Text = s[1];
                textBox2.Text = s[2];
                textBox3.Text = s[3];
                textBox4.Text = s[4];

                textBox5.Text = s[6];

                string gs = s[5];
                if (panel1.Visible)
                {
                    dataGridView2.Rows.Clear();
                    string[] bd2 = gs.Split(';');
                    foreach (string ss in bd2)
                    {
                        if (ss != "")
                        {
                            string[] f = ss.Split('-');
                            int i = dataGridView2.Rows.Count;
                            dataGridView2.Rows.Add();
                            for (int h = 0; h < 2; h++)
                                dataGridView2.Rows[i].Cells[h].Value = f[h];
                        }

                    }
                }
                else
                {
                    dataGridView1.Rows.Clear();
                    string[] bd2 = gs.Split(';');
                    foreach (string ss in bd2)
                    {
                        if (ss != "")
                        {
                            string[] f = ss.Split('-');
                            int i = dataGridView1.Rows.Count;
                            dataGridView1.Rows.Add();
                            for (int h = 0; h < 2; h++)
                                dataGridView1.Rows[i].Cells[h].Value = f[h];
                        }

                    }
                }

                textBox6.Text = s[7];
                string[] gsf = s[8].Split(';');
                listBox1.Items.Clear();
                foreach (string st3 in gsf)
                {
                    if (st3 == "" || st3 == null) continue;
                    listBox1.Items.AddRange(new object[] { st3 });
                }
                if (listBox1.Items.Count != 0)
                    listBox1.SelectedIndex = 0;
                label11.Text = s[9] + " руб.";
            }
        }
    }
}
