static void Main()
    {
        Console.WriteLine("Welcome to Furniture Shop");
        Chair chair1 = new Chair();
        Chair chair2 = new Chair();
        Bed   bed1   = new Bed();

        Console.WriteLine("{0}\tprice{1}\tid={2}", chair2, chair2.price, chair2.GetHashCode());
        Console.WriteLine("{0}\tprice{1}\tid={2}", chair1, chair1.price, chair1.GetHashCode());
        Console.WriteLine("{0}\tprice{1}\tid={2}", bed1, bed1.price, bed1.GetHashCode());

        LinkedList list = new LinkedList();
        Set        set  = new Set();

        list.Add(20);
        list.Add(30);
        set.Add(20);
        set.Add(30);

        DTable table1 = new DTable(); //which table?

        table1.Add(2, 3, 4);

        Table table2 = new Table();

        Console.WriteLine(table2.price);

        Search search = new Search();

        Console.WriteLine(search);
    }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Grid"/> class.
 /// </summary>
 public Grid()
 {
     m_DebugString    = new StringBuilder(string.Empty);
     m_SystemMessages = new SystemMessageCollection(this, SystemMessageStyle.WebGrid);
     MasterTable      = new Table(this);
     m_DesignRender   = new DesignRender(this);
     m_GridTrace      = new GridTrace(this);
     m_PagerSettings  = new Pager(this);
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebGrid.Text">Text</see> class.
 /// </summary>
 /// <param name="columnName">The column name.</param>
 /// <param name="table">The table object.</param>
 public Text(string columnName, Data.Table table)
     : base(columnName, table)
 {
     Grid         = table.m_Grid;
     m_Table      = table;
     ColumnId     = columnName;
     Searchable   = true;
     GridAlign    = HorizontalPosition.Left;
     m_ColumnType = ColumnType.Text;
 }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WebGrid.Decimal">Decimal</see> class.
        /// </summary>
        /// <param name="columnName">The column name.</param>
        /// <param name="table">The column grid.</param>
        public Decimal(string columnName, Table table)
            : base(columnName, table)
        {
            Grid = table.m_Grid;
            m_Table = table;
            ColumnId = columnName;
            m_ColumnType = ColumnType.Decimal;

            Init();
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebGrid.Number">Number</see> class.
 /// </summary>
 /// <param name="columnName">The column name.</param>
 /// <param name="table">The table object.</param>
 public Number(string columnName, Table table)
     : base(columnName, table)
 {
     Grid = table.m_Grid;
     m_Table = table;
     ColumnId = columnName;
     Searchable = false;
     GridAlign = HorizontalPosition.Left;
     EditAlign = HorizontalPosition.Right;
     m_ColumnType = ColumnType.Number;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebGrid.Chart">Chart</see> class.
 /// </summary>
 /// <param name="columnName">The name of the column.</param>
 /// <param name="table">The table object.</param>
 public Chart(string columnName, Table table)
     : base(columnName, table)
 {
     Grid           = table.m_Grid;
     m_Table        = table;
     ColumnId       = columnName;
     Searchable     = false;
     Sortable       = false;
     IsInDataSource = false;
     m_ColumnType   = ColumnType.Chart;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GridColumn"/> class.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="table">The grid.</param>
 public GridColumn(string columnName, Table table)
     : base(columnName, table)
 {
     Grid = table.m_Grid;
     m_Table = table;
     ColumnId = columnName;
     GridAlign = HorizontalPosition.Center;
     EditAlign = HorizontalPosition.Center;
     m_ColumnType = ColumnType.GridColumn;
     m_AllowEdit = false ;
     m_AllowUpdate = false ;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="File">Image</see> class.
 /// </summary>
 /// <param name="columnName">The name of the data-source column.</param>
 /// <param name="table">The table object.</param>
 public File(string columnName, Data.Table table)
     : base(columnName, table)
 {
     Grid         = table.m_Grid;
     m_Table      = table;
     ColumnId     = columnName;
     m_ColumnType = ColumnType.File;
     Sortable     = false;
     Searchable   = false;
     GridVAlign   = VerticalPosition.middle;
     EditVAlign   = VerticalPosition.middle;
     EditAlign    = HorizontalPosition.Center;
     GridAlign    = HorizontalPosition.Center;
 }
Exemple #9
0
        internal override void CopyFrom(Column column)
        {
            base.CopyFrom(column);
            if (column.ColumnType != ColumnType.Foreignkey) return;
            Foreignkey fk = (Foreignkey)column;
            m_ForeignkeyTable = fk.m_ForeignkeyTable;

            m_ValueColumn = fk.m_ValueColumn;

            m_ConnectionString = fk.m_ConnectionString;
            m_ConnectionStringSet = fk.m_ConnectionStringSet;
            m_Foreignkeytype = fk.m_Foreignkeytype;
            m_SelectMenuWidth = fk.m_SelectMenuWidth;
            m_SelectMenuMaxHeight = fk.m_SelectMenuMaxHeight;
            m_FilterExpression = fk.m_FilterExpression;
            m_TreeParentId = fk.m_TreeParentId;
            m_SortExpression = fk.m_SortExpression;
            m_EnableOnlyTreeLeaf = fk.m_EnableOnlyTreeLeaf;
            m_RecordsPerRow = fk.m_RecordsPerRow;
            m_TreeStructureSeperator = fk.m_TreeStructureSeperator;
            m_RememberState = fk.m_RememberState;
            m_identityColumn = fk.m_identityColumn;
        }
Exemple #10
0
        // 2005.01.09 - jorn, optimized
        internal static string BuildDisplayTextSql(string table, string columns, string alias, bool noComma,
            Table foreigntable)
        {
            if (string.IsNullOrEmpty(columns) || columns.IndexOf("+") == -1)
                return string.Format("{0}[{1}]{2}", table, columns, alias);
            table = table.Trim(); //
            string[] columnarray = columns.Split('+');
            StringBuilder columnvalue = new StringBuilder(string.Empty);

            if (noComma == false && table.StartsWith(","))
                table = table.Substring(1);

            for (int i = 0; i < columnarray.Length; i++)
            {
                if (noComma == false)
                    columnvalue.Append(i == 0 ? ", " : " + ");
                else if (i > 0)
                    columnvalue.Append(" + ");

                string column = columnarray[i].Trim();
                if (column.StartsWith("'") && column.EndsWith("'"))
                    columnvalue.Append(column);
                else
                {
                    columnvalue.AppendFormat(
                        foreigntable.Columns[column].ColumnType == ColumnType.Text
                            ? "{0}[{1}]"
                            : "CAST ({0}[{1}] as varchar(12) )", table, column);
                }
            }
            columnvalue.Append(alias);
            return columnvalue.ToString();
        }
Exemple #11
0
        // 2005.01.09 - jorn, optimized
        internal static string BuildDisplayText(int index, string valueColumns, Table table)
        {
            try
            {
                Row row = table.Rows[index];
                // NEW
                if (string.IsNullOrEmpty(valueColumns) ||
                    valueColumns.IndexOf("+", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    if (string.IsNullOrEmpty(valueColumns))
                        throw new GridException(string.Format("ValueColumn property is null or empty in foreignkey for grid '{0}'", table.m_Grid.ID));
                    //Table is not loaded yet.
                    if (table.Columns.GetIndex(valueColumns) == -1)
                        throw new GridException(string.Format("Could not find ValueColumn '{0}' property in Foreignkey for grid '{1}'", valueColumns, table.m_Grid.ID));
                    return row[valueColumns].Value != null ? row[valueColumns].Value.ToString() : null;
                }
                string[] columns = valueColumns.Split('+');
                StringBuilder _columnvalue = new StringBuilder(string.Empty);

                for (int i = 0; i < columns.Length; i++)
                {
                    string column = columns[i].Trim();
                    if (column.StartsWith("'") && column.EndsWith("'"))
                        _columnvalue.Append(column.Replace("'", string.Empty));
                    else
                        _columnvalue.Append(row[column].Value);
                }
                return _columnvalue.ToString();
            }
            catch (Exception e)
            {
                throw new GridException("Error processing foreign key", e);
            }
        }
Exemple #12
0
        // 24.03.2005 - jorn : removed ColumnType to avoid resetting of all data. This  might have affects elsewhere :|
        internal virtual void CopyFrom(Column column)
        {
            if (column == this)
                return;
            m_Grid = column.m_Grid;
            m_TreeIndentText = column.m_TreeIndentText;
            m_TreeLevel = column.m_TreeLevel;
            m_Columnname = column.m_Columnname;
            m_ColumnType = column.m_ColumnType;
            m_Title = column.m_Title;
            m_HeaderText = column.m_HeaderText;
            m_IsInDataSource = column.m_IsInDataSource;
            DisplayIndex = column.DisplayIndex;
            m_MaxSize = column.m_MaxSize;
            m_MinSize = column.m_MinSize;
            m_AllowEmpty = column.m_AllowEmpty;
            m_NullText = column.m_NullText;
             m_DbDefaultValue = column.m_DbDefaultValue;
            m_HyperLinkColumn = column.m_HyperLinkColumn;
            m_Visibility = column.m_Visibility;
            m_Primarykey = column.m_Primarykey;
            m_Identity = column.m_Identity;
            m_AllowUpdate = column.m_AllowUpdate;
            m_Table = column.m_Table;
            m_Required = column.m_Required;
            m_WidthEditableColumn = column.m_WidthEditableColumn;
            m_WidthColumnTitle = column.m_WidthColumnTitle;
            m_WidthColumnHeaderTitle = column.m_WidthColumnHeaderTitle;
            m_HeightEditableColumn = column.m_HeightEditableColumn;
            m_EditAlign = column.m_EditAlign;
            m_EditVAlign = column.m_EditVAlign;
            m_EditAlignTitle = column.m_EditAlignTitle;
            m_GridAlign = column.m_GridAlign;
            m_GridVAlign = column.m_GridVAlign;
            m_SaveValueToViewState = column.m_SaveValueToViewState;
            m_Searchable = column.m_Searchable;
            m_Sortable = column.m_Sortable;
            m_Groupable = column.m_Groupable;
            m_UseAllRows = column.m_UseAllRows;
            m_AllowEdit = column.m_AllowEdit;
            m_HtmlEncode = column.m_HtmlEncode;
            m_DataSourceId = column.m_DataSourceId;
            m_DataSourcePrimaryKeys = column.m_DataSourcePrimaryKeys;
            m_LoadColumnDataSourceData = column.m_LoadColumnDataSourceData;
            m_FilterByColumn = column.m_FilterByColumn;
            m_EnableFilterByColumn = column.m_EnableFilterByColumn;
            m_Cssclass = column.m_Cssclass;
            m_CssclassTitle = column.m_CssclassTitle;

            m_Rowspan = column.m_Rowspan;
            m_NonBreaking = column.m_NonBreaking;
            m_AutoPostback = column.m_AutoPostback;
            m_ForcePostBack = column.m_ForcePostBack;

            m_NewRowInDetail = column.m_NewRowInDetail;
            m_NewRowInGrid = column.m_NewRowInGrid;

            m_PreDetailText = column.m_PreDetailText;
            m_PreGridText = column.m_PreGridText;
            m_PostDetailText = column.m_PostDetailText;
            m_PostGridText = column.m_PostGridText;
            m_HideDetailTitle = column.m_HideDetailTitle;
            TextTruncate = column.TextTruncate;
            UniqueValueRequired = column.UniqueValueRequired;
            m_Attributes = column.m_Attributes;
            m_MaskedInput = column.m_MaskedInput;
            m_DisableMaskedInput = column.m_DisableMaskedInput;

            m_TypeCode = column.m_TypeCode;
            Tag = column.Tag;

            SystemMessageStyle = column.SystemMessageStyle;
            SystemMessage = column.SystemMessage;
            ConfirmMessage = column.ConfirmMessage;
            ValidExpression = column.ValidExpression;
            m_HideIfEmpty = column.m_HideIfEmpty;
            IsCreatedByWebGrid = column.IsCreatedByWebGrid;
            m_AllowEditInGrid = column.m_AllowEditInGrid;
            m_GridModeEditTransparent = column.m_GridModeEditTransparent;
            m_TooltipEditTitle = column.m_TooltipEditTitle;
            m_TooltipGridHeaderTitle = column.m_TooltipGridHeaderTitle;
            m_ToolTipInput = column.m_ToolTipInput;
            m_DefaultDataSourceId = column.m_DefaultDataSourceId;
            m_defaultValue = column.m_defaultValue;
              /*  m_GridViewTemplate = column.m_GridViewTemplate;
            m_GridViewTemplateCache = column.m_GridViewTemplateCache;
            m_DetailViewTemplate = column.m_DetailViewTemplate;
            m_DetailViewTemplateCache = column.m_DetailViewTemplateCache;*/
        }
Exemple #13
0
 internal static Column GetColumnFromType(string columnName, Table table, ColumnType columnType)
 {
     Column column;
     switch (columnType)
     {
         case ColumnType.Text:
             column = new Text(columnName, table);
             break;
         case ColumnType.Number:
             column = new Number(columnName, table);
             break;
         case ColumnType.Decimal:
             column = new Decimal(columnName, table);
             break;
         case ColumnType.Checkbox:
             column = new Checkbox(columnName, table);
             break;
         case ColumnType.DateTime:
             column = new DateTime(columnName, table);
             break;
         case ColumnType.Foreignkey:
             column = new Foreignkey(columnName, table);
             break;
         case ColumnType.ManyToMany:
             column = new ManyToMany(columnName, table);
             break;
         case ColumnType.GridColumn:
             column = new GridColumn(columnName, table);
             break;
         case ColumnType.Chart:
             column = new Chart(columnName, table);
             break;
         case ColumnType.File:
             column = new File(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.Image:
             column = new Image(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.ToolTip:
             column = new ToolTipColumn(columnName, table) { IsInDataSource = false };
             break;
         case ColumnType.SystemColumn:
             column = new SystemColumn(columnName, Enums.SystemColumn.Undefined, table) { IsInDataSource = false };
             break;
         default:
             column = new UnknownColumn(columnName, table);
             break;
     }
     return column;
 }
Exemple #14
0
        internal static void StreamToBrowser(Page page, Table table, string fileName, string content)
        {
            if (content == null || page == null) return;
            page.Response.Clear();
            page.Response.ContentType = "application/vnd.ms-excel";
            page.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", fileName));
            page.Response.Write(content);

            page.Response.End();
        }
Exemple #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Foreignkey">Foreignkey</see> class.
 /// </summary>
 /// <param name="columnName">The column name.</param>
 /// <param name="table">The table object.</param>
 public Foreignkey(string columnName, Table table)
     : base(columnName, table)
 {
     Grid = table.m_Grid;
     m_Table = table;
     Searchable = true;
     ColumnId = columnName;
     m_SaveValueToViewState = true;
     m_ColumnType = ColumnType.Foreignkey;
 }
Exemple #16
0
        internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell)
        {
            string uniqueID = cell.CellClientId;

            if (ChartType == ChartType.HorizontalBar)
            {
                if (m_Image == null) // Draw using table
                {
                    StringBuilder bg = new StringBuilder(string.Empty);
                    if (BackgroundImage != null)
                    {
                        bg.AppendFormat(" background=\"{0}\"", BackgroundImage);
                    }
                    StringBuilder s = new StringBuilder(string.Empty);
                    s.AppendFormat("<table height=\"{0}\">", HeightEditableColumn);
                    if (m_StartImage != null)
                    {
                        s.AppendFormat(
                            "<td><img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/></td>", m_StartImage,
                            HeightEditableColumn, Title);
                    }
                    s.AppendFormat("<td width=\"{0}\" {1}></td>", BarWidth, bg);
                    if (m_EndImage != null)
                    {
                        s.AppendFormat(
                            "<td><img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/></td>", m_EndImage,
                            HeightEditableColumn, Title);
                    }
                    s.Append("</table>");
                    LabelHtml(s.ToString(), writer, cell);
                    return;
                }
                else // Draw using image
                {
                    StringBuilder s = new StringBuilder(string.Empty);
                    if (m_StartImage != null)
                    {
                        s.AppendFormat("<img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/>",
                                       m_StartImage, HeightEditableColumn, Title);
                    }
                    s.AppendFormat("<img alt=\"{3}\" border=\"0\" src=\"{0}\"  height={1} width={2}/>",
                                   m_Image, HeightEditableColumn, BarWidth, Title);
                    if (m_EndImage != null)
                    {
                        s.AppendFormat("<img alt=\"{2}\" border=\"0\" src=\"{0}\"  height={1}/>", m_EndImage,
                                       HeightEditableColumn, Title);
                    }

                    LabelHtml(s.ToString(), writer, cell);
                    return;
                }
            }
            if (ChartType == ChartType.HorizontalBar)
            {
                // 2005.01.09 - jorn, string optimization
                StringBuilder namesBuilder = new StringBuilder();
                string        values       = string.Empty;
                Table         t            = Grid.MasterTable;
                for (int i = 0; i < t.Rows.Count; i++)
                {
                    if (namesBuilder.Length != 0)
                    {
                        namesBuilder.Append(",");
                    }
                    if (values.Length != 0)
                    {
                        values += ",";
                    }
                    namesBuilder.Append(HttpUtility.UrlEncode(t.Rows[i][TitleColumn].Value.ToString(), Encoding.Default));
                    try
                    {
                        values +=
                            HttpUtility.UrlEncode(t.Rows[i][ValueColumn].Value.ToString().Replace(",", "."),
                                                  Encoding.Default);
                    }
                    catch
                    {
                        values += "0";
                    }
                }

                string width = "150";
                if (WidthEditableColumn.IsEmpty == false)
                {
                    width = WidthEditableColumn.Value.ToString();
                }
                string s =
                    string.Format(
                        "<img alt=\"{4}\" border=\"0\" src=\"?wgpiechart={0}&values={1}&names={2}&width={3}\"/>",
                        uniqueID, values, namesBuilder, width, Title);
                LabelHtml(s, writer, cell);
                return;
            }
            else
            {
                ArrayList values = new ArrayList();

                Table t = Grid.MasterTable;
                for (int i = 0; i < t.Rows.Count; i++)
                {
                    double val  = double.Parse(t.Rows[i][ValueColumn].Value.ToString());
                    string name = string.Empty;
                    if (t.Rows[i][TitleColumn].Value != null)
                    {
                        name = t.Rows[i][TitleColumn].Value.ToString();
                    }

                    ChartValue cv = new ChartValue(name, val);
                    values.Add(cv);

                    /*					if(names != string.Empty) names += ",";
                     *                  if(values != string.Empty) values += ",";
                     *                  names += HttpUtility.UrlEncode( t.Rows[i][ TitleColumn ].Value );
                     *                  try
                     *                  {
                     *                      values += HttpUtility.UrlEncode( t.Rows[i][ ValueColumn ].Value.Replace(",",".") );
                     *                  }
                     *                  catch
                     *                  {
                     *                      values += "0";
                     *                  }*/
                }

                int width = (int)WidthEditableColumn.Value;
                if (width < 16)
                {
                    width = 150;
                }
                int height = (int)HeightEditableColumn.Value;
                if (height < 16)
                {
                    height = 200;
                }

                //try
                //{
                Util.Chart c = new Util.Chart(ChartType, width, height);
                if (BackgroundImage != null && Grid.GotHttpContext)
                {
                    if (BackgroundImage.ToUpperInvariant().StartsWith("HTTP://") == false)
                    {
                        BackgroundImage = HttpContext.Current.Server.MapPath(BackgroundImage);
                    }
                    c.ChartBackground = new ChartBackground(BackgroundImage);
                }
                c.ShowPieValues          = false;
                c.ChartHeadline.Headline = Title;
                c.AddDataArray(values);
                c.RenderLabelBoard = TitleBoardOnChart;
                if (Grid.GotHttpContext)
                {
                    HttpContext.Current.Session[string.Format("{0}_{1}_img", Grid.ClientID, uniqueID)] = c.Render();
                }

                string s; //src=\"?wgchart=" + this.Grid.ColumnId + "_" + this.FormElementName + "_img\"
                if (Grid.GotHttpContext &&
                    HttpContext.Current.Request.Browser.Type.ToUpperInvariant().StartsWith("IE"))
                {
                    s =
                        string.Format(
                            "<img height=\"{0}\" width=\"{1}\"  src=\"{2}\" style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='?wgchart={3}_{4}_img', sizingMethod='scale');\" alt=\"{5}\" border=\"0\" />",
                            Unit.Pixel(height), Unit.Pixel(width), Grid.Page.ClientScript.GetWebResourceUrl(Grid.GetType(), "WebGrid.Resources.images.transparent.gif"), Grid.ClientID, uniqueID, Title);
                }
                else
                {
                    s =
                        string.Format("<img alt=\"{2}\" border=\"0\" src=\"?wgchart={0}_{1}_img\"/>",
                                      Grid.ClientID, uniqueID, Title);
                }
                LabelHtml(s, writer, cell);
                return;
            }

            /*
             * else		// impossible!!!
             * {
             *  return null;
             * }*/
        }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Grid"/> class.
 /// </summary>
 public Grid()
 {
     m_DebugString = new StringBuilder(string.Empty);
     m_SystemMessages = new SystemMessageCollection(this, SystemMessageStyle.WebGrid);
     MasterTable = new Table(this);
     m_DesignRender = new DesignRender(this);
     m_GridTrace = new GridTrace(this);
     m_PagerSettings = new Pager(this);
 }
Exemple #18
0
 internal BeforeGetDataEventArgs BeforeGetDataEvent(Table table)
 {
     if (BeforeGetData != null)
     {
         BeforeGetDataEventArgs ea = new BeforeGetDataEventArgs {Table = table};
         BeforeGetData(this, ea);
         return ea;
     }
     return null;
 }
Exemple #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Column">Column</see> class.
 /// </summary>
 /// <param name="columnName">ColumnId of the column.</param>
 /// <param name="table">Table object.</param>
 protected Column(string columnName, Table table)
 {
     Grid = table.m_Grid;
     m_Table = table;
     ColumnId = columnName;
     DisplayIndex = Grid.MasterTable.Columns.Count*10 + 10;
 }
Exemple #20
0
        internal static string ExcelFile(Table table, bool allRows)
        {
            table.GetData(true, allRows);
            StringBuilder returnValue = new StringBuilder();

            RowCollection rows = table.Rows;
            ColumnCollection settings = table.Columns;

            returnValue.Append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd/\">");
            returnValue.Append("<html>\n");
            returnValue.Append("<head>\n");
            returnValue.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
            returnValue.Append("</head>\n");
            returnValue.Append("<body>\n");
            returnValue.Append("<table>\r\n<tr>\r\n");

            int[] sortedID = new int[settings.Count];

            for (int i = 0; i < sortedID.Length; i++)
                sortedID[i] = i;

            for (int i = 0; i < sortedID.Length; i++)
                for (int j = 0; j < sortedID.Length; j++)
                {
                    if (settings[sortedID[i]].DisplayIndex > settings[sortedID[j]].DisplayIndex) continue;
                    int tmp = sortedID[i];
                    sortedID[i] = sortedID[j];
                    sortedID[j] = tmp;
                }

            for (int i = 0; i < sortedID.Length; i++)
            {
                Column column = settings[sortedID[i]];

                if (column.IsVisible == false)
                    continue;
                if (column.ColumnType == ColumnType.File || column.ColumnType == ColumnType.SystemColumn)
                    continue;

                returnValue.AppendFormat("<th {0} style=\" border:thin silver solid\" >{1}</th>\r\n", Alignment(column),
                                         HttpUtility.HtmlEncode(column.Title));
            }

            returnValue.Append("</tr>\r\n");

            for (int i = 0; i < rows.Count; i++)
            {

                returnValue.Append("<tr>\r\n");
                for (int ii = 0; ii < sortedID.Length; ii++)
                {
                    Column column = rows[i].Columns[settings[sortedID[ii]].ColumnId];

                    if (column.IsVisible == false || column.ColumnType == ColumnType.SystemColumn || column.ColumnType == ColumnType.File)
                        continue;
                    if (rows[i][column.ColumnId].Value == null && column.IsInDataSource == false && column.ColumnType == ColumnType.Decimal &&
                        ((Decimal) column).Sum != null)
                        returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                 Alignment(column),
                                                 HttpUtility.HtmlEncode(
                                                     ((Decimal)column).GetSum(rows[i][column.ColumnId]).ToString("N")));
                    else if (rows[i][column.ColumnId].Value == null)
                        returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" ></td>\r\n",
                                                 Alignment(column));
                    else if (column.ColumnType == ColumnType.Decimal && ((Decimal) column).Sum != null)
                        returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                 Alignment(column),
                                                 HttpUtility.HtmlEncode(
                                                     ((Decimal)column).GetSum(rows[i][column.ColumnId]).ToString("N")));
                    else switch (column.ColumnType)
                    {
                        case ColumnType.Number:
                            try
                            {
                                returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                         Alignment(column),
                                                         HttpUtility.HtmlEncode(int.Parse(rows[i][column.ColumnId].Value.ToString()).ToString("N")));
                                break;
                            }
                            catch
                            {
                                returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                         Alignment(column), HttpUtility.HtmlEncode(rows[i][column.ColumnId].Value.ToString()));
                                break;
                            }
                        case ColumnType.DateTime:
                            try
                            {
                                returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                         Alignment(column), HttpUtility.HtmlEncode(rows[i][column.ColumnId].Value.ToString()));
                                break;
                            }
                            catch
                            {
                                returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                         Alignment(column), HttpUtility.HtmlEncode(rows[i][column.ColumnId].Value.ToString()));
                                break;
                            }
                       default:
                            returnValue.AppendFormat("<td {0} style=\" border:thin silver solid\" >{1}</td>\r\n",
                                                     Alignment(column), HttpUtility.HtmlEncode(rows[i][column.ColumnId].Value.ToString()));
                            break;
                    }
                }

                returnValue.Append("</tr>\r\n");
            }
            returnValue.Append("</table>\r\n");
            returnValue.Append("</body>\n");
            returnValue.Append("</html>\n");

            return returnValue.ToString();
        }
Exemple #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WebGrid.Chart">Chart</see> class.
 /// </summary>
 /// <param name="columnName">The name of the column.</param>
 /// <param name="table">The table object.</param>
 public Chart(string columnName, Table table)
     : base(columnName, table)
 {
     Grid = table.m_Grid;
     m_Table = table;
     ColumnId = columnName;
     Searchable = false;
     Sortable = false;
     IsInDataSource = false;
     m_ColumnType = ColumnType.Chart;
 }