예제 #1
0
        public static void array_2()
        {
            trabajador[] trabajadores = new trabajador[3] {
                new trabajador()
                {
                    id         = 1,
                    nombre     = "Christian",
                    trabajando = true
                },
                new trabajador()
                {
                    id         = 2,
                    nombre     = "Alec",
                    trabajando = false
                },
                new trabajador()
                {
                    id         = 3,
                    nombre     = "Ricardo",
                    trabajando = true
                }
            };

            Console.WriteLine("¿Cuántos trabajadores te gustaría ver? (1 - {0})", trabajadores.Length);
            int nums = int.Parse(Console.ReadLine());

            for (int i = 0; i < nums; i++)
            {
                Console.WriteLine("id: {0} nombre: {1} trabajando: {2}", trabajadores[i].id, trabajadores[i].nombre, trabajadores[i].trabajando);
            }
        }
예제 #2
0
        //-----------------------FUNCIONES DE CREAR, EDITAR Y ELIMINAR
        public static bool Add_Trabajador_Sucursal(String[] valores)
        {
            trabajador nuevo = new trabajador()
            {
                cedula            = "0",
                primer_nombre     = " Trabajador Default " + valores[0],
                segundo_nombre    = "---",
                primer_apellido   = "---",
                segundo_apellido  = "---",
                email             = "---",
                fecha_nacimiento  = Convert.ToDateTime("1900-01-01"),
                edo_civil         = "Soltero(a)",
                sexo              = "Masculino",
                foto              = "~/source/archivos/foto_perfil/usuario.png",
                telefono_casa     = "---",
                telefono_movil    = "---",
                activo            = 1,
                id_ccf            = 0,
                direccion         = "---",
                id_municipio      = 1,
                id_puesto_trabajo = Mgr_PuestoTrabajo.Get_PuestoTrabajo(),
                es_discapacitado  = "No",
                desc_discapacidad = "---",
                id_horario        = Mgr_Horario.Get_Horario(),
                id_estatus_actual = 1,
                fecha_ingreso     = DateTime.Now
            };

            return(CRUD.Add_Fila(nuevo));
        }
예제 #3
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;
            }
        }
예제 #4
0
        public ActionResult Create(trabajador trabajador)
        {
            if (ModelState.IsValid)
            {
                db.trabajador.Add(trabajador);
                db.SaveChanges();
                if (IsUserExist(trabajador.tra_cedula))
                {
                    AccountController account = new AccountController();
                    account.CreateUserProfile(trabajador.tra_cedula, trabajador.tra_cedula);
                    UserManager  userManager  = new UserManager();
                    int          Userid       = userManager.UpdateTrabajador(trabajador.tra_cedula, trabajador.tra_id);
                    UsersInRoles usersinroles = new UsersInRoles();
                    usersinroles.RoleId = 6;
                    usersinroles.UserId = Userid;
                    account.CreateUsersInRole(usersinroles);
                }
                else
                {
                    AccountController account     = new AccountController();
                    UserManager       userManager = new UserManager();
                    int UserId = userManager.UserId(trabajador.tra_cedula);
                    account.UpdateUsersInRole(UserId, 6);
                }


                return(RedirectToAction("Index"));
            }
            ViewBag.tra_empresa = new SelectList(db.empresa, "emp_id", "emp_nombre", trabajador.tra_empresa);
            return(View(trabajador));
        }
