public void refreshZhurnal() { listViewZhurnal.Items.Clear(); queueZhurnal.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `id`, `date`, `FiO`, `N_kvit_nach`, `N_kvit_koniec`, `N_ekskursii` FROM `zhurnal` ORDER BY `id`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewZhurnal.Items.Clear(); queueZhurnal.Clear(); _Zhurnal m = new _Zhurnal(); // int i = 1; foreach (DataRow dataRow in dataTable.Rows) { // ListViewItem item1 = new ListViewItem(i.ToString(), 0); ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim()); m.id = dataRow["id"].ToString(); m.date = dataRow["date"].ToString(); item1.SubItems.Add(dataRow["date"].ToString().Trim()); m.FiO = dataRow["FiO"].ToString(); item1.SubItems.Add(dataRow["FiO"].ToString().Trim()); m.N_kvit_nach = dataRow["N_kvit_nach"].ToString(); item1.SubItems.Add(dataRow["N_kvit_nach"].ToString().Trim()); m.N_kvit_koniec = dataRow["N_kvit_koniec"].ToString(); item1.SubItems.Add(dataRow["N_kvit_koniec"].ToString().Trim()); m.N_ekskursii = dataRow["N_ekskursii"].ToString().Trim(); item1.SubItems.Add(dataRow["N_ekskursii"].ToString().Trim()); listViewZhurnal.Items.Add(item1); listViewZhurnal.Items[listViewZhurnal.Items.Count - 1].Tag = dataRow["id"].ToString(); queueZhurnal.Enqueue(m); // ++i; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewZhurnal_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; // buttonExcel.Enabled = true; buttonDelete.Enabled = true; comboBoxEkskursovod.Enabled = true; comboBoxNekskursii.Enabled = true; textBoxKvitNach.Enabled = true; textBoxKvitKoniec.Enabled = true; textBoxKolCzel.Enabled = true; textBoxZakaz.Enabled = true; dateTimePicker1.Enabled = true; dateTimePicker1.Value = DateTime.Today; dateTimePicker2.Enabled = true; dateTimePicker2.Value = DateTime.Today; dateTimePickerDate.Enabled = true; dateTimePickerDate.Value = DateTime.Today; bNew = false; if (listViewZhurnal.FocusedItem == null) return; int k = queueZhurnal.Count; for (int i = 0; i < k; i++) { m_zhurnal = (_Zhurnal)queueZhurnal.Dequeue(); if (m_zhurnal.id.ToString() == (string)listViewZhurnal.Items[listViewZhurnal.FocusedItem.Index].Tag) { /* _Ekskursii c; int k2 = queueEkskursii.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_Ekskursii)queueEkskursii.Dequeue(); if (c.id.ToString() == m_zhurnal.N_ekskursii.ToString()) { for (int iii = 0; iii < comboBoxNekskursii.Items.Count; iii++) { if (((_Ekskursii)comboBoxNekskursii.Items[iii]).id == c.id) { comboBoxNekskursii.SelectedIndex = iii; m_ekskursii = c; break; } } }; queueEkskursii.Enqueue(c); } dateTimePickerDate.Value = DateTime.Parse(m_zhurnal.date); dateTimePickerDate.Enabled = true; _Ekskursovody a; k2 = queueEkskursovod.Count; for (int i2 = 0; i2 < k2; i2++) { a = (_Ekskursovody)queueEkskursovod.Dequeue(); if (a.id.ToString() == m_zhurnal.FiO.ToString()) { for (int iii = 0; iii < comboBoxEkskursovod.Items.Count; iii++) { if (((_Ekskursovody) comboBoxEkskursovod.Items[iii]).id == a.id) { comboBoxEkskursovod.SelectedIndex = iii; m_ekskursovody = a; break; } } }; queueEkskursovod.Enqueue(a); } queueZhurnal.Enqueue(m_zhurnal); break;*/ textBoxKvitNach.Text = m_zhurnal.N_kvit_nach; textBoxKvitKoniec.Text = m_zhurnal.N_kvit_koniec; textBoxKolCzel.Text = m_zhurnal.kol_czel; textBoxZakaz.Text = m_zhurnal.zakazczik; }; queueZhurnal.Enqueue(m_zhurnal); } }
private void listViewZhurnal_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; // buttonExcel.Enabled = true; buttonDelete.Enabled = true; comboBoxEkskursovod.Enabled = true; comboBoxNekskursii.Enabled = true; textBoxKvitNach.Enabled = true; textBoxKvitKoniec.Enabled = true; textBoxKolCzel.Enabled = true; textBoxZakaz.Enabled = true; dateTimePicker1.Enabled = true; dateTimePicker1.Value = DateTime.Today; dateTimePicker2.Enabled = true; dateTimePicker2.Value = DateTime.Today; dateTimePickerDate.Enabled = true; dateTimePickerDate.Value = DateTime.Today; bNew = false; if (listViewZhurnal.FocusedItem == null) { return; } int k = queueZhurnal.Count; for (int i = 0; i < k; i++) { m_zhurnal = (_Zhurnal)queueZhurnal.Dequeue(); if (m_zhurnal.id.ToString() == (string)listViewZhurnal.Items[listViewZhurnal.FocusedItem.Index].Tag) { /* _Ekskursii c; * int k2 = queueEkskursii.Count; * for (int i2 = 0; i2 < k2; i2++) * { * c = (_Ekskursii)queueEkskursii.Dequeue(); * if (c.id.ToString() == m_zhurnal.N_ekskursii.ToString()) * { * * for (int iii = 0; iii < comboBoxNekskursii.Items.Count; iii++) * { * if (((_Ekskursii)comboBoxNekskursii.Items[iii]).id == c.id) * { * comboBoxNekskursii.SelectedIndex = iii; * m_ekskursii = c; * break; * } * } * }; * queueEkskursii.Enqueue(c); * } * * dateTimePickerDate.Value = DateTime.Parse(m_zhurnal.date); * dateTimePickerDate.Enabled = true; * * _Ekskursovody a; * k2 = queueEkskursovod.Count; * for (int i2 = 0; i2 < k2; i2++) * { * a = (_Ekskursovody)queueEkskursovod.Dequeue(); * if (a.id.ToString() == m_zhurnal.FiO.ToString()) * { * * for (int iii = 0; iii < comboBoxEkskursovod.Items.Count; iii++) * { * if (((_Ekskursovody) comboBoxEkskursovod.Items[iii]).id == a.id) * { * comboBoxEkskursovod.SelectedIndex = iii; * m_ekskursovody = a; * break; * } * } * }; * queueEkskursovod.Enqueue(a); * } * * queueZhurnal.Enqueue(m_zhurnal); * break;*/ textBoxKvitNach.Text = m_zhurnal.N_kvit_nach; textBoxKvitKoniec.Text = m_zhurnal.N_kvit_koniec; textBoxKolCzel.Text = m_zhurnal.kol_czel; textBoxZakaz.Text = m_zhurnal.zakazczik; } ; queueZhurnal.Enqueue(m_zhurnal); } }