Example #1
0
        // Add the Column Data.
        public Insert PutColumn(ColumnData columnData)
        {
            try
            {
                // Here we will Add the column data into the Column SQL & Binders.
                if (bindObjs.ContainsKey(columnData.GetColumn()))
                {
                    // This Column is Already Added.
                    return(this);
                }
                else
                {
                    // Only let to proceed if the Column does'nt have the special rows.
                    bool doProceed = true;
                    if (cdb.IsSystemUser)
                    {
                        // The user is the system
                        doProceed = true;
                    }
                    else if (columnData.GetColumn().ElementAt(columnData.GetColumn().Length - 1) == '_')
                    {
                        // This column is not a valid column and must be left only for the system to edit.
                        doProceed = false;
                        AddStatus("User cannot Add " + columnData.GetColumn() + " System Column");
                    }

                    // Proceed if the user is allowed to.
                    if (doProceed)
                    {
                        // This Columns is valid.
                        if (columnDataBuilder.Length > 0)
                        {
                            columnDataBuilder.Append(", ");
                            columnPlaceHolderBuilder.Append(", ");
                        }

                        // Lets check and add the random.
                        if (columnData.Get().ToString().ToUpper() == RANDOM)
                        {
                            // The user wants to add a column to have random value.
                            columnDataBuilder.Append(columnData.GetColumn());
                            columnPlaceHolderBuilder.Append(" (ABS(RANDOM())) ");
                        }
                        else
                        {
                            // The user wants a normal column.
                            columnDataBuilder.Append(columnData.GetColumn());
                            columnPlaceHolderBuilder.Append("@")
                            .Append(columnData.GetColumn());
                            // Put the Bind object.
                            bindObjs.Add(columnData.GetColumn(), columnData.Get());
                        }
                    }

                    return(this);
                }
            }
            catch (Exception e)
            {
                // There was an Error.
                AddStatus("Put Column Error : " + e.Message + " : " + e.StackTrace);
                return(this);
            }
        }