예제 #5
0
        //-----------------------FUNCIONES DE CONSULTAR
        public static int Get_Trabajador()
        {
            GrupoLiEntities contexto = new GrupoLiEntities();
            var             consulta = new trabajador();
            int             id       = contexto.trabajador.Max(x => x.id_trabajador);

            return(id);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            trabajador trabajador = db.trabajador.Find(id);

            db.trabajador.Remove(trabajador);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #7
0
        protected void EliminarRegistro(object sender, EventArgs e)
        {
            trabajador tabla = new trabajador();

            ObjUsuario.Error = Capa_Datos.CRUD.Delete_Fila(tabla, Convert.ToInt32(hdfTrabajadorIDDel.Value));
            Modal.CerrarModal("deleteModal", "DeleteModalScript", this);
            Modal.MostrarAlertaDelete(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtBuscar);
            LlenarGridView();
        }
예제 #8
0
        public static bool Add_Trabajador(String[] valores, FileUpload fuFoto)
        {
            string     ruta  = Utilidades.GuardarImagen(fuFoto, valores[0] + "_foto", Paginas.Archivos_Foto_Perfil.Value);
            trabajador nuevo = new trabajador()
            {
                cedula            = valores[0],
                primer_nombre     = valores[1],
                segundo_nombre    = valores[2],
                primer_apellido   = valores[3],
                segundo_apellido  = valores[4],
                email             = valores[5],
                fecha_nacimiento  = Convert.ToDateTime(valores[6]),
                edo_civil         = valores[7],
                sexo              = valores[8],
                foto              = ruta,
                telefono_casa     = valores[9],
                telefono_movil    = valores[10],
                activo            = 1,
                id_ccf            = Convert.ToInt32(valores[11]),
                direccion         = valores[12],
                id_municipio      = Convert.ToInt32(valores[13]),
                id_puesto_trabajo = Convert.ToInt32(valores[14]),
                es_discapacitado  = valores[15],
                desc_discapacidad = valores[16] == string.Empty ? "---" : valores[16],
                id_horario        = Convert.ToInt32(valores[17]),
                id_estatus_actual = Convert.ToInt32(valores[18]),
                fecha_ingreso     = Convert.ToDateTime(valores[19]),
                tipo_vinculacion  = valores[20],
                tipo_horario      = valores[21],
                id_perfil_cargo   = Convert.ToInt32(valores[22]),
                salario           = Convert.ToInt32(valores[23]),
                mano_dominante    = valores[24]
            };
            Boolean berror = false;

            if (CRUD.Add_Fila(nuevo))
            {
                int idTrabajador           = Get_Trabajador();
                trabajador_estatus nuevoTE = new trabajador_estatus()
                {
                    id_estatus       = Convert.ToInt32(valores[18]),
                    id_trabajador    = idTrabajador,
                    fecha_registro   = DateTime.Now,
                    motivo           = "Registro de Trabajador",
                    id_enfermedad    = 0,
                    id_sistema       = 0,
                    url_constancia   = "",
                    fecha_constancia = DateTime.Now,
                    dias_reposo      = 0,
                    tpo_enfermedad   = ""
                };
                berror = CRUD.Add_Fila(nuevoTE);
            }


            return(berror);
        }
        public void Nuevo()
        {
            TrabajadorActual = new trabajador();

            TrabajadorActual.direccion = "";

            NotifyPropertyChanged("TrabajadorActual");
            PrincipalViewModel.EstatusNuevo = true;
        }
 public ActionResult Edit([Bind(Include = "Id,nombre,edad,tipo")] trabajador trabajador)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trabajador).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(trabajador));
 }
예제 #11
0
        private void cargardatos(string id)
        {
            trabajador ListaTrabajador = new trabajador();

            // ListaTrabajador = ObjUsuario.objModeloBD.Get_Trabajador(Convert.ToInt32(id));

            lblNombre.Text = ListaTrabajador.primer_nombre + " " + ListaTrabajador.primer_apellido;
            lblEdad.Text   = Convert.ToString(ListaTrabajador.fecha_nacimiento);
            lblCedula.Text = ListaTrabajador.cedula;
        }
예제 #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            trabajador  trabajador  = db.trabajador.Find(id);
            UserManager usermanager = new UserManager();

            usermanager.DeleteUser(id, 6);
            db.trabajador.Remove(trabajador);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #13
