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

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

        public string zak = "";

        private void button1_Click(object sender, EventArgs e)
        {
            string putin = "";
            if (Application.StartupPath.IndexOf("comp") != -1)
            {
                putin = Application.StartupPath.Substring(0, Application.StartupPath.IndexOf("\\comp"));
            }
            else
            {
                putin = Application.StartupPath;
            }
            string[] tmp = zak.Replace("<", "").Split('>');
            foreach(string str33 in tmp)
            {
                if (str33 == null || str33 == "") continue;
                if (File.Exists(putin + "\\baza\\" + str33 + "\\zakaz.akv"))
                {
                    string h = "";
                    StreamReader Sr = new StreamReader(new FileStream(putin + "\\baza\\" + str33 + "\\zakaz.akv", FileMode.Open, FileAccess.Read, FileShare.Read));
                    h = Sr.ReadToEnd();
                    Sr.Close();
                    string[] tmps = h.Split('|');
                    if (radioButton1.Checked) tmps[10] = "1";
                    else if (radioButton3.Checked) tmps[10] = "2";
                    else tmps[10] = "3";
                    //собираем обратно массив
                    string newzak = "";
                    for(int i =0;i<tmps.Length;i++)
                    {
                        newzak += tmps[i] + "|";
                    }
                    newzak = newzak.Substring(0, newzak.Length - 1);
                    File.WriteAllText(putin + "\\baza\\" + str33 + "\\zakaz.akv", newzak, Encoding.UTF8);
                }
            }
            Form17 fs = this.Owner as Form17;
            fs.reload_active();
            this.Close();
        }


    }
}
