private void listViewBilety2_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxName.Enabled = true; bNew = false; if (listViewBilety2.FocusedItem == null) { return; } int k = queueBilety2.Count; for (int i = 0; i < k; i++) { m_bilety2 = (_Bilety2)queueBilety2.Dequeue(); if (m_bilety2.id.ToString() == (string)listViewBilety2.Items[listViewBilety2.FocusedItem.Index].Tag) { textBoxName.Text = m_bilety2.name; textBoxCena.Text = m_bilety2.cena; textBoxFiO.Text = m_bilety2.FiO; textBoxKvK.Text = m_bilety2.KvK; textBoxKvN.Text = m_bilety2.KvN; dateTimePicker1.Value = DateTime.Parse(m_bilety2.date); queueBilety2.Enqueue(m_bilety2); break; } ; queueBilety2.Enqueue(m_bilety2); } }
public void refreshSdano() { listViewBilety2.Items.Clear(); queueBilety2.Clear(); listViewBilety2.Columns.Clear(); listViewBilety2.Columns.Add("№", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Дата", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Ф.И.О.", -2, HorizontalAlignment.Left); listViewBilety2.Columns[0].Width = 25; listViewBilety2.Columns[1].Width = 200; listViewBilety2.Columns[2].Width = 200; listViewBilety2.Columns[3].Width = 200; listViewBilety2.Columns[4].Width = 200; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = String.Format("SELECT `id`, cast(`date` as char) AS `date`, `N_kvit_nach`, `N_kvit_koniec`, `FiO` FROM `bilety2_sdano` WHERE `date` >= '{0}' and `date` <= '{1}' ORDER BY `date`", DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day, DateTime.Parse(dateTimePicker3.Text).Year + "-" + DateTime.Parse(dateTimePicker3.Text).Month + "-" + DateTime.Parse(dateTimePicker3.Text).Day); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety2.Items.Clear(); queueBilety2.Clear(); _Bilety2 t = new _Bilety2(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim(), 0); t.id = int.Parse(dataRow["id"].ToString()); item1.SubItems.Add(dataRow["date"].ToString().Trim()); t.date = dataRow["date"].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["FiO"].ToString().Trim()); t.FiO = dataRow["FiO"].ToString().Trim(); listViewBilety2.Items.Add(item1); listViewBilety2.Items[listViewBilety2.Items.Count - 1].Tag = dataRow["id"].ToString(); queueBilety2.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
//конечные номера билетов и названия экскурсий public void refreshOst2() { listViewBilety2.Items.Clear(); queueBilety2.Clear(); listViewBilety2.Columns.Clear(); listViewBilety2.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Название", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Стоимость", -2, HorizontalAlignment.Left); listViewBilety2.Columns[0].Width = 150; listViewBilety2.Columns[1].Width = 150; listViewBilety2.Columns[2].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "select `bilety2_vydano`.`N_kvit_koniec` AS `N_kvit_koniec`,`bilety2_vydano`.`naimenovanie` AS `naimenovanie`,`bilety2_vydano`.`cena` AS `stoimost` from `bilety2_vydano` order by `bilety2_vydano`.`N_kvit_koniec`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety2.Items.Clear(); queueBilety2.Clear(); _Bilety2 t = new _Bilety2(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["N_kvit_koniec"].ToString().Trim()); t.KvN = 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(); listViewBilety2.Items.Add(item1); listViewBilety2.Items[listViewBilety2.Items.Count - 1].Tag = dataRow["N_kvit_koniec"].ToString(); queueBilety2.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
public void refreshBilety2() { listViewBilety2.Items.Clear(); queueBilety2.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `id`, `name` FROM `tbl_hostel` ORDER BY `name`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety2.Items.Clear(); queueBilety2.Clear(); _Bilety2 t = new _Bilety2(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim(), 0); t.id = int.Parse(dataRow["id"].ToString()); item1.SubItems.Add(dataRow["name"].ToString().Trim()); t.name = dataRow["name"].ToString().Trim(); listViewBilety2.Items.Add(item1); listViewBilety2.Items[listViewBilety2.Items.Count - 1].Tag = dataRow["id"].ToString(); queueBilety2.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewBilety2_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxName.Enabled = true; bNew = false; if (listViewBilety2.FocusedItem == null) return; int k = queueBilety2.Count; for (int i = 0; i < k; i++) { m_bilety2 = (_Bilety2)queueBilety2.Dequeue(); if (m_bilety2.id.ToString() == (string)listViewBilety2.Items[listViewBilety2.FocusedItem.Index].Tag) { textBoxName.Text = m_bilety2.name; textBoxCena.Text = m_bilety2.cena; textBoxFiO.Text = m_bilety2.FiO; textBoxKvK.Text = m_bilety2.KvK; textBoxKvN.Text = m_bilety2.KvN; dateTimePicker1.Value = DateTime.Parse(m_bilety2.date); queueBilety2.Enqueue(m_bilety2); break; }; queueBilety2.Enqueue(m_bilety2); } }
public void refreshVydano() { listViewBilety2.Items.Clear(); queueBilety2.Clear(); listViewBilety2.Columns.Clear(); listViewBilety2.Columns.Add("№", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Дата", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Наименование", -2, HorizontalAlignment.Left); listViewBilety2.Columns.Add("Цена", -2, HorizontalAlignment.Left); listViewBilety2.Columns[0].Width = 25; listViewBilety2.Columns[1].Width = 200; listViewBilety2.Columns[2].Width = 200; listViewBilety2.Columns[3].Width = 200; listViewBilety2.Columns[4].Width = 200; listViewBilety2.Columns[5].Width = 200; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = String.Format ("SELECT `id`, cast(`date` as char) AS `date`, `N_kvit_nach`, `N_kvit_koniec`, `naimenovanie`, `cena` FROM `bilety2_vydano` WHERE `date` >= '{0}' and `date` <= '{1}' ORDER BY `date`", DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day, DateTime.Parse(dateTimePicker3.Text).Year + "-" + DateTime.Parse(dateTimePicker3.Text).Month + "-" + DateTime.Parse(dateTimePicker3.Text).Day); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewBilety2.Items.Clear(); queueBilety2.Clear(); _Bilety2 t = new _Bilety2(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["id"].ToString().Trim(), 0); t.id = int.Parse(dataRow["id"].ToString()); item1.SubItems.Add(dataRow["date"].ToString().Trim()); t.date = dataRow["date"].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["naimenovanie"].ToString().Trim()); t.name = dataRow["naimenovanie"].ToString().Trim(); item1.SubItems.Add(dataRow["cena"].ToString().Trim()); t.cena = dataRow["cena"].ToString().Trim(); listViewBilety2.Items.Add(item1); listViewBilety2.Items[listViewBilety2.Items.Count - 1].Tag = dataRow["id"].ToString(); queueBilety2.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }