protected override bool SaveRecord() { if (!CheckFields()) { return(false); } try { if (!IsForReadOnly()) { string newId = Save(); if (_Id == null) { _Id = newId; } return(true); } return(false); } catch (Exception de) { WinFormsServ.Error("Ошибка обновления данных" + de.Message); return(false); } }
//заполняет мультифильтр-юзерконтрол private void FillMulti() { try { DataSet ds = _bdc.GetDataSet(_currentItem.Query); //если ничего нет - выходим if (ds.Tables[0].Rows.Count == 0) { return; } List <ListItem> list = new List <ListItem>(); foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new ListItem(dr["Id"].ToString(), dr["Name"].ToString())); } fMult.ClearLists(); fMult.FillList(list, true); } catch (Exception ex) { WinFormsServ.Error("Ошибка при заполнении фильтра:" + ex.Message); } }
//обновление списка public void UpdateVedList() { try { using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from ent in context.extExamsVed where ent.StudyLevelGroupId == StudyLevelGroupId && ent.FacultyId == FacultyId && (StudyBasisId != null ? ent.StudyBasisId == StudyBasisId : true == true) select new { ent.Id, ent.ExamName, ent.Date, StBasis = ent.StudyBasisId == null ? "" : ent.StudyBasisAcr, AddVed = ent.IsAddVed ? " дополнительная" : "", ent.AddCount }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.ExamName + ' ' + u.Date.ToShortDateString() + ' ' + u.StBasis + u.AddVed + (u.AddCount > 1 ? "(" + Convert.ToString(u.AddCount) + ")" : ""))).ToList(); ComboServ.FillCombo(cbExamVed, lst, true, false); } } catch (Exception ex) { WinFormsServ.Error("Ошибка при обновлении списка ведомостей: " + ex.Message); } }
private void btnOk_Click(object sender, EventArgs e) { if (!isAdditional) { using (PriemEntities context = new PriemEntities()) { int cnt = (from ev in context.extExamsVed where ev.ExamId == ExamId && ev.Date == dtDateExam.Value.Date && ev.FacultyId == facultyId && (studyBasisId == null ? ev.StudyBasisId == null : ev.StudyBasisId == studyBasisId) && !ev.IsAddVed select ev).Count(); if (cnt > 0) { WinFormsServ.Error(string.Format("{0}едомость на этот экзамен на эту дату {1} уже существует! ", isAdditional ? "Дополнительная в" : "В", studyBasisId == null ? "" : "на эту основу обучения")); return; } } } ExamsVedCard frm = new ExamsVedCard(owner, studyLevelGroupId, facultyId, ExamId, dtDateExam.Value, studyBasisId, isAdditional); frm.Show(); this.Close(); }
public void FillPaidData() { try { using (PriemEntities context = new PriemEntities()) { PayDataEntry payData = (from ab in context.qAbiturient join pde in context.PayDataEntry on ab.EntryId equals pde.EntryId where ab.Id == _abitId select pde).FirstOrDefault(); if (payData == null) { return; } Qualification = payData.Qualification; Srok = payData.EducPeriod; DateStart = payData.DateStart; DateFinish = payData.DateFinish; ProrektorId = payData.ProrektorId; } } catch (DataException de) { WinFormsServ.Error("Ошибка при заполнении формы " + de.Message); } }
protected override void ExtraInit() { base.ExtraInit(); _title = "Экзамен"; _tableName = "ed.[ExamInEntry]"; try { if (_Id != null) { chbToAllStudyBasis.Visible = false; } chbToAllStudyBasis.Checked = true; using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from f in context.Exam join en in context.ExamName on f.ExamNameId equals en.Id select new { Id = f.Id, Name = en.Name, IsAdd = f.IsAdditional }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.Name + (u.IsAdd ? " (доп)" : ""))).ToList(); ComboServ.FillCombo(cbExam, lst, false, false); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы " + exc.Message); } }
protected override void ExtraInit() { base.ExtraInit(); btnAdd.Visible = btnRemove.Visible = false; try { using (PriemEntities context = new PriemEntities()) { ComboServ.FillCombo(cbFaculty, HelpClass.GetComboListByTable("ed.qFaculty", "ORDER BY Acronym"), false, false); ComboServ.FillCombo(cbStudyForm, HelpClass.GetComboListByTable("ed.StudyForm", "ORDER BY Id"), false, false); FillLicenseProgram(); FillObrazProgram(); ComboServ.FillCombo(cbLanguage, HelpClass.GetComboListByTable("ed.Language"), false, true); ComboServ.FillCombo(cbOlympType, HelpClass.GetComboListByTable("ed.OlympType", " ORDER BY Id"), false, true); ComboServ.FillCombo(cbOlympName, HelpClass.GetComboListByTable("ed.OlympName"), false, true); ComboServ.FillCombo(cbOlympSubject, HelpClass.GetComboListByTable("ed.OlympSubject"), false, true); ComboServ.FillCombo(cbOlympValue, HelpClass.GetComboListByTable("ed.OlympValue"), false, true); ComboServ.FillCombo(cbOlympLevel, HelpClass.GetComboListByTable("ed.OlympLevel"), false, true); UpdateDataGrid(); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы " + exc.Message); } }
private bool SaveMarks() { try { using (PriemEntities context = new PriemEntities()) { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew)) { string mark = null; for (int i = 0; i < dgvMarks.Rows.Count; i++) { int persNum = int.Parse(dgvMarks["Номер", i].Value.ToString()); Guid persId = new Guid(dgvMarks["PersonId", i].Value.ToString()); if (dgvMarks["Баллы", i].Value != null) { mark = dgvMarks["Баллы", i].Value.ToString().Trim(); } int?updatedMark; int mrk; if (string.IsNullOrEmpty(mark)) { updatedMark = null; } else if (int.TryParse(mark, out mrk) && mrk >= 0 && mrk < 101) { updatedMark = mrk; } else { dgvMarks.CurrentCell = dgvMarks["Баллы", i]; WinFormsServ.Error(dgvMarks["Номер", i].Value.ToString() + ": неправильно введены данные"); return(false); } if (_isOral) { context.ExamsVedHistory_UpdateMarkOral(_vedId, persId, persNum, updatedMark); } else { context.ExamsVedHistory_UpdateMark(_vedId, persId, persNum, updatedMark); } } transaction.Complete(); return(true); } } } catch (Exception exc) { WinFormsServ.Error("Ошибка сохранения данных: \n" + exc.Message); return(false); } }
private void FillProfile() { try { using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from ent in GetEntry(context) where ent.LicenseProgramId == LicenseProgramId && ent.ObrazProgramId == ObrazProgramId && ent.ProfileId != null select new { Id = ent.ProfileId, Name = ent.ProfileName }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.Name)).ToList(); if (lst.Count() > 0) { ComboServ.FillCombo(cbProfile, lst, false, false); cbProfile.Enabled = true; } else { ComboServ.FillCombo(cbProfile, new List <KeyValuePair <string, string> >(), true, false); cbProfile.Enabled = false; } } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы FillProfile" + exc.Message); } }
private void Unfixieren() { try { using (PriemEntities context = new PriemEntities()) { Guid?entryId = (from fv in context.qEntry where fv.StudyLevelGroupId == StudyLevelGroupId && fv.IsReduced == IsReduced && fv.IsParallel == IsParallel && fv.IsSecond == IsSecond && fv.FacultyId == FacultyId && fv.LicenseProgramId == LicenseProgramId && fv.ObrazProgramId == ObrazProgramId && (ProfileId == null ? fv.ProfileId == 0 : fv.ProfileId == ProfileId) && fv.StudyFormId == StudyFormId && fv.StudyBasisId == StudyBasisId select fv.Id).FirstOrDefault(); //удалили context.FirstWave_DELETE(entryId, false, false); } } catch (Exception ex) { WinFormsServ.Error("Ошибка при WEB FIXIEREN !"); } MessageBox.Show("DONE!"); }
private void btnUpdateImport_Click(object sender, EventArgs e) { if (!MainClass.IsPasha()) { return; } if (MessageBox.Show("Обновить IsImported = true?", "Обновление", MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (DataGridViewRow dgvr in dgvAbiturients.SelectedRows) { string sId = dgvr.Cells["Id"].Value.ToString(); try { string query; query = string.Format("UPDATE [Application] SET IsImported = 1 WHERE Id = '{0}'", sId); _bdcInet.ExecuteQuery(query); } catch (Exception ex) { WinFormsServ.Error("Ошибка обновления данных" + ex.Message); goto Next; } Next :; } UpdateDataGrid(); } }
private void btnDeleteAb_Click(object sender, EventArgs e) { if (MainClass.IsPasha()) { using (PriemEntities context = new PriemEntities()) { if (MessageBox.Show("Удалить из рейтингового списка?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew)) { foreach (DataGridViewRow dgvr in dgvAbits.SelectedRows) { Guid abId = new Guid(dgvr.Cells["Id"].Value.ToString()); try { context.Fixieren_DELETE(abId); context.FirstWave_DeleteByAbId(abId); } catch (Exception ex) { WinFormsServ.Error("Ошибка удаления данных" + ex.Message); } } transaction.Complete(); } UpdateDataGrid(); } } } }
private void btnDelete_Click(object sender, EventArgs e) { if (ExamVedId == null || ExamVedRoomId == null) { return; } using (PriemEntities context = new PriemEntities()) { if (MessageBox.Show("Удалить выбранную ведомость в помещении? ", "Внимание", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew)) { context.ExamsVedRoomHistory_DeleteByVedRoomId(ExamVedRoomId); context.ExamsVedRoom_Delete(ExamVedRoomId); UpdateVedRoomList(); } } catch (Exception de) { WinFormsServ.Error("Ошибка удаления данных " + de.Message); } } } }
public void UpdateVedRoomList() { try { if (ExamVedId == null) { ComboServ.FillCombo(cbExamVedRoom, new List <KeyValuePair <string, string> >(), false, false); cbExamVedRoom.Enabled = false; } else { using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from ent in context.ExamsVedRoom where ent.ExamsVedId == ExamVedId orderby ent.Number, ent.RoomNumber select new { ent.Id, ent.Number, ent.RoomNumber }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.Number + ": " + u.RoomNumber)).ToList(); ComboServ.FillCombo(cbExamVedRoom, lst, true, false); cbExamVedRoom.Enabled = true; } } } catch (Exception ex) { WinFormsServ.Error("Ошибка при обновлении списка ведомостей: " + ex.Message); } }
//функция заполнения грида private void FillGrid(DataGridView dgv, string sQuery, string sWhere, string sOrderby) { try { //подготовили грид InitGrid(dgv); DataSet ds = bdc.GetDataSet(sQuery + sWhere + sOrderby); //заполняем строки foreach (DataRow dr in ds.Tables[0].Rows) { DataGridViewRow r = new DataGridViewRow(); r.CreateCells(dgv, false, dr["Id"].ToString(), dr["Ид_номер"].ToString(), dr["ФИО"].ToString(), dr["Документ_об_образовании"].ToString(), dr["Паспорт"].ToString()); dgv.Rows.Add(r); } //блокируем редактирование for (int i = 1; i < dgv.ColumnCount; i++) { dgv.Columns[i].ReadOnly = true; } dgv.Update(); } catch (Exception ex) { WinFormsServ.Error("Ошибка при заполнении грида данными протокола: " + ex.Message); } }
private void FillStudyBasis() { try { using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from ent in GetEntry(context) where ent.LicenseProgramId == LicenseProgramId && ent.ObrazProgramId == ObrazProgramId && (ProfileId == null ? ent.ProfileId == null : ent.ProfileId == ProfileId) && ent.FacultyId == FacultyId && ent.StudyFormId == StudyFormId select new { Id = ent.StudyBasisId, Name = ent.StudyBasis.Name }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.Name)).ToList(); ComboServ.FillCombo(cbStudyBasis, lst, false, false); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы FillStudyBasis" + exc.Message); } }
protected override void FillCard() { if (_Id == null) { return; } try { using (PriemEntities context = new PriemEntities()) { ExamInEntry ent = (from ex in context.ExamInEntry where ex.Id == IntId select ex).FirstOrDefault(); ExamId = ent.ExamId; IsProfil = ent.IsProfil; EgeMin = ent.EgeMin; } } catch (Exception exc) { WinFormsServ.Error("Ошибка при заполнении формы " + exc.Message); } }
protected override void ExtraInit() { base.ExtraInit(); _title = "Экзамен"; _tableName = "ed.[Exam]"; try { using (PriemEntities context = new PriemEntities()) { List <KeyValuePair <string, string> > lst = ((from f in context.ExamName select new { Id = f.Id, Name = f.Name }).Distinct()).ToList().Select(u => new KeyValuePair <string, string>(u.Id.ToString(), u.Name)).ToList(); ComboServ.FillCombo(cbExamName, lst, false, false); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы " + exc.Message); } }
public void UpdateProtocolList(object sender, EventArgs e) { try { _currentProtocolIndex = cbProtocolNum.SelectedIndex; using (PriemEntities context = new PriemEntities()) { int protType = TypeToInt(_protocolType); var protocols = (from p in context.qProtocol where !p.IsOld && p.ProtocolTypeId == protType && p.FacultyId == FacultyId && p.StudyFormId == StudyFormId && p.StudyBasisId == StudyBasisId orderby p.Number select new { p.Id, p.Number }).ToList().Select(x => new KeyValuePair <string, string>(x.Id.ToString(), x.Number)).ToList(); ComboServ.FillCombo(cbProtocolNum, protocols, true, false); } } catch (Exception ex) { WinFormsServ.Error("Ошибка при обновлении списка протоколов: " + ex.Message); } }
public DocsClass(int personBarcode, int?abitCommitBarcode) { _bdcInet = new DBPriem(); _bdcInetFiles = new DBPriem(); try { _bdcInet.OpenDatabase(MainClass.connStringOnline); _bdcInetFiles.OpenDatabase(MainClass.connStringOnlineFiles); } catch (Exception exc) { WinFormsServ.Error(exc.Message); } _personId = _bdcInet.GetStringValue("SELECT Person.Id FROM Person WHERE Person.Barcode = " + personBarcode); if (abitCommitBarcode == null) { _abitId = null; } else { _abitId = _bdcInet.GetStringValue("SELECT qAbiturient.Id FROM qAbiturient WHERE qAbiturient.CommitNumber = " + abitCommitBarcode); _commitId = _bdcInet.GetStringValue("SELECT qAbiturient.CommitId FROM qAbiturient WHERE qAbiturient.CommitNumber = " + abitCommitBarcode); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { //сохраняем параметры try { if (MainClass._config != null) { MainClass._config.AddValue("lstAbitDef", smiListAbit.Checked.ToString()); MainClass._config.SaveConfig(); } } catch (Exception ex) { WinFormsServ.Error("Ошибка при чтении параметров из файла: " + ex.Message); } try { MainClass.DeleteAllOpenByHolder(); } catch (Exception ex) { WinFormsServ.Error("Ошибка записи в базу: " + ex.Message); } MainClass.DeleteTempFiles(); }
public List <KeyValuePair <string, string> > UpdateFiles() { try { if (_personId == null) { return(null); } List <KeyValuePair <string, string> > lstFiles = new List <KeyValuePair <string, string> >(); string query = string.Format("SELECT Id, FileName + ' (' + convert(nvarchar, extAbitFileNames_All.LoadDate, 104) + ' ' + convert(nvarchar, extAbitFileNames_All.LoadDate, 108) + ')' + FileExtention AS FileName FROM extAbitFileNames_All WHERE extAbitFileNames_All.PersonId = '{0}' {1} {2}", _personId, !string.IsNullOrEmpty(_abitId) ? " AND (extAbitFileNames_All.ApplicationId = '" + _abitId + "' OR extAbitFileNames_All.ApplicationId IS NULL)" : "", !string.IsNullOrEmpty(_commitId) ? " AND (extAbitFileNames_All.CommitId = '" + _commitId + "' OR extAbitFileNames_All.CommitId IS NULL)" : ""); DataSet ds = _bdcInetFiles.GetDataSet(query + " ORDER BY extAbitFileNames_All.LoadDate DESC"); foreach (DataRow dRow in ds.Tables[0].Rows) { lstFiles.Add(new KeyValuePair <string, string>(dRow["Id"].ToString(), dRow["FileName"].ToString())); } return(lstFiles); } catch (System.Exception exc) { WinFormsServ.Error("Ошибка обновления данных о приложениях: " + exc.Message); return(null); } }
protected override void GetSource() { try { using (PriemEntities context = new PriemEntities()) { IQueryable <qEntry> query; if (string.IsNullOrEmpty(_orderBy)) { query = context.qEntry.OrderBy(c => c.StudyLevelName).ThenBy(c => c.FacultyName).ThenBy(c => c.ObrazProgramName).ThenBy(c => c.ProfileName).ThenBy(c => c.StudyFormId).ThenBy(c => c.StudyBasisId); } else { query = context.qEntry.OrderBy(_orderBy); } GetFilters(ref query); Dgv.DataSource = query; SetVisibleColumnsAndNameColumns(); } } catch (Exception exc) { WinFormsServ.Error(exc.Message); } }
/// <summary> /// on save or modify /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (_modified == false) { btnSave.Text = BaseFormsLib.Constants.BTN_SAVE_TITLE; this.Text = Title + BaseFormsLib.Constants.CARD_MODIFIED; SetReadOnly(false); _modified = true; } else { try { DataTable tableChanges = dataTable.GetChanges(); if (tableChanges != null) { UpdateSource(tableChanges); dataTable.AcceptChanges(); BindGrid(GetSource()); } btnSave.Text = BaseFormsLib.Constants.BTN_CHANGE_TITLE; this.Text = Title + BaseFormsLib.Constants.CARD_READ_ONLY; SetReadOnly(true); _modified = false; } catch (Exception ex) { WinFormsServ.Error("Ошибка при сохранении данных:" + ex.Message); } } return; }
protected override void ExtraInit() { base.ExtraInit(); _title = "Данные по договору"; _tableName = "ed.PaidData"; this.MdiParent = null; try { using (PriemEntities context = new PriemEntities()) { _Id = (from pd in context.PaidData where pd.AbiturientId == _abitId orderby pd.DogovorDate descending select pd.Id).FirstOrDefault().ToString(); if (string.IsNullOrEmpty(_Id) || _Id == Guid.Empty.ToString()) { _Id = null; } ComboServ.FillCombo(cbDogovorType, HelpClass.GetComboListByTable("ed.DogovorType", "ORDER BY Id"), false, false); UpdateAfterDogovorType(); ComboServ.FillCombo(cbProrektor, HelpClass.GetComboListByTable("ed.Prorektor"), false, false); ComboServ.FillCombo(cbPayPeriod, HelpClass.GetComboListByTable("ed.PayPeriod"), false, false); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы " + exc.Message); } }
protected override void FillCard() { if (_Id == null) { return; } try { using (PriemEntities context = new PriemEntities()) { ExamName exn = (from pr in context.ExamName where pr.Id == IntId select pr).FirstOrDefault(); ExamName = exn.Name; NamePad = exn.NamePad; Acronym = exn.Acronym; } } catch (Exception ex) { WinFormsServ.Error("Ошибка при заполнении формы " + ex.Message); } }
//проверка и подсчет private int CheckFilters(List <iFilter> list) { int filtCount = 0, leftBrackCount = 0, rightBrackCount = 0; foreach (iFilter obj in lbFilters.Items) { list.Add(obj); if (obj is Filter) { filtCount++; } else if (obj is LeftBracket) { leftBrackCount++; } else if (obj is RightBracket) { rightBrackCount++; } } if (leftBrackCount != rightBrackCount) { WinFormsServ.Error("Неправильная расстановка скобок"); return(-1); } return(filtCount); }
protected override void FillCard() { if (_Id == null) { return; } try { using (PriemEntities context = new PriemEntities()) { OlympBook olymp = (from ec in context.OlympBook where ec.Id == GuidId select ec).FirstOrDefault(); if (olymp == null) { return; } OlympTypeId = olymp.OlympTypeId; OlympNameId = olymp.OlympNameId; OlympSubjectId = olymp.OlympSubjectId; OlympLevelId = olymp.OlympLevelId; } } catch (DataException de) { WinFormsServ.Error("Ошибка при заполнении формы " + de.Message); } }
private void btnDeleteFromVed_Click(object sender, EventArgs e) { if (ExamVedId == null) { return; } if (MainClass.IsPasha()) { if (MessageBox.Show("Удалить person из ведомости?", "Удаление", MessageBoxButtons.YesNo) == DialogResult.Yes) { using (PriemEntities context = new PriemEntities()) { foreach (DataGridViewRow dgvr in dgvList.SelectedRows) { Guid persId = new Guid(dgvr.Cells["Id"].Value.ToString()); try { context.ExamsVedHistory_DeleteByPersonAndVedId(ExamVedId, persId); } catch (Exception ex) { WinFormsServ.Error("Ошибка удаления данных" + ex.Message); goto Next; } Next :; } UpdateDataGrid(); } } } }
protected override void ExtraInit() { base.ExtraInit(); Dgv.ReadOnly = false; btnRemove.Visible = btnAdd.Visible = false; //this.Width = 774; try { using (PriemEntities context = new PriemEntities()) { ComboServ.FillCombo(cbFaculty, HelpClass.GetComboListByTable("ed.qFaculty", "ORDER BY Acronym"), false, false); ComboServ.FillCombo(cbStudyLevelGroup, HelpClass.GetComboListByTable("ed.StudyLevelGroup", "ORDER BY Acronym"), false, false); ComboServ.FillCombo(cbStudyBasis, HelpClass.GetComboListByTable("ed.StudyBasis", "ORDER BY Name"), false, true); cbStudyBasis.SelectedIndex = 0; FillStudyForm(); FillLicenseProgram(); FillObrazProgram(); FillExams(); ComboServ.FillCombo(cbOlympType, HelpClass.GetComboListByTable("ed.OlympType", " ORDER BY Id"), false, true); ComboServ.FillCombo(cbOlympName, HelpClass.GetComboListByTable("ed.OlympName"), false, true); ComboServ.FillCombo(cbOlympSubject, HelpClass.GetComboListByTable("ed.OlympSubject"), false, true); ComboServ.FillCombo(cbOlympValue, HelpClass.GetComboListByTable("ed.OlympValue"), false, true); ComboServ.FillCombo(cbOlympLevel, HelpClass.GetComboListByTable("ed.OlympLevel"), false, true); } } catch (Exception exc) { WinFormsServ.Error("Ошибка при инициализации формы " + exc.Message); } }