protected void acctdropdown_SelectedIndexChanged() {
if ( acctdropdown.SelectedValue != "" ) {
string authenticatednetid = HttpContext.Current.User.Identity.Name;
CurrentPerson = JS_Person.LoadUsingNetid( authenticatednetid );
HtmlGenericControl apptitle = (HtmlGenericControl)Page.FindControl( "apptitle" );
//if (apptitle == null)
//Page.FindControl("main-menu").Visible = false;
Panel appcontent = (Panel)Page.FindControl( "appcontent" );
appcontent.Style.Value = "margin:0";
var accounthaspreviousnote = Budget_Web_Form_Final_vw.getdc.Budget_Web_Form_Final_vws.Where( b => b.Account == acctdropdown.SelectedValue & b.User == loggedinuser.Netid & b.Prev_Yr_Note != "" ).OrderBy( b => b.SO ).ThenBy( b => b.Sub_Account ).ThenBy( b => b.Object_Code ).ToList();
HtmlGenericControl headerscriptcontrol = new HtmlGenericControl( "div" );
//fixedCols: 7,
if ( accounthaspreviousnote.Count() != 0 )
headerscriptcontrol.InnerHtml = @"";
else
//fixedCols: 7,
headerscriptcontrol.InnerHtml = @"";
headerscript.Controls.Add( headerscriptcontrol );
var accountdata = Budget_Web_Form_Final_vw.getdc.Budget_Web_Form_Final_vws.Where( b => b.Account == acctdropdown.SelectedValue & b.User == loggedinuser.Netid ).OrderBy( b => b.SO ).ThenBy( b => b.Sub_Account ).ThenBy( b => b.Object_Code ).ToList();
if ( accountdata.Count != 0 ) {
// put account date in header above main table
TableRow headerrow = new TableRow();
TableCell headercell = new TableCell();
headercell.HorizontalAlign = HorizontalAlign.Right;
headercell.Text = "Org:";
headerrow.Cells.Add( headercell );
headercell = new TableCell();
headercell = new TableCell();
headercell.Text = accountdata[ 0 ].Org;
headerrow.Cells.Add( headercell );
BudgetHeaderTable.Rows.Add( headerrow );
headercell = new TableCell();
headerrow = new TableRow();
headercell = new TableCell();
headercell.HorizontalAlign = HorizontalAlign.Right;
headercell.Text = "Org Desc:";
headerrow.Cells.Add( headercell );
headercell = new TableCell();
headercell.Text = accountdata[ 0 ].Org_Desc;
headerrow.Cells.Add( headercell );
BudgetHeaderTable.Rows.Add( headerrow );
headerrow = new TableRow();
headercell = new TableCell();
headercell.HorizontalAlign = HorizontalAlign.Right;
headercell.Text = "Account:";
headerrow.Cells.Add( headercell );
headercell = new TableCell();
headercell.Text = accountdata[ 0 ].Account;
headerrow.Cells.Add( headercell );
BudgetHeaderTable.Rows.Add( headerrow );
headerrow = new TableRow();
headercell = new TableCell();
headercell.HorizontalAlign = HorizontalAlign.Right;
headercell.Text = "Account Name:";
headerrow.Cells.Add( headercell );
headercell = new TableCell();
headercell.Text = accountdata[ 0 ].Account_Name;
headerrow.Cells.Add( headercell );
BudgetHeaderTable.Rows.Add( headerrow );
TableRow objrow = new TableRow();
objrow.TableSection = TableRowSection.TableHeader;
objrow.CssClass = "budgettableheader";
TableHeaderCell objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "Category Name";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "C.O.";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "Sub Account";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "Object Code";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "Object Name";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "Sub Object";
objrow.Cells.Add( objdataheadercell );
//objdataheadercell = new TableHeaderCell();
//objdataheadercell.Text = "FY16 Current Forecast";
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Actuals", SearchPage.PreviousYear );
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} YTD", SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Full Year Budget", SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Full Year Forecast", SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Forecast Note", SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
if ( accounthaspreviousnote.Count() != 0 ) {
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Budget Note", SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
}
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Forecast - {1} Budget", SearchPage.CurrentYear, SearchPage.CurrentYear );
objrow.Cells.Add( objdataheadercell );
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = System.String.Format( "{0} Forecast - {1} Actuals", SearchPage.CurrentYear, SearchPage.PreviousYear );
objrow.Cells.Add(objdataheadercell);
objdataheadercell = new TableHeaderCell();
objdataheadercell.Text = "";
objrow.Cells.Add( objdataheadercell );
BudgetTable.Rows.Add( objrow );
string lastcat = "";
string lastcatfullname = "";
string lastCO = "";
decimal? BQ1 = 0;
decimal? BQ2 = 0;
decimal? BQ3 = 0;
decimal? BQ4 = 0;
decimal? ObjectCurrentForecast = 0;
decimal? ObjectBudgetVariance = 0;
decimal? ObjectForecastMinusActual = 0;
decimal? BQ1_all = 0;
decimal? BQ2_all = 0;
decimal? BQ3_all = 0;
decimal? BQ4_all = 0;
decimal? ObjectBudgetVariance_all = 0;
decimal? ObjectForecastMinusActual_all = 0;
decimal? ObjectCurrentForecast_all = 0;
//UpdatePanel BQ1totalupdatepanel = new UpdatePanel();
//UpdatePanel BQ2totalupdatepanel = new UpdatePanel();
//UpdatePanel BQ3totalupdatepanel = new UpdatePanel();
UpdatePanel BQ4totalupdatepanel = new UpdatePanel();
UpdatePanel FYBudgettotalupdatepanel = new UpdatePanel();
UpdatePanel BudgetVariancetotalupdatepanel = new UpdatePanel();
UpdatePanel ForecastMinusActualtotalupdatepanel = new UpdatePanel();
TableCell objdatacell = new TableCell();
foreach ( var accline in accountdata ) {
string CategoryNameNoSpace = accline.Category_Name.Replace( " ", "" );
objrow = new TableRow();
objrow.TableSection = TableRowSection.TableBody;
objrow.Height = 70;
objrow.ID = "ObjectRow_" + accline.RecID;
objdatacell = new TableCell();
//AsyncPostBackTrigger BQ1trigger = new AsyncPostBackTrigger();
//BQ1trigger.ControlID = "BQ1_" + accline.RecID + "_" + CategoryNameNoSpace;
//BQ1trigger.EventName = "TextChanged";
//BQ1totalupdatepanel.Triggers.Add(BQ1trigger);
//AsyncPostBackTrigger BQ2trigger = new AsyncPostBackTrigger();
//BQ2trigger.ControlID = "BQ2_" + accline.RecID + "_" + CategoryNameNoSpace;
//BQ2trigger.EventName = "TextChanged";
//BQ2totalupdatepanel.Triggers.Add(BQ2trigger);
//AsyncPostBackTrigger BQ3trigger = new AsyncPostBackTrigger();
//BQ3trigger.ControlID = "BQ3_" + accline.RecID + "_" + CategoryNameNoSpace;
//BQ3trigger.EventName = "TextChanged";
//BQ3totalupdatepanel.Triggers.Add(BQ3trigger);
AsyncPostBackTrigger BQ4trigger = new AsyncPostBackTrigger();
BQ4trigger.ControlID = "BQ4_" + accline.RecID + "_" + CategoryNameNoSpace;
BQ4trigger.EventName = "TextChanged";
BQ4totalupdatepanel.Triggers.Add( BQ4trigger );
if ( CategoryNameNoSpace != lastcat ) {
if ( lastcat != "" ) {
//BQ1totalupdatepanel.ID = lastcat + "_BQ1";
//BQ1totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//BQ2totalupdatepanel.ID = lastcat + "_BQ2";
//BQ2totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//BQ3totalupdatepanel.ID = lastcat + "_BQ3";
//BQ3totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
BQ4totalupdatepanel.ID = lastcat + "_BQ4";
BQ4totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
FYBudgettotalupdatepanel.ID = lastcat + "_FYBudget";
FYBudgettotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
BudgetVariancetotalupdatepanel.ID = lastcat + "_BudgetVariance";
BudgetVariancetotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
ForecastMinusActualtotalupdatepanel.ID = lastcat + "_ForecastMinusActual";
ForecastMinusActualtotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
TableRow totalrow = new TableRow();
totalrow.TableSection = TableRowSection.TableBody;
totalrow.ID = "Category_total_TR_" + lastcat;
totalrow.CssClass = "budgetcategorytotal";
TableCell totalcell = new TableCell();
totalcell.Text = lastcatfullname + " Total";
totalcell.CssClass = "categorytotalcelllabel";
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
//totalcell = new TableCell();
//totalcell.ID = "Category_total_" + lastcat + "_CurrentForecast";
//HtmlGenericControl dummmydiv = new HtmlGenericControl("div");
//totalcontent.InnerHtml = string.Format("{0:C0}", ObjectCurrentForecast);
//dummmydiv.Controls.Add(totalcontent);
//totalcell.Controls.Add(dummmydiv);
//totalrow.Cells.Add(totalcell);
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ1";
//totalcell.Text = BQ1.ToString();
HtmlGenericControl totalcontent = new HtmlGenericControl( "div" );
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ1_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ1 );
//BQ1totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ1totalupdatepanel = new UpdatePanel();
//BQ1totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ2";
//totalcell.Text = BQ2.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ2_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ2 );
//BQ2totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ2totalupdatepanel = new UpdatePanel();
//BQ2totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ3";
//totalcell.Text = BQ3.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ3_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ3 );
//BQ3totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
// BQ3totalupdatepanel = new UpdatePanel();
//BQ3totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ4";
//totalcell.Text = BQ4.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ4_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ4 );
BQ4totalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BQ4totalupdatepanel );
totalrow.Cells.Add( totalcell );
BQ4totalupdatepanel = new UpdatePanel();
BQ4totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
if ( accounthaspreviousnote.Count() != 0 ) {
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
}
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BudgetVariance";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BudgetVariance_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectBudgetVariance );
BudgetVariancetotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BudgetVariancetotalupdatepanel );
totalrow.Cells.Add( totalcell );
BudgetVariancetotalupdatepanel = new UpdatePanel();
BudgetVariancetotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_ForecastMinusActual";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_ForecastMinusActual_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectForecastMinusActual );
ForecastMinusActualtotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( ForecastMinusActualtotalupdatepanel );
totalrow.Cells.Add( totalcell );
ForecastMinusActualtotalupdatepanel = new UpdatePanel();
ForecastMinusActualtotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
BudgetTable.Rows.Add( totalrow );
BQ1 = 0;
BQ2 = 0;
BQ3 = 0;
BQ4 = 0;
ObjectBudgetVariance = 0;
ObjectForecastMinusActual = 0;
ObjectCurrentForecast = 0;
}
objdatacell.Text = accline.Category_Name;
lastcat = CategoryNameNoSpace;
lastcatfullname = accline.Category_Name;
} else {
objdatacell.Text = "";
}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
if ( lastCO != accline.Consolidation_Object )
objdatacell.Text = accline.Consolidation_Object;
else
objdatacell.Text = "";
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.ID = "subacct_" + accline.RecID;
UpdatePanel textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_subacct";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
DropDownList subacctInput = new DropDownList();
string qry = @"SELECT DISTINCT ACCT_NBR, SUB_ACCT_NBR, SUB_ACCT_NAME
FROM KFS_COA
WHERE (ACCT_CLOSED_FLG = 'N') AND (ACCT_NBR = '" + accline.Account + "')" +
" AND (len([SUB_ACCT_CLOSED_FLG]) = 0 or [SUB_ACCT_CLOSED_FLG] = 'N')" +
" ORDER BY ACCT_NBR, SUB_ACCT_NBR";
var KfsConnectionString = ConfigurationManager.ConnectionStrings[ "Kfs" ].ConnectionString;
using ( var sqlConnection = new SqlConnection( KfsConnectionString ) ) {
sqlConnection.Open();
using ( var sqlCommand = new SqlCommand( qry, sqlConnection ) ) {
using ( var dr = sqlCommand.ExecuteReader() ) {
if ( dr.HasRows ) {
ListItem subacctdropdownitem = new ListItem();
//subacctdropdownitem.Text = "";
//subacctdropdownitem.Value = "";
//subacctInput.Items.Add(subacctdropdownitem);
while ( dr.Read() ) {
subacctdropdownitem = new ListItem();
subacctdropdownitem.Text = StringTools.NonNullValue( dr[ "SUB_ACCT_NBR" ].ToString () );
subacctdropdownitem.Value = StringTools.NonNullValue( dr[ "SUB_ACCT_NBR" ].ToString() );
subacctInput.Items.Add( subacctdropdownitem );
}
}
}
}
}
if ( subacctInput.Items.FindByValue( accline.Sub_Account ) == null )
subacctInput.Items.Add( accline.Sub_Account );
subacctInput.SelectedValue = accline.Sub_Account;
if ( StringTools.NonNullValue( accline.ReadOnly ) == "Y" ) {
//if (!CurrentPerson.IsInRole("Department - Financial Services"))
subacctInput.Enabled = false;
}
subacctInput.ID = "subacct_" + accline.RecID + "_" + CategoryNameNoSpace;
subacctInput.Attributes.Add( "onfocus", "setinitalval(this)" );
subacctInput.Attributes.Add( "onchange", "highlightifchanged(this)" );
//subacctInput.Attributes.Add("onkeyup", "highlightifchanged(this)");
//subacctInput.Attributes.Add("onmouseup", "highlightifchanged(this)");
subacctInput.AutoPostBack = true;
subacctInput.SelectedIndexChanged += DDL_TextChanged;
ScriptManager.GetCurrent( Page ).RegisterAsyncPostBackControl( subacctInput );
textboxupdatepanel.ContentTemplateContainer.Controls.Add( subacctInput );
objdatacell.Controls.Add( textboxupdatepanel );
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.Text = accline.Object_Code;
objdatacell.ID = "objectcode_" + accline.RecID;
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.Text = accline.Object_Name;
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.ID = "subobject_" + accline.RecID;
textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_subobject";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
DropDownList subobjectInput = new DropDownList();
qry = @"SELECT DISTINCT OBJ_CD, SUB_OBJ_CD, SUB_OBJ_CD_SHORT_NAME
FROM BudgetFom_Object_tbl
WHERE (OBJ_CD = '" + accline.Object_Code + "')" +
" ORDER BY OBJ_CD, SUB_OBJ_CD";
using ( var sqlConnection = new SqlConnection( KfsConnectionString ) ) {
sqlConnection.Open();
using ( var sqlCommand = new SqlCommand( qry, sqlConnection ) ) {
using ( var dr = sqlCommand.ExecuteReader() ) {
if ( dr.HasRows ) {
ListItem subobjectdropdownitem = new ListItem();
//subacctdropdownitem.Text = "";
//subacctdropdownitem.Value = "";
//subacctInput.Items.Add(subacctdropdownitem);
while ( dr.Read() ) {
subobjectdropdownitem = new ListItem();
subobjectdropdownitem.Text = StringTools.NonNullValue( (string)dr[ "SUB_OBJ_CD" ].ToString() ) + "-" + StringTools.NonNullValue( (string)dr[ "SUB_OBJ_CD_SHORT_NAME" ].ToString() );
subobjectdropdownitem.Value = StringTools.NonNullValue( (string)dr[ "SUB_OBJ_CD" ].ToString() );
subobjectInput.Items.Add( subobjectdropdownitem );
}
}
}
}
}
if ( subobjectInput.Items.FindByValue( accline.Sub_Object ) == null )
subobjectInput.Items.Add( accline.Sub_Object );
subobjectInput.SelectedValue = accline.Sub_Object;
if ( StringTools.NonNullValue( accline.ReadOnly ) == "Y" ) {
//if (!CurrentPerson.IsInRole("Department - Financial Services"))
subobjectInput.Enabled = false;
}
subobjectInput.ID = "subobject_" + accline.RecID + "_" + CategoryNameNoSpace;
subobjectInput.Attributes.Add( "onfocus", "setinitalval(this)" );
subobjectInput.Attributes.Add( "onkeyup", "highlightifchanged(this)" );
subobjectInput.Attributes.Add( "onmouseup", "highlightifchanged(this)" );
subobjectInput.AutoPostBack = true;
subobjectInput.SelectedIndexChanged += DDL_TextChanged;
ScriptManager.GetCurrent( Page ).RegisterAsyncPostBackControl( subobjectInput );
textboxupdatepanel.ContentTemplateContainer.Controls.Add( subobjectInput );
objdatacell.Controls.Add( textboxupdatepanel );
objrow.Cells.Add( objdatacell );
//objdatacell = new TableCell();
//HtmlGenericControl forecastcontent = new HtmlGenericControl("div");
//HtmlGenericControl forecastdummmydiv = new HtmlGenericControl("div");
//objdatacell.ID = "ObjectCurrentForecastCell_" + accline.RecID;
//forecastcontent.InnerHtml = string.Format("{0:F0}", accline.Current_Budget);
//forecastdummmydiv.Controls.Add(forecastcontent);
//objdatacell.Controls.Add(forecastdummmydiv);
//if (accline.Current_Budget != null)
//{
// ObjectCurrentForecast = ObjectCurrentForecast + accline.Current_Budget;
// if (CategoryNameNoSpace == "Expense")
// ObjectCurrentForecast_all = ObjectCurrentForecast_all - accline.Current_Budget;
// else
// ObjectCurrentForecast_all = ObjectCurrentForecast_all + accline.Current_Budget;
//}
//objrow.Cells.Add(objdatacell);
objdatacell = new TableCell();
HtmlGenericControl actualscontent = new HtmlGenericControl( "div" );
HtmlGenericControl actualsdummmydiv = new HtmlGenericControl( "div" );
actualscontent.InnerHtml = string.Format( "{0:F0}", accline.PY_Actual );
actualsdummmydiv.Controls.Add( actualscontent );
objdatacell.Controls.Add( actualsdummmydiv );
objdatacell.ID = "BQ1_" + accline.RecID;
if ( accline.PY_Actual != null ) {
BQ1 = BQ1 + accline.PY_Actual;
if ( CategoryNameNoSpace == "Expense" )
BQ1_all = BQ1_all - accline.PY_Actual;
else
BQ1_all = BQ1_all + accline.PY_Actual;
}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
HtmlGenericControl budgetcontent = new HtmlGenericControl( "div" );
HtmlGenericControl budgetdummmydiv = new HtmlGenericControl( "div" );
budgetcontent.InnerHtml = string.Format( "{0:F0}", accline.Actual );
budgetdummmydiv.Controls.Add( budgetcontent );
objdatacell.Controls.Add( budgetdummmydiv );
objdatacell.ID = "BQ2_" + accline.RecID;
if ( accline.Actual != null ) {
BQ2 = BQ2 + accline.Actual;
if ( CategoryNameNoSpace == "Expense" )
BQ2_all = BQ2_all - accline.Actual;
else
BQ2_all = BQ2_all + accline.Actual;
}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
HtmlGenericControl ytdcontent = new HtmlGenericControl( "div" );
HtmlGenericControl ytddummmydiv = new HtmlGenericControl( "div" );
ytdcontent.InnerHtml = string.Format( "{0:F0}", accline.Current_Budget );
ytddummmydiv.Controls.Add( ytdcontent );
objdatacell.Controls.Add( ytddummmydiv );
objdatacell.ID = "BQ3_" + accline.RecID;
if ( accline.Current_Budget != null ) {
BQ3 = BQ3 + accline.Current_Budget;
if ( CategoryNameNoSpace == "Expense" )
BQ3_all = BQ3_all - accline.Current_Budget;
else
BQ3_all = BQ3_all + accline.Current_Budget;
}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.ID = "BQ4_" + accline.RecID;
textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_BQ4";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
TextBox BQ4Input = new TextBox();
BQ4Input.Columns = 8;
BQ4Input.Text = string.Format( "{0:F0}", accline.Forecast );
BQ4Input.ID = "BQ4_" + accline.RecID + "_" + CategoryNameNoSpace;
BQ4Input.Attributes.Add( "onfocus", "setinitalval(this)" );
BQ4Input.Attributes.Add( "onkeyup", "highlightifchanged(this)" );
BQ4Input.Attributes.Add( "onchange", "if(!checkfordecimal(this)){return false;}" );
BQ4Input.Attributes.Add( "onblur", "if(!checkfordecimalmsg(this,event)){return false;}" );
BQ4Input.AutoPostBack = true;
if ( StringTools.NonNullValue( accline.ReadOnly ) == "Y" ) {
//if (!CurrentPerson.IsInRole("Department - Financial Services"))
BQ4Input.Enabled = false;
}
BQ4Input.TextChanged += TextBox2_TextChanged;
ScriptManager.GetCurrent( Page ).RegisterAsyncPostBackControl( BQ4Input );
textboxupdatepanel.ContentTemplateContainer.Controls.Add( BQ4Input );
objdatacell.Controls.Add( textboxupdatepanel );
if ( accline.Budget != null ) {
BQ4 = BQ4 + accline.Budget;
if ( CategoryNameNoSpace == "Expense" )
BQ4_all = BQ4_all - accline.Budget;
else
BQ4_all = BQ4_all + accline.Budget;
}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.ID = "note_" + accline.RecID;
textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_note";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
TextBox noteInput = new TextBox();
noteInput.TextMode = TextBoxMode.MultiLine;
noteInput.Rows = 2;
noteInput.Text = accline.Note;
noteInput.ID = "note_" + accline.RecID + "_" + CategoryNameNoSpace;
noteInput.Attributes.Add( "onfocus", "setinitalval(this)" );
noteInput.Attributes.Add( "onkeyup", "highlightifchanged(this)" );
noteInput.AutoPostBack = true;
noteInput.TextChanged += TextBox2_TextChanged;
ScriptManager.GetCurrent( Page ).RegisterAsyncPostBackControl( noteInput );
textboxupdatepanel.ContentTemplateContainer.Controls.Add( noteInput );
objdatacell.Controls.Add( textboxupdatepanel );
objrow.Cells.Add( objdatacell );
if ( accounthaspreviousnote.Count() != 0 ) {
objdatacell = new TableCell();
HtmlGenericControl prev_yr_div = new HtmlGenericControl( "div" );
prev_yr_div.InnerHtml = accline.Prev_Yr_Note;
prev_yr_div.Style.Add( "max-width", "200px" );
objdatacell.Controls.Add( prev_yr_div );
objrow.Cells.Add( objdatacell );
}
objdatacell = new TableCell();
objdatacell.ID = "ObjectBudgetVarianceCell_" + accline.RecID;
textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_BudgetVariance";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
HtmlGenericControl BudgetVariance = new HtmlGenericControl( "div" );
BudgetVariance.InnerHtml = string.Format( "{0:F0}", accline.Forecast - accline.Current_Budget );
BudgetVariance.ID = "BudgetVariance_" + accline.RecID + "_" + CategoryNameNoSpace;
textboxupdatepanel.ContentTemplateContainer.Controls.Add( BudgetVariance );
objdatacell.Controls.Add( textboxupdatepanel );
//if (accline.CB_Budget_Variance != null)
//{
ObjectBudgetVariance = ObjectBudgetVariance + accline.Budget - accline.Current_Budget;
ObjectBudgetVariance_all = ObjectBudgetVariance_all + accline.Budget - accline.Current_Budget;
//}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
objdatacell.ID = "ObjectForecastMinusActualCell_" + accline.RecID;
textboxupdatepanel = new UpdatePanel();
textboxupdatepanel.ID = accline.RecID + "_ForecastMinusActual";
textboxupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
HtmlGenericControl ForecastMinusActual = new HtmlGenericControl( "div" );
ForecastMinusActual.InnerHtml = string.Format( "{0:F0}", accline.Forecast - accline.PY_Actual );
ForecastMinusActual.ID = "ForecastMinusActual_" + accline.RecID + "_" + CategoryNameNoSpace;
textboxupdatepanel.ContentTemplateContainer.Controls.Add( ForecastMinusActual );
objdatacell.Controls.Add( textboxupdatepanel );
//if (accline.CB_Budget_Variance != null)
//{
ObjectForecastMinusActual = ObjectForecastMinusActual + accline.Forecast - accline.PY_Actual;
ObjectForecastMinusActual_all = ObjectForecastMinusActual_all + accline.Budget - accline.PY_Actual;
//}
objrow.Cells.Add( objdatacell );
objdatacell = new TableCell();
LinkButton btnDeleteObjcode = new LinkButton();
btnDeleteObjcode.Command += btnDeleteObjcode_Click;
btnDeleteObjcode.CommandArgument = accline.RecID.ToString();
btnDeleteObjcode.Text = "Delete";
btnDeleteObjcode.OnClientClick = "if(!ConfirmDelete('" + accline.Object_Code + "','" + accline.Object_Name + "',event)){return false;}";
objdatacell.Controls.Add( btnDeleteObjcode );
objrow.Cells.Add( objdatacell );
BudgetTable.Rows.Add( objrow );
}
if ( lastcat != "" ) // total for the last category name and account totals
{
// total for the last category name
TableRow totalrow = new TableRow();
totalrow.TableSection = TableRowSection.TableBody;
totalrow.ID = "Category_total_TR_" + lastcat;
totalrow.CssClass = "budgetcategorytotal";
TableCell totalcell = new TableCell();
totalcell.Text = lastcatfullname + " Total";
totalcell.CssClass = "categorytotalcelllabel";
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
//totalcell = new TableCell();
//totalcell.ID = "Category_total_" + lastcat + "_CurrentForecast";
//HtmlGenericControl dummmydiv = new HtmlGenericControl("div");
//totalcontent.InnerHtml = string.Format("{0:C0}", ObjectCurrentForecast);
//dummmydiv.Controls.Add(totalcontent);
//totalcell.Controls.Add(dummmydiv);
//totalrow.Cells.Add(totalcell);
//BQ1totalupdatepanel.ID = lastcat + "_BQ1";
//BQ1totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
HtmlGenericControl totalcontent = new HtmlGenericControl( "div" );
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ1";
//totalcell.Text = BQ1.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ1_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ1 );
//BQ1totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ2totalupdatepanel.ID = lastcat + "_BQ2";
//BQ2totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ2";
//totalcell.Text = BQ2.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ2_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ2 );
//BQ2totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ3totalupdatepanel.ID = lastcat + "_BQ3";
//BQ3totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ3";
//totalcell.Text = BQ3.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ3_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ3 );
//BQ3totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
BQ4totalupdatepanel.ID = lastcat + "_BQ4";
BQ4totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BQ4";
//totalcell.Text = BQ4.ToString();
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BQ4_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ4 );
BQ4totalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BQ4totalupdatepanel );
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
if ( accounthaspreviousnote.Count() != 0 ) {
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
}
BudgetVariancetotalupdatepanel.ID = lastcat + "_BudgetVariance";
BudgetVariancetotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_BudgetVariance";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_BudgetVariance_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectBudgetVariance );
BudgetVariancetotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BudgetVariancetotalupdatepanel );
totalrow.Cells.Add( totalcell );
ForecastMinusActualtotalupdatepanel.ID = lastcat + "_ForecastMinusActual";
ForecastMinusActualtotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
totalcell = new TableCell();
totalcell.ID = "Category_total_" + lastcat + "_ForecastMinusActual";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Category_total_" + lastcat + "_ForecastMinusActual_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectForecastMinusActual );
ForecastMinusActualtotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( ForecastMinusActualtotalupdatepanel );
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
BudgetTable.Rows.Add( totalrow );
// total for the account totals
totalrow = new TableRow();
totalrow.TableSection = TableRowSection.TableBody;
totalrow.ID = "Account_total_TR";
totalrow.CssClass = "budgetaccounttotal";
totalcell = new TableCell();
totalcell.Text = "Operating Margin";
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
//totalcell = new TableCell();
//totalcell.ID = "Account_total_CurrentForecast";
//dummmydiv = new HtmlGenericControl("div");
//totalcontent.InnerHtml = string.Format("{0:C0}", ObjectCurrentForecast_all);
//dummmydiv.Controls.Add(totalcontent);
//totalcell.Controls.Add(dummmydiv);
//totalrow.Cells.Add(totalcell);
//BQ1totalupdatepanel = new UpdatePanel();
//BQ1totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//BQ1totalupdatepanel.ID = "Account_BQ1";
totalcontent = new HtmlGenericControl( "div" );
totalcell = new TableCell();
totalcell.ID = "Account_total_BQ1";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Account_total_BQ1_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ1_all );
//BQ1totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ2totalupdatepanel = new UpdatePanel();
//BQ2totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//BQ2totalupdatepanel.ID = "Account_BQ2";
totalcell = new TableCell();
totalcell.ID = "Account_total_BQ2";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Account_total_BQ2_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ2_all );
//BQ2totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
//BQ3totalupdatepanel = new UpdatePanel();
//BQ3totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//BQ3totalupdatepanel.ID = "Account_BQ3";
totalcell = new TableCell();
totalcell.ID = "Account_total_BQ3";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Account_total_BQ3_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ3_all );
//BQ3totalupdatepanel.ContentTemplateContainer.Controls.Add(totalcontent);
totalcell.Controls.Add( totalcontent );
totalrow.Cells.Add( totalcell );
BQ4totalupdatepanel = new UpdatePanel();
BQ4totalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
BQ4totalupdatepanel.ID = "Account_BQ4";
totalcell = new TableCell();
totalcell.ID = "Account_total_BQ4";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Account_total_BQ4_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", BQ4_all );
BQ4totalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BQ4totalupdatepanel );
totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
if ( accounthaspreviousnote.Count() != 0 ) {
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
}
BudgetVariancetotalupdatepanel = new UpdatePanel();
BudgetVariancetotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
BudgetVariancetotalupdatepanel.ID = "Account_BudgetVariance";
totalcell = new TableCell();
totalcell.ID = "Account_total_BudgetVariance";
totalcontent = new HtmlGenericControl( "div" );
totalcontent.ID = "Account_total_BudgetVariance_content";
totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectBudgetVariance_all );
BudgetVariancetotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
totalcell.Controls.Add( BudgetVariancetotalupdatepanel );
totalrow.Cells.Add( totalcell );
//ForecastMinusActualtotalupdatepanel = new UpdatePanel();
//ForecastMinusActualtotalupdatepanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
//ForecastMinusActualtotalupdatepanel.ID = "Account_ForecastMinusActual";
//totalcell = new TableCell();
//totalcell.ID = "Account_total_ForecastMinusActual";
//totalcontent = new HtmlGenericControl( "div" );
//totalcontent.ID = "Account_total_ForecastMinusActual_content";
//totalcontent.InnerHtml = string.Format( "{0:C0}", ObjectForecastMinusActual_all );
//ForecastMinusActualtotalupdatepanel.ContentTemplateContainer.Controls.Add( totalcontent );
//totalcell.Controls.Add( ForecastMinusActualtotalupdatepanel );
//totalrow.Cells.Add( totalcell );
totalcell = new TableCell();
totalrow.Cells.Add( totalcell );
BudgetTable.Rows.Add( totalrow );
}
} else //requested account not found; someone probably manually edited queryparam acct
{
accountheadercontainer.Visible = false;
addobjectcodecontainer.Visible = false;
btnFinish.Visible = false;
BudgetTable.Visible = false;
lblDebug.Text = "That's not a valid account for you.";
}
} else //requested account not found; someone probably manually edited queryparam acct
{
accountheadercontainer.Visible = false;
addobjectcodecontainer.Visible = false;
btnFinish.Visible = false;
BudgetTable.Visible = false;
lblDebug.Text = "That's not a valid account for you.";
}
//lblDebug.Text += acctdropdown.SelectedValue + "sent";
}