Beispiel #1
0
        public string GetDataForExport(BaseColumn col, BaseRecord rec)
        {
            String val = "";

            if (col.TableDefinition.IsExpandableNonCompositeForeignKey(col))
            {
                //  Foreign Key column, so we will use DFKA and String type.
                val = rec.Format(col);
            }
            else
            {
                switch (col.ColumnType)
                {
                case BaseColumn.ColumnTypes.Binary:
                case BaseColumn.ColumnTypes.Image:
                    break;

                case BaseColumn.ColumnTypes.Currency:
                case BaseColumn.ColumnTypes.Number:
                case BaseColumn.ColumnTypes.Percentage:
                    val = rec.Format(col);
                    break;

                default:
                    val = rec.Format(col);
                    break;
                }
            }
            return(val);
        }
Beispiel #2
0
        /// <summary>
        /// This method takes a record and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(BaseRecord rec, BaseColumn col)
		{
			ForeignKey fkColumn = PhotoClubsTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);
			if (fkColumn == null)
				return null;
			String _DFKA = fkColumn.PrimaryKeyDisplayColumns;
			if (_DFKA.Trim().StartsWith("="))
            {
                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation 
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return rec.Format(c);
                    }
                }
                            
				String tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
				return EvaluateFormula(_DFKA, rec, null, tableName);
			}
			else
				return null;
		}
Beispiel #3
0
        /// <summary>
        /// This method takes a keyValue and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(String keyValue, BaseColumn col, String formatPattern)
        {
            if (keyValue == null)
            {
                return(null);
            }
            ForeignKey fkColumn = AreasTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);

            if (fkColumn == null)
            {
                return(null);
            }
            String _DFKA = fkColumn.PrimaryKeyDisplayColumns;

            if (_DFKA.Trim().StartsWith("="))
            {
                String          tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                PrimaryKeyTable t         = (PrimaryKeyTable)DatabaseObjects.GetTableObject(tableName);
                BaseRecord      rec       = null;

                if (t != null)
                {
                    try
                    {
                        rec = (BaseRecord)t.GetRecordData(keyValue, false);
                    }
                    catch
                    {
                        rec = null;
                    }
                }
                if (rec == null)
                {
                    return("");
                }

                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column        = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return(rec.Format(c));
                    }
                }
                return(EvaluateFormula(_DFKA, rec, null, tableName));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        protected internal object GetValueForExcelExport(ExcelColumn col, BaseRecord rec)
        {
            object  val        = "";
            bool    isNull     = false;
            decimal deciNumber = default(decimal);

            if (col == null)
            {
                return(null);
            }
            //DFKA value is evaluated in the <tablename>ExportExcelButton_Click method in the <tablename>.controls file
            //if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
            //{
            //    //  Foreign Key column, so we will use DFKA and String type.
            //    val = rec.Format(col.DisplayColumn);
            //}
            //else
            //{
            switch (col.DisplayColumn.ColumnType)
            {
            case BaseColumn.ColumnTypes.Number:
            case BaseColumn.ColumnTypes.Percentage:
            case BaseColumn.ColumnTypes.Currency:
                ColumnValue numVal = rec.GetValue(col.DisplayColumn);

                //If the value of the column to be exported is nothing, add an empty cell to the Excel file
                if (numVal.IsNull)
                {
                    isNull = true;
                }
                else
                {
                    deciNumber = numVal.ToDecimal();
                    val        = deciNumber;
                }

                break;

            case BaseColumn.ColumnTypes.Date:
                ColumnValue dateVal = rec.GetValue(col.DisplayColumn);
                if (dateVal.IsNull)
                {
                    isNull = true;
                }
                else
                {
                    // Specify the default Excel format for the date field
                    // val = rec.Format(col.DisplayColumn, "s");
                    // val += ".000";
                    val = rec.GetValue(col.DisplayColumn).Value;
                }

                break;

            case BaseColumn.ColumnTypes.Very_Large_String:
                val = rec.GetValue(col.DisplayColumn).ToString();


                break;

            case BaseColumn.ColumnTypes.Boolean:
                val = rec.Format(col.DisplayColumn);

                break;

            default:

                val = rec.Format(col.DisplayColumn);

                break;
            }
            //}
            if (isNull)
            {
                return(null);
            }
            else
            {
                return(val);
            }
        }
        /// <summary>
        /// This method takes a record and a Column and returns an evaluated value of DFKA formula.
        /// </summary>
        public static string GetDFKA(BaseRecord rec, BaseColumn col)
        {
            ForeignKey fkColumn = UsersTable.Instance.TableDefinition.GetExpandableNonCompositeForeignKey(col);
            if (fkColumn == null)
                return null;
            String _DFKA = fkColumn.PrimaryKeyDisplayColumns;
            if (_DFKA.Trim().StartsWith("="))
            {
                // if the formula is in the format of "= <Primary table>.<Field name>, then pull out the data from the rec object instead of doing formula evaluation
                string tableCodeName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                string column = _DFKA.Trim('=').Trim();
                if (column.StartsWith(tableCodeName + ".", StringComparison.InvariantCultureIgnoreCase))
                {
                    column = column.Substring(tableCodeName.Length + 1);
                }

                foreach (BaseColumn c in fkColumn.PrimaryKeyTableDefinition.Columns)
                {
                    if (column == c.CodeName)
                    {
                        return rec.Format(c);
                    }
                }

                String tableName = fkColumn.PrimaryKeyTableDefinition.TableCodeName;
                return EvaluateFormula(_DFKA, rec, null, tableName);
            }
            else
                return null;
        }