0
        //
        // GET: /Trabajador/Details/5

        public ActionResult Details(int id = 0)
        {
            trabajador trabajador = db.trabajador.Find(id);

            if (trabajador == null)
            {
                return(HttpNotFound());
            }
            return(View(trabajador));
        }
예제 #14
0
        //
        // GET: /Trabajador/Edit/5

        public ActionResult Edit(int id = 0)
        {
            trabajador trabajador = db.trabajador.Find(id);

            if (trabajador == null)
            {
                return(HttpNotFound());
            }
            ViewBag.tra_empresa = new SelectList(db.empresa, "emp_id", "emp_nombre", trabajador.tra_empresa);
            return(View(trabajador));
        }
예제 #15
0
 public ActionResult Edit(trabajador trabajador)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trabajador).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.tra_empresa = new SelectList(db.empresa, "emp_id", "emp_nombre", trabajador.tra_empresa);
     return(View(trabajador));
 }
예제 #16
0
        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            DateTime fechaActual   = DateTime.Now;
            string   NombreArchivo = string.Empty;
            string   ruta          = string.Empty;

            if (fuFoto.HasFile)
            {
                ruta = Utilidades.GuardarImagen(fuFoto, txtCedula.Text + "_foto", Paginas.Archivos_Foto_Perfil.Value);
            }

            GrupoLiEntities contexto     = new GrupoLiEntities();
            int             idTrabajador = Convert.ToInt32(ViewState["TrabajadorID"]);
            trabajador      Edit         = contexto.trabajador.SingleOrDefault(b => b.id_trabajador == idTrabajador);

            if (Edit != null)
            {
                Edit.cedula           = txtCedula.Text;
                Edit.primer_nombre    = txtNombre1.Text;
                Edit.segundo_nombre   = txtNombre2.Text;
                Edit.primer_apellido  = txtApellido1.Text;
                Edit.segundo_apellido = txtApellido2.Text;
                Edit.email            = txtEmail.Text;
                Edit.fecha_nacimiento = Convert.ToDateTime(txtFechadeNacimiento.Text);
                Edit.edo_civil        = ddlEdoCivil.SelectedValue;
                Edit.sexo             = ddlSexo.SelectedValue;
                if (ruta.Length > 0)
                {
                    Edit.foto = ruta;
                }
                Edit.telefono_casa     = txtTelCasa.Text;
                Edit.telefono_movil    = txtTelCelular.Text;
                Edit.fecha_registro    = Convert.ToDateTime(fechaActual.ToString("dd-MM-yyy"));
                Edit.id_ccf            = Convert.ToInt32(ddlCcf.SelectedValue);
                Edit.direccion         = txtDireccion.Text;
                Edit.id_municipio      = Convert.ToInt32(ddlMunicipio.SelectedValue);
                Edit.id_puesto_trabajo = Convert.ToInt32(ddlPuestoTrabajo.SelectedValue);
                Edit.es_discapacitado  = ddlDiscapacitado.SelectedValue;
                Edit.desc_discapacidad = txtDiscapacidad.Text;
                Edit.id_horario        = Convert.ToInt32(ddlHorario.SelectedValue);
                Edit.id_estatus_actual = Convert.ToInt32(ddlEstatus.SelectedValue);
                Edit.fecha_ingreso     = Convert.ToDateTime(txtFechaIngreso.Text);
                Edit.tipo_vinculacion  = ddlTipoVinculacion.SelectedValue;
                Edit.tipo_horario      = ddlTipoHorario.SelectedValue;
                Edit.id_perfil_cargo   = Convert.ToInt32(ddlCargo.SelectedValue);
                Edit.salario           = Convert.ToInt32(txtSalario.Text);
                Edit.mano_dominante    = ddlManodominante.SelectedValue;
            }

            ObjUsuario.Error = CRUD.Edit_Fila(contexto);


            Modal.MostrarAlertaEdit(phAlerta, divAlerta, lbAlerta, ObjUsuario.Error, txtNombre1);
        }
        public ActionResult Create([Bind(Include = "Id,nombre,edad,tipo")] trabajador trabajador)
        {
            if (ModelState.IsValid)
            {
                db.trabajador.Add(trabajador);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trabajador));
        }
