示例#1
0
 public static int GetOleDbTypeIndex(OleDbType type)
 {
     if (type == System.Data.OleDb.OleDbType.BigInt ||
         type == System.Data.OleDb.OleDbType.UnsignedBigInt
         )
     {
         return(FLD_Long_integer);
     }
     else if (EPField.IsInteger(type))
     {
         return(FLD_Integer);
     }
     else if (type == System.Data.OleDb.OleDbType.Currency)
     {
         return(FLD_Currency);
     }
     else if (EPField.IsNumber(type))
     {
         return(FLD_Decimal);
     }
     else if (EPField.IsDatetime(type))
     {
         if (type == System.Data.OleDb.OleDbType.DBTimeStamp)
         {
             return(FLD_Date_time);
         }
         else if (type == OleDbType.DBTime)
         {
             return(FLD_Time);
         }
         else
         {
             return(FLD_Date);
         }
     }
     else if (type == System.Data.OleDb.OleDbType.Boolean)
     {
         return(FLD_Bool);
     }
     else if (type == System.Data.OleDb.OleDbType.LongVarChar ||
              type == System.Data.OleDb.OleDbType.LongVarWChar)
     {
         return(FLD_Text);
     }
     else if (type == System.Data.OleDb.OleDbType.Binary ||
              type == System.Data.OleDb.OleDbType.LongVarBinary ||
              type == System.Data.OleDb.OleDbType.VarBinary
              )
     {
         return(FLD_Binary);
     }
     else if (EPField.IsString(type))
     {
         return(FLD_String);
     }
     else
     {
         return(FLD_Unknown);
     }
 }
 public void LoadData(DataGridViewColumnCollection cols)
 {
     _cols = cols;
     _tbl  = new DataTable();
     _tbl.Columns.Add("ColumnName", typeof(string));
     _tbl.Columns[0].ReadOnly = true;
     _tbl.Columns.Add("HeaderText", typeof(string));
     _tbl.Columns.Add("DataType", typeof(string));
     for (int i = 0; i < cols.Count; i++)
     {
         OleDbType t = OleDbType.VarWChar;
         if (cols[i].ValueType != null)
         {
             t = EPField.ToOleDBType(cols[i].ValueType);
         }
         string tx;
         if (t == OleDbType.DBTime)
         {
             tx = "Time";
         }
         else if (EPField.IsDatetime(t))
         {
             tx = "DateTime";
         }
         else if (EPField.IsInteger(t))
         {
             tx = "Integer";
         }
         else if (EPField.IsNumber(t))
         {
             tx = "Decimal";
         }
         else if (EPField.IsBoolean(t))
         {
             tx = "Boolean";
         }
         else
         {
             tx = "Text";
         }
         string s = cols[i].DataPropertyName;
         if (string.IsNullOrEmpty(s))
         {
             s = cols[i].HeaderText;
             if (string.IsNullOrEmpty(s))
             {
                 s = cols[i].Name;
             }
         }
         string sh = cols[i].HeaderText;
         if (string.IsNullOrEmpty(sh))
         {
             sh = cols[i].DataPropertyName;
             if (string.IsNullOrEmpty(sh))
             {
                 sh = cols[i].Name;
             }
         }
         _tbl.Rows.Add(s, sh, tx);
     }
     dataGridView1.AllowUserToAddRows      = false;
     dataGridView1.AllowUserToDeleteRows   = false;
     dataGridView1.AllowUserToOrderColumns = false;
     dataGridView1.AllowUserToResizeRows   = false;
     dataGridView1.Columns.Clear();
     dataGridView1.AutoGenerateColumns     = true;
     dataGridView1.DataSource              = _tbl;
     dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
     dataGridView1.Columns[0].SortMode     = DataGridViewColumnSortMode.NotSortable;
     dataGridView1.Columns[1].SortMode     = DataGridViewColumnSortMode.NotSortable;
     dataGridView1.Columns[2].SortMode     = DataGridViewColumnSortMode.NotSortable;
 }