using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_TransactionAnalysis : System.Web.UI.Page
{
    decimal Success, Pending, Refund, Fail,Total;
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["AdminEMAILID"] == null)
            {
                Response.Redirect("AdminLogin.aspx");
            }
            TransactionAnalysis();
        }
        catch (Exception ex)
        {
            throw (ex);
        }  
    }
    public void TransactionAnalysis()
    {
        DataSet ds = SqlHelper.GetDataSet(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "udp_dashbord_Transaction_Analysis");
        gridviewTransactionAnalysis.DataSource = ds;
        gridviewTransactionAnalysis.DataBind();
    }
    protected void gridviewTransactionAnalysis_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Success += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Success"));
                Pending += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Pending"));
                Refund += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Refunded"));
                Fail += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Fail"));
                Total += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Total"));
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                e.Row.Cells[0].Text = "Total";
                e.Row.Cells[1].Text = Success.ToString();
                e.Row.Cells[2].Text = Pending.ToString();
                e.Row.Cells[3].Text = Refund.ToString();
                e.Row.Cells[4].Text = Fail.ToString();
                e.Row.Cells[5].Text = Total.ToString();
            }
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }
}
