public void mostrar() { List <string> ids = new List <string>(); try { DAL.Empleados empleados = new DAL.Empleados(); DataTable dt = empleados.ObtenerDataTable("DataTable1", txtEmpleadoEstado.Text); rv1.LocalReport.ReportPath = Server.MapPath("~/Reports/PersonalReporte.rdlc"); rv1.ProcessingMode = ProcessingMode.Local; ReportDataSource datasource = new ReportDataSource("DataSet1", dt); rv1.LocalReport.DataSources.Clear(); rv1.LocalReport.DataSources.Add(datasource); rv1.Enabled = true; rv1.Visible = true; rv1.ExportContentDisposition = ContentDisposition.AlwaysInline; } catch (Exception Exception) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.Forms.FrmReporteAdelantos", "mostrar", 0, "Error al intentar mostrar el documento.", Exception.Message, "", true, LogManager.EMensaje.Critico, Exception.StackTrace); //Notify(m); } }
protected void btnEliminar_Click(object sender, EventArgs e) { if (ViewState["EmpleadoID"] != null) { DAL.Empleados emp = new DAL.Empleados(); if (!emp.tiene_tareas_asignadas(Convert.ToInt32(ViewState["EmpleadoID"])) && !emp.tiene_adelantos_asignados(Convert.ToInt32(ViewState["EmpleadoID"]))) { if (emp.borrar(Convert.ToInt32(ViewState["EmpleadoID"]))) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Empleado borrado!", 3000), true); obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro()); logs.modulo = "RRHH - PERSONAL"; logs.accion = "BORRO EL EMPLEADO: " + emp.Apellido.ToUpper() + ", " + emp.Nombre.ToUpper(); logs.usuario = Session["usr"].ToString(); if (Session["id"] != null) { logs.empleado_id = Session["id"].ToString(); } logs.guardar(); LimpiarControles(); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El empleado no puede ser borrado ya que posee registros relacionados.", 3000), true); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe seleccionar un empleado para poder borrarlo", 3000), true); } }
protected void txtGrupo_SelectedIndexChanged(object sender, EventArgs e) { if (txtGrupo.SelectedValue.ToString() != "") { DAL.Empleados emp = new DAL.Empleados(); List <DAL.Empleados> lista_empleados = emp.Obtener_miembros_grupos(txtGrupo.Text, false); if (lista_empleados.Count > 0) { frmBuscarEmpleado.Visible = true; grdEmpleados.DataSource = lista_empleados; grdEmpleados.DataBind(); foreach (GridViewRow row in grdEmpleados.Rows) { CheckBox chk = (row.Cells[0].FindControl("cbox") as CheckBox); if (chk.Checked == false) { chk.Checked = true; } } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se encontraron registros"), true); txtGrupo.Text = ""; } txtGrupo.SelectedIndex = 0; } }
void cargar_empleados() { double totalregs = 0; DAL.Empleados emp = new DAL.Empleados(); List <DAL.Empleados> lista_empleados = new List <DAL.Empleados>(); List <DAL.Empleados> empleados_asignados = (List <DAL.Empleados>)Session["empleados_asignados"]; lista_empleados = emp.obtenerFiltrado(ObtenerItemFiltro_Empleados(), obtenerOrdenActual_Empleados(), false, 0, -1, out totalregs, false); if (totalregs > 1) { frmBuscarEmpleado.Visible = true; grdEmpleados.DataSource = lista_empleados; grdEmpleados.DataBind(); } if (totalregs == 1) { empleados_asignados.AddRange(lista_empleados); } if (totalregs <= 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se encontraron registros"), true); } txtEmpleado.Text = ""; cargar_empleadosAsignados(); }
protected void txtEmpleado_SelectedIndexChanged(object sender, EventArgs e) { DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(txtEmpleado.SelectedValue.ToString()); txtDescripcion.Text = emp.Apellido.ToUpper(); }
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.Empleados VistaEmpleados = new DAL.Empleados(); VistaEmpleados.Subscribe(this); double cantidadRegistros = 0; List <DAL.Empleados> datosObtenidos = VistaEmpleados.obtenerFiltrado(filtro, orden, false, registroInicio, registroFin, out cantidadRegistros, false); if (VistaEmpleados.UltimoMensaje != null) { UltimoMensaje = VistaEmpleados.UltimoMensaje; Notify(UltimoMensaje); return; } ArrayList lista = new ArrayList(); foreach (DAL.Empleados item in datosObtenidos) { var itemLista = new { Id = item.Id, Apellido = item.Apellido, Nombre = item.Nombre, Mail = item.Mail, Grupo = item.Grupo }; lista.Add(itemLista); } cargarGrilla(lista); calcularTotalPaginas(tamañoPagina, cantidadRegistros); pagPaginador.setPaginaActual(paginaActual); }
protected void grdEmpleados_SelectedIndexChanged(object sender, EventArgs e) { frmSeleccionar.Visible = false; LimpiarControles(); int id = 0; int.TryParse(grdEmpleados.SelectedDataKey.Value.ToString(), out id); if (id != 0) { DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(id.ToString()); if (ViewState["EmpleadoID"] != null) { ViewState["EmpleadoID"] = emp.Id; } else { ViewState.Add("EmpleadoID", emp.Id); } txtCodigo.Text = emp.Id.ToString(); txtApellido.Text = emp.Apellido; txtNombre.Text = emp.Nombre; txtFechaAlta.Text = emp.Fecha_Alta; txtFechaBaja.Text = emp.Fecha_Baja; txtFechaCierre.Text = emp.Fecha_Cierre; txtGrupo.SelectedValue = emp.Grupo; txtTelLaboral.Text = emp.Tel_laboral; txtTelPersonal.Text = emp.Tel_personal; txtPassword.Text = emp.Password; txtPassword.Attributes.Add("value", emp.Password); txtMail.Text = emp.Mail; txtFechaNacimiento.Text = emp.Fecha_Nacimiento; txtDomicilio.Text = emp.Domicilio; txtCUIL.Text = emp.CUIL; txtTarea.Text = emp.Tarea; txtHijos.Text = emp.hijos.ToString(); txtContacto.Text = emp.Persona_contacto; txtTelAlternativo.Text = emp.Tel_Alternativo; txtProvincia.ClearSelection(); //txtProvincia.Items.FindByValue(emp.Provincia).Selected = true; txtProvincia.SelectedValue = emp.Provincia; txtEstadoCivil.ClearSelection(); //txtEstadoCivil.Items.FindByValue(emp.Estado_Civil).Selected = true; txtEstadoCivil.SelectedValue = emp.Estado_Civil; chPercibeAdelantos.Checked = emp.PercibeAdelantos; } }
void cargar_empleados_asignadores() { DAL.Empleados emp = new DAL.Empleados(); List <DAL.Empleados> lista_empleados = new List <DAL.Empleados>(); lista_empleados.Add(new DAL.Empleados { Id = 0, ApellidoyNombre = "" }); lista_empleados.AddRange(emp.Obtener_lista("ACTIVOS")); txtAsignadoPor.DataSource = lista_empleados; txtAsignadoPor.DataTextField = "ApellidoyNombre"; txtAsignadoPor.DataValueField = "Id"; txtAsignadoPor.DataBind(); }
void cargar_empleados() { DAL.Empleados emp = new DAL.Empleados(); List <DAL.Empleados> lista_empleados = new List <DAL.Empleados>(); lista_empleados.Add(new DAL.Empleados { Id = 0, ApellidoyNombre = "" }); lista_empleados.AddRange(emp.Obtener_lista_adelantos(true)); txtEmpleado.DataSource = lista_empleados; txtEmpleado.DataTextField = "ApellidoyNombre"; txtEmpleado.DataValueField = "Id"; txtEmpleado.DataBind(); }
protected void btnEliminar_Click(object sender, EventArgs e) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Si") { if (ViewState["adelanto_id"] != null) { DAL.Empleados_Adelantos emp_adelanto = new DAL.Empleados_Adelantos(); emp_adelanto = emp_adelanto.obtener_datos(ViewState["adelanto_id"].ToString()); DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(emp_adelanto.empleado_id.ToString()); if (emp.Fecha_Cierre != null && emp.Fecha_Cierre != "") { DateTime fecha_cierre = Convert.ToDateTime(emp.Fecha_Cierre); DateTime fecha_adelanto = Convert.ToDateTime(emp_adelanto.fecha); if (fecha_adelanto > fecha_cierre) { emp_adelanto.borrar(Convert.ToInt32(ViewState["adelanto_id"])); obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro()); limpiar(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("El registro no puede ser borrado ya que la fecha de registro es inferior a la fecha de cierre", 3000), true); } } else { emp_adelanto.borrar(Convert.ToInt32(ViewState["adelanto_id"])); obtenerDatosFiltrados(false, obtenerOrdenActual(), ObtenerItemFiltro()); limpiar(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Debe seleccionar un registro para poder borrarlo", 3000), true); } } }
protected void btnGuardar_Click(object sender, EventArgs e) { DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(Session["id"].ToString()); if (emp.Password.ToString() == DAL.Varios.MD5Hash(txtClaveAnterior.Text)) { if (txtClaveNueva.Text == txtRepetirClave.Text) { emp.Password = txtClaveNueva.Text; emp.Guardar(false); ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operación realizada!", 3000), true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Las claves no coinciden", 3000), true); } } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("La clave anterior no es válida", 3000), true); } }
protected void btnEmpleadosDialogoSeleccionar_Click(object sender, EventArgs e) { int count = 0; int count_repetidos = 0; //se usa solo para el msg_toast List <DAL.Empleados> empleados_asignados = (List <DAL.Empleados>)Session["empleados_asignados"]; foreach (GridViewRow row in grdEmpleados.Rows) { CheckBox chk = (row.Cells[0].FindControl("cbox") as CheckBox); string id = row.Cells[1].Text; if (chk.Checked == true) { int index = empleados_asignados.FindIndex(item => item.Id.ToString() == id); if (index < 0) { DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(id); empleados_asignados.Add(emp); } else { count_repetidos++; } } count++; } if (count_repetidos == 1) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Un empleado no se agrego ya que existe en la lista de asignados"), true); } if (count_repetidos > 1) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Algunos empleados no se agregaron ya que existen en la lista de asignados"), true); } frmBuscarEmpleado.Visible = false; cargar_empleadosAsignados(); }
void cargar_empleados() { List <DAL.Empleados> lista_empleados = (List <DAL.Empleados>)Session["lista_empleados"]; List <DAL.Empleados> lista_asignados = (List <DAL.Empleados>)Session["lista_asignados"]; if (lista_empleados != null) { lista_empleados.Clear(); } double totalregs = 0; DAL.Empleados emp = new DAL.Empleados(); lista_empleados = emp.Obtener_lista_adelantos(true, txtEmpleado.Text); totalregs = lista_empleados.Count; if (totalregs > 1) { frmBuscarEmpleado.Visible = true; grdEmpleados.DataSource = lista_empleados; grdEmpleados.DataBind(); } if (totalregs == 1) { lista_asignados.AddRange(lista_empleados); Session["lista_asignados"] = lista_asignados; } if (totalregs <= 0) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("No se encontraron registros"), true); } txtEmpleado.Text = ""; cargar_empleadosAsignados(); }
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(); } }
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); } }
void guardarDatos(bool nuevo) { DateTime fecha = DateTime.Now; decimal importe = 0; bool errores = false; try { fecha = Convert.ToDateTime(txtFecha.Text); } catch { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe ingresar una fecha válida."), true); } if (!decimal.TryParse(txtImporte.Text.Replace(".", ","), out importe)) { errores = true; ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe ingresar valor númerico válido en el campo importe."), true); } if (txtEmpleado.SelectedValue.ToString() == "0") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Debe especificar un empleado."), true); errores = true; } if (txtAsignadoPor.SelectedValue.ToString() == "0") { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("El campo Asignado Por no puede ser nulo"), true); errores = true; } DAL.Empleados emp = new DAL.Empleados(); emp = emp.Obtener(txtEmpleado.SelectedValue.ToString()); if (emp.Fecha_Cierre != null && emp.Fecha_Cierre != "") { if (Convert.ToDateTime(emp.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); } } if (!errores) { DAL.Empleados_Adelantos emp_adelantos = new DAL.Empleados_Adelantos(); if (!nuevo) { emp_adelantos.adelanto_id = Convert.ToInt32(ViewState["adelanto_id"].ToString()); } emp_adelantos.fecha = txtFecha.Text; emp_adelantos.empleado_id = Convert.ToInt32(txtEmpleado.SelectedItem.Value); emp_adelantos.descripcion = txtDescripcion.Text; emp_adelantos.importe = importe; emp_adelantos.asignado_por = txtAsignadoPor.SelectedValue.ToString(); emp_adelantos.Guardar(nuevo); limpiar(); ScriptManager.RegisterStartupScript(Page, this.GetType(), "notification", DAL.Varios.crear_mensaje("Operacion Realizada", 3000), true); } }
protected void btnTodos_Click(object sender, EventArgs e) { int count = 0, count_repetidos = 0; DAL.Empleados emp = new DAL.Empleados(); List <DAL.Empleados> lista_empleados = emp.Obtener_lista_adelantos(true); List <DAL.Empleados> lista_asignados = (List <DAL.Empleados>)Session["lista_asignados"]; foreach (DAL.Empleados row in lista_empleados) { int index = -1; index = lista_asignados.FindIndex(item => item.Id.ToString() == row.Id.ToString()); if (index < 0) { lista_asignados.Add(lista_empleados[count]); Session["lista_asignados"] = lista_asignados; count++; } else { count_repetidos++; } } cargar_empleadosAsignados(); if (count_repetidos == 1) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Un empleado no se agrego ya que existe en la lista de asignados"), true); } if (count_repetidos > 1) { ScriptManager.RegisterStartupScript(Page, this.GetType(), "toast", DAL.Varios.crear_mensaje("Algunos empleados no se agregaron ya que existen en la lista de asignados"), true); } if (todos) { foreach (GridViewRow row in grdEmpleados.Rows) { CheckBox chk = (row.Cells[0].FindControl("cbox") as CheckBox); if (chk.Checked == true) { chk.Checked = false; } } todos = false; } else { foreach (GridViewRow row in grdEmpleados.Rows) { CheckBox chk = (row.Cells[0].FindControl("cbox") as CheckBox); if (chk.Checked == false) { chk.Checked = true; } } todos = true; } }