public void refreshJournal() { listViewJournal.Items.Clear(); queueJournal.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `id`, `payment_name_id`, `account_id`, `sum`, `date`, `student`, `group`, `edu_years_id`, `hostel_id`, semester, pdv FROM `tbl_journal`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; _Journal m = new _Journal(); int i = 1; foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(i.ToString(), 0); m.id = int.Parse(dataRow["id"].ToString()); m.semester = int.Parse(dataRow["semester"].ToString()); m.sum = double.Parse(dataRow["sum"].ToString().Replace(".", ",")); m.date = dataRow["date"].ToString(); item1.SubItems.Add(dataRow["date"].ToString().Trim()); m.student = dataRow["student"].ToString(); item1.SubItems.Add(dataRow["student"].ToString().Trim()); m.group = dataRow["group"].ToString(); item1.SubItems.Add(dataRow["group"].ToString().Trim()); item1.SubItems.Add(m.sum.ToString()); m.pdv = int.Parse(dataRow["pdv"].ToString()); m.payment_name_id = int.Parse(dataRow["payment_name_id"].ToString().Trim()); m.account_id = int.Parse(dataRow["account_id"].ToString().Trim()); m.edu_year_id = int.Parse(dataRow["edu_years_id"].ToString().Trim()); m.hostel_id = 0; if (dataRow["hostel_id"].ToString().Trim().Length>0) m.hostel_id = int.Parse(dataRow["hostel_id"].ToString().Trim()); _PaymentNames c; int k2 = queuePaymentNames.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_PaymentNames)queuePaymentNames.Dequeue(); if (c.id == m.payment_name_id) { item1.SubItems.Add(c.name); queuePaymentNames.Enqueue(c); break; }; queuePaymentNames.Enqueue(c); } _Semester s; k2 = queueSemesters.Count; for (int i2 = 0; i2 < k2; i2++) { s = (_Semester)queueSemesters.Dequeue(); if (s.id == m.semester) { item1.SubItems.Add(s.name); queueSemesters.Enqueue(s); break; }; queueSemesters.Enqueue(s); } _Pdv p; k2 = queuePdv.Count; for (int i2 = 0; i2 < k2; i2++) { p = (_Pdv)queuePdv.Dequeue(); if (p.id == m.pdv) { item1.SubItems.Add(p.name); queuePdv.Enqueue(p); break; }; queuePdv.Enqueue(p); } listViewJournal.Items.Add(item1); listViewJournal.Items[listViewJournal.Items.Count - 1].Tag = dataRow["id"].ToString(); queueJournal.Enqueue(m); ++i; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
public void refreshJournal() { listViewJournal.Items.Clear(); queueJournal.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `id`, `payment_name_id`, `account_id`, `sum`, `date`, `student`, `group`, `edu_years_id`, `hostel_id`, semester, pdv FROM `tbl_journal`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; _Journal m = new _Journal(); int i = 1; foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(i.ToString(), 0); m.id = int.Parse(dataRow["id"].ToString()); m.semester = int.Parse(dataRow["semester"].ToString()); m.sum = double.Parse(dataRow["sum"].ToString().Replace(".", ",")); m.date = dataRow["date"].ToString(); item1.SubItems.Add(dataRow["date"].ToString().Trim()); m.student = dataRow["student"].ToString(); item1.SubItems.Add(dataRow["student"].ToString().Trim()); m.group = dataRow["group"].ToString(); item1.SubItems.Add(dataRow["group"].ToString().Trim()); item1.SubItems.Add(m.sum.ToString()); m.pdv = int.Parse(dataRow["pdv"].ToString()); m.payment_name_id = int.Parse(dataRow["payment_name_id"].ToString().Trim()); m.account_id = int.Parse(dataRow["account_id"].ToString().Trim()); m.edu_year_id = int.Parse(dataRow["edu_years_id"].ToString().Trim()); m.hostel_id = 0; if (dataRow["hostel_id"].ToString().Trim().Length > 0) { m.hostel_id = int.Parse(dataRow["hostel_id"].ToString().Trim()); } _PaymentNames c; int k2 = queuePaymentNames.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_PaymentNames)queuePaymentNames.Dequeue(); if (c.id == m.payment_name_id) { item1.SubItems.Add(c.name); queuePaymentNames.Enqueue(c); break; } ; queuePaymentNames.Enqueue(c); } _Semester s; k2 = queueSemesters.Count; for (int i2 = 0; i2 < k2; i2++) { s = (_Semester)queueSemesters.Dequeue(); if (s.id == m.semester) { item1.SubItems.Add(s.name); queueSemesters.Enqueue(s); break; } ; queueSemesters.Enqueue(s); } _Pdv p; k2 = queuePdv.Count; for (int i2 = 0; i2 < k2; i2++) { p = (_Pdv)queuePdv.Dequeue(); if (p.id == m.pdv) { item1.SubItems.Add(p.name); queuePdv.Enqueue(p); break; } ; queuePdv.Enqueue(p); } listViewJournal.Items.Add(item1); listViewJournal.Items[listViewJournal.Items.Count - 1].Tag = dataRow["id"].ToString(); queueJournal.Enqueue(m); ++i; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewMarks_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonExcel.Enabled = true; buttonDelete.Enabled = true; textBoxStudent.Enabled = true; textBoxGroup.Enabled = true; textBoxSum.Enabled = true; comboBoxPaymentNames.Enabled = true; comboBoxAccounts.Enabled = true; comboBoxEduYear.Enabled = true; comboBoxHostel.Enabled = true; comboBoxSemester.Enabled = true; comboBoxPdv.Enabled = true; bNew = false; if (listViewJournal.FocusedItem == null) return; int k = queueJournal.Count; for (int i = 0; i < k; i++) { m_journal = (_Journal)queueJournal.Dequeue(); if (m_journal.id.ToString() == (string)listViewJournal.Items[listViewJournal.FocusedItem.Index].Tag) { textBoxStudent.Text = m_journal.student; //MessageBox.Show(m_journal.student); textBoxGroup.Text = m_journal.group; textBoxSum.Text = m_journal.sum.ToString(); _PaymentNames c; int k2 = queuePaymentNames.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_PaymentNames)queuePaymentNames.Dequeue(); if (c.id.ToString() == m_journal.payment_name_id.ToString()) { for (int iii = 0; iii < comboBoxPaymentNames.Items.Count; iii++) { if (((_PaymentNames)comboBoxPaymentNames.Items[iii]).id == c.id) { comboBoxPaymentNames.SelectedIndex = iii; m_payment_name = c; break; } } }; queuePaymentNames.Enqueue(c); } dateTimePickerDate.Value = DateTime.Parse(m_journal.date); dateTimePickerDate.Enabled = true; _Ekskursovody a; k2 = queueAccounts.Count; for (int i2 = 0; i2 < k2; i2++) { a = (_Ekskursovody)queueAccounts.Dequeue(); if (a.id.ToString() == m_journal.account_id.ToString()) { for (int iii = 0; iii < comboBoxAccounts.Items.Count; iii++) { if (((_Ekskursovody)comboBoxAccounts.Items[iii]).id == a.id) { comboBoxAccounts.SelectedIndex = iii; m_account = a; break; } } }; queueAccounts.Enqueue(a); } _Semester s; k2 = queueSemesters.Count; for (int i2 = 0; i2 < k2; i2++) { s = (_Semester)queueSemesters.Dequeue(); if (s.id.ToString() == m_journal.semester.ToString()) { for (int iii = 0; iii < comboBoxSemester.Items.Count; iii++) { if (((_Semester)comboBoxSemester.Items[iii]).id == s.id) { comboBoxSemester.SelectedIndex = iii; m_semester = s; break; } } }; queueSemesters.Enqueue(s); } _Pdv p; k2 = queuePdv.Count; for (int i2 = 0; i2 < k2; i2++) { p = (_Pdv)queuePdv.Dequeue(); if (p.id.ToString() == m_journal.pdv.ToString()) { for (int iii = 0; iii < comboBoxPdv.Items.Count; iii++) { if (((_Pdv)comboBoxPdv.Items[iii]).id == p.id) { comboBoxPdv.SelectedIndex = iii; m_pdv = p; break; } } }; queuePdv.Enqueue(p); } _Hostel h; k2 = queueHostel.Count; for (int i2 = 0; i2 < k2; i2++) { h = (_Hostel)queueHostel.Dequeue(); if (h.id.ToString() == m_journal.hostel_id.ToString()) { for (int iii = 0; iii < comboBoxHostel.Items.Count; iii++) { if (((_Hostel)comboBoxHostel.Items[iii]).id == h.id) { comboBoxHostel.SelectedIndex = iii; m_hostel = h; break; } } }; queueHostel.Enqueue(h); } _EduYears ey; k2 = queueEduYears.Count; for (int i2 = 0; i2 < k2; i2++) { ey = (_EduYears)queueEduYears.Dequeue(); if (ey.id.ToString() == m_journal.edu_year_id.ToString()) { for (int iii = 0; iii < comboBoxEduYear.Items.Count; iii++) { if (((_EduYears)comboBoxEduYear.Items[iii]).id == ey.id) { comboBoxEduYear.SelectedIndex = iii; m_edu_year = ey; break; } } }; queueEduYears.Enqueue(ey); } queueJournal.Enqueue(m_journal); break; }; queueJournal.Enqueue(m_journal); } }
private void listViewMarks_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonExcel.Enabled = true; buttonDelete.Enabled = true; textBoxStudent.Enabled = true; textBoxGroup.Enabled = true; textBoxSum.Enabled = true; comboBoxPaymentNames.Enabled = true; comboBoxAccounts.Enabled = true; comboBoxEduYear.Enabled = true; comboBoxHostel.Enabled = true; comboBoxSemester.Enabled = true; comboBoxPdv.Enabled = true; bNew = false; if (listViewJournal.FocusedItem == null) { return; } int k = queueJournal.Count; for (int i = 0; i < k; i++) { m_journal = (_Journal)queueJournal.Dequeue(); if (m_journal.id.ToString() == (string)listViewJournal.Items[listViewJournal.FocusedItem.Index].Tag) { textBoxStudent.Text = m_journal.student; //MessageBox.Show(m_journal.student); textBoxGroup.Text = m_journal.group; textBoxSum.Text = m_journal.sum.ToString(); _PaymentNames c; int k2 = queuePaymentNames.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_PaymentNames)queuePaymentNames.Dequeue(); if (c.id.ToString() == m_journal.payment_name_id.ToString()) { for (int iii = 0; iii < comboBoxPaymentNames.Items.Count; iii++) { if (((_PaymentNames)comboBoxPaymentNames.Items[iii]).id == c.id) { comboBoxPaymentNames.SelectedIndex = iii; m_payment_name = c; break; } } } ; queuePaymentNames.Enqueue(c); } dateTimePickerDate.Value = DateTime.Parse(m_journal.date); dateTimePickerDate.Enabled = true; _Ekskursovody a; k2 = queueAccounts.Count; for (int i2 = 0; i2 < k2; i2++) { a = (_Ekskursovody)queueAccounts.Dequeue(); if (a.id.ToString() == m_journal.account_id.ToString()) { for (int iii = 0; iii < comboBoxAccounts.Items.Count; iii++) { if (((_Ekskursovody)comboBoxAccounts.Items[iii]).id == a.id) { comboBoxAccounts.SelectedIndex = iii; m_account = a; break; } } } ; queueAccounts.Enqueue(a); } _Semester s; k2 = queueSemesters.Count; for (int i2 = 0; i2 < k2; i2++) { s = (_Semester)queueSemesters.Dequeue(); if (s.id.ToString() == m_journal.semester.ToString()) { for (int iii = 0; iii < comboBoxSemester.Items.Count; iii++) { if (((_Semester)comboBoxSemester.Items[iii]).id == s.id) { comboBoxSemester.SelectedIndex = iii; m_semester = s; break; } } } ; queueSemesters.Enqueue(s); } _Pdv p; k2 = queuePdv.Count; for (int i2 = 0; i2 < k2; i2++) { p = (_Pdv)queuePdv.Dequeue(); if (p.id.ToString() == m_journal.pdv.ToString()) { for (int iii = 0; iii < comboBoxPdv.Items.Count; iii++) { if (((_Pdv)comboBoxPdv.Items[iii]).id == p.id) { comboBoxPdv.SelectedIndex = iii; m_pdv = p; break; } } } ; queuePdv.Enqueue(p); } _Hostel h; k2 = queueHostel.Count; for (int i2 = 0; i2 < k2; i2++) { h = (_Hostel)queueHostel.Dequeue(); if (h.id.ToString() == m_journal.hostel_id.ToString()) { for (int iii = 0; iii < comboBoxHostel.Items.Count; iii++) { if (((_Hostel)comboBoxHostel.Items[iii]).id == h.id) { comboBoxHostel.SelectedIndex = iii; m_hostel = h; break; } } } ; queueHostel.Enqueue(h); } _EduYears ey; k2 = queueEduYears.Count; for (int i2 = 0; i2 < k2; i2++) { ey = (_EduYears)queueEduYears.Dequeue(); if (ey.id.ToString() == m_journal.edu_year_id.ToString()) { for (int iii = 0; iii < comboBoxEduYear.Items.Count; iii++) { if (((_EduYears)comboBoxEduYear.Items[iii]).id == ey.id) { comboBoxEduYear.SelectedIndex = iii; m_edu_year = ey; break; } } } ; queueEduYears.Enqueue(ey); } queueJournal.Enqueue(m_journal); break; } ; queueJournal.Enqueue(m_journal); } }