コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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;
            }
        }