private void LoadBlockFieldItems(XmlNode Node, TBlockFieldItems BlockFieldItems) { TBlockFieldItem BFI; int I; XmlNode BlockFieldItemNode; for (I = 0; I < Node.ChildNodes.Count; I++) { BlockFieldItemNode = Node.ChildNodes[I]; BFI = new TBlockFieldItem(); BFI.DataField = BlockFieldItemNode.Attributes["DataField"].Value; BFI.Description = BlockFieldItemNode.Attributes["Description"].Value; BFI.Length = int.Parse(BlockFieldItemNode.Attributes["Length"].Value.ToString()); foreach (XmlNode RefNode in BlockFieldItemNode.ChildNodes) { BFI.RefField = new TRefField(); BFI.RefField.SelectCommand = RefNode.Attributes["SelectCommand"].Value; BFI.RefField.ValueMember = RefNode.Attributes["ValueMember"].Value; BFI.RefField.DisplayMember = RefNode.Attributes["DisplayMember"].Value; foreach (XmlNode ColumnNode in RefNode.ChildNodes) { RefColumns aColumn = new RefColumns(); aColumn.Column = ColumnNode.Attributes["Column"].Value; aColumn.HeaderText = ColumnNode.Attributes["HeaderText"].Value; aColumn.Width = int.Parse(ColumnNode.Attributes["Width"].Value); BFI.RefField.LookupColumns.Add(aColumn); } } //IPC保留缺口 //BlockFieldItem.CheckNull = DR["CHECK_NULL"].ToString(); //BlockFieldItem.DefaultValue = DR["DEFAULT_VALUE"].ToString(); BlockFieldItems.Add(BFI); } }
private InfoRefVal GenRefVal(TBlockFieldItem FieldItem, string TableName) { String Name = "rv" + TableName + FieldItem.DataField; InfoRefVal Result = FDesignerHost.CreateComponent(typeof(InfoRefVal), Name) as InfoRefVal; InfoCommand aInfoCommand = new InfoCommand(FClientData.DatabaseType); aInfoCommand.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true); //aInfoCommand.Connection = FClientData.Owner.GlobalConnection; IDbDataAdapter DA = DBUtils.CreateDbDataAdapter(aInfoCommand); DataSet aDataSet = new DataSet(); //SYS_REFVAL aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL where REFVAL_NO = '{0}'", FieldItem.RefValNo); WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, FieldItem.RefValNo); if (aDataSet.Tables[0].Rows.Count != 1) throw new Exception(String.Format("Unknown REFVAL_NO in SYS_REFVAL: {0}", FieldItem.RefValNo)); Result.Caption = aDataSet.Tables[0].Rows[0]["CAPTION"].ToString(); Result.DisplayMember = aDataSet.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(); Result.ValueMember = aDataSet.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(); Result.SelectAlias = aDataSet.Tables[0].Rows[0]["SELECT_ALIAS"].ToString(); Result.SelectCommand = aDataSet.Tables[0].Rows[0]["SELECT_COMMAND"].ToString(); //SYS_REFVSL_D1 --> Columns aDataSet.Clear(); aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", FieldItem.RefValNo); WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, FieldItem.RefValNo); foreach (DataRow DR in aDataSet.Tables[0].Rows) { RefColumns RC = new RefColumns(); RC.Column = DR["FIELD_NAME"].ToString(); RC.HeaderText = DR["HEADER_TEXT"].ToString(); Result.Columns.Add(RC); } return Result; }