public Olymps(DB_Connector connection, ApplicationEdit parent) { InitializeComponent(); _DB_Connection = connection; _DB_Helper = new DB_Helper(_DB_Connection); _Parent = parent; cbDiplomaType.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.DIPLOMA_TYPE).Values.ToArray()); cbClass.SelectedItem = "10"; cbDiscipline.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS).Values.ToArray()); cbCountry.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.COUNTRY).Values.ToArray()); Forms.ApplicationEdit.ODoc loadedDocument = _Parent.OlympicDoc; if ((loadedDocument.olympType != null) && (loadedDocument.olympType != "")) { cbOlympType.SelectedItem = loadedDocument.olympType; tbDocNumber.Text = loadedDocument.olympDocNumber.ToString(); if ((loadedDocument.diplomaType != null) && (loadedDocument.diplomaType != "")) { cbDiplomaType.SelectedItem = loadedDocument.diplomaType; } if (loadedDocument.olympID != 0) { tbOlympID.Text = loadedDocument.olympID.ToString(); cbOlympName.SelectedIndex = cbOlympName.FindString(_DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> > { new Tuple <string, Relation, object>("olympic_id", Relation.EQUAL, loadedDocument.olympID) })[0][0].ToString()); cbOlympProfile.SelectedIndex = cbOlympProfile.FindString(loadedDocument.olympProfile); } else { if (loadedDocument.olympName != null) { cbOlympName.Text = loadedDocument.olympName; } cbOlympProfile.SelectedItem = loadedDocument.olympProfile; } if (loadedDocument.olympClass != 0) { cbClass.SelectedItem = loadedDocument.olympClass.ToString(); } if ((loadedDocument.olympDist != null) && (loadedDocument.olympDist != "")) { cbDiscipline.SelectedItem = loadedDocument.olympDist; } if ((loadedDocument.country != null) && (loadedDocument.country != "")) { cbCountry.SelectedItem = loadedDocument.country; } } }
public SportDocs(DB_Connector connection, ApplicationEdit parent) { InitializeComponent(); _DB_Connection = connection; _Parent = parent; _DB_Helper = new DB_Helper(_DB_Connection); cbDocType.Items.Add(DB_Helper.SportAchievementGTO); cbDocType.Items.Add(DB_Helper.SportAchievementWorldChampionship); cbDocType.Items.Add(DB_Helper.SportAchievementEuropeChampionship); foreach (string itemName in _DB_Helper.GetDictionaryItems(FIS_Dictionary.SPORT_DIPLOMA_TYPE).Values) { cbDocType.Items.Add(itemName); } cbDocType.SelectedIndex = 0; Forms.ApplicationEdit.SDoc loadedDocument = _Parent.SportDoc; if ((loadedDocument.diplomaType != null) && (loadedDocument.diplomaType != "")) { cbDocType.SelectedItem = loadedDocument.diplomaType; tbDocName.Text = loadedDocument.docName; dtpDocDate.Value = loadedDocument.docDate; tbOrgName.Text = loadedDocument.orgName; } }
private void btLoad_Click(object sender, EventArgs e) { if (cbCampaign.SelectedIndex == -1) { MessageBox.Show("Не выбрана кампания"); } else { foreach (var record in _DB_Helper.GetDictionaryItems(FIS_Dictionary.IND_ACH_CATEGORIES)) { bool found = false; foreach (DataGridViewRow row in dgvAchievements.Rows) { if (record.Key == (uint)row.Cells[4].Value) { found = true; } } if (!found) { dgvAchievements.Rows.Add(0, record.Value, 0, record.Value, record.Key); } } } }
private void FillComboBox(ComboBox cb, FIS_Dictionary dictionary) { cb.Items.AddRange(_DB_Helper.GetDictionaryItems(dictionary).Values.ToArray()); if (cb.Items.Count > 0) { cb.SelectedIndex = 0; } }
public QuotDocs(DB_Connector connection, Forms.ApplicationEdit.QDoc loadedDocument) { InitializeComponent(); _DB_Connection = connection; DB_Helper dbHelper = new DB_Helper(_DB_Connection); cbCause.SelectedIndex = 0; cbMedCause.SelectedIndex = 0; cbOrphanhoodDocType.DataSource = dbHelper.GetDictionaryItems(FIS_Dictionary.ORPHAN_DOC_TYPE).Values.ToArray(); cbOrphanhoodDocType.SelectedIndex = 0; cbDisabilityGroup.DataSource = dbHelper.GetDictionaryItems(FIS_Dictionary.DISABILITY_GROUP).Values.ToArray(); cbDisabilityGroup.SelectedIndex = 0; _Document = loadedDocument; if (loadedDocument.cause == "Медицинские показатели") { cbCause.SelectedItem = loadedDocument.cause; cbMedCause.SelectedItem = loadedDocument.medCause; tbMedDocSeries.Text = loadedDocument.medDocSerie; tbMedDocNumber.Text = loadedDocument.medDocNumber; cbDisabilityGroup.SelectedItem = loadedDocument.disabilityGroup; tbConclusionNumber.Text = loadedDocument.conclusionNumber; dtpConclusionDate.Value = loadedDocument.conclusionDate; } else if (loadedDocument.cause == "Сиротство") { cbOrphanhoodDocType.SelectedItem = loadedDocument.orphanhoodDocType; tbOrphanhoodDocName.Text = loadedDocument.orphanhoodDocName; dtpOrphanhoodDocDate.Value = loadedDocument.orphanhoodDocDate; tbOrphanhoodDocOrg.Text = loadedDocument.orphanhoodDocOrg; } }
public InstitutionAchievementsEdit(DB_Connector connection) { InitializeComponent(); _DB_Connection = connection; _DB_Helper = new DB_Helper(_DB_Connection); foreach (var campaign in _DB_Connection.Select(DB_Table.CAMPAIGNS, "name")) { cbCampaign.Items.Add(campaign[0]); } cbAchievementType.DataSource = new BindingSource(_DB_Helper.GetDictionaryItems(FIS_Dictionary.IND_ACH_CATEGORIES), null); cbAchievementType.DisplayMember = "Value"; cbAchievementType.ValueMember = "Value"; }
private void UpdateTable() { dataGridView.Rows.Clear(); Dictionary <uint, string> subjects = _DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS); foreach (DB_Queries.Exam exam in DB_Queries.GetCampaignExams(_DB_Connection, Classes.Settings.CurrentCampaignID)) { dataGridView.Rows.Add( exam.ID, subjects[exam.SubjID], exam.Date, exam.RegStartDate, exam.RegEndDate ); } }
public ExaminationEdit(DB_Connector connection, uint?id) { _DB_Connection = connection; _ID = id; #region Components InitializeComponent(); dataGridView_Capacity.ValueType = typeof(ushort); Tuple <uint, uint> curCampStartEnd = DB_Queries.GetCampaignStartEnd(_DB_Connection, Classes.Settings.CurrentCampaignID); dtpDate.MinDate = new DateTime((int)curCampStartEnd.Item1, 1, 1); dtpDate.MaxDate = new DateTime((int)curCampStartEnd.Item2, 12, 31); dtpRegStartDate.MinDate = dtpDate.MinDate; dtpRegStartDate.MaxDate = dtpDate.MaxDate; dtpRegEndDate.MinDate = dtpDate.MinDate; dtpRegEndDate.MaxDate = dtpDate.MaxDate; foreach (DateTimePicker dtp in Controls.OfType <DateTimePicker>()) { dtp.Tag = _ID.HasValue; } if (_ID.HasValue) { dtpRegStartDate.Enabled = !DB_Queries.ExaminationHasMarks(_DB_Connection, _ID.Value); dtpRegEndDate.Enabled = !DB_Queries.ExaminationHasMarks(_DB_Connection, _ID.Value); } #endregion _DB_Helper = new DB_Helper(_DB_Connection); Dictionary <uint, string> subjects = _DB_Helper.GetDictionaryItems(FIS_Dictionary.SUBJECTS); cbSubject.Items.AddRange(subjects.Values.ToArray()); if (_ID.HasValue) { object[] exam = _DB_Connection.Select(DB_Table.EXAMINATIONS, new string[] { "subject_id", "date", "reg_start_date", "reg_end_date" }, new List <Tuple <string, Relation, object> > { new Tuple <string, Relation, object>("id", Relation.EQUAL, _ID) })[0]; cbSubject.SelectedItem = subjects[(uint)exam[0]]; dtpDate.Value = (DateTime)exam[1]; dtpRegStartDate.Value = (DateTime)exam[2]; dtpRegEndDate.Value = (DateTime)exam[3]; foreach (object[] row in _DB_Connection.Select( DB_Table.EXAMINATIONS_AUDIENCES, new string[] { "number", "capacity", "priority" }, new List <Tuple <string, Relation, object> > { new Tuple <string, Relation, object>("examination_id", Relation.EQUAL, _ID) }).OrderBy(s => s[2])) { dataGridView.Rows.Add(row[0], row[1]); } } }
private void UpdateDictionaryItems(FIS_Dictionary dictionary, string dictionaryName, Dictionary <uint, string> fisDictionaryItems) { Dictionary <uint, string> dbDictionaryItems = _DB_Helper.GetDictionaryItems(dictionary); string addedReport = "В справочник №" + dictionary + " \"" + dictionaryName + "\" добавлены элементы:"; ushort addedCount = 0; string deletedReport = ""; foreach (var item in fisDictionaryItems) { if (dbDictionaryItems.ContainsKey(item.Key)) { if (item.Value != dbDictionaryItems[item.Key] && SharedClasses.Utility.ShowChoiceMessageWithConfirmation( "Справочник №" + dictionary + " \"" + dictionaryName + "\":\nв ФИС изменилось наименование элемента с кодом " + item.Key + ":\nC \"" + dbDictionaryItems[item.Key] + "\"\nна \"" + item.Value + "\".\n\nОбновить наименование в БД?", "Действие" )) { _DB_Connection.Update(DB_Table.DICTIONARIES_ITEMS, new Dictionary <string, object> { { "name", item.Value } }, new Dictionary <string, object> { { "dictionary_id", dictionary }, { "item_id", item.Key } } ); } } else { _DB_Connection.Insert(DB_Table.DICTIONARIES_ITEMS, new Dictionary <string, object> { { "dictionary_id", dictionary }, { "item_id", item.Key }, { "name", item.Value } } ); addedReport += "\n" + item.Key + " \"" + item.Value + "\""; addedCount++; } } foreach (var item in dbDictionaryItems) { if (!fisDictionaryItems.ContainsKey(item.Key)) { deletedReport += item.Key + ", "; } } if (addedCount != 0) { addedReport += "\nВсего: " + addedCount; ShowUpdateMessage(addedReport); } if (deletedReport != "") { deletedReport = "Справочник №" + dictionary + ": в ФИС отсутствуют элементы с ID: " + deletedReport.Remove(deletedReport.Length - 2); MessageBox.Show(deletedReport, "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void cbOlympType_SelectedIndexChanged(object sender, EventArgs e) { if (cbOlympType.SelectedItem.ToString() == "Диплом победителя/призера олимпиады школьников") { label2.Enabled = false; tbDocNumber.Enabled = false; label3.Enabled = false; cbDiplomaType.Enabled = true; label4.Enabled = true; label5.Enabled = true; cbClass.Enabled = true; label7.Enabled = true; cbDiscipline.Enabled = true; label8.Enabled = true; cbCountry.Enabled = false; label9.Enabled = false; cbOlympName.ValueMember = "Value"; cbOlympName.DisplayMember = "Name"; cbOlympName.DataSource = _DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_id", "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> > { new Tuple <string, Relation, object>("year", Relation.GREATER_EQUAL, DateTime.Now.Year - 1) }).Select(s => new { Name = s[1].ToString(), Value = new OlympTuple((uint)s[0], Name) }).ToArray(); } else if (cbOlympType.SelectedItem.ToString() == "Диплом победителя/призера всероссийской олимпиады школьников") { label2.Enabled = false; tbDocNumber.Enabled = true; label3.Enabled = true; cbDiplomaType.Enabled = true; label4.Enabled = true; label5.Enabled = true; cbClass.Enabled = true; label7.Enabled = true; cbDiscipline.Enabled = true; label8.Enabled = true; cbCountry.Enabled = false; label9.Enabled = false; cbOlympName.ValueMember = "Value"; cbOlympName.DisplayMember = "Name"; cbOlympName.DataSource = _DB_Connection.Select(DB_Table.DICTIONARY_19_ITEMS, new string[] { "olympic_id", "olympic_name" }, new System.Collections.Generic.List <Tuple <string, Relation, object> > { new Tuple <string, Relation, object>("year", Relation.EQUAL, DateTime.Now.Year) }).Select(s => new { Name = s[1].ToString(), Value = new OlympTuple((uint)s[0], Name) }).ToArray(); } else if (cbOlympType.SelectedItem.ToString() == "Диплом 4 этапа всеукраинской олимпиады") { label2.Enabled = true; tbDocNumber.Enabled = true; label3.Enabled = true; cbDiplomaType.Enabled = true; label4.Enabled = true; label5.Enabled = false; cbClass.Enabled = false; label7.Enabled = false; cbDiscipline.Enabled = false; label8.Enabled = false; cbCountry.Enabled = false; label9.Enabled = false; cbOlympName.DataSource = null; cbOlympName.Text = ""; tbOlympID.Text = ""; cbOlympProfile.DataSource = null; cbOlympProfile.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.OLYMPICS_PROFILES).Values.ToArray()); } else if (cbOlympType.SelectedItem.ToString() == "Диплом международной олимпиады") { label2.Enabled = true; tbDocNumber.Enabled = true; label3.Enabled = true; cbDiplomaType.Enabled = false; label4.Enabled = false; label5.Enabled = false; cbClass.Enabled = false; label7.Enabled = false; cbDiscipline.Enabled = false; label8.Enabled = false; cbCountry.Enabled = true; label9.Enabled = true; cbOlympName.DataSource = null; cbOlympName.Text = ""; tbOlympID.Text = ""; cbOlympProfile.DataSource = null; cbOlympProfile.Items.AddRange(_DB_Helper.GetDictionaryItems(FIS_Dictionary.OLYMPICS_PROFILES).Values.ToArray()); } }