示例#1
0
 /// <summary>
 /// Load the observer controls for the codes field
 /// </summary>
 public void LoadDDLCodeObservers()
 {
     if (this.observerControls == null || this.observerControls.Count == 0)
     {
         foreach (KeyValuePair <string, int> pair in pairAssociated)
         {
             //get field and its control
             int            fieldId    = pair.Value;
             List <Control> assocCtrls = new List <Control>();
             foreach (Epi.Fields.Field f in view.Fields)
             {
                 if (f.Id == fieldId)
                 {
                     Epi.Fields.Field field = f;
                     assocCtrls = this.ControlFactory.GetAssociatedControls(field);
                     break;
                 }
             }
             if (assocCtrls.Count > 1)
             {
                 foreach (Control c in assocCtrls)
                 {
                     if (c is TextBox)
                     {
                         this.observerControls.Add(pair.Key, c);
                     }
                 }
             }
         }
     }
     if (sourceTableName.Length != 0 && codeTable == null)
     {
         codeTable = view.GetProject().CodeData.GetCodeTableData(sourceTableName);
         DataColumn[] pk = new DataColumn[] { codeTable.Columns[fieldName] };
         codeTable.PrimaryKey = pk;
     }
 }
示例#2
0
 public void SaveToCollection(Epi.Fields.Field field)
 {
     throw new NotImplementedException();
 }
示例#3
0
 public void RemoveFromCollection(Epi.Fields.Field field)
 {
     throw new NotImplementedException();
 }
示例#4
0
        /// <summary>
        /// Generates a FilterCondition object using primitive type inputs
        /// </summary>
        /// <param name="columnName">The name of the column on which to filter</param>
        /// <param name="rawColumnName">The name of the column on which to filter, without brackets</param>
        /// <param name="columnType">The data type of the column on which to filter</param>
        /// <param name="friendlyOperand">The friendly operand</param>
        /// <param name="friendlyValue">The friendly value</param>
        /// <returns>FilterCondition</returns>
        public FilterCondition GenerateFilterCondition(string columnName, string rawColumnName, string columnType, string friendlyOperand, string friendlyValue)
        {
            #region Input Validation
            if (string.IsNullOrEmpty(columnName))
            {
                throw new ApplicationException("Column name cannot be empty.");
            }
            else if (string.IsNullOrEmpty(friendlyOperand))
            {
                throw new ApplicationException("Friendly operand cannot be empty.");
            }
            else if (string.IsNullOrEmpty(columnType))
            {
                throw new ApplicationException("Column type cannot be empty.");
            }
            else if (!operandTypes.ContainsKey(friendlyOperand))
            {
                throw new ApplicationException("Operand not found in dictionary.");
            }
            #endregion // Input Validation

            Configuration config = dashboardHelper.Config;

            Epi.Fields.Field field = null;

            foreach (DataRow fieldRow in dashboardHelper.FieldTable.Rows)
            {
                if (fieldRow["columnname"].Equals(rawColumnName))
                {
                    if (fieldRow["epifieldtype"] is Epi.Fields.Field)
                    {
                        field = fieldRow["epifieldtype"] as Epi.Fields.Field;
                    }
                    break;
                }
            }

            string operand           = string.Empty;
            string value             = string.Empty;
            string friendlyCondition = string.Empty;

            operand = operandTypes[friendlyOperand];

            switch (columnType)
            {
            case "System.DateTime":
                value = "#" + friendlyValue.Trim() + "#";
                break;

            case "System.String":

                if (operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_IS_ANY_OF]) ||
                    operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_IS_NOT_ANY_OF]))
                {
                    string[]    values = friendlyValue.Split(',');
                    WordBuilder wb     = new WordBuilder(",");

                    foreach (string str in values)
                    {
                        wb.Add("'" + str.Trim().Replace("'", "''") + "'");
                    }

                    value = "(" + wb.ToString() + ")";
                }
                else
                {
                    value = "'" + friendlyValue.Trim().Replace("'", "''") + "'";
                    if (value.Equals("''") && operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_MISSING]))
                    {
                        operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO];
                    }
                    else if (value.Equals("''") && operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING]))
                    {
                        operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_EQUAL_TO];
                    }
                }
                break;

            case "System.Boolean":
                if (friendlyValue.Equals(config.Settings.RepresentationOfYes))
                {
                    value = "1";
                }
                else
                {
                    value = "0";
                }
                break;

            case "System.Int16":
            case "System.Byte":
                if (field != null && field is Epi.Fields.YesNoField)
                {
                    if (friendlyValue.Equals(config.Settings.RepresentationOfYes))
                    {
                        value = "1";
                    }
                    else if (friendlyValue.Equals(config.Settings.RepresentationOfNo))
                    {
                        value = "0";
                    }
                    else if (friendlyValue.Equals(config.Settings.RepresentationOfMissing))
                    {
                        value = string.Empty;
                    }
                }
                else
                {
                    value = friendlyValue.Trim();
                }
                break;

            default:
                value = friendlyValue.Trim();
                break;
            }

            if (friendlyValue.Equals(config.Settings.RepresentationOfMissing))
            {
                value         = string.Empty;
                friendlyValue = string.Empty;
                if (friendlyOperand.Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING) || friendlyOperand.Equals(SharedStrings.FRIENDLY_OPERATOR_NOT_EQUAL_TO))
                {
                    operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING]; // "is not null";
                }
                else if (friendlyOperand.Equals(SharedStrings.FRIENDLY_OPERATOR_MISSING))
                {
                    operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_MISSING]; // "is null";
                    value   = string.Empty;
                }
                else
                {
                    operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_MISSING]; // "is null";
                }
            }

            if (operand.Equals("like"))
            {
                value = value.Trim().Replace('*', '%');
            }

            if (operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING]) || operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_MISSING]))
            {
                value = string.Empty;
            }

            if (columnType.Equals("System.DateTime") && !string.IsNullOrEmpty(value))
            {
                DateTime dt = DateTime.Parse(friendlyValue, System.Globalization.CultureInfo.InvariantCulture);
                friendlyValue = dt.ToString("d", System.Globalization.CultureInfo.CurrentCulture);
            }

            friendlyCondition = string.Format(SharedStrings.FRIENDLY_CONDITION_DATA_FILTER, columnName, friendlyOperand, friendlyValue);
            FilterCondition newCondition = new FilterCondition(friendlyCondition, columnName, rawColumnName, columnType, operand, friendlyOperand, value, friendlyValue);

            return(newCondition);
        }
