示例#1
0
        public FormTableViewer getViewer(GiangManh.MM.Database.Tables table)
        {
            string sql = "SELECT * FROM {0} ";

            switch (table)
            {
            case Database.Tables.Marks:
                sql += "ORDER BY st_id";
                break;

            case Database.Tables.Students:
                sql += "ORDER BY gr_id ASC, no ASC";
                break;
            }
            SqlCeResultSet  r      = db.Select(string.Format(sql, table));
            FormTableViewer viewer = new FormTableViewer();

            viewer._MMHostForm     = this;
            viewer.MdiParent       = this;
            viewer.Text            = string.Format("{0} {1}", viewer.Text, table);
            viewer.grid.DataSource = r;
            FormTableViewerTag tag = new FormTableViewerTag(db, table);

            tag.expand                    = string.Format("{0}", table);
            viewer.Tag                    = tag;
            viewer.grid.DataError        += new DataGridViewDataErrorEventHandler(grid_DataError);
            viewer.grid.CellValueChanged += new DataGridViewCellEventHandler(grid_CellValueChanged);
            string[] caption = db.TableCaptions(table);
            if (caption.Length == viewer.grid.Columns.Count)
            {
                for (int i = 0; i < viewer.grid.Columns.Count; i++)
                {
                    viewer.grid.Columns[i].HeaderText = caption[i];
                }
            }
            return(viewer);
        }
示例#2
0
 public FormTableViewerTag(Database db, Database.Tables table)
 {
     this.db    = db;
     this.Table = table;
 }