public void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text != "")
            {
                CrearConsulta cons = new CrearConsulta();

                if (cons.resultquery1cond("tipos_veh", "Form_Asociado", "Tipo", comboBox1.Text) == "Moto")
                {
                    this.Hide();
                    FormMotos f = new FormMotos(this.comboBox1.Text.ToString());
                    f.Show();
                }

                if (cons.resultquery1cond("tipos_veh", "Form_Asociado", "Tipo", comboBox1.Text) == "Carro")
                {
                    this.Hide();
                    FormVehiculos f = new FormVehiculos(this.comboBox1.Text.ToString());

                    f.Show();
                    this.Hide();
                }
            }
        }
Exemplo n.º 2
0
        public void updatequery(string tipo, int inventario, DateTime fechasal, DateTime horasal)
        {
            string        query;
            CrearConsulta cons = new CrearConsulta();

            if (cons.resultquery1cond("tipos_veh", "Form_Asociado", "Tipo", tipo) == "Moto")
            {
                query = "UPDATE `invent_motos` SET `Fecha_Salida`='" + fechasal.ToString("yyyy-MM-dd") + "', `Hora_Salida`='" + horasal.ToString("H:mm:ss") + "' WHERE (`Inventario`='" + inventario + "' AND `Tipo Vehiculo`='" + tipo + "')";
            }
            else
            {
                query = "UPDATE `invent_carros` SET `Fecha_Salida`='" + fechasal.ToString("yyyy-MM-dd") + "', `Hora_Salida`='" + horasal.ToString("H:mm:ss") + "' WHERE (`Inventario`='" + inventario + "' AND `Tipo Vehiculo`='" + tipo + "')";
            }

            string MySqlConnectionString = "datasource=127.0.0.1;port=3306;username=root;password=;Database=patiosd1c";

            MySqlConnection databaseConnection = new MySqlConnection(MySqlConnectionString);
            MySqlCommand    commandDatabase    = databaseConnection.CreateCommand();

            commandDatabase.CommandText = query;
            databaseConnection.Open();
            commandDatabase.ExecuteNonQuery();
            databaseConnection.Close();

            /*
             * try
             * {
             *  databaseConnection.Open();
             *
             *
             * }catch(Exception e)
             * {
             *  MessageBox.Show("Query Error: " + e.Message);
             * }
             * MySqlDataReader reader = commandDatabase.ExecuteReader();*/
        }