示例#5
0
        /// <summary>
        /// Generates a FilterCondition object using primitive type inputs
        /// </summary>
        /// <param name="columnName">The name of the column on which to filter</param>
        /// <param name="rawColumnName">The name of the column on which to filter, without brackets</param>
        /// <param name="columnType">The data type of the column on which to filter</param>
        /// <param name="friendlyOperand">The friendly operand</param>
        /// <param name="friendlyValue">The friendly value</param>
        /// <returns>FilterCondition</returns>
        public FilterCondition GenerateFilterCondition(string columnName, string rawColumnName, string columnType, string friendlyOperand, string friendlyValue)
        {
            #region Input Validation
            if (string.IsNullOrEmpty(columnName))
            {
                throw new ApplicationException("Column name cannot be empty.");
            }
            else if (string.IsNullOrEmpty(friendlyOperand))
            {
                throw new ApplicationException("Friendly operand cannot be empty.");
            }
            else if (string.IsNullOrEmpty(columnType))
            {
                throw new ApplicationException("Column type cannot be empty.");
            }
            else if (!operandTypes.ContainsKey(friendlyOperand))
            {
                throw new ApplicationException("Operand not found in dictionary.");
            }
            #endregion // Input Validation

            Configuration config = dashboardHelper.Config;

            Epi.Fields.Field field = null;

            foreach (DataRow fieldRow in dashboardHelper.FieldTable.Rows)
            {
                if (fieldRow["columnname"].Equals(rawColumnName))
                {
                    if (fieldRow["epifieldtype"] is Epi.Fields.Field)
                    {
                        field = fieldRow["epifieldtype"] as Epi.Fields.Field;
                    }
                    break;
                }
            }

            string operand           = string.Empty;
            string value             = string.Empty;
            string friendlyCondition = string.Empty;

            operand = operandTypes[friendlyOperand];

            switch (columnType)
            {
            case "System.DateTimeOffset":
            case "System.DateTime":
                if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfMissing.ToUpper())    //"MISSING")
                {
                    value = string.Empty;
                }
                else
                {
                    value = "#" + friendlyValue.Trim() + "#";
                }

                break;

            case "System.String":
                if (friendlyValue.Trim().Length > 0)
                {
                    value = "'" + friendlyValue.Trim().Replace("'", "''") + "'";
                }

                break;

            case "System.Boolean":
                //  if (friendlyValue.Equals(config.Settings.RepresentationOfYes))
                if (friendlyValue == null)
                {
                    value = string.Empty;
                }
                else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfYes.ToUpper())    //"YES")
                {
                    value = "1";
                }
                else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfNo.ToUpper())    //"NO")
                {
                    value = "0";
                }
                else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfMissing.ToUpper())    //"MISSING")
                {
                    value = "missing";
                }
                else
                {
                    value = string.Empty;
                }
                break;

            case "System.Int16":
            case "System.Byte":
                if (field != null && field is Epi.Fields.YesNoField)
                {
                    //  if (friendlyValue.Equals(config.Settings.RepresentationOfYes))
                    if (friendlyValue == null)
                    {
                        value = string.Empty;
                    }

                    else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfYes.ToUpper())    //"YES")
                    {
                        value = "1";
                    }
                    else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfNo.ToUpper())    //"NO")
                    {
                        value = "0";
                    }
                    else if (friendlyValue.ToUpper() == Ewav.Web.Config.ConfigDataSet.RepresentationOfMissing.ToUpper())    //"MISSING")
                    {
                        value = "missing";
                    }
                    else
                    {
                        value = string.Empty;
                    }
                }
                else
                {
                    value = friendlyValue.Trim();
                }
                break;

            default:
                value = friendlyValue.Trim();
                break;
            }

            //if (friendlyValue.Equals(config.Settings.RepresentationOfMissing))
            //{
            //    if (friendlyOperand.Equals(SharedStrings.FRIENDLY_OPERATOR_EQUAL_TO))
            //    {
            //        operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_MISSING]; // "is null";
            //        value = string.Empty;
            //    }
            //    else
            //    {
            //        operand = operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING]; // "is not null";
            //        value = string.Empty;
            //    }
            //}

            //if (operand.Equals("like"))
            //{
            //    value = value.Trim().Replace('*', '%');
            //}

            //if (operand.Equals(operandTypes[SharedStrings.FRIENDLY_OPERATOR_NOT_MISSING]))
            //{
            //    value = string.Empty;
            //}

            if ((columnType.Equals("System.DateTime") || columnType.Equals("System.DateTimeOffset")) && !string.IsNullOrEmpty(value))
            {
                DateTime dt = DateTime.Parse(friendlyValue, System.Globalization.CultureInfo.InvariantCulture);
                friendlyValue = dt.ToString("d", System.Globalization.CultureInfo.CurrentCulture);
            }

            friendlyCondition = string.Format(SharedStrings.FRIENDLY_CONDITION_DATA_FILTER, columnName, friendlyOperand, friendlyValue);
            FilterCondition newCondition = new FilterCondition(friendlyCondition, columnName, rawColumnName, columnType, operand, friendlyOperand, value, friendlyValue);

            return(newCondition);
        }
 public GoToFieldEventArgs(Epi.Fields.Field pField)
 {
     this.mField = pField;
 }
        private void AssignProjectDataFunction()
        {
            object result = this.value.Execute();


            if (Util.IsEmpty(result))
            {
                this.Context.CurrentDataRow[this.QualifiedId] = DBNull.Value;
            }
            else
            {
                if (this.View.Fields.Contains(this.QualifiedId))
                {
                    Epi.Fields.Field F = this.View.Fields[this.QualifiedId];
                    switch (F.FieldType)
                    {
                    case MetaFieldType.YesNo:
                        int temp_int = 0;
                        if (int.TryParse(result.ToString(), out temp_int))
                        {
                            if (temp_int == 0 || temp_int == 1)
                            {
                                this.Context.CurrentDataRow[this.QualifiedId] = result;
                            }
                            else
                            {
                                throw new System.Exception(string.Format("You have attempted to assign an incompatible value ({0}) to {1}", result, this.QualifiedId));
                            }
                        }
                        else
                        {
                            throw new System.Exception(string.Format("You have attempted to assign an incompatible value ({0}) to {1}", result, this.QualifiedId));
                        }
                        break;

                    default:
                        try
                        {
                            this.Context.CurrentDataRow[this.QualifiedId] = result;
                        }
                        catch (System.Exception ex)
                        {
                            if (ex != null)
                            {
                                throw new System.Exception(string.Format("You have attempted to assign an incompatible value ({0}) to {1}", result, this.QualifiedId));
                            }
                        }
                        break;
                    }
                }
                else
                {
                    try
                    {
                        this.Context.CurrentDataRow[this.QualifiedId] = result;
                    }
                    catch (System.Exception ex)
                    {
                        if (ex != null)
                        {
                            throw new System.Exception(string.Format("You have attempted to assign an incompatible value ({0}) to {1}", result, this.QualifiedId));
                        }
                    }
                }
            }

            this.ReturnResult = result;
        }