public void CreateField(FldDef fldDef) { IDynaField field = null; switch (fldDef.fld_type) { case 167: //varchar field = new StringField(fldDef.fld_name, DbType.String, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 175: //char[]->varchar field = new StringField(fldDef.fld_name, DbType.StringFixedLength, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 35: //text field = new TextField(fldDef.fld_name, DbType.AnsiString, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 48: //byte field = new ByteField(fldDef.fld_name, DbType.Byte, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 52: //int16 field = new Int16Field(fldDef.fld_name, DbType.Int16, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 56: //int32 field = new Int32Field(fldDef.fld_name, DbType.Int32, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 40: //date field = new DateField(fldDef.fld_name, DbType.Date, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 61: //datetime field = new DateField(fldDef.fld_name, DbType.DateTime, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; case 62: //double field = new DoubleField(fldDef.fld_name, DbType.Double, fldDef.fld_size, fldDef.inp_mask, fldDef.out_mask); break; } if (field != null) { field.Value = fldDef.def_val; FieldDict.Add(fldDef.fld_name, field); } }
public bool LoadMeta() { loaded = false; IDbConnection dbConn = null; IDbCommand qryComm = null, fldComm = null; IDataReader qryReader = null, fldReader = null; try { recDict.Clear(); //get connection from pool dbConn = GetConnection(); dbConn.Open(); //qryDict qryComm = dbConn.CreateCommand(); qryComm.CommandType = CommandType.Text; qryComm.CommandText = "select Qry_Name, Qry_Head, Qry_Lord, Fld_Dict, Qry_Mask from T_QryDict"; qryReader = qryComm.ExecuteReader(); qryList.Clear(); while (qryReader.Read()) { QryDef qryDef = new QryDef(); qryDef.qry_name = qryReader.GetString(0); qryDef.qry_head = qryReader.GetString(1); qryDef.qry_lord = qryReader.GetString(2); qryDef.fld_dict = qryReader.GetString(3); qryDef.qry_mask = qryReader.GetInt32(4); qryList.Add(qryDef); } qryReader.Close(); //fldList fldComm = dbConn.CreateCommand(); fldComm.CommandType = CommandType.Text; fldComm.CommandText = "select Qry_Name, Fld_Name, Fld_Head, Fld_Type, Fld_Size, Inp_Mask, Out_Mask, Def_Val from T_FldDict"; fldReader = fldComm.ExecuteReader(); fldList.Clear(); while (fldReader.Read()) { FldDef fldDef = new FldDef(); fldDef.qry_name = fldReader.GetString(0); fldDef.fld_name = fldReader.GetString(1); fldDef.fld_head = fldReader.GetString(2); fldDef.fld_type = fldReader.GetInt32(3); fldDef.fld_size = fldReader.GetInt32(4); fldDef.inp_mask = fldReader.GetInt32(5); fldDef.out_mask = fldReader.GetInt32(6); fldDef.def_val = fldReader.GetString(7); fldList.Add(fldDef); } fldReader.Close(); loaded = true; } catch (DbException sx) { //if (ShowError != null) ShowError(sx.Message); lastError = sx.Message; } catch (Exception ex) { //if (ShowError != null) ShowError(ex.Message); lastError = ex.Message; } finally { if (fldReader != null) { fldReader.Close(); } if (qryReader != null) { qryReader.Close(); } if (dbConn != null) { dbConn.Close(); } } return(loaded); }