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); } } }
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_Gastos VistaTareas = new DAL.Empleados_Gastos(); //VistaTareas.Subscribe(this); double cantidadRegistros = 0; List <DAL.Empleados_Gastos> datosObtenidos = VistaTareas.obtenerFiltrado(filtro, orden, true, registroInicio, registroFin, out cantidadRegistros); if (VistaTareas.UltimoMensaje != null) { UltimoMensaje = VistaTareas.UltimoMensaje; Notify(UltimoMensaje); return; } cargarGrilla(datosObtenidos); calcularTotalPaginas(tamañoPagina, cantidadRegistros); pagPaginador.setPaginaActual(paginaActual); }
protected void grdEstados_SelectedIndexChanged(object sender, EventArgs e) { frmSeleccionar.Visible = false; ViewState["id"] = grdEstados.SelectedDataKey.Value.ToString(); DAL.Empleados_Gastos gastos = new DAL.Empleados_Gastos(); gastos = gastos.obtener_gastos(ViewState["id"].ToString()); txtFecha.Text = gastos.fecha; txtImporte.Text = gastos.importe.ToString(); txtTipo.SelectedValue = gastos.detalles; txtGrupo.SelectedValue = gastos.grupo_id; if (gastos.asignado_por == null || gastos.asignado_por == "") { txtAsignadoPor.SelectedIndex = 0; } else { txtAsignadoPor.SelectedValue = gastos.asignado_por; } }
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(); } }