using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Telerik.Web.UI;
using System.Globalization;

using BE;
using BL;
using Utilitaria;



public partial class List_ProvisionCobranzas : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["Usuario"] == null)
        {
            Response.Redirect(Utilitaria.Cls_Enums.CerrarSesion.Salir);
        }
        if (!IsPostBack)
        {
            ViewState["HotelID"] =  Session["HotelID"];
            ViewState["EstablecimientoID"] = Session["EmpresaID"];
        }
    }

   

    private void listar_Pagos()
    {
        BEConfigTransferencias objBEConfigTransferencias = new BEConfigTransferencias();
        BLConfigTransferencias objBLConfigTransferencias = new BLConfigTransferencias();

        tk_Pagos.DataSource = objBLConfigTransferencias.fnSelPagosAll(0);

        objBEConfigTransferencias = null;
        objBLConfigTransferencias = null;

    }
    private void listar_TarjetaCreditos()
    {
        BEConfigTransferencias objBEConfigTransferencias = new BEConfigTransferencias();
        BLConfigTransferencias objBLConfigTransferencias = new BLConfigTransferencias();

        tk_TarjetaCredito.DataSource = objBLConfigTransferencias.fnSelTarjetaCreditosAll(0);

        objBEConfigTransferencias = null;
        objBLConfigTransferencias = null;

    }

   
  
    protected void showMessage(string strMessage)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", "alert('" + strMessage + "');", true);


    }

    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "Rebind")
        {
            tk_Pagos.MasterTableView.SortExpressions.Clear();
            tk_Pagos.MasterTableView.GroupByExpressions.Clear();
            tk_Pagos.Rebind();

            tk_TarjetaCredito.MasterTableView.SortExpressions.Clear();
            tk_TarjetaCredito.MasterTableView.GroupByExpressions.Clear();
            tk_TarjetaCredito.Rebind();

        }
        else if (e.Argument == "RebindAndNavigate")
        {
            tk_Pagos.MasterTableView.SortExpressions.Clear();
            tk_Pagos.MasterTableView.GroupByExpressions.Clear();
            tk_Pagos.MasterTableView.CurrentPageIndex = tk_Pagos.MasterTableView.PageCount - 1;
            tk_Pagos.Rebind();

            tk_TarjetaCredito.MasterTableView.SortExpressions.Clear();
            tk_TarjetaCredito.MasterTableView.GroupByExpressions.Clear();
            tk_TarjetaCredito.MasterTableView.CurrentPageIndex = tk_TarjetaCredito.MasterTableView.PageCount - 1;
            tk_TarjetaCredito.Rebind();

        }
    }
    String CurrUrl;
    String par;

    protected void tk_Pagos_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        listar_Pagos();
    }
    protected void tk_Pagos_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {

            GridDataItem dataItem = (GridDataItem)e.Item;


            par = "&pgs=" + dataItem["PagoId"].Text;
            HyperLink linkItem = new HyperLink();
            linkItem.NavigateUrl = "#";
            linkItem.Text = dataItem["nombre"].Text;
            linkItem.CssClass = "gridtext";
            linkItem.Attributes.Add("OnClick", String.Format("return ShowEditPagos('{0}','{1}','{2}');", dataItem["PagoId"], e.Item.ItemIndex, par));
            dataItem["nombre"].Controls.Add(linkItem);

        }


    }

    protected void tk_TarjetaCredito_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        listar_TarjetaCreditos();
    }
    protected void tk_TarjetaCredito_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {

            GridDataItem dataItem = (GridDataItem)e.Item;


            par = "&pgs=" + dataItem["TarjetaCreditoId"].Text;
            HyperLink linkItem = new HyperLink();
            linkItem.NavigateUrl = "#";
            linkItem.Text = dataItem["nombre"].Text;
            linkItem.CssClass = "gridtext";
            linkItem.Attributes.Add("OnClick", String.Format("return ShowEditTarjetasCredito('{0}','{1}','{2}');", dataItem["TarjetaCreditoId"], e.Item.ItemIndex, par));
            dataItem["nombre"].Controls.Add(linkItem);

        }


    }


   
}
