Exemple #1
0
        public static int CrearConductorTemporal(int id_cuart_vol, List <int> carros)
        {
            // generar temporal
            var nuevo = new z_conductores
            {
                id_tipo_conductor = 2,
                id_cuart_vol      = id_cuart_vol,
                licencia_vence    = DateTime.Now.AddYears(10),
                tipo_licencia     = "F",
                codigo_conductor  = "TEMP",
                temporal          = true,
                disponible        = true
            };

            foreach (int i in carros)
            {
                nuevo.id_carros += "," + i;
            }
            nuevo.id_carros = nuevo.id_carros.Trim(',');

            nuevo.addz_conductores(nuevo);
            int id_conductor = nuevo.id_conductor;

            return(id_conductor);
        }
Exemple #2
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            if (!enNuevo)
            {
                // preparar nuevo
                listConductores.Enabled  = false;
                btnActualizar.Enabled    = false;
                btnEliminar.Enabled      = false;
                radioCuartelero.Checked  = true;
                listNombres.SelectedItem = null;
                textVoluntarios.Text     = "";

                textCodigo.Text    = "";
                textTipo.Text      = "";
                dateLicencia.Value = DateTime.Now;

                FillCarros();
                btnNuevo.Text = "Insertar";

                carrosCheck = new List <int>();
                conductor   = new z_conductores();

                enNuevo = true;
            }
            else
            {
                if (Validar(false))
                {
                    try
                    {
                        conductor.codigo_conductor  = textCodigo.Text;
                        conductor.disponible        = true;
                        conductor.id_cuart_vol      = ((KeyValuePair <string, int>)listNombres.SelectedItem).Value;
                        conductor.id_tipo_conductor = radioCuartelero.Checked ? 1 : 2;
                        conductor.licencia_vence    = dateLicencia.Value;
                        conductor.tipo_licencia     = textTipo.Text;
                        // carros
                        foreach (int i in carrosCheck)
                        {
                            conductor.id_carros += "," + i;
                        }
                        conductor.id_carros = conductor.id_carros.Trim(',');
                        conductor.addz_conductores(conductor);

                        listConductores.Enabled = true;
                        btnActualizar.Enabled   = true;
                        btnEliminar.Enabled     = true;

                        btnNuevo.Text = "Nuevo";
                        FillConductores();
                        enNuevo = false;
                    }
                    catch (Exception ex)
                    {
                        Log.ShowAndLog(ex);
                    }
                }
            }
        }