Example #1
0
    // Evento para la aplicacion automatica de pagos
    protected void btnAplicarPagos_Click(object sender, EventArgs e)
    {
        string usuario = Session["Usuario"].ToString();

        //long ter_Id = 0;

        foreach (GridViewRow rows in grvConsutarSop.Rows)
        {
            long sop_Identificacion = long.Parse(rows.Cells[4].Text);
            if (sop_Identificacion > 0)
            {
                string estAplicado = rows.Cells[11].Text;
                if (estAplicado != "APLICADO" && estAplicado != "RECHAZADO" && estAplicado != "PENDIENTE")
                {
                    //if (sop_Identificacion != ter_Id)
                    //{
                    int registros = AdministrarSoportesBancarios.AplicarPagosSoporteBancario(int.Parse(rows.Cells[1].Text), int.Parse(rows.Cells[2].Text), sop_Identificacion, usuario);
                    //ter_Id = sop_Identificacion;
                    if (registros > 0)
                    {
                        AdministrarSoportesBancarios.CambiarEstadoSoporteBancario(int.Parse(rows.Cells[1].Text), int.Parse(rows.Cells[2].Text), sop_Identificacion);

                        // Consultar convenio y si tiene mas de un convenio
                        DataTable dt = new DataTable();
                        dt = AdministrarSoportesBancarios.ConsultarCovenioCedula(sop_Identificacion);

                        if (dt.Rows.Count > 0)
                        {
                            int con_Id = int.Parse(dt.Rows[0]["con_Id"].ToString());
                            int pro_Id = int.Parse(dt.Rows[0]["pro_Id"].ToString());
                            // Llamada funcion aplicacion novedades
                            ActualizarNovedadesAplicadas(sop_Identificacion, con_Id, pro_Id);
                        }

                        ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('Ha terminado el proceso de aplicación de pagos');", true);
                    }
                    //}
                    //else
                    //{
                    //    ClientScript.RegisterStartupScript(GetType(), "alert", "alert('El número de identificación no es un dato válido');", true);
                    //}
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "alert", "alert('El soporte no pudo ser aplicado');", true);
                }
            }
            ConsultarDetalleSoportes();
        }
        //Response.RedirectToRoute("soporteBancario");
    }