private void reqSel(object sender, RoutedEventArgs e) { reqTask p = new reqTask(); p = (reqTask)reqList.SelectedItem; if (p.reqID == "ID Запроса ") { return; } req_goods.Items.Clear(); string sql = "Select good_id,quantity from order_list where order_id="; for (int i = 0; i < p.reqID.Length - 1; i++) { sql += p.reqID[i]; } SqlCommand cmd = new SqlCommand(); SqlConnection sc = DBSQLServerUtils.GetDBConnection(); sc.Open(); reqGoods buff = new reqGoods(); buff.goodID = "ID Товара "; buff.quan = "Количество"; req_goods.Items.Add(buff); cmd.Connection = sc; cmd.CommandText = sql; try { using (DbDataReader reader1 = cmd.ExecuteReader()) { if (reader1.HasRows) { while (reader1.Read()) { buff = new reqGoods(); int idGood = reader1.GetOrdinal("good_id"); int quant = reader1.GetOrdinal("quantity"); buff.goodID = reader1.GetInt32(idGood).ToString() + " "; buff.quan = reader1.GetInt32(quant).ToString(); req_goods.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(); } }