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_app_feedback : 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();
        }
    }

    public void PopDetails()
    {
        string search = "";
        //if (txtFromDate.Text != "" && txtToDate.Text != "")
        //{
        //    search = " where feedback_date between '" + txtFromDate.Text + "' and '" + txtToDate.Text + "'";
        //}
        DataTable dt = dOper.return_dt("select * from app_feedback " + search + " order by feedback_date desc");
        gv.DataSource = dt;
        gv.DataBind();
    }
    protected void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gv.PageIndex = e.NewPageIndex;
        PopDetails();
    }
    protected void btnShow_Click(object sender, EventArgs e)
    {
        PopDetails();
    }
    public override void VerifyRenderingInServerForm(Control control)
    {

    }
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        string str_report = "Feedback-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;
    }
}