예제 #18
0
            public void evaluacionTrabajador (string idCargo)
            {
                if (_trabajadores.Count == 30)
                    return;


                trabajador _datosTrabajador = _trabajadores.Find(t => t.idCargo == idCargo);

                envioDatos _envioDatos = new Llamada(_datosTrabajador);

                _Llamadas.Add(_llamada);

                Console.WriteLine("La información del trabajador fue enviada por : ", nombreTrabajador);
            }
        // GET: trabajador/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            trabajador trabajador = db.trabajador.Find(id);

            if (trabajador == null)
            {
                return(HttpNotFound());
            }
            return(View(trabajador));
        }
        public void Buscar(string cedulax)
        {
            var bt = bd.trabajador.FirstOrDefault(x => x.cedula == cedulax);

            if (bt != null)
            {
                TrabajadorActual = bt;
                PrincipalViewModel.EstatusNuevo = false;
                NotifyPropertyChanged("TrabajadorActual");
            }
            else
            {
                TrabajadorActual = new trabajador {
                    cedula = cedulax
                };
                PrincipalViewModel.EstatusNuevo = true;
                NotifyPropertyChanged("TrabajadorActual");
            }
        }
예제 #21
0
        public static void array_3()
        {
            trabajador[] trabajadores = new trabajador[3] {
                new trabajador()
                {
                    id         = 1,
                    nombre     = "Christian",
                    trabajando = true
                },
                new trabajador()
                {
                    id         = 2,
                    nombre     = "Alec",
                    trabajando = true
                },
                new trabajador()
                {
                    id         = 3,
                    nombre     = "Ricardo",
                    trabajando = true
                }
            };

            int id = 0;

            while (true)
            {
                Console.WriteLine("¿A qué usuario quisiera dar de alta o de baja? (integre 1 al 3)");
                id = int.Parse(Console.ReadLine());
                if (id < 0 || id > trabajadores.Length)
                {
                    continue;
                }
                break;
            }
            trabajadores[id - 1].trabajando = false;
            for (int i = 0; i < trabajadores.Length; i++)
            {
                Console.WriteLine("id: {0} nombre: {1} trabajando: {2}", trabajadores[i].id, trabajadores[i].nombre, trabajadores[i].trabajando);
            }
        }
 //[ValidateAntiForgeryToken]
 public ActionResult Authorize(trabajador trabajadorModel)
 {
     using (DIRESAEntities db = new DIRESAEntities())
     {
         var userDetails = db.trabajadors.Where(x => x.usuario == trabajadorModel.usuario && x.contraseña == trabajadorModel.contraseña).FirstOrDefault();
         if (userDetails == null)
         {
             trabajadorModel.LoginErrorMessagge = "Usuario o contraseña no valido";
             return(View("Index", trabajadorModel));
         }
         else
         {
             Session["DNI"]       = userDetails.DNI;
             Session["usuario"]   = userDetails.usuario;
             Session["apellidos"] = userDetails.apellidos;
             Session["nombre"]    = userDetails.nombre;
             Session["acceso"]    = userDetails.acceso;
             return(RedirectToAction("Index", "Home"));
         }
     }
 }
예제 #23
0
        public static void array_1()
        {
            Console.WriteLine("¿Cuántos trabajadores quiéres ingresar?");
            int cantidad = int.Parse(Console.ReadLine());

            trabajador[] trabajadores = new trabajador[cantidad];
            for (int i = 0; i < trabajadores.Length; i++)
            {
                Console.WriteLine("Ingrese el nombre de los trabajadores:");
                string nombre = Console.ReadLine();

                trabajadores[i]            = new trabajador();
                trabajadores[i].id         = i + 1;
                trabajadores[i].nombre     = nombre;
                trabajadores[i].trabajando = true;
            }

            for (int i = 0; i < trabajadores.Length; i++)
            {
                Console.WriteLine("id: {0} nombre: {1} trabajando: {2}", trabajadores[i].id, trabajadores[i].nombre, trabajadores[i].trabajando);
            }

            Console.WriteLine("Cantidad de trabajadores que hay son: {0}", trabajadores.Length);
        }