Beispiel #6
0
        protected internal string GetValueForExcelExport(ExcelColumn col, BaseRecord rec)
        {
            String val = "";
            bool isNull = false;
            decimal deciNumber;

            if (col == null)
                return null;
            //DFKA value is evaluated in the <tablename>ExportExcelButton_Click method in the <tablename>.controls file
            //if (col.DisplayColumn.TableDefinition.IsExpandableNonCompositeForeignKey(col.DisplayColumn))
            //{
            //    //  Foreign Key column, so we will use DFKA and String type.
            //    val = rec.Format(col.DisplayColumn);
            //}
            //else
            //{
                switch (col.DisplayColumn.ColumnType)
                {

                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                    case BaseColumn.ColumnTypes.Currency:
                        ColumnValue numVal = rec.GetValue(col.DisplayColumn);
                        //If the value of the column to be exported is nothing, add an empty cell to the Excel file
                        if (numVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {
                            deciNumber = numVal.ToDecimal();
                            val = deciNumber.ToString(System.Globalization.CultureInfo.InvariantCulture);

                            if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Currency)
                            {
                                val = rec.Format(col.DisplayColumn, "c");
                            }
                            else if (col.DisplayColumn.ColumnType == BaseColumn.ColumnTypes.Percentage)
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            } else if (col.DisplayFormat == "Standard")
                            {
                                val = rec.Format(col.DisplayColumn, "F2");
                            }
                        }
                        break;
                    case BaseColumn.ColumnTypes.Date:
                        ColumnValue dateVal = rec.GetValue(col.DisplayColumn);
                        if (dateVal.IsNull)
                        {
                            isNull = true;
                        }
                        else
                        {  // Specify the default Excel format for the date field
                            // val = rec.Format(col.DisplayColumn, "s");
                            // val += ".000";
                            val = rec.Format(col.DisplayColumn, "d");
                        }
                        break;
                    case BaseColumn.ColumnTypes.Very_Large_String:
                        val = rec.GetValue(col.DisplayColumn).ToString();
                        break;

                    case BaseColumn.ColumnTypes.Boolean:
                        val = rec.Format(col.DisplayColumn);
                        break;

                    default:
                        val = rec.Format(col.DisplayColumn);
                        break;
                }
            //}
            if (isNull)
                return null;
            else
                return val;
        }
Beispiel #7
0
        public string GetDataForExport(BaseColumn col, BaseRecord rec)
        {
            String val = "";

            if (col.TableDefinition.IsExpandableNonCompositeForeignKey(col))
            {
                //  Foreign Key column, so we will use DFKA and String type.
                val = rec.Format(col);
            }
            else
            {
                switch (col.ColumnType)
                {
                    case BaseColumn.ColumnTypes.Binary:
                    case BaseColumn.ColumnTypes.Image:
                        break;
                    case BaseColumn.ColumnTypes.Currency:
                    case BaseColumn.ColumnTypes.Number:
                    case BaseColumn.ColumnTypes.Percentage:
                        val = rec.Format(col);
                        break;
                    default:
                        val = rec.Format(col);
                        break;
                }
            }
            return val;
        }