//массив из журнала public void refreshOst1() { listViewBilety.Items.Clear(); queueBilety.Clear(); listViewBilety.Columns.Clear(); listViewBilety.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety.Columns[0].Width = 150; listViewBilety.Columns[1].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = String.Format("select `zhurnal`.`N_kvit_nach` AS `N_kvit_nach`,`zhurnal`.`N_kvit_koniec` AS `N_kvit_koniec` from `zhurnal` WHERE `date` like \"{0}%\" order by `N_kvit_nach`", comboBoxYear.Text); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety.Items.Clear(); queueBilety.Clear(); _Bilety t = new _Bilety(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["N_kvit_nach"].ToString().Trim()); t.id = dataRow["N_kvit_nach"].ToString().Trim(); item1.SubItems.Add(dataRow["N_kvit_koniec"].ToString().Trim()); t.name = dataRow["N_kvit_koniec"].ToString().Trim(); listViewBilety.Items.Add(item1); listViewBilety.Items[listViewBilety.Items.Count - 1].Tag = dataRow["N_kvit_nach"].ToString(); queueBilety.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
//начальные и конечные номера билетов из журнала public void refreshOst1() { listViewKvit.Items.Clear(); queueKvit.Clear(); listViewKvit.Columns.Clear(); listViewKvit.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewKvit.Columns[0].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "select `rasselenie`.`N_kvit` AS `N_kvit` from `rasselenie` order by `N_kvit`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewKvit.Items.Clear(); queueKvit.Clear(); _Bilety t = new _Bilety(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["N_kvit"].ToString().Trim()); t.id = dataRow["N_kvit"].ToString().Trim(); listViewKvit.Items.Add(item1); listViewKvit.Items[listViewKvit.Items.Count - 1].Tag = dataRow["N_kvit"].ToString(); queueKvit.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewBilety_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxKvN.Enabled = true; comboBoxEkskursii.Enabled = true; textBoxKvK.Enabled = true; dateTimePicker1.Enabled = true; bNew = false; if (listViewBilety.FocusedItem == null) return; int k = queueBilety.Count; for (int i = 0; i < k; i++) { m_bilety = (_Bilety)queueBilety.Dequeue(); if (m_bilety.id == (string)listViewBilety.Items[listViewBilety.FocusedItem.Index].Tag) { textBoxKvN.Text = m_bilety.KvN; comboBoxEkskursii.Text = m_bilety.name; textBoxKvK.Text = m_bilety.KvK; dateTimePicker1.Value = DateTime.Parse(m_bilety.date); queueBilety.Enqueue(m_bilety); _Ekskursii c; int k2 = queueEkskursii.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_Ekskursii)queueEkskursii.Dequeue(); if (c.nazvanie.ToString() == m_bilety.name.ToString()) { for (int iii = 0; iii < comboBoxEkskursii.Items.Count; iii++) { if (((_Ekskursii)comboBoxEkskursii.Items[iii]).id == c.id) { comboBoxEkskursii.SelectedIndex = iii; m_ekskursii = c; break; } } }; queueEkskursii.Enqueue(c); } break; }; queueBilety.Enqueue(m_bilety); } }
//конечные номера билетов и названия экскурсий для массива 2 public void refreshOst2() { listViewBilety.Items.Clear(); queueBilety.Clear(); listViewBilety.Columns.Clear(); listViewBilety.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Название", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Стоимость", -2, HorizontalAlignment.Left); listViewBilety.Columns[0].Width = 150; listViewBilety.Columns[1].Width = 150; listViewBilety.Columns[2].Width = 150; listViewBilety.Columns[3].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); //string sql = "select `bilety`.`N_kvit_koniec` AS `N_kvit_koniec`,`bilety`.`naimenovanie` AS `naimenovanie`,`ekskursii`.`stoimost` AS `stoimost` from (`bilety` join `ekskursii` on((`bilety`.`naimenovanie` = `ekskursii`.`nazvanie`))) order by `bilety`.`N_kvit_koniec`"; string sql = String.Format("select `bilety`.`N_kvit_nach` AS `N_kvit_nach`, `bilety`.`N_kvit_koniec` AS `N_kvit_koniec`,`bilety`.`naimenovanie` AS `naimenovanie`,`ekskursii`.`stoimost` AS `stoimost` from (`bilety` join `ekskursii` on((`bilety`.`naimenovanie` = `ekskursii`.`nazvanie`))) WHERE `date` like \"{0}%\" order by `bilety`.`N_kvit_koniec`", comboBoxYear.Text); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety.Items.Clear(); queueBilety.Clear(); _Bilety t = new _Bilety(); foreach (DataRow dataRow in dataTable.Rows) { //ListViewItem item1 = new ListViewItem(dataRow["N_kvit_koniec"].ToString().Trim()); //t.id = dataRow["N_kvit_koniec"].ToString().Trim(); ListViewItem item1 = new ListViewItem(dataRow["N_kvit_nach"].ToString().Trim()); t.id = dataRow["N_kvit_nach"].ToString().Trim(); item1.SubItems.Add(dataRow["N_kvit_koniec"].ToString().Trim()); t.date = dataRow["N_kvit_koniec"].ToString().Trim(); item1.SubItems.Add(dataRow["naimenovanie"].ToString().Trim()); t.name = dataRow["naimenovanie"].ToString().Trim(); item1.SubItems.Add(dataRow["stoimost"].ToString().Trim()); t.cena = dataRow["stoimost"].ToString().Trim(); listViewBilety.Items.Add(item1); listViewBilety.Items[listViewBilety.Items.Count - 1].Tag = dataRow["N_kvit_koniec"].ToString(); queueBilety.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
public void refreshBilety() { listViewBilety.Items.Clear(); queueBilety.Clear(); listViewBilety.Columns.Clear(); listViewBilety.Columns.Add("№", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Дата поступления", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Наименование", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Количество", -2, HorizontalAlignment.Left); listViewBilety.Columns.Add("Цена", -2, HorizontalAlignment.Left); listViewBilety.Columns[0].Width = 25; listViewBilety.Columns[1].Width = 150; listViewBilety.Columns[2].Width = 300; listViewBilety.Columns[3].Width = 150; listViewBilety.Columns[4].Width = 150; listViewBilety.Columns[5].Width = 150; listViewBilety.Columns[6].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = String.Format("SELECT `bilety`.`id`, `bilety`.`N_kvit_nach`, `bilety`.`N_kvit_koniec`, `bilety`.`naimenovanie`, ((`bilety`.`N_kvit_koniec` - `bilety`.`N_kvit_nach`) + 1) AS `kol_vo`, `ekskursii`.`stoimost` as`cena`, cast(`bilety`.`date` as char) AS `date` FROM `bilety` join `ekskursii` ON `bilety`.`naimenovanie`=`ekskursii`.`nazvanie` WHERE `date` like \"{0}%\" ORDER BY `id`", comboBoxYear.Text); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety.Items.Clear(); queueBilety.Clear(); _Bilety t = new _Bilety(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim()); t.id = dataRow["id"].ToString().Trim(); item1.SubItems.Add(dataRow["date"].ToString().Trim()); t.date = dataRow["date"].ToString().Trim(); item1.SubItems.Add(dataRow["naimenovanie"].ToString().Trim()); t.name = dataRow["naimenovanie"].ToString().Trim(); item1.SubItems.Add(dataRow["N_kvit_nach"].ToString().Trim()); t.KvN = dataRow["N_kvit_nach"].ToString().Trim(); item1.SubItems.Add(dataRow["N_kvit_koniec"].ToString().Trim()); t.KvK = dataRow["N_kvit_koniec"].ToString().Trim(); item1.SubItems.Add(dataRow["kol_vo"].ToString().Trim()); t.kol = dataRow["kol_vo"].ToString().Trim(); item1.SubItems.Add(dataRow["cena"].ToString().Trim()); t.cena = dataRow["cena"].ToString().Trim(); listViewBilety.Items.Add(item1); listViewBilety.Items[listViewBilety.Items.Count - 1].Tag = dataRow["id"].ToString(); queueBilety.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewBilety_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxKvN.Enabled = true; comboBoxEkskursii.Enabled = true; textBoxKvK.Enabled = true; dateTimePicker1.Enabled = true; bNew = false; if (listViewBilety.FocusedItem == null) { return; } int k = queueBilety.Count; for (int i = 0; i < k; i++) { m_bilety = (_Bilety)queueBilety.Dequeue(); if (m_bilety.id == (string)listViewBilety.Items[listViewBilety.FocusedItem.Index].Tag) { textBoxKvN.Text = m_bilety.KvN; comboBoxEkskursii.Text = m_bilety.name; textBoxKvK.Text = m_bilety.KvK; dateTimePicker1.Value = DateTime.Parse(m_bilety.date); queueBilety.Enqueue(m_bilety); _Ekskursii c; int k2 = queueEkskursii.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_Ekskursii)queueEkskursii.Dequeue(); if (c.nazvanie.ToString() == m_bilety.name.ToString()) { for (int iii = 0; iii < comboBoxEkskursii.Items.Count; iii++) { if (((_Ekskursii)comboBoxEkskursii.Items[iii]).id == c.id) { comboBoxEkskursii.SelectedIndex = iii; m_ekskursii = c; break; } } } ; queueEkskursii.Enqueue(c); } break; } ; queueBilety.Enqueue(m_bilety); } }