public static List <PmsField> InitialFieldList(string _strTableName) { List <PmsField> _pmsFieldList = new List <PmsField>(); try { System.Data.DataTable table = PMSDBStructure.GetTableFieldInfo(_strTableName); if (table == null || table.Rows.Count == 0) { return(_pmsFieldList); } foreach (DataRow row in table.Rows) { PmsField field = new PmsField(); try { field.fieldName = row["FieldName"].ToString(); string strType = row["FieldType"].ToString(); strType = strType.ToLower(); int length = 20; length = Convert.ToInt32((row["FieldLength"])); field.fieldDescription = row["FieldDescription"].ToString(); field.fieldType = PmsField.ToPMSDataType(strType, length); field.fieldKey = (bool)row["FieldPrimaryKey"]; field.fieldNull = (bool)row["FieldNullAble"]; field.fieldDefault = row["FieldDefault"]; } catch { } string propEx = PMSDBStructure.GetTableColumnPropertie(_strTableName, field.fieldName, "ColumnType"); //存在加密 if (propEx == PMS.Libraries.ToolControls.PMSPublicInfo.ColumnType.Encrypted) { field.fieldEncryptType = PMSDBStructure.GetTableColumnPropertie(_strTableName, field.fieldName, "EncryptType"); } _pmsFieldList.Add(field); } } catch (Exception ex) { PMS.Libraries.ToolControls.PMSPublicInfo.PublicFunctionClass.EnhancedStackTrace(ex); } return(_pmsFieldList); }
private void RelationFieldChoose_Load(object sender, EventArgs e) { if (pmsFieldList == null) { return; } if (BTable == false) { this.columnHeader1.Text = "名称"; } foreach (PmsField pf in pmsFieldList) { if (CtrlType == "CheckBox")//只能选择布尔型关联字段 { if (pf.fieldType != "BIT") { continue; } } else if (CtrlType == "PictureBox")//只能选择Image型关联字段 { if (pf.fieldType != "IMAGE") { continue; } } else if (CtrlType == "VARCHAR")//只能选择字符串型关联字段 { if (!pf.fieldType.StartsWith("VARCHAR")) { continue; } } else if (CtrlType == "TextBox")//不能选择Image型关联字段 { if (pf.fieldType == "IMAGE") { continue; } if ((pf.fieldForeigner && pf.fieldForeignerType == PMS.Libraries.ToolControls.PMSPublicInfo.ColumnType.MapTree)) { continue; } } else if (CtrlType == "ComboBox")//不能选择Image型关联字段 { if (pf.fieldType == "GUID") { continue; } if ((pf.fieldForeigner && pf.fieldForeignerType == PMS.Libraries.ToolControls.PMSPublicInfo.ColumnType.MapTree)) { continue; } } else if (CtrlType == "ForeignKeyCtrl")//只能选择guid类型的外键关系字段 { //if (!(pf.fieldForeigner && pf.fieldForeignerType == PMS.Libraries.ToolControls.PMSPublicInfo.ColumnType.MapTree) || pf.fieldType != "GUID") if (!pf.fieldName.Equals("ParentID", StringComparison.CurrentCultureIgnoreCase)) { continue; } } ListViewItem lvi = new ListViewItem(pf.fieldName); lvi.Tag = pf.fieldType; try { if (BTable) { lvi.SubItems.Add(PMSDBStructure.GetTablePropertie(pf.fieldName, "Description")); } else { if (!string.IsNullOrEmpty(pf.fieldDescription)) { lvi.SubItems.Add(pf.fieldDescription); } } } catch { } listBox1.Items.Add(lvi); } if (strRField != null) { foreach (ListViewItem tvi in listBox1.Items) { if (tvi.Text == strRField) { tvi.Selected = true; break; } } } else { if (listBox1.Items.Count > 0) { listBox1.Items[0].Selected = true; } } }