Exemplo n.º 1
0
        //старт
        private void btnStart_Click(object sender, EventArgs e)
        {
            string newfile = folderBrowser.SelectedPath + "/AbiturientDB.mdb";

            FileInfo fi = new FileInfo(_emptyBase);

            fi.CopyTo(newfile, true);

            _odc = new OleDbClass();
            _odc.OpenDatabase(newfile);

            _alQueries = new ArrayList();
            PrepareRegion();
            MigrateProfSpez();
            MigrateOrders();
            MigrateAbits();
            _odc.ExecuteWithTrasaction(_alQueries);
            MessageBox.Show("Готово!");
            _odc.CloseDataBase();
        }
Exemplo n.º 2
0
        private void btnMetro_Click(object sender, EventArgs e)
        {
            string newfile = folderBrowser.SelectedPath + "/MetroDB.mdb";

            FileInfo fi = new FileInfo(_metroBase);

            fi.CopyTo(newfile, true);

            _alQueries = new ArrayList();

            _odc = new OleDbClass();
            _odc.OpenDatabase(newfile);

            string query = string.Format("SELECT DISTINCT ed.extAbit.Id, ed.Person.Name, ed.Person.SecondName, ed.Person.Surname, " +
                                         "ed.Person.BirthDate, ed.extAbit.StudyNumber, ed.extAbit.StudyLevelId, " +
                                         "ed.Person.PassportTypeId, case when ed.Person.PassportTypeId=1 then 'Р' when ed.Person.PassportTypeId=3 then 'З' else '' end as PassportType, " +
                                         "ed.Person.PassportSeries, ed.Person.PassportNumber,  " +
                                         "ed.extEntryView.Id AS EntryProtId " +
                                         "FROM ed.extAbit INNER JOIN ed.Person ON ed.extAbit.PersonId = ed.Person.Id " +
                                         "INNER JOIN ed.extEntryView ON ed.extEntryView.AbiturientId = ed.extAbit.Id " +
                                         "WHERE ed.extAbit.StudyFormId = 1 {0}", GetFilter("extAbit"));

            DataSet ds = _bdc.GetDataSet(query);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string ser = dr["PassportSeries"].ToString();
                string ser1 = string.Empty, ser2 = string.Empty;
                string pType = dr["PassportTypeId"].ToString();

                int    num  = 0;
                string temp = ser.Replace(" ", "").Replace("-", "");
                if (pType == "1" && int.TryParse(temp, out num) && temp.Length == 4)
                {
                    ser  = ser.Replace(" ", "").Replace("-", "");
                    ser1 = ser.Substring(0, 2);
                    ser2 = ser.Substring(2, 2);
                }
                else
                {
                    ser1 = ser;
                }

                string dateEnd;
                string course;

                string stLevel = dr["StudyLevelId"].ToString();
                if (stLevel == "16")
                {
                    dateEnd = "31.08.2016";
                    course  = "1";
                }
                else if (stLevel == "17")
                {
                    dateEnd = "31.08.2014";
                    course  = "5";
                }
                else
                {
                    dateEnd = "31.08.2017";
                    course  = "1";
                }

                string datebirth = ((DateTime)dr["BirthDate"]).ToString("dd.MM.yyyy");

                string s = string.Format(
                    "INSERT INTO sList ([DOC_KIND], [DOC_SN], [DOC_S]," +
                    "[DOC_NUM],[SDOCUM],[NAME_F],[NAME_I], [NAME_O]," +
                    "[ORGCODE], [DATEEND], [BIRTHDAY], [COURSE])" +
                    "VALUES ('{0}','{1}','{2}'," +
                    "'{3}','{4}','{5}','{6}','{7}'," +
                    "'21','{8}','{9}','{10}')",
                    dr["PassportType"].ToString(), ser1, ser2,
                    dr["PassportNumber"].ToString(), dr["StudyNumber"].ToString(), dr["Surname"].ToString(), dr["Name"].ToString(), dr["SecondName"].ToString(),
                    dateEnd, datebirth, course);

                _alQueries.Add(s);
            }

            _odc.ExecuteWithTrasaction(_alQueries);
            MessageBox.Show("Done!");
        }