public override WhereClause AddGlobalWhereClause() { CompoundFilter filter = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause wc = new WhereClause(); String formula; if (BaseFormulaEvaluator.ShouldApplyGlobalWhereClause("1")) { formula = EvaluateFormula("1"); filter.AddFilter(new BaseClasses.Data.ColumnValueFilter(RegistrationsTable.RecordDeleted, formula, BaseClasses.Data.BaseFilter.ComparisonOperator.Not_Equals, false)); wc.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator); } if (BaseFormulaEvaluator.ShouldApplyGlobalWhereClause("Session(\"ActiveEventId\")")) { formula = EvaluateFormula("Session(\"ActiveEventId\")"); filter.AddFilter(new BaseClasses.Data.ColumnValueFilter(RegistrationsTable.EventId, formula, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); wc.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator); } return(wc); }
public override WhereClause AddGlobalWhereClause() { CompoundFilter filter = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause wc = new WhereClause(); String formula; if (BaseFormulaEvaluator.ShouldApplyGlobalWhereClause("1")) { formula = EvaluateFormula("1"); filter.AddFilter(new BaseClasses.Data.ColumnValueFilter(PhotoClubContactLinksTable.RecordDeleted, formula, BaseClasses.Data.BaseFilter.ComparisonOperator.Not_Equals, false)); wc.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator); } return(wc); }
public override WhereClause AddGlobalWhereClause() { CompoundFilter filter = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause wc = new WhereClause(); String formula; if (BaseFormulaEvaluator.ShouldApplyGlobalWhereClause("\"registration\"")) { formula = EvaluateFormula("\"registration\""); filter.AddFilter(new BaseClasses.Data.ColumnValueFilter(UsersTable.UserName0, formula, BaseClasses.Data.BaseFilter.ComparisonOperator.Not_Equals, false)); wc.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator); } return(wc); }
public static bool UserInTheseRoles(string[] rollList, string[] roles) { // Create a where clause for the Static clause defined at design time. CompoundFilter filter = new CompoundFilter(CompoundFilter.CompoundingOperators.Or_Operator, null); WhereClause whereClause = new WhereClause(); // Find RoleId(s) for defined roles foreach (string r in rollList) { filter.AddFilter(new BaseClasses.Data.ColumnValueFilter(BaseClasses.Data.BaseTable.CreateInstance(@"NOIC.Business.Roles1Table, App_Code").TableDefinition.ColumnList.GetByUniqueName(@"Roles_.RoleName"), r, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); } whereClause.AddFilter(filter, CompoundFilter.CompoundingOperators.And_Operator); OLR.Business.Roles1Record[] roleDetails = OLR.Business.Roles1Table.GetRecords(whereClause, null, 0, 0); // Now test to see if current logging in user is assigned one of these roles. string[] matchedRoles = { }; //string roles = ""; foreach (var r in roleDetails) { matchedRoles = Array.FindAll(roles, s => s.Equals(r.RoleID.ToString())); } return(matchedRoles.Length > 0); }
public virtual void SetFieldTripId() { string selectedValue = null; // figure out the selectedValue // Set the FieldTripId QuickSelector on the webpage with value from the // DatabaseOLR_db%dbo.FieldTripOptions database record. // this.DataSource is the DatabaseOLR_db%dbo.FieldTripOptions record retrieved from the database. // this.FieldTripId is the ASP:QuickSelector on the webpage. // You can modify this method directly, or replace it with a call to // base.SetFieldTripId(); // and add your own custom code before or after the call to the base function. if (this.DataSource != null && this.DataSource.FieldTripIdSpecified) { // If the FieldTripId is non-NULL, then format the value. // The Format method will return the Display Foreign Key As (DFKA) value selectedValue = this.DataSource.FieldTripId.ToString(); } else { // FieldTripId is NULL in the database, so use the Default Value. // Default Value could also be NULL. if (this.DataSource != null && this.DataSource.IsCreated) { selectedValue = null; } else { selectedValue = FieldTripOptionsTable.FieldTripId.DefaultValue; } } // Add the Please Select item. if (selectedValue == null || selectedValue == "") { MiscUtils.ResetSelectedItem(this.FieldTripId, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "OLR"), "--PLEASE_SELECT--")); } // Populate the item(s) to the control this.FieldTripId.SetFieldMaxLength(50); System.Collections.Generic.IDictionary <string, object> variables = new System.Collections.Generic.Dictionary <string, object>(); FormulaEvaluator evaluator = new FormulaEvaluator(); if (selectedValue != null && selectedValue.Trim() != "" && !MiscUtils.SetSelectedValue(this.FieldTripId, selectedValue) && !MiscUtils.SetSelectedDisplayText(this.FieldTripId, selectedValue)) { // construct a whereclause to query a record with DatabaseOLR_db%dbo.FieldTrips.FieldTripId = selectedValue CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause whereClause2 = new WhereClause(); filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(FieldTripsTable.FieldTripId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator); // Execute the query try { FieldTripsRecord[] rc = FieldTripsTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1); System.Collections.Generic.IDictionary <string, object> vars = new System.Collections.Generic.Dictionary <string, object> (); // if find a record, add it to the dropdown and set it as selected item if (rc != null && rc.Length == 1) { FieldTripsRecord itemValue = rc[0]; string cvalue = null; string fvalue = null; if (itemValue.FieldTripIdSpecified) { cvalue = itemValue.FieldTripId.ToString(); } Boolean _isExpandableNonCompositeForeignKey = FieldTripOptionsTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(FieldTripOptionsTable.FieldTripId); if (_isExpandableNonCompositeForeignKey && FieldTripOptionsTable.FieldTripId.IsApplyDisplayAs) { fvalue = FieldTripOptionsTable.GetDFKA(itemValue, FieldTripOptionsTable.FieldTripId); } if ((!_isExpandableNonCompositeForeignKey) || (String.IsNullOrEmpty(fvalue))) { fvalue = itemValue.Format(FieldTripsTable.Description); } if (fvalue == null || fvalue.Trim() == "") { fvalue = cvalue; } MiscUtils.ResetSelectedItem(this.FieldTripId, new ListItem(fvalue, cvalue)); } } catch { } } string url = this.ModifyRedirectUrl("../FieldTrips/FieldTrips-QuickSelector.aspx", "", true); url = this.Page.ModifyRedirectUrl(url, "", true); url += "?Target=" + this.FieldTripId.ClientID + "&DFKA=" + (this.Page as BaseApplicationPage).Encrypt("Description") + "&IndexField=" + (this.Page as BaseApplicationPage).Encrypt("FieldTripId") + "&EmptyValue=" + (this.Page as BaseApplicationPage).Encrypt("--PLEASE_SELECT--") + "&EmptyDisplayText=" + (this.Page as BaseApplicationPage).Encrypt(this.Page.GetResourceValue("Txt:PleaseSelect")) + "&Mode=" + (this.Page as BaseApplicationPage).Encrypt("FieldValueSingleSelection") + "&RedirectStyle=" + (this.Page as BaseApplicationPage).Encrypt("Popup"); this.FieldTripId.Attributes["onClick"] = "initializePopupPage(this, '" + url + "', " + Convert.ToString(FieldTripId.AutoPostBack).ToLower() + ", event); return false;"; }
protected virtual void UOMID_SelectedIndexChanged(object sender, EventArgs args) { // If a large list selector or a Quick Add link is used, the dropdown list // will contain an item that was not in the original (smaller) list. During postbacks, // this new item will not be in the list - since the list is based on the original values // read from the database. This function adds the value back if necessary. // In addition, This dropdown can be used on make/model/year style dropdowns. Make filters the result of Model. // Mode filters the result of Year. When users change the value of Make, Model and Year are repopulated. // When this function is fire for Make or Model, we don't want the following code executed. // Therefore, we check this situation using Items.Count > 1 // Since both of these feature use javascript to fire this event, this can be skip if the event is fired by server side, // so we check if it is not postback if (!this.Page.IsPostBack && this.UOMID.Items.Count > 1) { string selectedValue = MiscUtils.GetValueSelectedPageRequest(this.UOMID); if (selectedValue != null && selectedValue.Trim() != "" && !MiscUtils.SetSelectedValue(this.UOMID, selectedValue) && !MiscUtils.SetSelectedDisplayText(this.UOMID, selectedValue)) { // construct a whereclause to query a record with UOM.UOMID = selectedValue CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause whereClause2 = new WhereClause(); filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(UOMTable.UOMID, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator); // Execute the query try { UOMRecord[] rc = UOMTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1); System.Collections.Generic.IDictionary<string, object> vars = new System.Collections.Generic.Dictionary<string, object> (); // if find a record, add it to the dropdown and set it as selected item if (rc != null && rc.Length == 1) { string fvalue = ScopeTable.UOMID.Format(selectedValue); ListItem item = new ListItem(fvalue, selectedValue); item.Selected = true; this.UOMID.Items.Add(item); } } catch { } } } }
// Fill the UOMID list. protected virtual void PopulateUOMIDDropDownList(string selectedValue, int maxItems) { this.UOMID.Items.Clear(); // 1. Setup the static list items // Add the Please Select item. this.UOMID.Items.Insert(0, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "FPCEstimate"), "--PLEASE_SELECT--")); // 2. Set up the WHERE and the ORDER BY clause by calling the CreateWhereClause_UOMIDDropDownList function. // It is better to customize the where clause there. WhereClause wc = CreateWhereClause_UOMIDDropDownList(); // Create the ORDER BY clause to sort based on the displayed value. OrderBy orderBy = new OrderBy(false, false); orderBy.Add(UOMTable.UOMName, OrderByItem.OrderDir.Asc); System.Collections.Generic.IDictionary<string, object> variables = new System.Collections.Generic.Dictionary<string, object> (); // 3. Read a total of maxItems from the database and insert them into the UOMIDDropDownList. UOMRecord[] itemValues = null; if (wc.RunQuery) { int counter = 0; int pageNum = 0; FormulaEvaluator evaluator = new FormulaEvaluator(); do { itemValues = UOMTable.GetRecords(wc, orderBy, pageNum, maxItems); foreach (UOMRecord itemValue in itemValues) { // Create the item and add to the list. string cvalue = null; string fvalue = null; if (itemValue.UOMIDSpecified) { cvalue = itemValue.UOMID.ToString().ToString(); if (counter < maxItems && this.UOMID.Items.FindByValue(cvalue) == null) { Boolean _isExpandableNonCompositeForeignKey = ScopeTable.Instance.TableDefinition.IsExpandableNonCompositeForeignKey(ScopeTable.UOMID); if(_isExpandableNonCompositeForeignKey && ScopeTable.UOMID.IsApplyDisplayAs) fvalue = ScopeTable.GetDFKA(itemValue, ScopeTable.UOMID); if ((!_isExpandableNonCompositeForeignKey) || (String.IsNullOrEmpty(fvalue))) fvalue = itemValue.Format(UOMTable.UOMName); if (fvalue == null || fvalue.Trim() == "") fvalue = cvalue; ListItem newItem = new ListItem(fvalue, cvalue); this.UOMID.Items.Add(newItem); counter += 1; } } } pageNum++; } while (itemValues.Length == maxItems && counter < maxItems); } // 4. Set the selected value (insert if not already present). if (selectedValue != null && selectedValue.Trim() != "" && !MiscUtils.SetSelectedValue(this.UOMID, selectedValue) && !MiscUtils.SetSelectedDisplayText(this.UOMID, selectedValue)) { // construct a whereclause to query a record with UOM.UOMID = selectedValue CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause whereClause2 = new WhereClause(); filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(UOMTable.UOMID, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator); // Execute the query try { UOMRecord[] rc = UOMTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1); System.Collections.Generic.IDictionary<string, object> vars = new System.Collections.Generic.Dictionary<string, object> (); // if find a record, add it to the dropdown and set it as selected item if (rc != null && rc.Length == 1) { string fvalue = ScopeTable.UOMID.Format(selectedValue); ListItem item = new ListItem(fvalue, selectedValue); item.Selected = true; this.UOMID.Items.Add(item); } } catch { } } }
public virtual void SetContactId() { string selectedValue = null; // figure out the selectedValue // Set the ContactId QuickSelector on the webpage with value from the // DatabaseOLR_db%dbo.HonourContactLinks database record. // this.DataSource is the DatabaseOLR_db%dbo.HonourContactLinks record retrieved from the database. // this.ContactId is the ASP:QuickSelector on the webpage. // You can modify this method directly, or replace it with a call to // base.SetContactId(); // and add your own custom code before or after the call to the base function. // Default Value could also be NULL. if (this.DataSource != null && this.DataSource.IsCreated) { selectedValue = this.DataSource.ContactId.ToString(); } else { selectedValue = EvaluateFormula("URL(\"ContactId\")"); } // Add the Please Select item. if (selectedValue == null || selectedValue == "") { MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "OLR"), "--PLEASE_SELECT--")); } // Populate the item(s) to the control this.ContactId.SetFieldMaxLength(50); System.Collections.Generic.IDictionary <string, object> variables = new System.Collections.Generic.Dictionary <string, object>(); FormulaEvaluator evaluator = new FormulaEvaluator(); if (selectedValue != null && selectedValue.Trim() != "" && !MiscUtils.SetSelectedValue(this.ContactId, selectedValue) && !MiscUtils.SetSelectedDisplayText(this.ContactId, selectedValue)) { // construct a whereclause to query a record with DatabaseOLR_db%dbo.Contacts.ContactId = selectedValue CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause whereClause2 = new WhereClause(); filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(ContactsTable.ContactId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator); // Execute the query try { ContactsRecord[] rc = ContactsTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1); System.Collections.Generic.IDictionary <string, object> vars = new System.Collections.Generic.Dictionary <string, object> (); // if find a record, add it to the dropdown and set it as selected item if (rc != null && rc.Length == 1) { ContactsRecord itemValue = rc[0]; string cvalue = null; string fvalue = null; if (itemValue.ContactIdSpecified) { cvalue = itemValue.ContactId.ToString(); } FormulaEvaluator evaluator2 = new FormulaEvaluator(); System.Collections.Generic.IDictionary <string, object> variables2 = new System.Collections.Generic.Dictionary <string, object>(); variables2.Add(itemValue.TableAccess.TableDefinition.TableCodeName, itemValue); fvalue = EvaluateFormula("=ContactId", itemValue, variables2, evaluator2); if (fvalue == null || fvalue.Trim() == "") { fvalue = cvalue; } MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(fvalue, cvalue)); } } catch { } } string url = this.ModifyRedirectUrl("../Contacts/Contacts-QuickSelector.aspx", "", true); url = this.Page.ModifyRedirectUrl(url, "", true); url += "?Target=" + this.ContactId.ClientID + "&Formula=" + (this.Page as BaseApplicationPage).Encrypt("=ContactId") + "&IndexField=" + (this.Page as BaseApplicationPage).Encrypt("ContactId") + "&EmptyValue=" + (this.Page as BaseApplicationPage).Encrypt("--PLEASE_SELECT--") + "&EmptyDisplayText=" + (this.Page as BaseApplicationPage).Encrypt(this.Page.GetResourceValue("Txt:PleaseSelect")) + "&Mode=" + (this.Page as BaseApplicationPage).Encrypt("FieldValueSingleSelection") + "&RedirectStyle=" + (this.Page as BaseApplicationPage).Encrypt("Popup"); this.ContactId.Attributes["onClick"] = "initializePopupPage(this, '" + url + "', " + Convert.ToString(ContactId.AutoPostBack).ToLower() + ", event); return false;"; }