示例#1
0
    // Obtener lista de cuentas de cobro desde la base de datos
    protected void grvListaCuentaCobro_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int         index = int.Parse(e.CommandArgument.ToString());
        GridViewRow row   = grvListaCuentaCobro.Rows[(index)];

        int    cueCob_Id     = int.Parse(row.Cells[1].Text);
        string cueCob_MesNum = row.Cells[2].Text;
        string cueCob_Mes    = row.Cells[3].Text;
        string cueCob_Anio   = row.Cells[4].Text;
        string cueCob_Gen    = row.Cells[5].Text;
        string cueCob_Total  = row.Cells[6].Text;

        //
        DataTable dt = new DataTable();

        dt.Columns.AddRange(new DataColumn[6] {
            new DataColumn("Cuenta de cobro", typeof(int)),
            new DataColumn("Mes", typeof(string)),
            new DataColumn("Mes Nombre", typeof(string)),
            new DataColumn("Año", typeof(string)),
            new DataColumn("Fecha de Generación", typeof(string)),
            new DataColumn("Total", typeof(string))
        });

        dt.Rows.Add(cueCob_Id, cueCob_MesNum, cueCob_Mes, cueCob_Anio, cueCob_Gen, cueCob_Total);

        Session["mesCuentaCobroNum"] = cueCob_MesNum;
        Session["mesCuentaCobro"]    = cueCob_Mes;
        Session["anioCuentaCobro"]   = cueCob_Anio;
        Session["totalCuentaCobro"]  = cueCob_Total;

        cargarInformacionCuentaCobro(sender, e, cueCob_Id);

        Session["dtNovedadCuentaCobro"] = dt;

        if (e.CommandName == "ConsultarCuentaCobro_Click")
        {
            lblCuentaCobroId.Text          = cueCob_Id.ToString();
            listaCuentasCobroDatos.Visible = true;
            btnExportarExcel.Visible       = true;

            grvCuentaCobro.DataSource = dt;
            grvCuentaCobro.DataBind();
            listaCuentasCobroDatos.Visible = true;
        }
        if (e.CommandName == "ImprimirCuentaCobro_Click")
        {
            Session["cueCob_Id"] = cueCob_Id;
            //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "window.location.replace('ImprimirCuentaCobro.aspx');", true);


            // Consultar cuenta bancaria realcionada a la cuenta de cobro
            int archivoId = int.Parse(Session["archivoId"].ToString());

            DataTable dtCuentaBancaria = new DataTable();
            dtCuentaBancaria = CuentasBancarias.ConsultarCuentasPorArchivo(archivoId);

            if (dtCuentaBancaria.Rows.Count > 0)
            {
                Response.RedirectToRoute("imprimirCuentaCobro");
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('No hay cuenta bancaria asociada a esta cuenta de cobro');", true);
            }
        }
        if (e.CommandName == "EliminarCuentaCobro_Click")
        {
            int eliMes = int.Parse(DateTime.Now.ToString("MM"));
            int eliDia = int.Parse(DateTime.Now.ToString("dd"));
            if (int.Parse(cueCob_MesNum) >= eliMes && eliDia <= diaLimiteEliminacion)
            {
                int reg = AdministrarNovedades.EliminarCuentasCobro(cueCob_Id, int.Parse(ddlArchivo.SelectedValue));
                if (reg > 0)
                {
                    ddlAnio_SelectedIndexChanged(sender, e);
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('" + "Cuenta de cobro eliminada" + "');", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('" + "No se puede eliminar la cuenta de cobro ya la fecha limite de eliminación ya caducó" + "');", true);
            }
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["usuario"] == null)
        {
            Response.RedirectToRoute("thor");
        }

        if (!IsPostBack)
        {
            DataTable dtNovedadCuentaCobro      = (DataTable)Session["dtNovedadCuentaCobro"];
            DataTable dtNovedadCuentaCobroDatos = (DataTable)Session["dtNovedadCuentaDatos"];

            // Asignar datos pagaduria
            lblConsecutivo.Text     = Session["cueCob_Id"].ToString();
            lblAgencia.Text         = Session["agencia"].ToString();
            lblFechaInicial.Text    = System.DateTime.Now.ToString("dd 'de' MMMM 'de' yyyy");
            lblPagaduriaCarta.Text  = Session["nombrePagaduria"].ToString();
            lblPagaduriaCarta2.Text = Session["nombrePagaduria"].ToString();

            totalCuentaCobro.Text  = Session["totalCuentaCobro"].ToString();
            lblDireccion.Text      = Session["direccionPagaduria"].ToString();
            lblTelefono.Text       = Session["telefonoPagaduria"].ToString();
            lblNombreDirector.Text = Session["nombreDirector"].ToString();
            //Vivi y Daniela
            lblCargo.Text = Session["cargo"].ToString();


            // Fecha mes de descuento
            lblMesDescuento.Text  = Session["mesCuentaCobro"].ToString();
            lblAnioDescuento.Text = Session["anioCuentaCobro"].ToString();

            int mesDescuento  = int.Parse(Session["mesCuentaCobroNum"].ToString());
            int anioDescuento = int.Parse(Session["anioCuentaCobro"].ToString());
            int mes           = mesDescuento + 1;
            int anio          = anioDescuento;

            if (mes > 12)
            {
                mes  = 1;
                anio = anio + 1;
            }
            string nombreMes = new DateTime(2015, mes, 1).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));

            lblMesVigencia.Text  = nombreMes;
            lblAnioVigencia.Text = anio.ToString();

            lblNombreAgencia.Text    = Session["nombreAgencia"].ToString();
            lblDireccionAgencia.Text = Session["direccionAgencia"].ToString();
            lblEmailAgencia.Text     = Session["emailAgencia"].ToString();
            lblTelefonAgencia.Text   = Session["telefonoAgencia"].ToString();

            grvMesCuentaDeCobro.DataSource = dtNovedadCuentaCobroDatos;
            grvMesCuentaDeCobro.DataBind();

            // Consultar cuenta bancaria realcionada a la cuenta de cobro
            int archivoId = int.Parse(Session["archivoId"].ToString());

            DataTable dtCuentaBancaria = new DataTable();
            dtCuentaBancaria = CuentasBancarias.ConsultarCuentasPorArchivo(archivoId);

            if (dtCuentaBancaria.Rows.Count > 0)
            {
                //lblCuentaBancariaCompania.Text = dtCuentaBancaria.Rows[0]["com_Nombre"].ToString();
                lblCuentaBancariaNumero.Text = dtCuentaBancaria.Rows[0]["cueBan_Numero"].ToString();
                lblCuentaBancariaTipo.Text   = dtCuentaBancaria.Rows[0]["tipCue_Nombre"].ToString();
                lblCuentaBancariaBanco.Text  = dtCuentaBancaria.Rows[0]["ban_Nombre"].ToString();
                if (dtCuentaBancaria.Rows[0]["com_Nombre"].ToString() == "TORRES GUARIN")
                {
                    lblCuentaBancariaPertenece.Text = "a nuestro nombre, ya que como intermediarios de seguros, nos corresponde recaudar los dineros ante la empresa, para proceder a hacer los pagos a la compañía aseguradora respectiva. A continuación la ";
                }
                else
                {
                    lblCuentaBancariaPertenece.Text = "a nombre de " + dtCuentaBancaria.Rows[0]["com_Nombre"].ToString() + ", A continuación la ";
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert", "alert('No hay cuenta bancaria asociada a esta cuenta de cobro');", true);
                Response.RedirectToRoute("cuentasCobro");
            }
        }
    }