private void listViewKvit_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxKvN.Enabled = true; textBoxKvK.Enabled = true; dateTimePicker1.Enabled = true; bNew = false; if (listViewKvit.FocusedItem == null) { return; } int k = queueKvit.Count; for (int i = 0; i < k; i++) { m_kvit = (_Kvit)queueKvit.Dequeue(); if (m_kvit.id == (string)listViewKvit.Items[listViewKvit.FocusedItem.Index].Tag) { textBoxKvN.Text = m_kvit.KvN; textBoxKvK.Text = m_kvit.KvK; dateTimePicker1.Value = DateTime.Parse(m_kvit.date); queueKvit.Enqueue(m_kvit); break; } ; queueKvit.Enqueue(m_kvit); } }
private void listViewKvit_SelectedIndexChanged(object sender, EventArgs e) { buttonApply.Enabled = true; buttonDelete.Enabled = true; textBoxKvN.Enabled = true; textBoxKvK.Enabled = true; dateTimePicker1.Enabled = true; bNew = false; if (listViewKvit.FocusedItem == null) return; int k = queueKvit.Count; for (int i = 0; i < k; i++) { m_kvit = (_Kvit)queueKvit.Dequeue(); if (m_kvit.id == (string)listViewKvit.Items[listViewKvit.FocusedItem.Index].Tag) { textBoxKvN.Text = m_kvit.KvN; textBoxKvK.Text = m_kvit.KvK; dateTimePicker1.Value = DateTime.Parse(m_kvit.date); queueKvit.Enqueue(m_kvit); break; }; queueKvit.Enqueue(m_kvit); } }
public void refreshKvit() { listViewKvit.Items.Clear(); queueKvit.Clear(); listViewKvit.Columns.Clear(); listViewKvit.Columns.Add("№", -2, HorizontalAlignment.Left); listViewKvit.Columns.Add("Дата поступления", -2, HorizontalAlignment.Left); listViewKvit.Columns.Add("Номер начало", -2, HorizontalAlignment.Left); listViewKvit.Columns.Add("Номер конец", -2, HorizontalAlignment.Left); listViewKvit.Columns.Add("Количество", -2, HorizontalAlignment.Left); listViewKvit.Columns[0].Width = 25; listViewKvit.Columns[1].Width = 150; listViewKvit.Columns[2].Width = 300; listViewKvit.Columns[3].Width = 150; listViewKvit.Columns[4].Width = 150; try { mainWin.m_dbConnector.Lock(); MySqlConnection conn = mainWin.m_dbConnector.getMySqlConnection(); string sql = "SELECT `id`, `N_kvit_nach`, `N_kvit_koniec`, ((`N_kvit_koniec` - `N_kvit_nach`) + 1) AS `kol_vo`, cast(`date` as char) AS `date` FROM `kvit` 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]; listViewKvit.Items.Clear(); queueKvit.Clear(); _Kvit t = new _Kvit(); 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["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(); listViewKvit.Items.Add(item1); listViewKvit.Items[listViewKvit.Items.Count - 1].Tag = dataRow["id"].ToString(); queueKvit.Enqueue(t); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { mainWin.m_dbConnector.Unlock(); } }