Exemplo n.º 1
0
        public override string EvaluateExpressions(string url, string arg, bool bEncrypt, bool includeSession)
        {
            FieldTripsRecord rec = null;

            try {
                rec = this.GetRecord();
            }
            catch (Exception) {
                // Do Nothing
            }

            if (rec == null && url.IndexOf("{") >= 0)
            {
                // Localization.

                throw new Exception(Page.GetResourceValue("Err:RecDataSrcNotInitialized", "OLR"));
            }

            if (includeSession)
            {
                return(EvaluateExpressions(url, arg, rec, bEncrypt));
            }
            else
            {
                return(EvaluateExpressions(url, arg, rec, bEncrypt, includeSession));
            }
        }
Exemplo n.º 2
0
        //Audit Trail methods

        //Evaluates Initialize when->Reading record formulas specified at the data access layer
        protected virtual void FieldTripsRecord_ReadRecord(Object sender, System.EventArgs e)
        {
            //Apply Initialize->Reading record formula only if validation is successful.
            FieldTripsRecord FieldTripsRec = (FieldTripsRecord)sender;

            if (FieldTripsRec != null && !FieldTripsRec.IsReadOnly)
            {
            }
        }
Exemplo n.º 3
0
        //Evaluates Initialize when->Updating formulas specified at the data access layer
        protected virtual void FieldTripsRecord_UpdatingRecord(Object sender, System.ComponentModel.CancelEventArgs e)
        {
            //Apply Initialize->Updating formula only if validation is successful.
            FieldTripsRecord FieldTripsRec = (FieldTripsRecord)sender;

            Validate_Updating();
            if (FieldTripsRec != null && !FieldTripsRec.IsReadOnly)
            {
            }
        }
Exemplo n.º 4
0
        public virtual void LoadData()
        {
            // Load the data from the database into the DataSource DatabaseOLR_db%dbo.FieldTrips record.
            // It is better to make changes to functions called by LoadData such as
            // CreateWhereClause, rather than making changes here.


            // The RecordUniqueId is set the first time a record is loaded, and is
            // used during a PostBack to load the record.
            if (this.RecordUniqueId != null && this.RecordUniqueId.Length > 0)
            {
                this.DataSource = FieldTripsTable.GetRecord(this.RecordUniqueId, true);

                return;
            }

            // This is the first time a record is being retrieved from the database.
            // So create a Where Clause based on the staic Where clause specified
            // on the Query wizard and the dynamic part specified by the end user
            // on the search and filter controls (if any).

            WhereClause wc = this.CreateWhereClause();

            // If there is no Where clause, then simply create a new, blank record.

            if (wc == null || !(wc.RunQuery))
            {
                this.DataSource = new FieldTripsRecord();

                return;
            }

            // Retrieve the record from the database.  It is possible
            FieldTripsRecord[] recList = FieldTripsTable.GetRecords(wc, null, 0, 2);
            if (recList.Length == 0)
            {
                // There is no data for this Where clause.
                wc.RunQuery = false;

                return;
            }

            // Set DataSource based on record retrieved from the database.
            this.DataSource = (FieldTripsRecord)FieldTripsRecord.Copy(recList[0], false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This is a shared function that can be used to get a FieldTripsRecord record using a where and order by clause.
        /// </summary>
        public static FieldTripsRecord GetRecord(BaseFilter join, string where, OrderBy orderBy)
        {
            SqlFilter whereFilter = null;

            if (where != null && where.Trim() != "")
            {
                whereFilter = new SqlFilter(where);
            }

            ArrayList recList = FieldTripsTable.Instance.GetRecordList(join, whereFilter, null, orderBy, BaseTable.MIN_PAGE_NUMBER, BaseTable.MIN_BATCH_SIZE);

            FieldTripsRecord rec = null;

            if (recList.Count > 0)
            {
                rec = (FieldTripsRecord)recList[0];
            }

            return(rec);
        }
        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;";
        }