Exemplo n.º 1
0
        private void button6_Click(object sender, EventArgs e)

        {
            using (TexnikymBDEntities db = new TexnikymBDEntities())
            {
                var ShabloneGr = db.ШаблонГруппы;
                var Students   = db.Студенты2;
                foreach (Студенты2 pl in Students)
                {
                    db.Студенты2.Remove(pl);
                }


                foreach (ШаблонГруппы rl in ShabloneGr)
                {
                    db.ШаблонГруппы.Remove(rl);
                }

                db.SaveChanges();

                MessageBox.Show("Данные удалены");
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
        private void button5_Click(object sender, EventArgs e)
        {
            using (TexnikymBDEntities db = new TexnikymBDEntities())
            {
                object missing = Type.Missing;


                Object Pa = textBox2.Text;                         // Путь к шаблону

                Word.Application wordApp = new Word.Application(); // Создаём объект приложения


                wordApp.Documents.Open(ref Pa, ref missing, true, ref missing, ref missing,
                                       ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                                       ref missing, ref missing, ref missing, ref missing, ref missing);

                Word.Document document = wordApp.ActiveDocument;

                int countTable = document.Tables.Count;

                for (int y = 1; y <= countTable; y++)
                {
                    List <Студенты2> ShabloniGr = new List <Студенты2>();
                    Word.Table       table      = document.Tables[y];

                    if (table.Rows.Count > 0 && table.Columns.Count > 0)
                    {
                        for (int i = 0; i < table.Columns.Count; i++)
                        {
                            progressBar2.Maximum = (countTable) * table.Columns.Count;
                            progressBar2.Value++;
                        }
                        for (int i = 0; i < table.Rows.Count - 1; i++)
                        {
                            string[] row = new string[table.Columns.Count];
                            for (int j = 0; j < table.Columns.Count; j++)
                            {
                                row[j] = table.Cell(i + 2, j + 1).Range.Text.Trim('a', 'r', 'n', 't').Replace("\r", " ").Replace("\a", "").Replace("\t", "");
                            }



                            DateTime d;
                            string   dateConv = row[2].Replace("\a", "");
                            string   tlFio    = dateConv;
                            string[] b        = tlFio.Split(new char[] { ' ', '.', ',' }, StringSplitOptions.RemoveEmptyEntries);
                            string   o        = b[0] + "." + b[1] + "." + b[2];

                            if (DateTime.TryParse(o, out d))
                            {
                                d = Convert.ToDateTime(o);
                            }
                            else
                            {
                                o = "2000-01-01 00:00:00.000";// Если дата введена не коретно то вводиться это число 2000-01-01 00:00:00.000
                            }
                            d = Convert.ToDateTime(o);

                            ShabloniGr.Add(new Студенты2
                            {
                                ФИО              = row[1],
                                ДатаРождения     = d,
                                ПаспортныеДанные = row[3],
                                МедицинскийПолис = row[4],
                                Снилс            = row[5],
                                ИНН              = row[6]
                            });
                        }
                    }
                    db.Студенты2.AddRange(ShabloniGr);
                    db.SaveChanges();
                }

                wordApp.ActiveDocument.Close();
                wordApp.Quit();

                db.Студенты2.Load();

                dataGridView2.DataSource = db.Студенты2.Local.ToBindingList();

                MessageBox.Show("Данные помещены");
            }
        }