Пример #1
0
        public void M()
        {
            LV.Items.Clear();
            string          sql        = @"SELECT ID,NAME_STOP
FROM  `MAINROUTE` inner join `STOPBUS` USING(ID_STOP_BUS) where TNUMBER ='" + Bus + "' and `ROUTE`='" + orient + "' "; // Строка запроса
            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();
                ListStation Station     = new ListStation(int.Parse(idBus), nameBusstat);
                LV.Items.Add(Station);
            }
        }
Пример #2
0
        private void button1_Copy1_Click(object sender, RoutedEventArgs e)
        {
            if (LV.SelectedIndex != -1)
            {
                panel2.Visibility = Visibility.Hidden;
                panel1.Visibility = Visibility.Hidden;
                panel3.Visibility = Visibility.Visible;
                update_station    = LV.SelectedItem as ListStation;
                SetCb();
                label.Content = update_station.Name;
                string          sql        = "SELECT `WEEKDAYS`,`WEEKEND` FROM `MAINROUTE` WHERE ID='" + update_station.ID + "';"; // Строка запроса
                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();

                one    = myData[0].ItemArray[0].ToString();
                second = myData[0].ItemArray[1].ToString();

                string querydel = "SELECT * FROM `TIMETRANSPORT` WHERE `ID_TIME`='" + one + "' or `ID_TIME`='" + second + "';";
                sqlCom = new MySqlCommand(querydel, connection);

                sqlCom.ExecuteNonQuery();
                dataAdapter = new MySqlDataAdapter(sqlCom);
                DataTable dt1 = new DataTable();
                dataAdapter.Fill(dt1);
                myData = dt1.Select();
                int k = 2;
                foreach (TextBox tx in chRd.Children)
                {
                    tx.Text = myData[0].ItemArray[k].ToString();
                    k++;
                }
                k = 2;
                foreach (TextBox tx in chRw.Children)
                {
                    tx.Text = myData[1].ItemArray[k].ToString();
                    k++;
                }
            }
        }
Пример #3
0
        private void button1_Copy_Click(object sender, RoutedEventArgs e)
        {
            if (LV.SelectedIndex != -1)
            {
                MessageBoxResult answer = MessageBox.Show("Удалить", "1", MessageBoxButton.YesNo);
                if (answer == MessageBoxResult.Yes)
                {
                    ListStation     temp       = LV.SelectedItem as ListStation;
                    string          sql        = "SELECT `WEEKDAYS`,`WEEKEND` FROM `MAINROUTE` WHERE ID='" + temp.ID + "';"; // Строка запроса
                    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();

                    string one    = myData[0].ItemArray[0].ToString();
                    string second = myData[0].ItemArray[1].ToString();

                    string querydel = "DELETE FROM `TIMETRANSPORT` WHERE `ID_TIME`='" + one + "' or `ID_TIME`='" + second + "';";
                    sqlCom = new MySqlCommand(querydel, connection);

                    sqlCom.ExecuteNonQuery();


                    string querydel1 = "DELETE FROM `MAINROUTE` WHERE ID='" + temp.ID + "';";
                    sqlCom = new MySqlCommand(querydel1, connection);

                    sqlCom.ExecuteNonQuery();
                }
                M();
            }
        }