private void btnActulizar_Click(object sender, EventArgs e)
        {
            if (EsNumero(txtNumero.Text) && (dtpExpedicion.Text != null) && (dtpVencimiento.Text) != null)
            {
                int numeroPase = Convert.ToInt32(dgvLic.CurrentRow.Cells["Numero_pase"].Value);
                //Clave foranea para conductor
                String   conductor     = cmbConductor.Text;
                String[] Dataconductor = conductor.Split(' ');
                long     idDriver      = coductoresController.MostarIdConductor(Dataconductor[0]);
                ////Clave foranea para transito
                int          idsecretaria = transitoController.MostrarSecretaria(cmbTransito.Text);
                BR.Licencias licencia     = new BR.Licencias(Convert.ToInt32(txtNumero.Text.Trim()), idDriver, idsecretaria, cmbCategoria.Text.Trim(), dtpExpedicion.Value.Date, dtpVencimiento.Value.Date);
                licencia.Numero_pase   = numeroPase;
                licencia.id_conductor  = idDriver;
                licencia.id_secretaria = idsecretaria;
                licencia.categoria     = cmbCategoria.Text.Trim();
                licencia.expedicon     = dtpExpedicion.Value.Date;
                licencia.vencimiento   = dtpVencimiento.Value.Date;

                //Conexion con la base de datos
                if (licenciasController.ActualizarLicencia(licencia))
                {
                    MessageBox.Show("Se Actualizo la licencia" + licencia.Numero_pase);
                    Limpiar();
                    llenarDataGridView();
                }
                else
                {
                    MessageBox.Show("No se pudo Crear");
                }
            }
        }
Example #2
0
        public bool CrearLicencia(BR.Licencias other)
        {
            bool resultado = false;

            try
            {
                //Mapeo
                BR.Licencias lic = new BR.Licencias(other.Numero_pase, other.id_conductor, other.id_secretaria, other.categoria, other.expedicon, other.vencimiento);
                db.Licencias.Add(lic);
                db.SaveChanges();
                resultado = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultado);
        }
Example #3
0
        public EN.Licencias MostarLicencia(int Numero)
        {
            TextInfo myTI = CultureInfo.CurrentCulture.TextInfo;

            try
            {
                BR.Licencias other = db.Licencias.Where(x => x.Numero_pase == Numero).FirstOrDefault();
                if (other != null)
                {
                    EN.Licencias lic = new EN.Licencias(other.Numero_pase, other.Conductor.nombre.ToUpper() + " " + other.Conductor.apellido.ToUpper(), myTI.ToTitleCase(other.Secretarias_transito.localidad), other.categoria, other.expedicon, other.vencimiento);
                    return(lic);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        public EN.Licencias MostarLicenciaPorNombre(string nombre)
        {
            TextInfo myTI = CultureInfo.CurrentCulture.TextInfo;

            try
            {
                var conductor = db.Conductor.Where(x => x.nombre.Contains(nombre)).FirstOrDefault();

                if (conductor != null)
                {
                    BR.Licencias other = db.Licencias.Where(x => x.id_conductor == conductor.id).FirstOrDefault();
                    EN.Licencias lic   = new EN.Licencias(other.Numero_pase, other.Conductor.nombre.ToUpper() + " " + other.Conductor.apellido.ToUpper(), myTI.ToTitleCase(other.Secretarias_transito.localidad), other.categoria, other.expedicon, other.vencimiento);
                    lic.cedula = other.Conductor.cedula;
                    return(lic);
                }

                return(null);
            }
            catch (Exception)
            {
                throw null;
            }
        }
Example #5
0
        public bool ActualizarLicencia(BR.Licencias other)
        {
            bool resultado = false;

            try
            {
                var lic = db.Licencias.Where(x => x.Numero_pase == other.Numero_pase).FirstOrDefault();

                lic.categoria     = other.categoria;
                lic.id_conductor  = other.id_conductor;
                lic.expedicon     = other.expedicon;
                lic.id_secretaria = other.id_secretaria;
                lic.Numero_pase   = other.Numero_pase;
                lic.vencimiento   = other.vencimiento;
                db.SaveChanges();
                resultado = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(resultado);
        }