private void whSel(object sender, RoutedEventArgs e) { wareHouse p = new wareHouse(); p = (wareHouse)warList.SelectedItem; if (p.whID == "ID Склада") { return; } warehouseGoods.Items.Clear(); string sql = "Select wh_id,good_id,AVAILABLE_QUANTITY from wh_goods where wh_id="; sql += p.whID; SqlCommand cmd = new SqlCommand(); SqlConnection sc = DBSQLServerUtils.GetDBConnection(); sc.Open(); wareGoods buff = new wareGoods(); buff.goodID = "ID Товара "; buff.quan = "Количество "; warehouseGoods.Items.Add(buff); cmd.Connection = sc; cmd.CommandText = sql; try { using (DbDataReader reader1 = cmd.ExecuteReader()) { if (reader1.HasRows) { while (reader1.Read()) { buff = new wareGoods(); int idGood = reader1.GetOrdinal("good_id"); int quant = reader1.GetOrdinal("AVAILABLE_QUANTITY"); buff.goodID = reader1.GetInt32(idGood).ToString() + " "; buff.quan = reader1.GetInt32(quant).ToString(); warehouseGoods.Items.Add(buff); } } } } catch (Exception ed) { MessageBox.Show(ed + ed.StackTrace); } finally { sc.Close(); } }
public Manager(Human h) { InitializeComponent(); addGiT.IsEnabled = false; wareHouse buff; buff = new wareHouse(); buff.whID = "ID Склада"; warList.Items.Add(buff); worker = h; string sql = "Select wh_id from warehouses"; SqlCommand cmd = new SqlCommand(); SqlConnection sc = DBSQLServerUtils.GetDBConnection(); sc.Open(); cmd.Connection = sc; cmd.CommandText = sql; try { using (DbDataReader reader1 = cmd.ExecuteReader()) { if (reader1.HasRows) { while (reader1.Read()) { buff = new wareHouse(); int idWH = reader1.GetOrdinal("wh_id"); buff.whID = reader1.GetInt32(idWH).ToString(); warList.Items.Add(buff); } } } } catch (Exception ed) { MessageBox.Show(ed + ed.StackTrace); } finally { sc.Close(); } reqTask buff_t; buff_t = new reqTask(); buff_t.reqID = "ID Запроса "; buff_t.shopID = "ID Магазина"; sql = "Select order_id,shop_id from orders"; reqList.Items.Add(buff_t); sc.Open(); cmd.Connection = sc; cmd.CommandText = sql; try { using (DbDataReader reader1 = cmd.ExecuteReader()) { if (reader1.HasRows) { while (reader1.Read()) { buff_t = new reqTask(); int idOR = reader1.GetOrdinal("order_id"); int idSH = reader1.GetOrdinal("shop_id"); buff_t.reqID = reader1.GetInt32(idOR).ToString() + " "; buff_t.shopID = reader1.GetInt32(idSH).ToString(); reqList.Items.Add(buff_t); } } } } catch (Exception ed) { MessageBox.Show(ed + ed.StackTrace); } finally { sc.Close(); } }