예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DateTime startDate = DateTime.Parse(Request.QueryString["from"].ToString());
        DateTime endDate   = DateTime.Parse(Request.QueryString["to"].ToString());

        dsReportTableAdapters.uspCountVisitsTableAdapter uspCountVisitsTA = new dsReportTableAdapters.uspCountVisitsTableAdapter();
        dsReport.uspCountVisitsDataTable uspCountVisitsDT = uspCountVisitsTA.GetUspCountVisits(startDate, endDate.AddDays(1));

        gvVisits.DataSource = uspCountVisitsDT;
        gvVisits.Caption    = "Traffic Report (Visits) :: Club Marketing Center - From " + Request.QueryString["from"] + " To " + Request.QueryString["to"].ToString();
        gvVisits.DataBind();

        Response.Clear();
        Response.ClearHeaders();                                  //For HTTPS
        Response.Cache.SetCacheability(HttpCacheability.Private); //For HTTPS

        //Response.AddHeader("content-disposition", "attachment; filename=SpifeAssociates"+Convert.ToDateTime(AssociatesDT.Rows[0]["downloaddate"].ToString()).ToShortDateString()+".xls");

        Response.AddHeader("content-disposition", "attachment; filename=Visits_CMC.xls");

        Response.Charset     = "";
        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter       stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);

        gvVisits.RenderControl(htmlWrite);

        Response.Write(stringWrite.ToString());
        Response.End();
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.ScriptTimeout = 180;
        //Enable the last month checkbox
        cbLastMonth.Attributes.Add("onclick", "SetLastMonth()");
        strToday       = DateTime.Now.ToShortDateString();
        strOneMonthAgo = DateTime.Now.AddMonths(-1).ToShortDateString();
        strTheLastDay  = GetLastDayOfMonth(DateTime.Now.AddMonths(-1)).ToShortDateString();
        strTheFirstDay = GetFirstDayOfMonth(DateTime.Now.AddMonths(-1)).ToShortDateString();



        string strTemp = string.Empty;

        if (!Page.IsPostBack)
        {
            calendarPopup1.SelectedDate = Convert.ToDateTime(calendarPopup1.SelectedDate.ToShortDateString()).AddMonths(-1);
            ltrBreadCrumb.Text          = " :: Traffic Report (Visits)";
        }
        else
        {
            Page.Validate();
            if (Page.IsValid)
            {
                if ((Request.Form["calendarPopup1$textBox"] != null) && (Request.Form["calendarPopup2$textBox"] != null))
                {
                    startDate = DateTime.Parse(Request.Form["calendarPopup1$textBox"]);
                    ViewState["startDate"] = startDate.ToShortDateString();
                    endDate = DateTime.Parse(Request.Form["calendarPopup2$textBox"]);
                    ViewState["endDate"] = endDate.ToShortDateString();

                    dsReportTableAdapters.uspCountVisitsTableAdapter uspCountVisitsTA = new dsReportTableAdapters.uspCountVisitsTableAdapter();
                    dsReport.uspCountVisitsDataTable uspCountVisitsDT = uspCountVisitsTA.GetUspCountVisits(startDate, endDate.AddDays(1));

                    gvVisits.DataSource = uspCountVisitsDT;
                    gvVisits.DataBind();

                    ltrBreadCrumb2.Text  = " :: Club Marketing Center - From " + startDate.ToShortDateString() + " To " + endDate.ToShortDateString();
                    siteletTable.Visible = false;
                    resultDiv.Visible    = true;
                }
            }


            ltrBreadCrumb.Text = " :: <a href=\"visits.aspx\">Traffic Report (Visits)</a>";
        }
    }