protected void grdGrupos_SelectedIndexChanged(object sender, EventArgs e) { frmSeleccionar.Visible = false; DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos(); string codigo = grdGrupos.SelectedDataKey.Value.ToString(); List <DAL.EmpleadosGrupos> datos = grupos.obtener(codigo); foreach (var item in datos) { if (ViewState["GrupoID"] != null) { ViewState["GrupoID"] = item.Id; } else { ViewState.Add("GrupoID", item.Id); } txtCodigo.Text = item.Id.ToString(); txtDescripcion.Text = item.Nombre; if (item.lider != null && item.lider != "") { txtEmpleado.SelectedValue = item.lider; } else { txtEmpleado.SelectedIndex = 0; } } }
} // Unsubscribe #endregion private void obtenerDatosFiltrados(bool todos, DAL.ItemOrden[] orden, DAL.ItemFiltro[] filtro) { int paginaActual = pagPaginador.obtenerPaginaActual(); int tamañoPagina = pagPaginador.obtenerRegistrosMostrar(); int registroInicio = ((paginaActual - 1) * tamañoPagina) + 1; int registroFin; if (todos) { registroFin = -1; } else { registroFin = tamañoPagina * paginaActual; } DAL.EmpleadosGrupos grupo = new DAL.EmpleadosGrupos(); //VistaTareas.Subscribe(this); double cantidadRegistros = 0; List <DAL.EmpleadosGrupos> datosObtenidos = grupo.obtenerFiltrado(filtro, orden, true, registroInicio, registroFin, out cantidadRegistros); if (grupo.UltimoMensaje != null) { UltimoMensaje = grupo.UltimoMensaje; Notify(UltimoMensaje); return; } ArrayList lista = new ArrayList(); foreach (DAL.EmpleadosGrupos item in datosObtenidos) { var itemLista = new { Id = item.Id, Nombre = item.Nombre, }; lista.Add(itemLista); } cargarGrilla(lista); calcularTotalPaginas(tamañoPagina, cantidadRegistros); pagPaginador.setPaginaActual(paginaActual); }
void cargar_grupos() { DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos(); List <DAL.EmpleadosGrupos> lista_grupos = new List <DAL.EmpleadosGrupos>(); lista_grupos.Add(new DAL.EmpleadosGrupos { Id = "0", Nombre = "" }); lista_grupos.AddRange(grupos.obtener()); txtGrupo.DataSource = lista_grupos; txtGrupo.DataValueField = "id"; txtGrupo.DataTextField = "nombre"; txtGrupo.DataBind(); }
protected void btnEliminar_Click(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; bool errores = false; if (confirmValue == "Si") { if (ViewState["id"] != null) { DAL.Empleados_Gastos gastos = new DAL.Empleados_Gastos(); gastos = gastos.obtener_gastos(ViewState["id"].ToString()); DAL.EmpleadosGrupos grupo = new DAL.EmpleadosGrupos(); List <DAL.Empleados> lista_empleados = grupo.obtener_miembros(gastos.grupo_id); foreach (DAL.Empleados item in lista_empleados) { try { DateTime fecha_cierre = Convert.ToDateTime(item.Fecha_Cierre); if (fecha_cierre >= Convert.ToDateTime(gastos.fecha)) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se puede borrar una operacion anterior a la fecha de cierre establecida"), true); } } catch (Exception) { } } if (!errores) { gastos.borrar(ViewState["id"].ToString()); limpiar(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Operacion realizada!", 3000), true); obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro()); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un registro para poder borrarlo", 3000), true); } } }
protected void btnEliminar_Click(object sender, EventArgs e) { if (ViewState["GrupoID"] != null) { DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos(); if (!grupos.existe_en_otros_registros(ViewState["GrupoID"].ToString())) { grupos.borrar(ViewState["GrupoID"].ToString()); obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro()); limpiar(); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se pudo completar la operacion ya que existe en otros registros", 3000), true); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un registro para poder borrarlo", 3000), true); } }
void GuardarEmpleado(bool nuevo) { DAL.Empleados emp = new DAL.Empleados(); bool errores = false; //bandera utilizada para controlar errores y continuar o no con la actulizacion de registros int id = 0; if (txtCodigo.Text != "") // comprueba que en caso de que se ingrese un codigo manualmente { try { id = Convert.ToInt32(txtCodigo.Text); //el codigo manual debe ser numerico } catch //caso contrario se da un error e informa al usuario { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("El campo código debe ser un valor númerico mayor a cero"), true); } } if (ViewState["EmpleadoID"] != null) //Si se esta actualizando { if (txtCodigo.Text != ViewState["EmpleadoID"].ToString()) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("El legajo no puede ser modificado!"), true); } } if (txtGrupo.Text != "") { DAL.EmpleadosGrupos grupo = new DAL.EmpleadosGrupos(); if (!grupo.existe_grupo(txtGrupo.Text)) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("El grupo especificado no existe"), true); } } if (nuevo && id > 0) //Si se ingresa un id manual y se trata de un nuevo registro comprueba que dicho id no exista en la bd { if (emp.existe_id(id.ToString())) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La operación no pudo completarse porque el codigo ingresado ya existe. Si lo desea puede dejar este campo en blanco para generar un código automaticamente."), true); } } if (txtNombre.Text == "" || txtApellido.Text == "" || txtFechaAlta.Text == "") //Verifico que los campos nombre, apellido y fecha de alta esten completos { if (txtNombre.Text == "") { lblNombre.ForeColor = Color.Red; } if (txtApellido.Text == "") { lblApellido.ForeColor = Color.Red; } if (txtFechaAlta.Text == "") { lblFechaAlta.ForeColor = Color.Red; } errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Los campos señalados en rojo son requeridos y no pueden estar vacío"), true); } try { if (txtFechaAlta.Text != "") { Convert.ToDateTime(txtFechaAlta.Text); } } catch { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La fecha de alta debe ser una fecha válida"), true); lblFechaAlta.ForeColor = Color.Red; } try { if (txtFechaCierre.Text != "") { Convert.ToDateTime(txtFechaCierre.Text); } } catch { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La fecha de cierre debe ser una fecha válida"), true); lblFechaCierre.ForeColor = Color.Red; } try { if (txtFechaBaja.Text != "") { Convert.ToDateTime(txtFechaBaja.Text); } } catch { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La fecha de baja debe ser una fecha válida"), true); lblFechaBaja.ForeColor = Color.Red; } if (txtMail.Text != "") { string pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"; if (!Regex.IsMatch(txtMail.Text, pattern)) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La direccion de mail no es correcta!. Ingrese una dirección válida"), true); } } if (!errores) //si no se presentan errores continua el guardado/actualizacion de registros { int hijos = 0; int.TryParse(txtHijos.Text, out hijos); emp.Id = id; emp.Apellido = txtApellido.Text; emp.Nombre = txtNombre.Text; emp.Fecha_Alta = txtFechaAlta.Text; emp.Fecha_Baja = txtFechaBaja.Text; emp.Fecha_Cierre = txtFechaCierre.Text; emp.Mail = txtMail.Text; emp.Grupo = txtGrupo.SelectedItem.Value; if (nuevo) { if (txtPassword.Text != "") { emp.Password = DAL.Varios.MD5Hash(txtPassword.Text); } } else { emp.Password = txtPassword.Text; } emp.Tel_laboral = txtTelLaboral.Text; emp.Tel_personal = txtTelPersonal.Text; emp.CUIL = txtCUIL.Text; emp.Domicilio = txtDomicilio.Text; emp.Tel_Alternativo = txtTelAlternativo.Text; emp.Persona_contacto = txtContacto.Text; emp.Provincia = txtProvincia.SelectedItem.Value; emp.Estado_Civil = txtEstadoCivil.SelectedItem.Value; emp.hijos = hijos; emp.Tarea = txtTarea.Text; emp.Fecha_Nacimiento = txtFechaNacimiento.Text; emp.PercibeAdelantos = chPercibeAdelantos.Checked; emp.Guardar(nuevo); if (nuevo) { logs.modulo = "RRHH - PERSONAL"; logs.accion = "ALTA DE EMPLEADO: " + txtApellido.Text.ToUpper() + ", " + txtNombre.Text.ToUpper(); logs.usuario = Session["usr"].ToString(); if (Session["id"] != null) { logs.empleado_id = Session["id"].ToString(); } } else { logs.modulo = "RRHH - PERSONAL"; logs.accion = "MODIFICACION DE EMPLEADO: " + txtApellido.Text.ToUpper() + ", " + txtNombre.Text.ToUpper(); logs.usuario = Session["usr"].ToString(); if (Session["id"] != null) { logs.empleado_id = Session["id"].ToString(); } } logs.guardar(); LimpiarControles(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Operacion realizada!", 3000), true); } }
public void mostrar(DateTime Desde, DateTime Hasta, string Titulo) { List <string> ids = new List <string>(); List <string> ids_grupos = new List <string>(); List <DAL.Empleados> empleados_asignados = (List <DAL.Empleados>)Session["empleados_asignados"]; foreach (DAL.Empleados item in empleados_asignados) { ids.Add(item.Id.ToString()); var gid = ids_grupos.Where(t => t.Contains(item.Grupo.ToString())); if (gid.Count() <= 0) { ids_grupos.Add(item.Grupo.ToString()); } } try { DAL.Tareas tareas = new DAL.Tareas(); DataTable dt = tareas.ObtenerDataTable(Desde, Hasta, "DataTable1", ids); rv1.LocalReport.ReportPath = Server.MapPath("~/Reports/TareasReporte.rdlc"); rv1.ProcessingMode = ProcessingMode.Local; ReportDataSource datasource = new ReportDataSource("DataSet1", dt); rv1.LocalReport.DataSources.Clear(); rv1.LocalReport.DataSources.Add(datasource); DAL.Empleados_Gastos gastos = new DAL.Empleados_Gastos(); dt = gastos.ObtenerDataTable(Desde.ToShortDateString(), Hasta.ToShortDateString(), ids_grupos); datasource = new ReportDataSource("DataSet2", dt); rv1.LocalReport.DataSources.Add(datasource); rv1.LocalReport.SetParameters(new ReportParameter("Desde", Desde.ToString("dd/MM/yyyy"))); rv1.LocalReport.SetParameters(new ReportParameter("Hasta", Hasta.ToString("dd/MM/yyyy"))); if (ids_grupos.Count() == 1) { DAL.EmpleadosGrupos grupo = new DAL.EmpleadosGrupos(); rv1.LocalReport.SetParameters(new ReportParameter("Titulo", "REPORTE DE RENDICIÓN DE " + grupo.obtener_nombre(ids_grupos[0]))); } else { rv1.LocalReport.SetParameters(new ReportParameter("Titulo", "REPORTE DE RENDICIÓN")); } rv1.Enabled = true; rv1.Visible = true; rv1.ExportContentDisposition = ContentDisposition.AlwaysInline; } catch (Exception Exception) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.Forms.FrmReporteVentas", "mostrar", 0, "Error al intentar mostrar el documento.", Exception.Message, "", true, LogManager.EMensaje.Critico, Exception.StackTrace); //Notify(m); } }
void guardar(bool nuevo) { decimal importe = 0; decimal.TryParse(txtImporte.Text.Replace(".", ","), out importe); DateTime fecha = DateTime.Now; bool errores = false; if (txtFecha.Text == "") { if (txtFecha.Text == "") { lblFecha.ForeColor = Color.Red; } errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Los campos señalados en rojo no pueden estar vacíos", 3000), true); } else { try { fecha = Convert.ToDateTime(txtFecha.Text); } catch { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("La fecha debe ser válida!", 3000), true); } } if (importe <= 0) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El importe debe ser mayor a cero", 3000), true); } if (txtAsignadoPor.SelectedValue.ToString() == "0") { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar la persona que esta asignando", 3000), true); } if (txtTipo.SelectedIndex == 0) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe especificar el gasto", 3000), true); } if (txtGrupo.SelectedValue.ToString() == "0") { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe especificar el grupo", 3000), true); } DAL.EmpleadosGrupos grupo = new DAL.EmpleadosGrupos(); List <DAL.Empleados> lista_empleados = grupo.obtener_miembros(txtGrupo.SelectedValue.ToString()); foreach (DAL.Empleados item in lista_empleados) { try { if (Convert.ToDateTime(item.Fecha_Cierre) >= fecha) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se puede cargar una operacion anterior a la fecha de cierre establecida"), true); break; } } catch { } } if (!errores) { DAL.Empleados_Gastos gastos = new DAL.Empleados_Gastos(); if (!nuevo) { gastos.id = ViewState["id"].ToString(); } gastos.fecha = txtFecha.Text; gastos.detalles = txtTipo.Text; gastos.importe = importe; gastos.grupo_id = txtGrupo.SelectedItem.Value; gastos.asignado_por = txtAsignadoPor.SelectedValue.ToString(); if (gastos.Guardar(nuevo)) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Operacion realizada!", 3000), true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Error al realizar el proceso", 3000), true); } limpiar(); } }
void guardar(bool nuevo) { bool errores = false; if (nuevo) { DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos(); int registros = 0; if (txtCodigo.Text != "") { registros = grupos.obtener(txtCodigo.Text).Count; } if (registros > 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("La operación no pudo realizarse ya que el código ingresado existe en la base de datos!.", 3000), true); errores = true; } } if (ViewState["GrupoID"] == null || ViewState["GrupoID"].ToString() == "") { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un grupo para poder editarlo", 3000), true); } if (txtEmpleado.SelectedValue == null || txtEmpleado.SelectedValue.ToString() == "0") { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un lider para el grupo", 3000), true); } if (txtDescripcion.Text == "") { if (txtDescripcion.Text == "") { lblDescripcion.ForeColor = Color.Red; } errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Los campos señalados en rojo no pueden estar vacíos", 3000), true); } DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(txtEmpleado.SelectedValue.ToString()); if (emp.es_lider(emp.Id.ToString())) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El empleado seleccionado ya es lider de un grupo, elimine el grupo o bien cambie de lider e intentelo nuevamente", 3000), true); } int last_id = 0; if (!errores) { lblDescripcion.ForeColor = Color.Black; DAL.EmpleadosGrupos grupos = new DAL.EmpleadosGrupos(); grupos.Id = txtCodigo.Text; grupos.Nombre = txtDescripcion.Text; grupos.lider = txtEmpleado.SelectedValue.ToString(); if (grupos.Guardar(nuevo, out last_id)) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Operacion realizada!", 3000), true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Error al realizar el proceso", 3000), true); } if (nuevo) { logs.modulo = "RRHH - GRUPOS"; logs.accion = "AGREGO EL GRUPO: " + grupos.Nombre.ToUpper(); logs.usuario = Session["usr"].ToString(); if (Session["id"] != null) { logs.empleado_id = Session["id"].ToString(); } logs.guardar(); emp.Grupo = last_id.ToString(); emp.Guardar(false); } else { logs.modulo = "RRHH - GRUPOS"; logs.accion = "MODIFICO EL GRUPO: " + grupos.Nombre.ToUpper(); logs.usuario = Session["usr"].ToString(); if (Session["id"] != null) { logs.empleado_id = Session["id"].ToString(); } logs.guardar(); emp.Grupo = txtCodigo.Text; emp.Guardar(false); } limpiar(); } }