using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Dundas.Charting.WebControl;
namespace CAMIT
{
/// <summary>
/// Summary description for ViewStateTest.
/// </summary>
public class ViewStateTest : System.Web.UI.Page
{
//protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.DropDownList DropDownList1 = new DropDownList();
public string Db2Conn = "Some Connection String";
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
public string coreSQL = "select sum(actual) Actual, department, sum(Capacity) Capacity from (select sum(pmain.estimate) Actual, loe.loe Capacity, deptgrp.description department from prtadmin.projectmain pmain, prtadmin.projectapp papp,prtadmin.application app, prtadmin.applicationgrp appgrp, prtadmin.departmentgrp deptgrp, prtadmin.applicationloe loe where pmain.projectid = papp.projectid and papp.applicationcd = app.applicationcd and appgrp.groupcd = app.applicationgrpcd and appgrp.deptgroupcd = deptgrp.deptgroupcd and app.applicationcd = loe.applicationcd and loe.year = 2006 and loe.month1 = 1 "; // ") group by deptgrp.description, loe.loe) x group by department"
public string groupSQL = " group by deptgrp.description, loe.loe) x group by department";
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(Page.IsPostBack)
{
string execSQL = coreSQL;
if(DropDownList1.SelectedValue != "0")
{
execSQL = coreSQL + " and papp.AppstatusCd= '" + DropDownList1.SelectedValue.ToString() + "' ";
}
Label1.Text = execSQL;
}
else
{
buildStatusDDL();
}
}
void buildStatusDDL()
{
/**Lets try programmatically creating the DDL
* DropDownList DropDownList1 = new DropDownList();
* **/
DropDownList1.ID = "DropDownList1";
DropDownList1.Visible = true;
DropDownList1.AutoPostBack = true;
DropDownList1.EnableViewState = true;
ListItem ListItem0 = new ListItem();
ListItem0.Text = "None";
ListItem0.Value = "0";
DropDownList1.Items.Add(ListItem0);
string mySelectQuery="select statusgroupcd, description from prtadmin.statusgroup";
OleDbConnection myConnection = new OleDbConnection(Db2Conn);
myConnection.Open();
OleDbCommand cmd = new OleDbCommand(mySelectQuery,myConnection);
OleDbDataReader rdr = cmd.ExecuteReader();
while(rdr.Read())
{
ListItem newListItem = new ListItem();
newListItem.Text = rdr.GetString(1);
newListItem.Value = rdr.GetString(0);
DropDownList1.Items.Add(newListItem);
}
DropDownList1.DataBind();
//Page.Controls.Add(DropDownList1);
PlaceHolder1.Controls.Add(DropDownList1);
}
DataView getData(string pSQL)
{
OleDbConnection myConnection = new OleDbConnection(Db2Conn);
Label1.Text = pSQL + groupSQL;
OleDbDataAdapter cmd = new OleDbDataAdapter(pSQL + groupSQL,Db2Conn);
System.Data.DataSet ds = new System.Data.DataSet();
cmd.Fill(ds);
DataView source = new DataView(ds.Tables[0]);
return source;
}
void buildActualVCapacityChart(string pSQL)
{
//code
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent()
{
this.DropDownList1.SelectedIndexChanged += new System.EventHandler(this.DropDownList1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}