private void listViewEkskursovody_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxName.Enabled = true; comboBoxCat.Enabled = true; textBox1.Enabled = true; textBox2.Enabled = true; textBox3.Enabled = true; textBox4.Enabled = true; textBox5.Enabled = true; textBox6.Enabled = true; textBox7.Enabled = true; comboBoxActivity.Enabled = true; bNew = false; if (listViewEkskursovody.FocusedItem == null) return; int k = queueEkskursovody.Count; for (int i = 0; i < k; i++) { m_account = (_Ekskursovody)queueEkskursovody.Dequeue(); if (m_account.id == (string)listViewEkskursovody.Items[listViewEkskursovody.FocusedItem.Index].Tag) { textBoxName.Text = m_account.name; comboBoxCat.Text = m_account.category; textBox1.Text = m_account.rozhd; textBox2.Text = m_account.passport; textBox3.Text = m_account.inn; textBox4.Text = m_account.strax; textBox6.Text = m_account.tel; textBox5.Text = m_account.id; textBox7.Text = m_account.address; comboBoxActivity.Text = m_account.activ; queueEkskursovody.Enqueue(m_account); break; }; queueEkskursovody.Enqueue(m_account); } }
public void refreshEkskursovody() { listViewEkskursovody.Items.Clear(); queueEkskursovody.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `N_ekskursovoda`, `FiO`, `category`, `rozhd`, `passport`, `inn`, `strax`, `tel`, `address`, `activ` FROM `ekskursovody` ORDER BY `activ`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; listViewEkskursovody.Items.Clear(); queueEkskursovody.Clear(); _Ekskursovody t = new _Ekskursovody(); foreach (DataRow dataRow in dataTable.Rows) { ListViewItem item1 = new ListViewItem(dataRow["N_ekskursovoda"].ToString().Trim()); t.id = dataRow["N_ekskursovoda"].ToString().Trim(); item1.SubItems.Add(dataRow["FiO"].ToString().Trim()); t.name = dataRow["FiO"].ToString().Trim(); item1.SubItems.Add(dataRow["category"].ToString().Trim()); t.category = dataRow["category"].ToString().Trim(); item1.SubItems.Add(dataRow["rozhd"].ToString().Trim()); t.rozhd = dataRow["rozhd"].ToString().Trim(); item1.SubItems.Add(dataRow["passport"].ToString().Trim()); t.passport = dataRow["passport"].ToString().Trim(); item1.SubItems.Add(dataRow["inn"].ToString().Trim()); t.inn = dataRow["inn"].ToString().Trim(); item1.SubItems.Add(dataRow["strax"].ToString().Trim()); t.strax = dataRow["strax"].ToString().Trim(); item1.SubItems.Add(dataRow["tel"].ToString().Trim()); t.tel = dataRow["tel"].ToString().Trim(); item1.SubItems.Add(dataRow["address"].ToString().Trim()); t.address = dataRow["address"].ToString().Trim(); item1.SubItems.Add(dataRow["activ"].ToString().Trim()); t.activ = dataRow["activ"].ToString().Trim(); listViewEkskursovody.Items.Add(item1); listViewEkskursovody.Items[listViewEkskursovody.Items.Count - 1].Tag = dataRow["N_ekskursovoda"].ToString(); queueEkskursovody.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
private void listViewZhurnal_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; comboBoxEkskursovod.SelectedIndex = -1; comboBoxEkskursovod.Enabled = true; comboBoxEkskursija.SelectedIndex = -1; comboBoxEkskursija.Enabled = true; comboBoxZakazczik.SelectedIndex = -1; comboBoxZakazczik.Enabled = true; textBoxKvN.Text = ""; textBoxKvN.Enabled = true; textBoxKvK.Text = ""; textBoxKvK.Enabled = true; textBoxKolCzel.Text = ""; textBoxKolCzel.Enabled = true; dateTimePickerDate.Enabled = true; 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) { comboBoxEkskursija.Text = m_ekskursii.id; comboBoxEkskursovod.Text = m_zhurnal.fio; comboBoxZakazczik.Text = m_zhurnal.zakaz; textBoxKvN.Text = m_zhurnal.kvn; textBoxKvK.Text = m_zhurnal.kvk; textBoxKolCzel.Text = m_zhurnal.kolczel; dateTimePickerDate.Value = DateTime.Parse(m_zhurnal.date); //фигня для comboboxов _Ekskursii c; int k2 = queueEkskursii.Count; for (int i2 = 0; i2 < k2; i2++) { c = (_Ekskursii)queueEkskursii.Dequeue(); if (c.id.ToString() == m_zhurnal.numer.ToString()) { for (int iii = 0; iii < comboBoxEkskursija.Items.Count; iii++) { if (((_Ekskursii)comboBoxEkskursija.Items[iii]).id == c.id) { comboBoxEkskursija.SelectedIndex = iii; m_ekskursii = c; break; } } }; queueEkskursii.Enqueue(c); } _Zakazczik d; k2 = queueZakazczik.Count; for (int i2 = 0; i2 < k2; i2++) { d = (_Zakazczik)queueZakazczik.Dequeue(); if (d.id.ToString() == m_zhurnal.zakaz.ToString()) { for (int iii = 0; iii < comboBoxZakazczik.Items.Count; iii++) { if (((_Zakazczik)comboBoxZakazczik.Items[iii]).id == d.id) { comboBoxZakazczik.SelectedIndex = iii; m_zakazczik = d; break; } } }; queueZakazczik.Enqueue(d); } _Ekskursovody a; k2 = queueEkskursovod.Count; for (int i2 = 0; i2 < k2; i2++) { a = (_Ekskursovody)queueEkskursovod.Dequeue(); if (a.name.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; }; queueZhurnal.Enqueue(m_zhurnal); } }
private void comboBoxEkskursovod_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxEkskursovod.SelectedIndex == -1) return; m_ekskursovody = (_Ekskursovody)comboBoxEkskursovod.SelectedItem; }
public void refreshEkskursovody() { string N_ekskursovoda = ""; if (comboBoxEkskursovod.SelectedIndex != -1) { N_ekskursovoda = m_ekskursovody.id.ToString(); } comboBoxEkskursovod.Items.Clear(); queueEkskursovod.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `N_ekskursovoda`, `FiO` FROM `ekskursovody` WHERE `activ` = \"A\" ORDER BY `FiO`"; MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; _Ekskursovody c = new _Ekskursovody(); foreach (DataRow dataRow in dataTable.Rows) { c.id = dataRow["N_ekskursovoda"].ToString(); c.name = dataRow["FiO"].ToString().Trim(); comboBoxEkskursovod.Items.Add(c); if (N_ekskursovoda != "" && N_ekskursovoda == c.id.ToString()) { comboBoxEkskursovod.SelectedItem = c; } queueEkskursovod.Enqueue(c); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }
//комбобоксы public void refreshEkskursovody() { string N_ekskursovoda = ""; if (comboBoxEkskursovod.SelectedIndex != -1) { N_ekskursovoda = m_ekskursovody.id.ToString(); } comboBoxEkskursovod.Items.Clear(); queueEkskursovod.Clear(); try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); //string sql = "SELECT `N_ekskursovoda`, `FiO` FROM `ekskursovody` ORDER BY `FiO`"; string sql = String.Format("SELECT DISTINCT `ekskursovody`.`N_ekskursovoda`,`ekskursovody`.`FiO` AS `FiO` from (`ekskursovody` join `zhurnal` on((`ekskursovody`.`FiO` = `zhurnal`.`FiO`))) where ((`zhurnal`.`date` >= '{0}') and (`zhurnal`.`date` <= '{1}')) order by `ekskursovody`.`FiO`", DateTime.Parse(dateTimePicker1.Text).Year + "-" + DateTime.Parse(dateTimePicker1.Text).Month + "-" + DateTime.Parse(dateTimePicker1.Text).Day, DateTime.Parse(dateTimePicker2.Text).Year + "-" + DateTime.Parse(dateTimePicker2.Text).Month + "-" + DateTime.Parse(dateTimePicker2.Text).Day); MySqlDataAdapter myAdapter = new MySqlDataAdapter(); myAdapter.SelectCommand = new MySqlCommand(sql, conn); DataSet dataSet = new DataSet(); myAdapter.Fill(dataSet); DataTable dataTable = dataSet.Tables[0]; _Ekskursovody c = new _Ekskursovody(); foreach (DataRow dataRow in dataTable.Rows) { c.id = dataRow["N_ekskursovoda"].ToString(); c.name = dataRow["FiO"].ToString().Trim(); comboBoxEkskursovod.Items.Add(c); if (N_ekskursovoda != "" && N_ekskursovoda == c.id.ToString()) { comboBoxEkskursovod.SelectedItem = c; } queueEkskursovod.Enqueue(c); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }