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 Form21 : Form
    {
        public Form21()
        {
            InitializeComponent();
        }

        public string zakaz = "";
        string putin = "";
        private void Form21_Shown(object sender, EventArgs e)
        {
            if (Application.StartupPath.IndexOf("comp") != -1)
            {
                putin = Application.StartupPath.Substring(0, Application.StartupPath.IndexOf("\\comp"));
            }
            else
            {
                putin = Application.StartupPath;
            }
            if (File.Exists(putin + "\\baza\\" + zakaz + "\\zakaz.akv"))
            {
                string h = "";
                StreamReader Sr = new StreamReader(new FileStream(putin + "\\baza\\" + zakaz + "\\zakaz.akv", FileMode.Open, FileAccess.Read, FileShare.Read));
                h = Sr.ReadToEnd();
                Sr.Close();
                string[] tmp = h.Split('|');

                if (File.Exists(putin + "\\baza\\" + zakaz + "\\doplata.akv"))
                {
                   
                    string str33 = "";
                    using (StreamReader sr = new StreamReader(new FileStream(putin + "\\baza\\" + zakaz + "\\doplata.akv", FileMode.Open, FileAccess.Read, FileShare.Read)))
                    {
                        while ((str33 = sr.ReadLine()) != null)
                        {
                            if (str33 == "") continue;
                            string[] tm = str33.Split('|');

                            int ii = dataGridView1.Rows.Count;
                            dataGridView1.Rows.Add();
                            dataGridView1.Rows[ii].Cells[0].Value = "Дата : "+tm[0];

                            dataGridView1.Rows[ii].Cells[2].Value = tm[1];

                            if (tm[2] == "1")
                                dataGridView1.Rows[ii].Cells[1].Value = "Наличный";
                            else if (tm[2] == "2")
                                dataGridView1.Rows[ii].Cells[1].Value = "Терминал";
                            else if (tm[2] == "4")
                                dataGridView1.Rows[ii].Cells[1].Value = "Карта";
                            else if (tm[2] == "3")
                                dataGridView1.Rows[ii].Cells[1].Value = "Безнал";

                            dataGridView1.Rows[ii].Cells[3].Value = tm[3];
                        }
                        

                    }
                    int i = dataGridView1.Rows.Count;
                    dataGridView1.Rows.Add();
                    dataGridView1.Rows[i].Cells[0].Value = tmp[0];

                    dataGridView1.Rows[i].Cells[2].Value = tmp[11];

                    if (tmp[10] == "1")
                        dataGridView1.Rows[i].Cells[1].Value = "Наличный";
                    else if (tmp[10] == "2")
                        dataGridView1.Rows[i].Cells[1].Value = "Терминал";
                    else if (tmp[10] == "3")
                        dataGridView1.Rows[i].Cells[1].Value = "Карта";
                    else if (tmp[10] == "4")
                        dataGridView1.Rows[i].Cells[1].Value = "Безнал";

                    dataGridView1.Rows[i].Cells[3].Value = "Взнос, полученный при оформлении заказа.";
                }
                else
                {
                    int i = dataGridView1.Rows.Count;
                    dataGridView1.Rows.Add();
                    dataGridView1.Rows[i].Cells[0].Value = tmp[0];
                    
                    dataGridView1.Rows[i].Cells[2].Value =  tmp[11];

                    if(tmp[10] == "1")
                        dataGridView1.Rows[i].Cells[1].Value = "Наличный";
                    else if (tmp[10] == "2")
                        dataGridView1.Rows[i].Cells[1].Value = "Терминал";
                    else if (tmp[10] == "3")
                        dataGridView1.Rows[i].Cells[1].Value = "Карта";
                    else if (tmp[10] == "4")
                        dataGridView1.Rows[i].Cells[1].Value = "Безнал";

                    dataGridView1.Rows[i].Cells[3].Value = "Взнос, полученный при оформлении заказа.";
                }
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