예제 #24
0
        public ActionResult Index(int tipo, int?paciente, string empresa, int?current_emp_id, string fecha, string sortOrder, int?page)
        {
            //variables auxiliares
            int emp_id = 0;

            //parametro de ordenacion
            ViewBag.CurrentSort = sortOrder;
            ViewBag.FechaSort   = String.IsNullOrEmpty(sortOrder) ? "Fecha" : "";
            //condicion para la paginacion
            if (Request.HttpMethod != "GET")
            {
                page = 1;
            }
            //ViewBag.FechaSort = sortOrder == "Fecha" ? "Fecha desc" : "Fecha";
            var historia = db.historia.Include(h => h.paciente).Where(h => h.his_tipo == tipo);

            //filtros de busqueda
            if (paciente != null)
            {
                historia = historia.Where(h => h.his_paciente == paciente);
                fecha    = null;
                empresa  = null;
                emp_id   = 0;
            }
            if (current_emp_id != null)
            {
                historia = historia.Where(p => p.paciente.pac_empresa == current_emp_id);
            }

            if (!String.IsNullOrEmpty(empresa))
            {
                emp_id         = Int32.Parse(empresa);
                current_emp_id = Int32.Parse(empresa);
                if (emp_id != 0)
                {
                    historia = historia.Where(p => p.paciente.pac_empresa.Equals(emp_id));
                }
                fecha    = null;
                paciente = null;
            }
            if (!String.IsNullOrEmpty(fecha))
            {
                historia = historia.Where(h => h.his_fecha == fecha);
                paciente = null;
                empresa  = null;
                emp_id   = 0;
            }


            //filtros por usuario
            if (User.IsInRole("trabajador"))
            {
                string     cedula     = Convert.ToString(User.Identity.Name);
                trabajador trabajador = db.trabajador.Where(t => t.tra_cedula == cedula).First();
                historia = historia.Where(a => a.paciente.pac_empresa == trabajador.tra_empresa);
            }
            if (User.IsInRole("doctor"))
            {
                string cedula = Convert.ToString(User.Identity.Name);
                doctor doctor = db.doctor.Where(d => d.doc_cedula == cedula).First();
                historia = historia.Where(h => h.paciente.pac_empresa == doctor.doc_empresa);
            }
            if (User.IsInRole("empresa"))
            {
                string  cedula   = Convert.ToString(User.Identity.Name);
                empresa empresa_ = db.empresa.Where(e => e.emp_cedula == cedula).First();
                historia = historia.Where(a => a.paciente.pac_empresa == empresa_.emp_id);
            }
            //metodo de ordenacion
            switch (sortOrder)
            {
            case "Fecha":
                historia = historia.OrderBy(s => s.his_id);
                break;

            case "Fecha desc":
                historia = historia.OrderByDescending(s => s.his_id);
                break;

            default:
                historia = historia.OrderByDescending(s => s.his_id);
                break;
            }

            ViewBag.paciente       = paciente;
            ViewBag.fecha          = fecha;
            ViewBag.tipo           = tipo;
            ViewBag.titulo         = titulo(tipo);
            ViewBag.empresa        = new SelectList(db.empresa, "emp_id", "emp_nombre", emp_id);
            ViewBag.current_emp_id = current_emp_id;
            int pageSize  = 10;
            int pageIndex = (page ?? 1);

            return(View(historia.ToPagedList(pageIndex, pageSize)));
            //return View(historia.ToList());
        }
 public ActionResult Usuarios(trabajador trabajador)
 {
     // Metodo para obtener un trabajador e insertar en la base de datos
     return(View());
 }