public void M() { LV.Items.Clear(); string sql = "SELECT * FROM STOPBUS"; // Строка запроса MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom); DataTable dt = new DataTable(); dataAdapter.Fill(dt); var myData = dt.Select(); for (int i = 0; i < myData.Length; i++) { //for (int j = 0; j < myData[i].ItemArray.Length; j++) String idBus = myData[i].ItemArray[0].ToString(); String nameBusstat = myData[i].ItemArray[1].ToString(); Busstop Station = new Busstop(int.Parse(idBus), nameBusstat); LV.Items.Add(Station); } }
private void SetCb() { cb2.Items.Clear(); string sql = "SELECT * FROM STOPBUS ORDER BY NAME_STOP"; // Строка запроса MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom); DataTable dt = new DataTable(); dataAdapter.Fill(dt); var myData = dt.Select(); for (int i = 0; i < myData.Length; i++) { //for (int j = 0; j < myData[i].ItemArray.Length; j++) String idBus = myData[i].ItemArray[0].ToString(); String nameBusstat = myData[i].ItemArray[1].ToString(); Busstop Station = new Busstop(int.Parse(idBus), nameBusstat); cb2.Items.Add(Station); } foreach (Busstop cmi in cb2.Items) { if (cmi.Name == update_station.Name) { cb2.SelectedItem = cmi; } } }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { listView.Items.Clear(); TextBox temp = sender as TextBox; string sql = "SELECT * FROM STOPBUS WHERE NAME_STOP LIKE '%" + temp.Text + "%' ORDER BY NAME_STOP"; // Строка запроса MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom); DataTable dt = new DataTable(); dataAdapter.Fill(dt); var myData = dt.Select(); for (int i = 0; i < myData.Length; i++) { //for (int j = 0; j < myData[i].ItemArray.Length; j++) String idBus = myData[i].ItemArray[0].ToString(); String nameBusstat = myData[i].ItemArray[1].ToString(); Busstop Station = new Busstop(int.Parse(idBus), nameBusstat); listView.Items.Add(Station); } }
private void LV_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (LV.SelectedItem != null) { Busstop temp = LV.SelectedItem as Busstop; TextBoxNameStation.Text = temp.Name; } }
private void step2_Click(object sender, RoutedEventArgs e) { if (listView.SelectedItem != null) { panel0.Visibility = Visibility.Visible; TBusStop = listView.SelectedItem as Busstop; panel1.Visibility = Visibility.Hidden; label.Content = TBusStop.Name + " будний"; maskTb.Text = ""; } }
private void Button_Click_2(object sender, RoutedEventArgs e) { if (LV.SelectedItem != null) { Busstop temp = LV.SelectedItem as Busstop; MySqlConnection conn = new MySqlConnection(connStr); conn.Open(); string text = TextBoxNameStation.Text; string sql = "UPDATE `STOPBUS` SET `NAME_STOP`='" + text + "' WHERE `ID_STOP_BUS`='" + temp.ID + "';"; // Строка запроса MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); M(); } }
private void Button_Click_3(object sender, RoutedEventArgs e) { if (LV.SelectedItem != null) { Busstop temp = LV.SelectedItem as Busstop; MySqlConnection conn = new MySqlConnection(connStr); conn.Open(); string sql = "DELETE FROM `STOPBUS` WHERE `ID_STOP_BUS`='" + temp.ID + "';"; // Строка запроса MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); M(); } }
private void step4_Click(object sender, RoutedEventArgs e) { day.Clear(); wday.Clear(); foreach (TextBox tx in chRd.Children) { day.Add(tx.Text); } foreach (TextBox tx in chRw.Children) { wday.Add(tx.Text); } string sql = "UPDATE `TIMETRANSPORT` SET "; string qp1 = ""; int k = 5; foreach (string st in day) { qp1 += "`T" + k + "`='" + st + "',"; if (k < 23) { k++; } else { k = 0; } } qp1 = qp1.Remove(qp1.Length - 1); qp1 += " WHERE `ID_TIME`='" + one + "';"; sql += qp1; MySqlConnection connection = new MySqlConnection(connStr); MySqlCommand sqlCom = new MySqlCommand(sql, connection); connection.Open(); sqlCom.ExecuteNonQuery(); sql = "UPDATE `TIMETRANSPORT` SET "; string qp2 = ""; k = 5; foreach (string st in wday) { qp2 += "`T" + k + "`='" + st + "',"; if (k < 23) { k++; } else { k = 0; } } qp2 = qp2.Remove(qp2.Length - 1); qp2 += " WHERE `ID_TIME`='" + second + "';"; sql += qp2; sqlCom = new MySqlCommand(sql, connection); sqlCom.ExecuteNonQuery(); Busstop temp = cb2.SelectedItem as Busstop; sql = "UPDATE `MAINROUTE` SET `ID_STOP_BUS`='" + temp.ID + "' WHERE ID='" + update_station.ID + "';"; sqlCom = new MySqlCommand(sql, connection); sqlCom.ExecuteNonQuery(); panel3.Visibility = Visibility.Hidden; M(); }