Example #1
0
        public void openCsv()
        {
            openFileDialog1.FileName = "file";//
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                name = openFileDialog1.FileName;
                List <Aval> CSV_Struct = new List <Aval>();
                CSV_Struct = Aval.ReadFile(name);
                for (int i = 0; i <= CSV_Struct.Count - 1; i++)
                {
                    //MessageBox.Show(i.ToString());
                    //listView1.Items.Add(CSV_Struct[i].name);
                    //listView1.Items[i].SubItems.Add(CSV_Struct[i].recivPayNum);
                    //listView1.Items[i].SubItems.Add(CSV_Struct[i].mfo);
                    //listView1.Items[i].SubItems.Add(CSV_Struct[i].rahunok);
                    //listView1.Items[i].SubItems.Add(CSV_Struct[i].zkpo);
                    //listView1.Items[i].SubItems.Add(CSV_Struct[i].datePayment.ToString());

                    int n = dataGridView1.Rows.Add();

                    dataGridView1.Rows[n].Cells[0].Value = "0";
                    dataGridView1.Rows[n].Cells[1].Value = "1";
                    dataGridView1.Rows[n].Cells[2].Value = CSV_Struct[i].recivPayNum;
                    dataGridView1.Rows[n].Cells[3].Value = CSV_Struct[i].datePayment.ToString();
                    dataGridView1.Rows[n].Cells[4].Value = "!!";
                    dataGridView1.Rows[n].Cells[5].Value = CSV_Struct[i].mfo;
                    dataGridView1.Rows[n].Cells[6].Value = "00";
                    dataGridView1.Rows[n].Cells[7].Value = CSV_Struct[i].rahunok;
                    dataGridView1.Rows[n].Cells[8].Value = CSV_Struct[i].summa;
                    //dataGridView1.Rows[n].Cells[9].Value = "0";
                    // dataGridView1.Rows[n].Cells[10].Value = CSV_Struct[i].name;

                    n = dataGridView2.Rows.Add();
                    dataGridView2.Rows[n].Cells[0].Value  = "0";
                    dataGridView2.Rows[n].Cells[1].Value  = "1";
                    dataGridView2.Rows[n].Cells[2].Value  = CSV_Struct[i].recivPayNum;
                    dataGridView2.Rows[n].Cells[3].Value  = CSV_Struct[i].dateP.ToString("dd.MM.yyyy");
                    dataGridView2.Rows[n].Cells[4].Value  = Properties.Settings.Default.mfo;
                    dataGridView2.Rows[n].Cells[5].Value  = CSV_Struct[i].mfo;
                    dataGridView2.Rows[n].Cells[6].Value  = Properties.Settings.Default.rahunok;
                    dataGridView2.Rows[n].Cells[7].Value  = CSV_Struct[i].rahunok;
                    dataGridView2.Rows[n].Cells[8].Value  = CSV_Struct[i].summa;
                    dataGridView2.Rows[n].Cells[9].Value  = "0";
                    dataGridView2.Rows[n].Cells[10].Value = CSV_Struct[i].name;
                    dataGridView2.Rows[n].Cells[12].Value = CSV_Struct[i].zkpo;
                    dataGridView2.Rows[n].Cells[11].Value = addDateToStr(findZkpo(CSV_Struct[i].zkpo), CSV_Struct[i].dateP.ToString("dd.MM.yyyy"));
                }
            }



            //string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"RO1306__.csv");


            //Заполняем listView из нашей структуры
        }
Example #2
0
        public static List <Aval> ReadFile(string filename)
        {
            List <Aval> res       = new List <Aval>();
            int         date      = 01012001;
            Regex       regexDate = new Regex(@"\w*[0-9]{2}[.][0-9]{2}[.][0-9]{2}р.");
            Regex       regexLine = new Regex(@".+;.+;.+;.+;.+;.+;.+;.+;.+;.+");
            bool        flag      = false;
            DateTime    datePl    = new DateTime();


            using (StreamReader sr = new StreamReader(filename, Encoding.GetEncoding(1251)))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    MatchCollection dateMatch = regexDate.Matches(line);
                    if (dateMatch.Count > 0)
                    {
                        //MessageBox.Show(line);
                        MatchCollection matchess = Regex.Matches(line, regexDate.ToString(), RegexOptions.IgnoreCase);
                        date   = Int32.Parse(matchess[0].ToString().Replace("за", "").Replace("р.", "").Trim().Replace(".", ""));
                        datePl = DateTime.Parse(matchess[0].ToString().Replace("за", "").Replace("р.", "").Trim());
                    }

                    string          lines2    = line.Replace("\"", "");
                    MatchCollection lineMatch = regexLine.Matches(line);
                    //MessageBox.Show(lines2);
                    if (lineMatch.Count > 0)
                    {
                        if (flag)
                        {
                            //MessageBox.Show(line);
                            Aval p = new Aval();
                            p.piece(line, datePl);
                            res.Add(p);
                        }

                        flag = true;
                    }
                }
            }

            return(res);
        }