protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { dsAuxCost = ContextBase.GetCacheData(); if (dsAuxCost == null) { Response.Redirect("~"); } else if (dsAuxCost.DataSetName != "ConAuxCost") { Response.Redirect("~"); } } else { ContextBase.RemoveCacheData(); //remove anything left in cache dsAuxCost = new DataSet("ConAuxCost"); DataCommand().Param("CostType", "All").MapSchema().FillDataSet(dsAuxCost, "dbo.AuxCost_Select", "AuxCost"); ContextBase.SetCacheData(dsAuxCost); BindGrids(); } }
private void AddNewParm(DataGridItem dgi, string type) { DataRow dr = dsAuxCost.Tables["AuxCost"].NewRow(); dr["AuxCostParm"] = ((TextBox)dgi.FindControl("txt" + type + "AuxCost")).Text.Trim(); dr["AllowPerUse"] = ((CheckBox)dgi.FindControl("chk" + type + "PerUse")).Checked; dr["AllowPerPeriod"] = ((CheckBox)dgi.FindControl("chk" + type + "PerPeriod")).Checked; dr["Description"] = ((TextBox)dgi.FindControl("txt" + type + "Description")).Text.Trim(); dsAuxCost.Tables["AuxCost"].Rows.Add(dr); ContextBase.SetCacheData(dsAuxCost); BindGrids(); }
protected void Page_Load(object sender, EventArgs e) { lblWarning.Text = string.Empty; lblWarning.Visible = false; if (Page.IsPostBack) { dsReport = ContextBase.GetCacheData(); if (dsReport == null) { Response.Redirect("~"); } else if (dsReport.DataSetName != "DatHistorical") { Response.Redirect("~"); } } else { ContextBase.RemoveCacheData(); //remove anything left in cache dsReport = new DataSet("DatHistorical"); DataCommand().Param("Action", "All").Param("sDate", DateTime.Parse("1/1/2000")).FillDataSet(dsReport, "dbo.Client_Select", "Client"); dsReport.Tables["Client"].PrimaryKey = new[] { dsReport.Tables["Client"].Columns["ClientID"] }; using (var reader = DataCommand().Param("Action", "All").ExecuteReader("dbo.Org_Select")) { ddlOrg.DataSource = reader; ddlOrg.DataValueField = "OrgID"; ddlOrg.DataTextField = "OrgName"; ddlOrg.DataBind(); ddlOrg.Items.Insert(0, new ListItem("-- Select --", "0")); ddlOrg.ClearSelection(); reader.Close(); } ContextBase.SetCacheData(dsReport); // populate site dropdown - preselect using site linked in from } }
protected void Page_Load(object sender, EventArgs e) { lblError.Visible = false; txtFormula.Attributes.Add("spellcheck", "false"); if (Page.IsPostBack) { dsFormula = ContextBase.GetCacheData(); if (dsFormula == null) { Response.Redirect("~"); } else if (dsFormula.DataSetName != "ConFormula") { Response.Redirect("~"); } } else { ContextBase.RemoveCacheData(); //remove anything left in cache Session["ItemType"] = Request.QueryString["ItemType"]; Session["Exp"] = Request.QueryString["Exp"]; string exp = Convert.ToString(Session["Exp"]); if (!string.IsNullOrEmpty(exp)) { tableNamePrefix = exp; btnBack.Text = "Return to Experimental Cost Config"; } litHeader.Text = string.Format("Configure {0} costing fomulas", tableNamePrefix); dsFormula = new DataSet("ConFormula"); DataCommand().Param("sDate", DateTime.Now).MapSchema().FillDataSet(dsFormula, $"dbo.{tableNamePrefix}CostFormula_Select", "Formula"); ContextBase.SetCacheData(dsFormula); } }
protected void DdlOrg_SelectedIndexChanged(object sender, EventArgs e) { if (ddlOrg.SelectedIndex != 0) { ddlAccount.Items.Clear(); if (dsReport.Tables.Contains("Account")) { dsReport.Tables.Remove(dsReport.Tables["Account"]); } // get account and clientAccount info DataCommand() .Param("Action", "AllByOrg") .Param("OrgID", int.Parse(ddlOrg.SelectedValue)) .FillDataSet(dsReport, "dbo.Account_Select", "Account"); ContextBase.SetCacheData(dsReport); LoadAccounts(); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { dsReport = ContextBase.GetCacheData(); if (dsReport == null) { Response.Redirect("~"); } else if (dsReport.DataSetName != "DatClient") { Response.Redirect("~"); } } else { dsReport = new DataSet("DatClient"); //get Role info DataCommand() .Param("TableName", "Role") .FillDataSet(dsReport, "dbo.Global_Select", "Role"); //get UserType info DataCommand() .Param("TableName", "Community") .FillDataSet(dsReport, "dbo.Global_Select", "Communities"); //grab all departments DataCommand() .Param("Action", "All") .FillDataSet(dsReport, "dbo.Department_Select", "Department"); ContextBase.SetCacheData(dsReport); UpdateClientDDL(); } }
private void UpdateClientDDL() { PopulateUserDropDownList(ddlUser, pp1.SelectedPeriod, btnReport, true); // The following is to generate report DateTime sDate = pp1.SelectedPeriod; DateTime eDate = sDate.AddMonths(1); //need to empty tables if (dsReport.Tables.Contains("ClientOrg")) { dsReport.Tables.Remove(dsReport.Tables["ClientOrg"]); } if (dsReport.Tables.Contains("ClientManager")) { dsReport.Tables.Remove(dsReport.Tables["ClientManager"]); } if (dsReport.Tables.Contains("Org")) { dsReport.Tables.Remove(dsReport.Tables["Org"]); } if (dsReport.Tables.Contains("Account")) { dsReport.Tables.Remove(dsReport.Tables["Account"]); } if (dsReport.Tables.Contains("ClientAccount")) { dsReport.Tables.Remove(dsReport.Tables["ClientAccount"]); } if (dsReport.Tables.Contains("Client")) { dsReport.Tables.Remove(dsReport.Tables["Client"]); } if (dsReport.Tables.Contains("DemCitizen")) { dsReport.Tables.Remove(dsReport.Tables["DemCitizen"]); } if (dsReport.Tables.Contains("DemDisability")) { dsReport.Tables.Remove(dsReport.Tables["DemDisability"]); } if (dsReport.Tables.Contains("DemEthnic")) { dsReport.Tables.Remove(dsReport.Tables["DemEthnic"]); } if (dsReport.Tables.Contains("DemGender")) { dsReport.Tables.Remove(dsReport.Tables["DemGender"]); } if (dsReport.Tables.Contains("DemRace")) { dsReport.Tables.Remove(dsReport.Tables["DemRace"]); } //display name column is appended to facilitate manager display DataCommand() .Param("Action", "AllActive") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.ClientOrg_Select", "ClientOrg"); dsReport.Tables["ClientOrg"].PrimaryKey = new[] { dsReport.Tables["ClientOrg"].Columns["ClientOrgID"] }; //Manager info DataCommand() .Param("Action", "AllActive") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.ClientManager_Select", "ClientManager"); //get Org info DataCommand() .MapSchema() .Param("Action", "AllActive") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.Org_Select", "Org"); dsReport.Tables["Org"].PrimaryKey = new[] { dsReport.Tables["Org"].Columns["OrgID"] }; //get Account info DataCommand() .Param("Action", "AllActive") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.Account_Select", "Account"); dsReport.Tables["Account"].PrimaryKey = new[] { dsReport.Tables["Account"].Columns["AccountID"] }; //get ClientAccount info DataCommand() .Param("Action", "AllActive") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.ClientAccount_Select", "ClientAccount"); //Client info - gets put into ddl, not needed in dataset DataCommand() .Param("Action", "All") .Param("sDate", sDate) .Param("eDate", eDate) .FillDataSet(dsReport, "dbo.Client_Select", "Client"); dsReport.Tables["Client"].PrimaryKey = new DataColumn[] { dsReport.Tables["Client"].Columns["ClientID"] }; //fill in demographics RBL - could be prettier... var command = DataCommand().MapSchema(); //select command command.Param("Action", "All"); command.Param("DemType", "DemCitizen"); command.FillDataSet(dsReport, "dbo.Dem_Select", "DemCitizen"); dsReport.Tables["DemCitizen"].PrimaryKey = new[] { dsReport.Tables["DemCitizen"].Columns["DemCitizenID"] }; command.Param("DemType", "DemDisability"); command.FillDataSet(dsReport, "dbo.Dem_Select", "DemDisability"); dsReport.Tables["DemDisability"].PrimaryKey = new[] { dsReport.Tables["DemDisability"].Columns["DemDisabilityID"] }; command.Param("DemType", "DemEthnic"); command.FillDataSet(dsReport, "dbo.Dem_Select", "DemEthnic"); dsReport.Tables["DemEthnic"].PrimaryKey = new[] { dsReport.Tables["DemEthnic"].Columns["DemEthnicID"] }; command.Param("DemType", "DemGender"); command.FillDataSet(dsReport, "dbo.Dem_Select", "DemGender"); dsReport.Tables["DemGender"].PrimaryKey = new[] { dsReport.Tables["DemGender"].Columns["DemGenderID"] }; command.Param("DemType", "DemRace"); command.FillDataSet(dsReport, "dbo.Dem_Select", "DemRace"); dsReport.Tables["DemRace"].PrimaryKey = new[] { dsReport.Tables["DemRace"].Columns["DemRaceID"] }; ContextBase.SetCacheData(dsReport); }
protected void BtnValidate_Click(object sender, EventArgs e) { tableNamePrefix = Convert.ToString(Session["Exp"]); // create instance of compile class Compile mCompile = new Compile(); int i; string strType = rblFormulaType.SelectedItem.Text; int selType = Convert.ToInt32(rblFormulaType.SelectedValue); // now try formula try { DateTime Period = new DateTime(DateTime.Now.Date.AddMonths(-1).Year, DateTime.Now.Date.AddMonths(-1).Month, 1); DataTable dtData = mCompile.CalcCost(strType, txtFormula.Text.Trim(), "", 0, Period, 0, 0, Compile.AggType.None, true, tableNamePrefix); if (dtData.Rows.Count > 0) { // add calcCost as a array element to facilitate display IList <string> temp; temp = mCompile.aryVars[selType].ToList(); temp.Add("CalcCost"); mCompile.aryVars[selType] = temp.ToArray(); temp = mCompile.aryVarFormats[selType].ToList(); temp.Add("{0:$#,##0.00}"); mCompile.aryVarFormats[selType] = temp.ToArray(); BoundColumn bc; for (i = 0; i < mCompile.aryVars[selType].Length; i++) { bc = new BoundColumn { DataField = mCompile.aryVars[selType][i] }; bc.ItemStyle.HorizontalAlign = HorizontalAlign.Right; bc.HeaderText = mCompile.aryVars[selType][i]; bc.HeaderStyle.Font.Bold = true; bc.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; if (mCompile.aryVarFormats[selType][i].Length > 0) { bc.DataFormatString = mCompile.aryVarFormats[selType][i]; } dgSample.Columns.Add(bc); } dgSample.DataSource = dtData; dgSample.DataBind(); } } catch (Exception ex) { lblError.Text = ex.Message; lblError.Visible = true; return; } // if no errors, store new formula. // if a new formula has been stored, over-write it DataRow[] fdr = dsFormula.Tables["Formula"].Select(string.Format("FormulaType = '{0}'", rblFormulaType.SelectedItem.Text), "EffDate ASC"); if (fdr.Length > 1) { dsFormula.Tables["Formula"].Rows.Remove(fdr[1]); } DataRow ndr = dsFormula.Tables["Formula"].NewRow(); ndr["FormulaType"] = rblFormulaType.SelectedItem.Text; ndr["Formula"] = txtFormula.Text; ndr["EffDate"] = DateTime.Now; dsFormula.Tables["Formula"].Rows.Add(ndr); ContextBase.SetCacheData(dsFormula); btnRevert.Enabled = true; }
private void Prepare(ref DateTime period, ref int clientId) { if (dsReport != null) { return; } lblRoom.Visible = false; lblTool.Visible = false; lblStore.Visible = false; dsReport = new DataSet("IndSumUsage"); // get account, resource and item info info DataCommand() .Param("Action", "All") .FillDataSet(dsReport, "dbo.Account_Select", "Account"); dsReport.Tables["Account"].PrimaryKey = new[] { dsReport.Tables["Account"].Columns["AccountID"] }; DataCommand() .Param("Action", "All") .FillDataSet(dsReport, "dbo.Room_Select", "Room"); dsReport.Tables["Room"].PrimaryKey = new[] { dsReport.Tables["Room"].Columns["RoomID"] }; DataCommand() .Param("Action", "AllResources") .FillDataSet(dsReport, "dbo.sselScheduler_Select", "Resource"); dsReport.Tables["Resource"].PrimaryKey = new[] { dsReport.Tables["Resource"].Columns["ResourceID"] }; DataCommand() .Param("Action", "Item") .FillDataSet(dsReport, "dbo.sselMAS_Select", "Item"); dsReport.Tables["Item"].PrimaryKey = new[] { dsReport.Tables["Item"].Columns["ItemID"] }; //2007-05-30 Adding billing type to data grid //2011-06-23 GetBillingTypes was only returning active billing types. This caused problems when // looking at historical data (null reference when the billing type is not active). I added // a second GetBillingTypes method that takes either DBNull or a Boolean. If True then only // IsActive=1, if False then only IsActive=0, if DBNull then both are returned. If no parameter // is passed to GetBillingTypes the results are the same as they always were - only IsActive=1 // are returned. dsReport.Tables.Add(BillingTypeManager.GetBillingTypes(DBNull.Value)); dsReport.Tables[4].TableName = "BillingType"; dsReport.Tables["BillingType"].PrimaryKey = new[] { dsReport.Tables["BillingType"].Columns["BillingTypeID"] }; //2009-02-17 Adding org name because users might have different orgs dsReport.Tables.Add(OrgDA.GetAllOrgs()); dsReport.Tables[5].TableName = "Org"; dsReport.Tables["Org"].PrimaryKey = new[] { dsReport.Tables["Org"].Columns["OrgID"] }; ContextBase.SetCacheData(dsReport); //2007-02-01 Add report button //So have to move the ddlUser populated code here if (CurrentUser.HasPriv(ClientPrivilege.Administrator | ClientPrivilege.Staff | ClientPrivilege.Executive)) { DateTime sDate = period; DateTime eDate = sDate.AddMonths(1); var command = DataCommand() .Param("sDate", sDate) .Param("eDate", eDate) .Param("ClientID", clientId); //Depending on the user prives, we need to retrieve different set of data if (CurrentUser.HasPriv(ClientPrivilege.Administrator | ClientPrivilege.Staff)) { command .Param("Privs", (int)(ClientPrivilege.LabUser | ClientPrivilege.Staff | ClientPrivilege.StoreUser)) .Param("Action", "All"); } else if (CurrentUser.HasPriv(ClientPrivilege.Executive)) { //for executive-only person, we only show the people he/she manages command.Param("Action", "ByMgr"); } using (var reader = command.ExecuteReader("dbo.Client_Select")) { ddlUser.DataSource = reader; ddlUser.DataTextField = "DisplayName"; ddlUser.DataValueField = "ClientID"; ddlUser.DataBind(); } } //2007-2-02 Two possible scenario //- if the current user is user himself, we have to add the empty ddlUser with only one entry //else, it's a good habit to include the user him/herself as well, since the above ddlUser data code return only a group of people //but sometimes the user him/herself is not belong to this group of people //ddlUser.Items.Insert(0, new ListItem(CacheManager.Current.CurrentUser.DisplayName, CacheManager.Current.ClientID.ToString())); //ddlUser.SelectedValue = CacheManager.Current.ClientID.ToString(); string urlData = Request.QueryString["URLdata"]; // iiiiyyyymm if (!string.IsNullOrEmpty(urlData)) { try { //wtf is going on here? clientId = Convert.ToInt32(urlData.Substring(0, 4)); int month = (Convert.ToInt32(urlData.Substring(8)) - (clientId % 10)) / 3; int year = (Convert.ToInt32(urlData.Substring(4, 4)) / 2) - clientId; SelectedPeriod = new DateTime(year, month, 1); period = SelectedPeriod; } catch { Session.Abandon(); Response.Redirect(ServiceProvider.Current.LoginUrl() + "?Action=Exit"); } } }