private void btnLoad_Click(object sender, EventArgs e) { loadClass = new LoadFromInet(); bdcInet = loadClass.BDCInet; int fileNum = 0; string barcText = tbPersonNum.Text.Trim(); if (barcText == string.Empty) { WinFormsServ.Error("Не введен номер"); return; } //if (barcText.Length == 7) //{ // if (barcText.StartsWith("2")) // { // WinFormsServ.Error("Выбран человек, подавший заявления в магистратуру"); // return; // } // barcText = barcText.Substring(1); //} if (!int.TryParse(barcText, out fileNum)) { WinFormsServ.Error("Неправильно введен номер"); return; } if (MainClass.CheckPersonBarcode(fileNum)) { try { //extPerson person = loadClass.GetPersonByBarcode(fileNum); DataTable dtEge = new DataTable(); //if(person != null) //{ // string queryEge = "SELECT EgeMark.Id, EgeMark.EgeExamNameId AS ExamId, EgeMark.Value, EgeCertificate.PrintNumber, EgeCertificate.Number, EgeMark.EgeCertificateId FROM EgeMark LEFT JOIN EgeCertificate ON EgeMark.EgeCertificateId = EgeCertificate.Id LEFT JOIN Person ON EgeCertificate.PersonId = Person.Id"; // DataSet dsEge = bdcInet.GetDataSet(queryEge + " WHERE Person.Barcode = " + fileNum + " ORDER BY EgeMark.EgeCertificateId "); // dtEge = dsEge.Tables[0]; //} CardFromInet crd = new CardFromInet(fileNum, null, true); crd.ToUpdateList += UpdateDataGrid; crd.Show(); } catch (Exception exc) { WinFormsServ.Error(exc.Message); tbPersonNum.Text = ""; tbPersonNum.Focus(); } } else { UpdateDataGrid(); using (PriemEntities context = new PriemEntities()) { extPersonAll person = (from per in context.extPersonAll where per.Barcode == fileNum select per).FirstOrDefault(); string fio = person.FIO; string num = person.PersonNum; string persId = person.Id.ToString(); WinFormsServ.Search(this.dgvAbiturients, "PersonNum", num); DialogResult dr = MessageBox.Show(string.Format("Абитуриент {0} с данным номером баркода уже импортирован в базу.\nОткрыть карточку абитуриента?", fio), "Внимание", MessageBoxButtons.YesNo); if (dr == System.Windows.Forms.DialogResult.Yes) { MainClass.OpenCardPerson(persId, this, null); } } } tbPersonNum.Text = ""; tbPersonNum.Focus(); loadClass.CloseDB(); }
public static void ImportMagAbits() { List <string> lstPersons = new List <string>(); List <string> lstAbits = new List <string>(); LoadFromInet loadClass = new LoadFromInet(); DBPriem _bdcInet = loadClass.BDCInet; using (PriemEntities context = new PriemEntities()) { string _sQuery = @"SELECT DISTINCT qAbiturient.Id, qAbiturient.PersonId, qAbiturient.Barcode AS AbitBarcode, extPerson.Barcode AS PersonBarcode FROM qAbiturient INNER JOIN extPerson ON qAbiturient.PersonId = extPerson.Id WHERE StudyLevelId = 17 AND Enabled = 1 AND IsApprovedByComission = 1 AND IsImported = 0"; DataSet ds = _bdcInet.GetDataSet(_sQuery); Guid?personId; foreach (DataRow dr in ds.Tables[0].Rows) { int?abitBarcode = (int?)dr["AbitBarcode"]; if (!MainClass.CheckAbitBarcode(abitBarcode)) { continue; } int?persBarcode = (int?)dr["PersonBarcode"]; if (!MainClass.CheckPersonBarcode(persBarcode)) { personId = (from pers in context.extForeignPerson where pers.Barcode == persBarcode select pers.Id).FirstOrDefault(); } else { extPersonAll person = loadClass.GetPersonByBarcode(persBarcode.Value); if (!CheckIdent(person)) { lstPersons.Add(persBarcode.ToString()); continue; } ObjectParameter entId = new ObjectParameter("id", typeof(Guid)); context.Person_Foreign_insert(person.Barcode, person.Name, person.SecondName, person.Surname, person.BirthDate, person.BirthPlace, person.PassportTypeId, person.PassportSeries, person.PassportNumber, person.PassportAuthor, person.PassportDate, person.Sex, person.CountryId, person.NationalityId, person.RegionId, person.Phone, person.Mobiles, person.Email, person.Code, person.City, person.Street, person.House, person.Korpus, person.Flat, person.CodeReal, person.CityReal, person.StreetReal, person.HouseReal, person.KorpusReal, person.FlatReal, person.HostelAbit, false, null, false, null, person.IsExcellent, person.LanguageId, person.SchoolCity, person.SchoolTypeId, person.SchoolName, person.SchoolNum, person.SchoolExitYear, person.SchoolAVG, person.ForeignCountryEducId, person.RegionEducId, person.IsEqual, person.EqualDocumentNumber, person.HasTRKI, person.TRKICertificateNumber, person.AttestatRegion, person.AttestatSeries, person.AttestatNum, person.DiplomSeries, person.DiplomNum, person.HighEducation, person.HEProfession, person.HEQualification, person.HEEntryYear, person.HEExitYear, person.HEStudyFormId, person.HEWork, person.Stag, person.WorkPlace, person.Privileges, person.PassportCode, person.PersonalCode, person.PersonInfo, person.ExtraInfo, person.ScienceWork, person.StartEnglish, person.EnglishMark, entId); //_bdcInet.ExecuteQuery("UPDATE Person SET IsImported = 1 WHERE Person.Barcode = " + persBarcode); personId = (Guid)entId.Value; } qAbiturient abit = loadClass.GetAbitByBarcode(abitBarcode.Value); int cnt = (from en in context.qEntry where en.Id == abit.EntryId && !en.IsClosed select en).Count(); if (cnt == 0) { lstAbits.Add(abitBarcode.ToString()); continue; } ObjectParameter abEntId = new ObjectParameter("id", typeof(Guid)); int competitionId; if (abit.StudyBasisId == 1) { competitionId = 4; } else { competitionId = 3; } context.Abiturient_Insert(personId, abit.EntryId, competitionId, false, false, false, false, null, abit.DocDate, DateTime.Now, false, false, null, null, null, null, abit.LanguageId, false, abit.Priority, abit.Barcode, abit.CommitId, abit.CommitNumber, abit.IsGosLine, abEntId); // _bdcInet.ExecuteQuery("UPDATE Application SET IsImported = 1 WHERE Application.Barcode = " + abitBarcode); } } }