Пример #1
0
        private void btnAgregarAutomovil_Click(object sender, EventArgs e)
        {
            veiculosTableAdapter ConsultaVeiculos = new veiculosTableAdapter();
            Boolean shot = true;

            if (txtAgregarAutomovilMatricula.Text != "" && txtAgregarAutomovilMarca.Text != "" && txtAgregarAutomovilModelo.Text != "" && txtAgregarAutomovilMotor.Text != "" && txtAgregarAutomovilTipo.Text != "" && txtAgregarAutomovilTransmision.Text != "" && txtAgregarAutomovilEstado.Text != "" && txtAgregarAutomovilPrecio.Text != "")
            {
                foreach (DataRow row in ConsultaVeiculos.BuscarVeiculo().Rows)
                {
                    if (row[0].ToString() == txtAgregarAutomovilMatricula.Text)
                    {
                        MessageBox.Show("La matricula: " + row[0].ToString() + " ya existe");
                        shot = false;
                    }
                }

                if (shot == true)
                {
                    ConsultaVeiculos.Insert(txtAgregarAutomovilMatricula.Text, txtAgregarAutomovilMarca.Text, txtAgregarAutomovilModelo.Text, txtAgregarAutomovilMotor.Text, txtAgregarAutomovilTipo.Text, txtAgregarAutomovilTransmision.Text, txtAgregarAutomovilEstado.Text, txtAgregarAutomovilPrecio.Text);
                    MessageBox.Show(txtAgregarAutomovilMatricula.Text + "Agregado");
                    txtAgregarAutomovilMatricula.Text   = "";
                    txtAgregarAutomovilMarca.Text       = "";
                    txtAgregarAutomovilModelo.Text      = "";
                    txtAgregarAutomovilMotor.Text       = "";
                    txtAgregarAutomovilTipo.Text        = "";
                    txtAgregarAutomovilTransmision.Text = "";
                    txtAgregarAutomovilEstado.Text      = "";
                    txtAgregarAutomovilPrecio.Text      = "";
                }
            }
            else
            {
                MessageBox.Show("Los datos no estan completados");
            }
        }
Пример #2
0
        private void btnReserva_Click(object sender, EventArgs e)
        {
            reservasTableAdapter reserva          = new reservasTableAdapter();
            veiculosTableAdapter ConsultaVeiculos = new veiculosTableAdapter();

            reserva.Insert(textBox7.Text + textBox4.Text, textBox1.Text, daterecogida.Value, dateentrega.Value, textBox8.Text, textBox9.Text, textBox10.Text);

            foreach (DataRow row in ConsultaVeiculos.BuscarVeiculo().Rows)
            {
                if (row[0].ToString() == textBox1.Text)
                {
                    ConsultaVeiculos.Hola("En uso", textBox1.Text);
                }
            }
            MessageBox.Show("Reserva exitosa");
        }