Ejemplo n.º 1
0
        public bool alta_vehiculo(vehiculo dto, String patio)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    var query = (from n in db.patios
                                 where n.nombre == patio
                                 &&
                                 n.idempresafk == dto.idempresafk
                                 select n).First();
                    vehiculo modelo = new vehiculo();

                    modelo.idempresafk      = dto.idempresafk;
                    modelo.numero           = dto.numero;
                    modelo.capacidad        = dto.capacidad;
                    modelo.tipo             = dto.tipo;
                    modelo.matricula        = dto.matricula;
                    modelo.version          = dto.version;
                    modelo.ano              = dto.ano;
                    modelo.ano_adquicision  = dto.ano_adquicision;
                    modelo.motor            = dto.motor;
                    modelo.km_mantenimiento = dto.km_mantenimiento;
                    modelo.status           = dto.status;
                    modelo.fecha_creacion   = dto.fecha_creacion;

                    db.vehiculoes.Add(modelo);
                    if (db.SaveChanges() > 0)
                    {
                        var query2 = (from n in db.vehiculoes
                                      where n.numero == dto.numero
                                      &&
                                      n.idempresafk == dto.idempresafk
                                      select n).First();
                        patio_vehiculo dtopatio = new patio_vehiculo();
                        dtopatio.idpatiofk    = query.id;
                        dtopatio.idvehiculofk = query2.id;
                        db.patio_vehiculo.Add(dtopatio);
                        if (db.SaveChanges() > 0)
                        {
                            return(true);
                        }
                        return(false);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al insertar  vehiculo -> " + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 2
0
        public bool alta_trabajador(int idempresa, String departamento, trabajador dto)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    var depa = (from n in db.departamentoes
                                where n.idempresafk == idempresa &&
                                n.nombre == departamento
                                select n).First();
                    MessageBox.Show(depa.id + "");
                    dto.iddepartamentofk = depa.id;
                    db.trabajadors.Add(dto);
                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error alta de trabajador" + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 3
0
        public bool altaempresa(empresaservicio dto)
        {
            try
            {
                String nombre = dto.nombre;
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    var consulta = db.empresaservicios.Where(c => c.nombre == dto.nombre).Count();

                    if (consulta > 0)
                    {
                        return(false);
                    }
                    db.empresaservicios.Add(dto);
                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al insertar  empresa-> " + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 4
0
        public bool inserta_departamento(int id, departamento dto)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    var consulta = db.patios.Where(c => c.nombre == dto.nombre && c.idempresafk == id).Count();

                    if (consulta > 0)
                    {
                        return(false);
                    }
                    db.departamentoes.Add(dto);
                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al insertar  departamento-> " + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 5
0
 public void registro(log datos)
 {
     try {
         using (kosmozbusEntities db = new kosmozbusEntities())
         {
             db.logs.Add(datos);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error l registra log " + ex);
         throw;
     }
 }
Ejemplo n.º 6
0
        public bool actualizar_departamento(departamento dto, int id, int idempresafk)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    departamento empresa = (from q in db.departamentoes
                                            where q.id == id
                                            where q.idempresafk == idempresafk

                                            select q).First();
                    empresa.nombre       = dto.nombre;
                    empresa.nombre_corto = dto.nombre_corto;

                    empresa.imagen          = dto.imagen;
                    empresa.no_departamento = dto.no_departamento;
                    empresa.fecha_creacion  = dto.fecha_creacion;
                    empresa.calle           = dto.calle;
                    empresa.colonia         = dto.colonia;
                    empresa.cp         = dto.cp;
                    empresa.municipio  = dto.municipio;
                    empresa.ciudad     = dto.ciudad;
                    empresa.encargado1 = dto.encargado1;
                    empresa.encargado2 = dto.encargado2;
                    empresa.correo1    = dto.correo1;
                    empresa.coreo2     = dto.coreo2;
                    empresa.telefono1  = dto.telefono1;
                    empresa.telefono2  = dto.telefono2;

                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al actulizar  empresa-> " + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 7
0
        public bool alta_estatus(estatu dto)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    db.estatus.Add(dto);
                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error alta de tipo estatus" + ex);
                return(false);

                throw;
            }
        }
Ejemplo n.º 8
0
        public bool alta_tipo(tipo_vehiculo dto)
        {
            try
            {
                using (kosmozbusEntities db = new kosmozbusEntities())
                {
                    db.tipo_vehiculo.Add(dto);
                    if (db.SaveChanges() > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error alta de tipo de vehiculo" + ex);
                return(false);

                throw;
            }
        }