Test

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.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack){
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;

for (int i = 0; i < 20; i++)
{
string strItem = “”;
if (month >6){
strItem =(year-i).ToString() + “-” + (year – i+1).ToString();
}else{
strItem =(year-i-1).ToString() + “-” + (year – i).ToString();
}
Console.WriteLine(i);
if (year – i < 2016) break;
drReportYear.Items.Add(new ListItem(strItem,strItem));
}

}
}

protected void drSelectYear_SelectedIndexChanged(object sender, EventArgs e)
{
if (drSelectYear.SelectedValue == “”)
{
Response.Write(“Please select a year”);
}
else
{
Response.Write(“pdf/” + drSelectYear.SelectedValue + ” PAOE AAM.pdf”);
Response.Redirect(“pdf/” + drSelectYear.SelectedValue + ” PAOE AAM.pdf”);
}
}

protected void Button1_Click(object sender, EventArgs e)
{
if (drRegionList.SelectedValue !=””) {
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;

//string item = (year-1).ToString() + “-” + (year).ToString();

if (month >6){
item =(year).ToString() + “-” + (year+1).ToString();
}else{
item =(year-1).ToString() + “-” + (year).ToString();
}
if (drReportYear.SelectedValue == item)
{
DataSet ds = GETData.getRegiondata(drRegionList.SelectedValue, drReportYear.SelectedValue);
Session[“Current_dataset”] = ds;
}
else
{
DataSet ds = GETData.getRegiondataHist(drRegionList.SelectedValue, drReportYear.SelectedValue);
Session[“Current_dataset”] = ds;
}
//Response.Redirect(“report1.aspx”);
Response.Redirect(“report1.aspx?region_name=” + drRegionList.SelectedItem + “&year=” + drReportYear.SelectedValue);
}else{
lblErr.Text = “No region selected!”;
lblErr.ForeColor = System.Drawing.Color.Red;

}
}
}