コード例 #1
0
        private void btnModificacion_Click(object sender, EventArgs e)
        {
            if (verificarDatosAutomovil(txtPatente.Text, txtModelo.Text))
            {
                if (SQLAutomovil.verificarPatente(txtPatente.Text, idautomovil))
                {
                    if (SQLAutomovil.verificarChofer(obtenerIDChofer(cmbChofer.Text), idautomovil))
                    {
                        int       idmarca             = obtenerIDMarca(selectMarca.Text);
                        DataTable turnosSeleccionados = obtenerTurnosSeleccionados();
                        int       idchofer            = obtenerIDChofer(cmbChofer.Text);

                        Automovil auto = new Automovil(idautomovil, turnosSeleccionados, txtPatente.Text, txtModelo.Text, idmarca, idchofer, txtRodado.Text, txtLicencia.Text, ckbHabilitado.Checked ? 1 : 0);
                        SQLAutomovil.modificarAutomovil(auto);
                        this.DialogResult = DialogResult.OK;
                        MessageBox.Show("El auto ha sido modificado correctamente");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Esta chofer ya tiene asignado un auto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Esta patente ya esta en uso", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
 private void btnEliminar_Click_1(object sender, EventArgs e)
 {
     if (tablaAutomoviles.Rows.Count > 0)
     {
         if (autoSeleccionado.habilitado == 1)
         {
             DialogResult dialogResult = MessageBox.Show("Esta seguro?", "Esta seguro que quiere dar de baja este Automovil?", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 int response = SQLAutomovil.eliminarAutomovil(autoSeleccionado);
                 if (response > 0)
                 {
                     MessageBox.Show("El automovil " + autoSeleccionado.idautomovil + " ha sido eliminado");
                     tablaAutomoviles.DataSource = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados();
                 }
                 else
                 {
                     MessageBox.Show("El automovil " + autoSeleccionado.idautomovil + " no ha podido eliminarse");
                 }
             }
         }
         else
         {
             MessageBox.Show("El auto ya esta eliminado", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     else
     {
         MessageBox.Show("Debe seleccionar algun automovil", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        public ModificacionAutomovil(Automovil auto)
        {
            InitializeComponent();
            cargarForm();

            idautomovil     = auto.idautomovil;
            txtPatente.Text = auto.patente;
            txtModelo.Text  = auto.modelo;

            string nombreYApellido = obtenerNombreYApellidoChofer(auto.idchofer);

            cmbChofer.SelectedIndex = cmbChofer.FindStringExact(nombreYApellido);

            tablaTurnos = SQLTurno.obtenerTodosLosTurnosHabilitados();

            turnosSeleccionados = SQLAutomovil.obtenerTurnosDefinidosAuto(auto.idautomovil);
            checkListTurno.Items.Clear();
            foreach (DataRow row in tablaTurnos.Rows)
            {
                Boolean check = estaSeleccionadoTurno(row["id_turno"].ToString());
                checkListTurno.Items.Add(row["descripcion"].ToString(), check);
            }

            string nombreMarca = obtenerNombreMarca(auto.idmarca);

            selectMarca.SelectedIndex = selectMarca.FindStringExact(nombreMarca);

            ckbHabilitado.Checked = auto.habilitado == 1? true : false;

            //No se usa esto??
            txtLicencia.Text = auto.licencia;
            txtRodado.Text   = auto.rodado;
        }
コード例 #4
0
        private void recargar()
        {
            DataTable autos;

            if (modificacion)
            {
                autos = SQLAutomovil.obtenerTodosLosAutomoviles();
            }
            else
            {
                autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados();
            }
            tablaAutomoviles.DataSource = autos;

            selectMarca.Items.Clear();
            tablaMarcas = SQLAutomovil.obtenerTodasLasMarcas();
            foreach (DataRow row in tablaMarcas.Rows)
            {
                selectMarca.Items.Add(row["nombre"].ToString());
            }

            this.tablaAutomoviles.Columns[0].Visible = false; //autoID
            this.tablaAutomoviles.Columns[3].Visible = false; //marcaID
            this.tablaAutomoviles.Columns[9].Visible = false; //choferID

            DataGridViewRow autoRow = tablaAutomoviles.Rows[0];

            autoSeleccionado = new Automovil(autoRow);

            selectMarca.Text     = "";
            txtModelo.Text       = "";
            txtPatente.Text      = "";
            txtChoferNombre.Text = "";
        }
コード例 #5
0
        private void ListaAutomoviles_Load(object sender, EventArgs e)
        {
            //Obtener todos los automoviles cuando se carga el formulario
            DataTable autos;

            if (modificacion)
            {
                autos = SQLAutomovil.obtenerTodosLosAutomoviles();
            }
            else
            {
                autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados();
            }
            tablaAutomoviles.DataSource = autos;
            selectMarca.Items.Clear();
            tablaMarcas = SQLAutomovil.obtenerTodasLasMarcas();
            foreach (DataRow row in tablaMarcas.Rows)
            {
                selectMarca.Items.Add(row["nombre"].ToString());
            }

            this.tablaAutomoviles.Columns[0].Visible = false; //autoID
            this.tablaAutomoviles.Columns[3].Visible = false; //marcaID
            this.tablaAutomoviles.Columns[9].Visible = false; //choferID

            DataGridViewRow autoRow = tablaAutomoviles.Rows[0];

            autoSeleccionado = new Automovil(autoRow);
        }
コード例 #6
0
 private void btnAlta_Click_1(object sender, EventArgs e)
 {
     if (verificarDatosAutomovil(txtPatente.Text, txtModelo.Text))
     {
         if (SQLAutomovil.verificarPatente(txtPatente.Text, -1))
         {
             if (SQLAutomovil.verificarChofer(obtenerIDChofer(cmbChofer.Text), -1))
             {
                 int       idmarca             = obtenerIDMarca(selectMarca.SelectedItem.ToString());
                 DataTable turnosSeleccionados = obtenerTurnosSeleccionados();
                 int       idchofer            = obtenerIDChofer(cmbChofer.SelectedItem.ToString());
                 Automovil auto = new Automovil(turnosSeleccionados, txtPatente.Text, txtModelo.Text, idmarca, idchofer, txtRodado.Text, txtLicencia.Text, 1);
                 SQLAutomovil.insertarAutomovil(auto);
                 MessageBox.Show("El Auto se ha dado de alta correctamente");
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Esta chofer ya tiene asignado un auto", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Esta patente ya esta en uso", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #7
0
        private void cmbTurnos_SelectedIndexChanged(object sender, EventArgs e)
        {
            lblAutomovil.Show();
            cmbAutomovil.Show();
            //Carga los automoviles del chofer seleccionado en el turno seleccionado
            tablaAutomoviles = SQLAutomovil.obtenerAutomovilDelChofer(obtenerIDChofer(cmbChoferes.SelectedItem.ToString()), obtenerIDTurno(cmbTurnos.SelectedItem.ToString()));

            foreach (DataRow row in tablaAutomoviles.Rows)
            {
                cmbAutomovil.Items.Add(row["patente_auto"].ToString());
            }
        }
コード例 #8
0
        public void cargarForm()
        {
            cmbChofer.Items.Clear();
            tablaChoferes = SQLChofer.obtenerTodosLosChoferesHabilitados();
            foreach (DataRow row in tablaChoferes.Rows)
            {
                cmbChofer.Items.Add(row["nombre"].ToString() + " " + row["apellido"].ToString());
            }

            selectMarca.Items.Clear();
            tablaMarcas = SQLAutomovil.obtenerTodasLasMarcas();
            foreach (DataRow row in tablaMarcas.Rows)
            {
                selectMarca.Items.Add(row["nombre"].ToString());
            }
        }
コード例 #9
0
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            if (verificarDatosAutomovil(txtPatente.Text, txtModelo.Text, selectMarca.GetItemText(selectMarca.SelectedItem), txtChoferNombre.Text, txtApellidoChofer.Text))
            {
                int idmarca = selectMarca.SelectedItem == null ? 0 : obtenerIDMarca(selectMarca.SelectedItem.ToString());

                Automovil autoABuscar = new Automovil(idmarca, txtModelo.Text, txtPatente.Text, txtChoferNombre.Text, txtApellidoChofer.Text);
                if (modificacion)
                {
                    tablaAutomoviles.DataSource = SQLAutomovil.filtrarAutomoviles(autoABuscar);
                }
                else
                {
                    tablaAutomoviles.DataSource = SQLAutomovil.filtrarAutomovilesHabilitados(autoABuscar);
                }
            }
        }
コード例 #10
0
        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            DataTable autos;

            if (modificacion)
            {
                autos = SQLAutomovil.obtenerTodosLosAutomoviles();
            }
            else
            {
                autos = SQLAutomovil.obtenerTodosLosAutomovilesHabilitados();
            }
            tablaAutomoviles.DataSource = autos;
            selectMarca.Text            = "";
            txtModelo.Text         = "";
            txtPatente.Text        = "";
            txtChoferNombre.Text   = "";
            txtApellidoChofer.Text = "";

            this.tablaAutomoviles.Columns[0].Visible = false; //autoID
            this.tablaAutomoviles.Columns[3].Visible = false; //marcaID
            this.tablaAutomoviles.Columns[9].Visible = false; //choferID
        }