Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            //string yourtext = "18.02. 2003";
            //string tlFio = yourtext;
            //string[] b = tlFio.Split(new char[] { ' ', '.', ',' }, StringSplitOptions.RemoveEmptyEntries);
            //string o = b[0] + "." + b[1] + "." + b[2];
            ////string text = yourtext.Replace(" ", ".");
            //DateTime d = Convert.ToDateTime(o);
            ////DateTime.TryParseExact(yourtext, "0:MM/dd/yy H:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out d);

            //this.Hide();
            //Form2 rr = new Form2();
            //rr.Show();



            //foreach (DataGridViewRow Row in dataGridView1.Rows)

            //{

            //    listBox1.Items.Add(Row.AccessibilityObject.Value);

            //    //foreach (DataGridViewCell Cell in dataGridView1.Cell)
            //    //{


            //    //}

            //}
            ////dataGridView1.Rows[1].Cells[1].Value
            ///

            var           someList  = new List <string>();
            DataTable     dataTable = new DataTable();
            List <Person> persons   = new List <Person>();

            if (dataGridView1.Rows.Count > 0 && dataGridView1.Columns.Count > 0) // Разобраться почему не проходит условие по дате и фио так как вставляеться данные рандомные
            {
                for (int i = 0; i < dataGridView1.Columns.Count && someList.Count != dataGridView1.Columns.Count; i++)
                {
                    dataTable.Columns.Add();
                    string it = dataGridView1.Columns[i].HeaderText;
                    //someList.Add(it.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", ""));
                    someList.Add(it);
                }
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    string[] row = new string[dataGridView1.Columns.Count];
                    for (int j = 0; j < dataGridView1.Columns.Count; j++)
                    {
                        string tt = Convert.ToString(dataGridView1[j, i].Value);
                        row[j] = tt.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", "").Replace("\v", " ");
                    }
                    string   tlFio = row[1];
                    string[] b     = tlFio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    string   o     = b[0] + " " + b[1] + " " + b[2];

                    if (dataGridView2.Rows.Count > 0 && dataGridView2.Columns.Count > 0)
                    {
                        for (int r = 0; r < dataGridView2.Rows.Count; r++)
                        {
                            string[] row2 = new string[dataGridView2.Columns.Count];
                            for (int h = 0; h < dataGridView2.Columns.Count; h++)
                            {
                                string tt = Convert.ToString(dataGridView2[h, r].Value);
                                row2[h] = tt.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", "");
                            }
                            string   rlFio = row2[1];
                            string[] c     = tlFio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            string   q     = c[0] + " " + c[1] + " " + c[2];

                            if (o == q && row[2] == row2[2])
                            {
                                if (string.IsNullOrEmpty(row[6]) || row[6] == " ")
                                {
                                    row[6] = row2[3];
                                    Person person = new Person
                                    {
                                        FIO           = row[1],
                                        DateBirdhsday = Convert.ToDateTime(row[2])
                                    };
                                    persons.Add(person);
                                }
                            }
                        }
                    }


                    dataTable.Rows.Add(row);
                }
            }

            if (persons.Count > 0)
            {
                foreach (Person p in persons)
                {
                    listBox1.Items.Add("ФИО " + p.FIO + " Дата рождения " + p.DateBirdhsday);
                }
            }



            dataGridView3.DataSource = dataTable;

            for (int i = 0; i < someList.Count; i++)
            {
                dataGridView3.Columns[i].HeaderText = someList[i];
            }



            if (dataGridView3.Rows.Count > 0 && dataGridView3.Columns.Count > 0)
            {
                for (int i = 0; i < dataGridView3.Rows.Count; i++)
                {
                    string[] row = new string[dataGridView3.Columns.Count];
                    for (int j = 0; j < dataGridView3.Columns.Count; j++)
                    {
                        string tt = Convert.ToString(dataGridView3[j, i].Value);
                        row[j] = tt.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", "").Replace("\v", " ");
                    }



                    List <NekorektData> nekorektDatas = new List <NekorektData>();

                    if (string.IsNullOrEmpty(row[6]) || row[6] == " ")
                    {
                        NekorektData nekorektData = new NekorektData
                        {
                            FIO           = row[1],
                            DateBirdhsday = Convert.ToDateTime(row[2])
                        };
                        nekorektDatas.Add(nekorektData);
                    }
                    if (nekorektDatas.Count > 0)
                    {
                        foreach (NekorektData l in nekorektDatas)
                        {
                            listBox2.Items.Add("ФИО " + l.FIO + " Дата рождения " + l.DateBirdhsday);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var                 someList      = new List <string>();
            DataTable           dataTable     = new DataTable();
            List <Person>       persons       = new List <Person>();
            List <NekorektData> nekorektDatas = new List <NekorektData>();

            foreach (DataGridViewRow row2 in dataGridView1.Rows)
            {
                string searchValue = row2.Cells[1].Value.ToString();
                string tr          = row2.Cells[6].Value.ToString();

                try
                {
                    string   tlFio = searchValue;
                    string[] c     = tlFio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    string   q     = c[0] + " " + c[1] + " " + c[2];

                    DateTime d = Convert.ToDateTime(row2.Cells[2].Value.ToString());


                    dataGridView2.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        string   rr     = row.Cells[1].Value.ToString();
                        string   tlFio2 = rr;
                        string[] r      = tlFio2.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        string   p      = r[0] + " " + r[1] + " " + r[2];

                        DateTime t = Convert.ToDateTime(row.Cells[2].Value.ToString());

                        if (p.Equals(q) && t == d)
                        {
                            if (string.IsNullOrEmpty(tr) || tr == " ")
                            {
                                row2.Cells[6].Value = row.Cells[3].Value.ToString();
                                Person person = new Person
                                {
                                    FIO           = searchValue,
                                    DateBirdhsday = d
                                };
                                persons.Add(person);
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            foreach (DataGridViewRow row22 in dataGridView1.Rows)
            {
                string   searchValue = row22.Cells[1].Value.ToString();
                string   tr          = row22.Cells[6].Value.ToString();
                DateTime d           = Convert.ToDateTime(row22.Cells[2].Value.ToString());



                if (string.IsNullOrEmpty(tr) || tr == " ")
                {
                    NekorektData nekorektData = new NekorektData
                    {
                        FIO           = searchValue,
                        DateBirdhsday = d
                    };
                    nekorektDatas.Add(nekorektData);
                }


                for (int i = 0; i < dataGridView1.Columns.Count && someList.Count != dataGridView1.Columns.Count; i++)
                {
                    dataTable.Columns.Add();
                    string it = dataGridView1.Columns[i].HeaderText;
                    //someList.Add(it.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", ""));
                    someList.Add(it);
                }
                string[] rrt = new string[someList.Count];
                for (int r = 0; r < someList.Count; r++)
                {
                    rrt[r] = row22.Cells[r].Value.ToString();
                }
                dataTable.Rows.Add(rrt);
            }

            if (nekorektDatas.Count > 0)
            {
                foreach (NekorektData l in nekorektDatas)
                {
                    listBox2.Items.Add("ФИО " + l.FIO + " Дата рождения " + l.DateBirdhsday);
                }
            }

            if (persons.Count > 0)
            {
                foreach (Person p in persons)
                {
                    listBox1.Items.Add("ФИО " + p.FIO + " Дата рождения " + p.DateBirdhsday);
                }
            }


            dataGridView3.DataSource = dataTable;

            for (int i = 0; i < someList.Count; i++)
            {
                dataGridView3.Columns[i].HeaderText = someList[i];
            }
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (TexnikymBDEntities db = new TexnikymBDEntities())
            {
                var Shablons = db.ШаблонГруппы;
                var Student  = db.Студенты2;



                foreach (ШаблонГруппы tl in Shablons)
                {
                    List <Person> persons = new List <Person>();


                    string   tlFio = tl.ФИО;
                    string[] b     = tlFio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    string   o     = b[0] + " " + b[1] + " " + b[2];

                    foreach (Студенты2 ii in Student)
                    {
                        string   iiFio = ii.ФИО;
                        string[] c     = iiFio.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        string   y     = c[0] + " " + c[1] + " " + c[2];

                        if (o == y && tl.ДатаРождения == ii.ДатаРождения)
                        {
                            if (string.IsNullOrEmpty(tl.Паспорт) || tl.Паспорт == " ")
                            {
                                tl.Паспорт = ii.ПаспортныеДанные;

                                Person person = new Person
                                {
                                    FIO           = ii.ФИО,
                                    DateBirdhsday = ii.ДатаРождения
                                };
                                persons.Add(person);
                            }
                        }
                    }



                    if (persons.Count > 0)
                    {
                        foreach (Person p in persons)
                        {
                            listBox1.Items.Add("ФИО " + p.FIO + " Дата рождения " + p.DateBirdhsday);
                        }
                    }
                }

                foreach (ШаблонГруппы tl in Shablons)
                {
                    List <NekorektData> nekorektDatas = new List <NekorektData>();

                    if (string.IsNullOrEmpty(tl.Паспорт) || tl.Паспорт == " ")
                    {
                        NekorektData nekorektData = new NekorektData
                        {
                            FIO           = tl.ФИО,
                            DateBirdhsday = tl.ДатаРождения
                        };
                        nekorektDatas.Add(nekorektData);
                    }
                    if (nekorektDatas.Count > 0)
                    {
                        foreach (NekorektData l in nekorektDatas)
                        {
                            listBox2.Items.Add("ФИО " + l.FIO + " Дата рождения " + l.DateBirdhsday);
                        }
                    }
                }

                db.SaveChanges();


                db.ШаблонГруппы.Load();

                dataGridView3.DataSource = db.ШаблонГруппы.Local.ToBindingList();
            }
        }