public Vacacion retornarObjetoVacacion(String identificacion) { //abrir conexion ConexionBD conexion = new ConexionBD(); conexion.abrirConexion(); Vacacion v = new Vacacion(); string consulta = "SELECT * FROM VACACION WHERE IDENTIFICACION =" + identificacion; try { SqlCommand comando = new SqlCommand(consulta, conexion.conn); //crea el comando, pero aun no ejecuta SqlDataReader lector = comando.ExecuteReader(); //lee los datos provenientes de la consulta y los guarda en lector while (lector.Read()) { v = new Vacacion(lector.GetValue(0).ToString(), Convert.ToDateTime(lector.GetValue(1)), Convert.ToDateTime(lector.GetValue(2))); } conexion.cerrarConexion(); } catch (Exception ex) { MessageBox.Show("Error al ejecutar la consulta"); } return(v); }
public async Task <IActionResult> Edit(int id, [Bind("Id,EmpleadoId,Desde,Hasta,AnioCorrespondiente,Completa,Comentarios")] Vacacion vacacion) { if (id != vacacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vacacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VacacionExists(vacacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmpleadoId"] = new SelectList(_context.Empleados, "Id", "Apellido", vacacion.EmpleadoId); return(View(vacacion)); }
public void Inicializado() { empleadoDA = new EmpleadoDA(); vacacionDA = new VacacionDA(); empleado = new Empleado(); vacacion = new Vacacion(); tablaEmpleados = empleadoDA.ListarEmpleadosActivos(); cmbEmpleado.DataSource = tablaEmpleados; cmbEmpleado.DisplayMember = "Nombres_apellidos"; cmbEmpleado.ValueMember = "IdEmpleado"; cmbEmpleado.SelectedIndex = -1; dtpFechaInicio.Value = DateTime.Now; dtpFechaFin.MinDate = DateTime.Now; //cmbEmpleado.SelectedIndex = 0; //int i = cmbEmpleado.SelectedIndex; //int idEmpleado = Convert.ToInt32(tablaEmpleados.Rows[i]["idEmpleado"].ToString()); //txtNroDocumento.Text = tablaEmpleados.Rows[i]["nroDocumento"].ToString(); //txtFechaIngreso.Text = tablaEmpleados.Rows[i]["fechaIngreso"].ToString(); //txtSaldo.Text = tablaEmpleados.Rows[i]["saldo"].ToString(); }
// // GET: /Vacaciones/Edit/5 public ActionResult Edit(int id) { Vacacion vacacion = db.Vacaciones.Find(id); ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoMaterno", vacacion.IdPersonalInterno); return(View(vacacion)); }
public ActionResult Create(Vacacion vacacion) { List <Actividad> actividades = db.Actividades.Where(a => a.IdPersonalInterno == vacacion.IdPersonalInterno).OrderByDescending(a => a.FechaFin).ToList(); if (DateTime.Compare(vacacion.FechaInicio, actividades[0].FechaFin) <= 0) { string error = "La fecha mínima de salida es: " + actividades[0].FechaFin.AddDays(1).ToShortDateString(); ModelState.AddModelError("FechaInicio", error); } if (vacacion.Periodo > 20) { string error = "El periodo máximo de vacaciones es 20 días"; ModelState.AddModelError("Periodo", error); } if (vacacion.Periodo <= 5) { string error = "El periodo mínimo de vacaciones es 5 días"; ModelState.AddModelError("Periodo", error); } if (ModelState.IsValid) { vacacion.FechaFin = vacacion.FechaInicio.AddDays(vacacion.Periodo); vacacion.Estado = "Aprobado"; vacacion.Anho = vacacion.FechaFin.Year; db.Vacaciones.Add(vacacion); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoMaterno", vacacion.IdPersonalInterno); return(View(vacacion)); }
public ActionResult Create(Vacacion vacacion) { List<Actividad> actividades = db.Actividades.Where(a => a.IdPersonalInterno == vacacion.IdPersonalInterno).OrderByDescending(a=>a.FechaFin).ToList(); if (DateTime.Compare(vacacion.FechaInicio,actividades[0].FechaFin)<=0) { string error = "La fecha mínima de salida es: " + actividades[0].FechaFin.AddDays(1).ToShortDateString(); ModelState.AddModelError("FechaInicio", error); } if (vacacion.Periodo > 20) { string error = "El periodo máximo de vacaciones es 20 días"; ModelState.AddModelError("Periodo", error); } if (vacacion.Periodo <= 5) { string error = "El periodo mínimo de vacaciones es 5 días"; ModelState.AddModelError("Periodo", error); } if (ModelState.IsValid) { vacacion.FechaFin = vacacion.FechaInicio.AddDays(vacacion.Periodo); vacacion.Estado = "Aprobado"; vacacion.Anho = vacacion.FechaFin.Year; db.Vacaciones.Add(vacacion); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoMaterno", vacacion.IdPersonalInterno); return View(vacacion); }
private List <int> validar_cambios(Vacacion vacacion) { List <Int32> lista = new List <Int32>(); if (!(vacacion.Fecha_Salida == this.vacacion.Fecha_Salida)) { lista.Add(0); } if (!(vacacion.Fecha_Regreso == this.vacacion.Fecha_Regreso)) { lista.Add(1); } if (!(vacacion.Numero_Dias == this.vacacion.Numero_Dias)) { lista.Add(2); } if (!(vacacion.Salario == this.vacacion.Salario)) { lista.Add(3); } if (vacacion.Estado != this.vacacion.Estado) { lista.Add(4); } return(lista); }
public int InsertarVacacion(Vacacion vacacion, string usuario) { parametrosEntrada = new MySqlParameter[10]; parametrosEntrada[0] = new MySqlParameter("@_idEmpleado", MySqlDbType.Int32); parametrosEntrada[1] = new MySqlParameter("@_mes", MySqlDbType.Int32); parametrosEntrada[2] = new MySqlParameter("@_ano", MySqlDbType.Int32); parametrosEntrada[3] = new MySqlParameter("@_cantDias", MySqlDbType.Int32); parametrosEntrada[4] = new MySqlParameter("@_fechaInicio", MySqlDbType.Date); parametrosEntrada[5] = new MySqlParameter("@_fechaFin", MySqlDbType.Date); parametrosEntrada[6] = new MySqlParameter("@_observacion", MySqlDbType.VarChar, 3000); parametrosEntrada[7] = new MySqlParameter("@_estado", MySqlDbType.Int32); parametrosEntrada[8] = new MySqlParameter("@_usuario_ins", MySqlDbType.VarChar, 100); parametrosEntrada[9] = new MySqlParameter("@_idVacacion", MySqlDbType.Int32); parametrosEntrada[0].Value = vacacion.IdEmpleado; parametrosEntrada[1].Value = vacacion.Mes; parametrosEntrada[2].Value = vacacion.Ano; parametrosEntrada[3].Value = vacacion.Dias; parametrosEntrada[4].Value = vacacion.FechaInicio; parametrosEntrada[5].Value = vacacion.FechaFin; parametrosEntrada[6].Value = vacacion.Observacion; parametrosEntrada[7].Value = 1; parametrosEntrada[8].Value = usuario; string[] datosSalida = new string[1]; objManager.EjecutarProcedureConDatosDevueltos(parametrosEntrada, "insert_vacacion", 9, 10, out datosSalida, 1); if (datosSalida != null) { vacacion.IdVacacion = Convert.ToInt32(datosSalida[0]); } return(vacacion.IdVacacion); }
public void CargarData() { try { vacacionDA = new VacacionDA(); vacacion = new Vacacion(); tablaEmpleado = vacacionDA.ListarVacaciones(); dgvVacaciones.DataSource = tablaEmpleado; vista.OptionsBehavior.AutoPopulateColumns = false; vista.OptionsSelection.MultiSelect = true; dgvVacaciones.Refresh(); usuario = vacacionDA.ObtenerPerfil(this.idUsuario); idPerfil = int.Parse(usuario.Rows[0]["perfil"].ToString()); if (idPerfil == idPerfilAnular) { this.Anular.Visible = true; } else { this.Anular.Visible = false; //this.FechaUltimaFactura.Width = 140; //this.FechaCorteAlquiler.Width = 140; } } catch (Exception e) { //MessageBox.Show(e.Message); OMITIMOS EL MENSAJE } }
// // GET: /Vacaciones/Create public ActionResult Create() { ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoPaterno"); Vacacion vacacion = new Vacacion(); vacacion.FechaInicio = DateTime.Today; return View(vacacion); }
public Boolean eliminar_sys() { if (existen_registros()) { Int32 id = Int32.Parse(dg_vacaciones.CurrentRow.Cells["Id"].Value.ToString()); String nombre = dg_vacaciones.CurrentRow.Cells["Nombre"].Value.ToString() + " " + dg_vacaciones.CurrentRow.Cells["Apellidos"].Value.ToString(); DialogResult dialogResult = MessageBox.Show("¿Desea establecer como inactiva la vacación del colaborador " + nombre + " ?", "Inactivo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { Vacacion vacacion = new Vacacion(); vacacion.Id = id; vacacion.Estado = false; if (vacacion.eliminar()) { MessageBox.Show("Vacación inactiva", "Excelente!", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } else { MessageBox.Show("Ocurrió un error", "Ups!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } return(false); } return(false); }
// // GET: /Vacaciones/Create public ActionResult Create() { ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoPaterno"); Vacacion vacacion = new Vacacion(); vacacion.FechaInicio = DateTime.Today; return(View(vacacion)); }
private void btnCancelar_Click(object sender, EventArgs e) { if (MessageBox.Show("Estas seguro que deseas cancelar el proceso", "◄ AVISO | LEASEIN ►", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { estadoComponentes(TipoVista.Limpiar); vacacion = new Vacacion(); } }
public ActionResult DeleteConfirmed(int id) { Vacacion vacacion = db.Vacacions.Find(id); db.Vacacions.Remove(vacacion); db.SaveChanges(); return(RedirectToAction("Index")); }
public Vacaciones_Agregar(Vacacion vacacion) { InitializeComponent(); this.vacacion = vacacion; colaborador = new Colaborador(); lista_colaboradores = colaborador.obtener_lista_activos(); setear_datos(); rb_activo.Checked = true; }
public static Vacacion GetVacacionById(int pk) { List <Vacacion> listadeVacaciones = new List <Vacacion>(); OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter objDataSet = new OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter(); VacacionesDS.VacacionesDataTable dtVacacion = objDataSet.GetVacacionByID(pk); Vacacion objVacacion = rowToDto(dtVacacion[0]); return(objVacacion); }
public ActionResult Edit(Vacacion vacacion) { if (ModelState.IsValid) { objsBs.Update(vacacion); return(RedirectToAction("Index", "Vacacion", new { area = "Admin" })); } return(View()); }
public ActionResult Create(Vacacion vacacion) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); string name = ticket.Name; vacacion.fkAutorizacion = Convert.ToInt32(name); VacacionBLL.InsertObjetoVacacion(vacacion); return(RedirectToAction("Index", "Vacaciones")); }
public ActionResult Edit([Bind(Include = "Id_Vacacion,Id_Empleado,Inicio_Vacaciones,Fin_Vacaciones,Año,Comentario")] Vacacion vacacion) { if (ModelState.IsValid) { db.Entry(vacacion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_Empleado = new SelectList(db.Empleados, "Id_Empleado", "Nombre_Empleado", vacacion.Id_Empleado); return(View(vacacion)); }
public Vacaciones_Agregar() { InitializeComponent(); vacacion = new Vacacion(); colaborador = new Colaborador(); llenar_cb_colaboradores(); lb_cantidad_dias.Text = "0"; rb_activo.Checked = true; editar = false; //setear_fechas_Y_salario(); }
public static Vacacion rowToDto(VacacionesDS.VacacionesRow row) { Vacacion objVacacion = new Vacacion(); objVacacion.pkVacacion = row.pkVacacion; objVacacion.dateFechaInicio = row.dateFechaInicio; objVacacion.dateFechaFin = row.dateFechaFin; objVacacion.fkEmpleado = row.fkEmpleado; objVacacion.fkAutorizacion = row.fkAutorizacion; return(objVacacion); }
public async Task <IActionResult> Create([Bind("Id,EmpleadoId,Desde,Hasta,AnioCorrespondiente,Completa,Comentarios")] Vacacion vacacion) { if (ModelState.IsValid) { _context.Add(vacacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmpleadoId"] = new SelectList(_context.Empleados, "Id", "Apellido", vacacion.EmpleadoId); return(View(vacacion)); }
public void actualizarVacacion(Vacacion v) { ConexionBD conexion = new ConexionBD(); SqlCommand comm = new SqlCommand(); comm.Connection = conexion.abrirConexion(); comm.CommandText = "sp_ActualizarVacacion"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@IDENTIFICACION", v.IdentificacionPersonalV); comm.Parameters.AddWithValue("@FECHA_INICIO", v.FechaInicioVacaciones); comm.Parameters.AddWithValue("@FECHA_FIN", v.FechaFinVacaciones); comm.ExecuteNonQuery(); }
public Vacacion validarPeriodoVacaciones(Vacacion vacacionPropuesta, EFDbContext db) { List<Actividad> actividades = db.Actividades.Where(a => a.IdPersonalInterno == vacacionPropuesta.IdPersonalInterno).OrderByDescending(a=>a.FechaFin).ToList(); if (DateTime.Compare(vacacionPropuesta.FechaInicio, actividades[0].FechaFin) > 0) { return vacacionPropuesta; } else { } return null; }
public Vacacion obtener() { Vacacion vacacion = new Vacacion(); Int32 id = Int32.Parse(dg_vacaciones.CurrentRow.Cells["Id"].Value.ToString()); foreach (Vacacion x in lista) { if (x.Id == id) { vacacion = x; } } return(vacacion); }
public static List <Vacacion> SelectAll() { List <Vacacion> listadeVacaciones = new List <Vacacion>(); OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter objDataSet = new OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter(); VacacionesDS.VacacionesDataTable dtVacacion = objDataSet.GetAllVacaciones(); foreach (VacacionesDS.VacacionesRow row in dtVacacion) { Vacacion objVacacion = rowToDto(row); listadeVacaciones.Add(objVacacion); } return(listadeVacaciones); }
// GET: Vacaciones/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vacacion vacacion = db.Vacacions.Find(id); if (vacacion == null) { return(HttpNotFound()); } return(View(vacacion)); }
public static List <Vacacion> GetVacacionesByIdEmpleaso(int empleado) { List <Vacacion> listadeVacaciones = new List <Vacacion>(); OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter objDataSet = new OnTime.DAL.VacacionesDSTableAdapters.VacacionesTableAdapter(); VacacionesDS.VacacionesDataTable dtVacacion = objDataSet.GetVacacionByIdEmpleado(empleado); foreach (VacacionesDS.VacacionesRow row in dtVacacion) { Vacacion objVacacion = rowToDto(row); listadeVacaciones.Add(objVacacion); } return(listadeVacaciones); }
// GET: Vacaciones/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vacacion vacacion = db.Vacacions.Find(id); if (vacacion == null) { return(HttpNotFound()); } ViewBag.Id_Empleado = new SelectList(db.Empleados, "Id_Empleado", "Nombre_Empleado", vacacion.Id_Empleado); return(View(vacacion)); }
//Muestra mensaje de confirmnacion si la vacacion fue agregado con exito ó mensaje de error en el caso contrario. public Boolean agregar_sys() { vacacion = obtener_datos(); if (vacacion.agregar()) { buscar_colaborador(Convert.ToInt32(cb_colaborador.SelectedValue)); colaborador.reducir_vacaciones(Convert.ToInt32(lb_cantidad_dias.Text) + colaborador.Vacaciones); MessageBox.Show("La vacación fue agregada con éxito", "Excelente!", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } else { MessageBox.Show("Ocurrió un error", "Ups!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private void cmbEmpleado_SelectedIndexChanged(object sender, EventArgs e) { int i = cmbEmpleado.SelectedIndex; if (i >= 0) //Esto verifica que se ha seleccionado algún item del comboBox { vacacion = new Vacacion(); int idEmpleado = Convert.ToInt32(tablaEmpleados.Rows[i]["IdEmpleado"].ToString()); txtNroDocumento.Text = tablaEmpleados.Rows[i]["nroDocumento"].ToString(); DateTime aux = Convert.ToDateTime(tablaEmpleados.Rows[i]["fechaIngreso"].ToString()); txtFechaIngreso.Text = aux.ToString("dd/MM/yyyy"); txtSaldo.Text = tablaEmpleados.Rows[i]["saldo"].ToString(); vacacion.IdEmpleado = idEmpleado; } else { txtNroDocumento.Text = ""; txtFechaIngreso.Text = ""; txtSaldo.Text = ""; } }
//verifica 30 dias por ley public int insertarVacacion(Vacacion v) { ConexionBD conexion = new ConexionBD(); SqlCommand comm = new SqlCommand(); comm.Connection = conexion.abrirConexion(); comm.CommandText = "sp_InsertarVacacion"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@IDENTIFICACION", v.IdentificacionPersonalV); comm.Parameters.AddWithValue("@FECHA_INICIO", v.FechaInicioVacaciones); comm.Parameters.AddWithValue("@FECHA_FIN", v.FechaFinVacaciones); //obtener parametro de retorno comm.Parameters.Add("@VERIFICACION", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output; comm.ExecuteNonQuery(); int retornoProcedure = Convert.ToInt32(comm.Parameters["@VERIFICACION"].Value); Console.WriteLine(retornoProcedure); if (retornoProcedure != 1) { MessageBox.Show("Ha sobrepasado el límite de 30 días de vacaciones para el año actual"); } return(retornoProcedure); }
//verifica que no pueda ingresar en el intervalo de otra vacacion public int verificarFechaParaVacacion(Vacacion v) { ConexionBD conexion = new ConexionBD(); SqlCommand comm = new SqlCommand(); comm.Connection = conexion.abrirConexion(); comm.CommandText = "sp_consultarFechaInicioVacacion"; comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@FECHA_INICIO", v.FechaInicioVacaciones); comm.Parameters.AddWithValue("@FECHA_FIN", v.FechaFinVacaciones); comm.Parameters.AddWithValue("@IDENTIFICACION", v.IdentificacionPersonalV); //obtener parametro de retorno comm.Parameters.Add("@VERIFICACION", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output; comm.ExecuteNonQuery(); int retornoProcedure = Convert.ToInt32(comm.Parameters["@VERIFICACION"].Value); Console.WriteLine(retornoProcedure); if (retornoProcedure != 0) { MessageBox.Show("No puede guardar una nueva vacación dentro del periodo de otra vacación"); } return(retornoProcedure); }
public ActionResult Edit(Vacacion vacacion) { if (vacacion.Periodo > 20) { string error = "El periodo máximo de vacaciones es 20 días"; ModelState.AddModelError("Periodo", error); } if (vacacion.Periodo <= 5) { string error = "El periodo mínimo de vacaciones es 5 días"; ModelState.AddModelError("Periodo", error); } if (ModelState.IsValid) { vacacion.FechaFin = vacacion.FechaInicio.AddDays(vacacion.Periodo); vacacion.Estado = "Aprobado"; vacacion.Anho = vacacion.FechaFin.Year; db.Entry(vacacion).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.IdPersonalInterno = new SelectList(db.PersonalesInternos, "IdPersonalInterno", "ApellidoMaterno", vacacion.IdPersonalInterno); return View(vacacion); }