using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using DataOper;
public partial class admin_report_registration : System.Web.UI.Page
{
    DataOperation dOper = new DataOperation();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //DateTime monthStartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            //DateTime endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
            //txtFromDate.Text = dOper.DateShow(monthStartDate.ToString("dd-MMM-yyyy"));
            //txtToDate.Text = dOper.DateShow(endDate.ToString("dd-MMM-yyyy"));
            PopDetails();
        }
    }
    protected void ddlMemberType_SelectedIndexChanged(object sender, EventArgs e)
    {
        PopDetails();
    }
    public void PopDetails()
    {
        string search = "";
        //if (txtFromDate.Text != "" && txtToDate.Text != "")
        //{
        //    search = " and action_on between '" + txtFromDate.Text + "' and '" + txtToDate.Text + "'";
        //}
        DataTable dt = dOper.return_dt("select * from tbl_registration_form where memberType like'" + ddlMemberType.SelectedValue + "%' " + search + " order by sln desc");
        gv.DataSource = dt;
        gv.DataBind();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {

    }
    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv.PageIndex = e.NewPageIndex;
        PopDetails();
    }
    protected void btnShow_Click(object sender, EventArgs e)
    {
        PopDetails();
    }
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        string str_report = "Registration-Report";
        gv.AllowPaging = false;
        PopDetails();
        System.IO.StringWriter sw = new System.IO.StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        Response.ClearContent();
        Response.AddHeader("content-disposition", "attachment; filename=" + str_report + ".xls");
        gv.RenderControl(htw);
        Response.Write(sw.ToString());
        Response.Flush();
        Response.End();
        gv.AllowPaging = true;
    }
}