Exemplo n.º 1
0
        public DataTable ToDataTable()
        {
            DataTable dt = new DataTable();

            foreach (NpcDataColumn column in Table.Columns)
            {
                String typeName = column.DataType.ToString();
                if ((typeName.Length > 18) &&
                    (typeName.Substring(0, 18) == "System.Nullable`1["))
                {
                    typeName = typeName.Substring(18, typeName.Length - 18 - 1);
                    dt.Columns.Add((String)column.ExtendedProperties["dbName"], Type.GetType(typeName));
                }
                else
                {
                    dt.Columns.Add((String)column.ExtendedProperties["dbName"], column.DataType);
                }
            }
            DataRow row = dt.NewRow();

            for (int i = 0; i < Table.Columns.Count; i++)
            {
                NpcDataColumn colunm = Table.Columns[i];
                Object        temp   = this[i];
                row[i] = (temp == null) ? DBNull.Value : temp;
            }
            dt.Rows.Add(row);
            return(dt);
        }
Exemplo n.º 2
0
 public NpcDataCell(NpcDataColumn column)
 {
     c = column;
     v = null;
 }
Exemplo n.º 3
0
        public NpcDataRow(NpcDataTable table)
        {
            Table     = table;
            ItemArray = new Object[table.Columns.Count];
            for (int i = 0; i < table.Columns.Count; i++)
            {
                NpcDataColumn colunm = Table.Columns[i];
                switch (colunm.DataType.ToString())
                {
                case "System.Boolean":
                case "System.Nullable`1[System.Boolean]":
                    ItemArray[i] = new NpcBoolean();
                    break;

                case "System.Byte":
                case "System.Nullable`1[System.Byte]":
                    ItemArray[i] = new NpcByte();
                    break;

                case "System.Byte[]":
                    ItemArray[i] = new NpcBytes();
                    break;

                case "System.Char":
                case "System.Nullable`1[System.Char]":
                    ItemArray[i] = new NpcChar();
                    break;

                case "System.DateTime":
                case "System.Nullable`1[System.DateTime]":
                    ItemArray[i] = new NpcDateTime();
                    break;

                case "System.Decimal":
                case "System.Nullable`1[System.Decimal]":
                    ItemArray[i] = new NpcDecimal();
                    break;

                case "System.Double":
                case "System.Nullable`1[System.Double]":
                    ItemArray[i] = new NpcDouble();
                    break;

                case "System.Int32":
                case "System.Nullable`1[System.Int32]":
                    ItemArray[i] = new NpcInt32();
                    break;

                case "System.Int64":
                case "System.Nullable`1[System.Int64]":
                    ItemArray[i] = new NpcInt64();
                    break;

                case "System.Guid":
                case "System.Nullable`1[System.Guid]":
                    ItemArray[i] = new NpcGuid();
                    break;

                case "System.Object":
                    ItemArray[i] = new NpcObject();
                    break;

                case "System.Single":
                case "System.Nullable`1[System.Single]":
                    ItemArray[i] = new NpcSingle();
                    break;

                case "System.String":
                    ItemArray[i] = new NpcString();
                    break;

                default:
                    ItemArray[i] = new NpcObject();
                    break;
                }
            }
        }
Exemplo n.º 4
0
 public NpcDataCell()
 {
     c = null;
     v = null;
 }