private void method_2(string string_2) { for (int i = 0; i < this.ifields_0.FieldCount; i++) { IField key = this.ifields_0.get_Field(i); if ((key.Editable && ((((key.Type != esriFieldType.esriFieldTypeOID) && (key.Type != esriFieldType.esriFieldTypeGeometry)) && (key.Type != esriFieldType.esriFieldTypeRaster)) && (key.Type != esriFieldType.esriFieldTypeBlob))) && this.FieldDomains.ContainsKey(key)) { CodeDomainEx ex = this.FieldDomains[key]; if (ex != null) { CodeDomainManage.AddFieldCodeDoaminMap(string_2, key.Name, ex.DomainID); } else { CodeDomainManage.DeleteCodeDoaminMap(string_2, key.Name); } } } }
public void ShowTable() { this.m_CanDo = false; this.m_pDataTable.Rows.Clear(); this.m_pDataTable.Columns.Clear(); this.m_CanDo = true; if (this.m_pCursor != null) { ComReleaser.ReleaseCOMObject(this.m_pCursor); this.m_pCursor = null; } if (this.m_pTable != null) { IQueryFilter queryFilter = null; System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; if (this.m_strWhere.Length > 1) { queryFilter = new QueryFilterClass { WhereClause = this.m_strWhere }; } try { if (this.IsShowAll) { this.m_RecordNum = this.m_pTable.RowCount(queryFilter); this.m_pCursor = this.m_pTable.Search(queryFilter, false); } else { ComReleaser.ReleaseCOMObject(this.m_pCursor); if (this.m_pTable is IFeatureLayer) { } } try { this.AddFilesInfoToListViewColumn(this.m_pTable.Fields); this.AddRecordToListView(false); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } if (this.m_pTable.HasOID) { } this.m_pXtraGrid.SetDataBinding(this.dataGrid1, this.m_pDataTable); this.m_pXtraGrid.ReadOnly = true; for (int i = 0; i < this.m_pTable.Fields.FieldCount; i++) { IList list; int num2; IField field = this.m_pTable.Fields.get_Field(i); if (field.Domain != null) { if (field.Domain is ICodedValueDomain) { list = new ArrayList(); num2 = 0; while (num2 < (field.Domain as ICodedValueDomain).CodeCount) { list.Add((field.Domain as ICodedValueDomain).get_Name(num2)); num2++; } this.m_pXtraGrid.SetColumnAttr(i, ColumnAttribute.CA_COMBOBOX, list); } else if ((field.Domain is IRangeDomain) && ((((field.Type == esriFieldType.esriFieldTypeDouble) || (field.Type == esriFieldType.esriFieldTypeSingle)) || (field.Type == esriFieldType.esriFieldTypeSmallInteger)) || (field.Type == esriFieldType.esriFieldTypeInteger))) { this.m_pXtraGrid.SetColumnAttr(i, ColumnAttribute.CA_SPINEDIT, (double)(field.Domain as IRangeDomain).MinValue, (double)(field.Domain as IRangeDomain).MaxValue); } } else { list = new ArrayList(); string name = (this.m_pTable as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(field.Name, name); if (codeDomainEx != null) { if ((codeDomainEx.ParentIDFieldName == null) || (codeDomainEx.ParentIDFieldName.Length == 0)) { NameValueCollection codeDomain = codeDomainEx.GetCodeDomain(); if (field.IsNullable) { list.Add("<空>"); } for (num2 = 0; num2 < codeDomain.Count; num2++) { string str2 = codeDomain.Keys[num2]; list.Add(str2); } this.m_pXtraGrid.SetColumnAttr(i, ColumnAttribute.CA_COMBOBOX, list); } else { this.m_pXtraGrid.SetColumnAttr(i, ColumnAttribute.CA_TREEVIEWCOMBOX, codeDomainEx); } } else if ((((field.Type == esriFieldType.esriFieldTypeDouble) || (field.Type == esriFieldType.esriFieldTypeSingle)) || (field.Type == esriFieldType.esriFieldTypeSmallInteger)) || (field.Type == esriFieldType.esriFieldTypeInteger)) { this.m_pXtraGrid.SetColumnAttr(i, ColumnAttribute.CA_SPINEDIT); } } } } catch { } System.Windows.Forms.Cursor.Current = Cursors.Default; } }
private void m_pDataTable_ColumnChanged(object sender, DataColumnChangeEventArgs e) { if (this.m_InEditing && this.m_CanDo) { object[] itemArray = e.Row.ItemArray; try { IRow row; int num; IField field; int num2; IWorkspaceEdit workspace = (this.m_pTable as IDataset).Workspace as IWorkspaceEdit; if (itemArray[0] is DBNull) { if (!(this.m_pTable is IFeatureClass)) { workspace.StartEditOperation(); row = this.m_pTable.CreateRow(); num = row.Fields.FindFieldByAliasName(e.Column.ColumnName); if (num != -1) { field = row.Fields.get_Field(num); if (field.Domain is ICodedValueDomain) { for (num2 = 0; num2 < (field.Domain as ICodedValueDomain).CodeCount; num2++) { if (e.ProposedValue.ToString() == (field.Domain as ICodedValueDomain).get_Name(num2)) { row.set_Value(num, (field.Domain as ICodedValueDomain).get_Value(num2)); break; } } } else { string name = (row.Table as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(field.Name, name); if (codeDomainEx != null) { row.set_Value(num, codeDomainEx.GetCodeByName(e.ProposedValue.ToString())); } else { row.set_Value(num, e.ProposedValue); } } row.Store(); } workspace.StopEditOperation(); this.m_CanDo = false; e.Row[this.m_pTable.OIDFieldName] = row.OID; this.m_CanDo = true; } } else { int num3 = Convert.ToInt32(itemArray[0]); IQueryFilter queryFilter = new QueryFilterClass { WhereClause = this.m_pTable.OIDFieldName + " = " + num3.ToString() }; ICursor o = this.m_pTable.Search(queryFilter, false); row = o.NextRow(); if (row != null) { workspace.StartEditOperation(); num = row.Fields.FindFieldByAliasName(e.Column.ColumnName); if (num != -1) { field = row.Fields.get_Field(num); if (field.Domain is ICodedValueDomain) { for (num2 = 0; num2 < (field.Domain as ICodedValueDomain).CodeCount; num2++) { if (e.ProposedValue.ToString() == (field.Domain as ICodedValueDomain).get_Name(num2)) { row.set_Value(num, (field.Domain as ICodedValueDomain).get_Value(num2)); break; } } } else { row.set_Value(num, e.ProposedValue); } } row.Store(); workspace.StopEditOperation(); } row = null; ComReleaser.ReleaseCOMObject(o); o = null; } } catch (COMException exception) { if (exception.ErrorCode == -2147467259) { MessageBox.Show("输入数据大于字段长度"); } else { MessageBox.Show(exception.Message); } e.Row.CancelEdit(); } catch (Exception exception2) { MessageBox.Show(exception2.Message); e.Row.CancelEdit(); } } }
private void AddRecordToListView(bool bAll) { try { if (bAll) { this.m_ShowRecNum = this.m_RecordNum - this.m_pDataTable.Rows.Count; } else { this.m_ShowRecNum = ((this.m_RecordNum - this.m_pDataTable.Rows.Count) > 300) ? ((long)300) : ((long)this.m_RecordNum); } IFields fields = this.m_pCursor.Fields; int num = 0; IRow row = this.m_pCursor.NextRow(); object[] values = new object[fields.FieldCount]; while (row != null) { for (int i = 0; i < fields.FieldCount; i++) { IField field = fields.get_Field(i); if (field.Type == esriFieldType.esriFieldTypeGeometry) { values[i] = this.m_strGeometry; continue; } if (field.Type == esriFieldType.esriFieldTypeBlob) { values[i] = "二进制数据"; continue; } object obj2 = row.get_Value(i); IDomain domain = field.Domain; if (domain != null) { if (domain is ICodedValueDomain) { for (int j = 0; j < (field.Domain as ICodedValueDomain).CodeCount; j++) { if ((domain as ICodedValueDomain).get_Value(j).ToString() == obj2.ToString()) { obj2 = (domain as ICodedValueDomain).get_Name(j); break; } } } } else { string name = (row.Table as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(field.Name, name); if (codeDomainEx != null) { obj2 = codeDomainEx.FindName(obj2.ToString()); } } values[i] = obj2; } this.m_pDataTable.Rows.Add(values); num++; if (row.HasOID) { this.m_MaxOID = row.OID; } if (num >= this.m_ShowRecNum) { return; } row = this.m_pCursor.NextRow(); } } catch { } }
private void FieldTypeDateCtrl_Load(object sender, EventArgs e) { this.cboDomain.Properties.Items.Clear(); try { int num = -1; this.cboDomain.Properties.Items.Add(new DomainWrap1()); if (this.iworkspace_0 is IWorkspaceDomains) { IEnumDomain domains = (this.iworkspace_0 as IWorkspaceDomains).Domains; if (domains != null) { domains.Reset(); for (IDomain domain2 = domains.Next(); domain2 != null; domain2 = domains.Next()) { if (domain2.FieldType == esriFieldType.esriFieldTypeDate) { this.cboDomain.Properties.Items.Add(new DomainWrap1(domain2)); if ((this.ifieldEdit_0.Domain != null) && (this.ifieldEdit_0.Domain.Name == domain2.Name)) { num = this.cboDomain.Properties.Items.Count - 1; } } } } } string domainID = ""; if (NewObjectClassHelper.m_pObjectClassHelper != null) { if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains.ContainsKey(this.ifieldEdit_0)) { if (NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0] != null) { domainID = NewObjectClassHelper.m_pObjectClassHelper.FieldDomains[this.ifieldEdit_0].DomainID; } } else if (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass != null) { string name = (NewObjectClassHelper.m_pObjectClassHelper.ObjectClass as IDataset).Name; domainID = CodeDomainManage.GetDamainName(this.ifieldEdit_0.Name, name); } } using (List <CodeDomainEx> .Enumerator enumerator = CodeDomainManage.CodeDomainExs.GetEnumerator()) { while (enumerator.MoveNext()) { CodeDomainEx current = enumerator.Current; if (current.FieldType == esriFieldType.esriFieldTypeDate) { this.cboDomain.Properties.Items.Add(new DomainWrap1(current)); if (domainID == current.DomainID) { goto Label_01F7; } } } goto Label_021F; Label_01F7: num = this.cboDomain.Properties.Items.Count - 1; } Label_021F: this.cboDomain.SelectedIndex = num; } catch { this.cboDomain.Enabled = false; } this.method_1(); }
private void Init() { this.gridControl1.Focus(); this.m_pVertXtraGrid.Clear(); int rowHandle = -1; if (this.m_pObject == null) { this.m_CanDo = true; } else { this.toolStripDropDownButton1.DropDownItemClicked += new ToolStripItemClickedEventHandler(this.toolStripDropDownButton1_DropDownItemClicked); try { ITableAttachments attachments = (ITableAttachments)this.m_pObject.Class; if (attachments != null) { if (attachments.HasAttachments) { this.toolStrip1.Visible = true; this.InitAttachment(); } else { this.toolStrip1.Visible = false; } } } catch { } IFields fields = this.m_pObject.Fields; string[] strArray = new string[2]; ISubtypes subtypes = this.m_pObject.Class as ISubtypes; IDomain domain = null; for (int i = 0; i < fields.FieldCount; i++) { IField pField = fields.get_Field(i); if (this.CheckFieldIsVisible(this.m_pFeatureLayer, pField)) { strArray[0] = pField.AliasName; if (pField.Type == esriFieldType.esriFieldTypeGeometry) { strArray[1] = this.GetShapeString(pField); this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true); } else if (pField.Type == esriFieldType.esriFieldTypeOID) { strArray[1] = this.m_pObject.OID.ToString(); this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true); } else if (pField.Type == esriFieldType.esriFieldTypeBlob) { strArray[1] = "<二进制数据>"; this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], true); } else { int num4; double minValue; double maxValue; object obj2 = this.m_pObject.get_Value(i); ICodedValueDomain domain2 = null; IList list = new ArrayList(); if ((subtypes != null) && subtypes.HasSubtype) { if (subtypes.SubtypeFieldName == pField.Name) { int num3; try { strArray[1] = subtypes.get_SubtypeName((this.m_pObject as IRowSubtypes).SubtypeCode); } catch { strArray[1] = obj2.ToString(); } IEnumSubtype subtype = subtypes.Subtypes; subtype.Reset(); for (string str = subtype.Next(out num3); str != null; str = subtype.Next(out num3)) { list.Add(str); } this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list, !this.FieldCanEdit(pField)); } else { domain = subtypes.get_Domain((this.m_pObject as IRowSubtypes).SubtypeCode, pField.Name); if (domain is ICodedValueDomain) { domain2 = domain as ICodedValueDomain; if (pField.IsNullable) { list.Add("<空>"); } strArray[1] = obj2.ToString(); num4 = 0; while (num4 < domain2.CodeCount) { list.Add(domain2.get_Name(num4)); if (obj2.ToString() == domain2.get_Value(num4).ToString()) { strArray[1] = domain2.get_Name(num4); } num4++; } this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list, !this.FieldCanEdit(pField)); } else if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) || (pField.Type == esriFieldType.esriFieldTypeSingle)) || (pField.Type == esriFieldType.esriFieldTypeDouble)) || (pField.Type == esriFieldType.esriFieldTypeInteger)) { minValue = 0.0; maxValue = 0.0; if (domain is IRangeDomain) { minValue = (double)(domain as IRangeDomain).MinValue; maxValue = (double)(domain as IRangeDomain).MaxValue; } if (pField.Editable) { this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, minValue, maxValue); } else { this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true); } } else if (pField.Type == esriFieldType.esriFieldTypeDate) { this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2, !this.FieldCanEdit(pField)); } else { strArray[1] = obj2.ToString(); this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], !this.FieldCanEdit(pField)); } } } else { domain = pField.Domain; if (domain != null) { if (domain is ICodedValueDomain) { domain2 = domain as ICodedValueDomain; if (pField.IsNullable) { list.Add("<空>"); } strArray[1] = obj2.ToString(); num4 = 0; while (num4 < domain2.CodeCount) { list.Add(domain2.get_Name(num4)); if (obj2.ToString() == domain2.get_Value(num4).ToString()) { strArray[1] = domain2.get_Name(num4); } num4++; } this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list, !this.FieldCanEdit(pField)); } else if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) || (pField.Type == esriFieldType.esriFieldTypeSingle)) || (pField.Type == esriFieldType.esriFieldTypeDouble)) || (pField.Type == esriFieldType.esriFieldTypeInteger)) { minValue = 0.0; maxValue = 0.0; if (domain is IRangeDomain) { minValue = (double)(domain as IRangeDomain).MinValue; maxValue = (double)(domain as IRangeDomain).MaxValue; } if (pField.Editable) { this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, minValue, maxValue); } else { this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true); } } else if (pField.Type == esriFieldType.esriFieldTypeDate) { this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2, !this.FieldCanEdit(pField)); } else { strArray[1] = obj2.ToString(); this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], !this.FieldCanEdit(pField)); } } else { string name = (this.m_pObject.Class as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(pField.Name, name); if (codeDomainEx != null) { if ((codeDomainEx.ParentIDFieldName == null) || (codeDomainEx.ParentIDFieldName.Length == 0)) { NameValueCollection codeDomain = codeDomainEx.GetCodeDomain(); if (pField.IsNullable) { list.Add("<空>"); } strArray[1] = obj2.ToString(); for (num4 = 0; num4 < codeDomain.Count; num4++) { string str3 = codeDomain.Keys[num4]; list.Add(str3); if (obj2.ToString() == codeDomain[str3]) { strArray[1] = str3; } } this.m_pVertXtraGrid.AddComBoBox(strArray[0], strArray[1], list, !this.FieldCanEdit(pField)); } else { strArray[1] = obj2.ToString(); this.m_pVertXtraGrid.AddTreeviewComBoBox(strArray[0], codeDomainEx.FindName(strArray[1]), codeDomainEx, !this.FieldCanEdit(pField)); } } else { if ((((pField.Type == esriFieldType.esriFieldTypeSmallInteger) || (pField.Type == esriFieldType.esriFieldTypeSingle)) || (pField.Type == esriFieldType.esriFieldTypeDouble)) || (pField.Type == esriFieldType.esriFieldTypeInteger)) { if (pField.Editable) { this.m_pVertXtraGrid.AddSpinEdit(strArray[0], obj2, false, 0.0, 0.0); } else { this.m_pVertXtraGrid.AddTextEdit(strArray[0], obj2, true); } } else if (pField.Type == esriFieldType.esriFieldTypeDate) { this.m_pVertXtraGrid.AddDateEdit(strArray[0], obj2, !this.FieldCanEdit(pField)); } else { strArray[1] = obj2.ToString(); this.m_pVertXtraGrid.AddTextEdit(strArray[0], strArray[1], !this.FieldCanEdit(pField)); } if (strArray[0] == this.m_EditFeildName) { rowHandle = i; } } } } } } } if (rowHandle >= 0) { this.gridView1.SelectRow(rowHandle); } this.gridView1.Focus(); this.m_CanDo = true; base.Parent.Focus(); } }
private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) { if (this.m_CanDo && (this.m_pObject != null)) { object obj2; IDomain domain; ICodedValueDomain domain2; int num3; ISubtypes subtypes = this.m_pObject.Class as ISubtypes; GridEditorItem row = this.gridView1.GetRow(e.RowHandle) as GridEditorItem; int index = this.m_pObject.Fields.FindFieldByAliasName(row.Name); IField pField = this.m_pObject.Fields.get_Field(index); this.m_EditFeildName = pField.AliasName; if ((subtypes != null) && subtypes.HasSubtype) { if (subtypes.SubtypeFieldName == pField.Name) { IEnumSubtype subtype = subtypes.Subtypes; subtype.Reset(); int subtypeCode = 0; for (string str = subtype.Next(out subtypeCode); str != null; str = subtype.Next(out subtypeCode)) { if (e.Value.ToString() == str) { this.UpdateFieldValue(pField, subtypeCode); break; } } } else if (e.Value.ToString() == "<空>") { obj2 = DBNull.Value; this.UpdateFieldValue(pField, obj2); } else { domain = subtypes.get_Domain((this.m_pObject as IRowSubtypes).SubtypeCode, pField.Name); if (domain is ICodedValueDomain) { domain2 = domain as ICodedValueDomain; for (num3 = 0; num3 < domain2.CodeCount; num3++) { if (domain2.get_Name(num3) == e.Value.ToString()) { this.UpdateFieldValue(pField, domain2.get_Value(num3)); break; } } } else { this.UpdateFieldValue(pField, e.Value); } } } else if (e.Value.ToString() == "<空>") { obj2 = DBNull.Value; this.UpdateFieldValue(pField, obj2); } else { string name = (this.m_pObject.Class as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(pField.Name, name); if (codeDomainEx != null) { if ((codeDomainEx.ParentIDFieldName == null) || (codeDomainEx.ParentIDFieldName.Length == 0)) { NameValueCollection codeDomain = codeDomainEx.GetCodeDomain(); for (num3 = 0; num3 < codeDomain.Count; num3++) { string str3 = codeDomain.Keys[num3]; if (str3 == e.Value.ToString()) { this.UpdateFieldValue(pField, codeDomain[str3]); break; } } } else { this.UpdateFieldValue(pField, codeDomainEx.GetCodeByName(e.Value.ToString())); } } else { domain = pField.Domain; if (domain is ICodedValueDomain) { domain2 = domain as ICodedValueDomain; for (num3 = 0; num3 < domain2.CodeCount; num3++) { if (domain2.get_Name(num3) == e.Value.ToString()) { this.UpdateFieldValue(pField, domain2.get_Value(num3)); break; } } } else if (this.UpdateFieldValue(pField, e.Value)) { this.m_CanDo = false; row.Value = this.m_pObject.get_Value(index); this.m_CanDo = true; } } } } }
private string method_7(IRow irow_0, IField ifield_0, int int_0) { int num; string str = irow_0.get_Value(int_0).ToString(); ISubtypes table = irow_0.Table as ISubtypes; ICodedValueDomain domain = null; IList list = new ArrayList(); IDomain domain2 = null; if ((table != null) && table.HasSubtype) { if (table.SubtypeFieldName == ifield_0.Name) { try { str = table.get_SubtypeName((irow_0 as IRowSubtypes).SubtypeCode); } catch { } } else { domain2 = table.get_Domain((irow_0 as IRowSubtypes).SubtypeCode, ifield_0.Name); if (domain2 is ICodedValueDomain) { domain = domain2 as ICodedValueDomain; if (ifield_0.IsNullable) { list.Add("<空>"); } num = 0; while (num < domain.CodeCount) { if (str == domain.get_Value(num).ToString()) { str = domain.get_Name(num); break; } num++; } } } } domain2 = ifield_0.Domain; if (domain2 != null) { if (domain2 is ICodedValueDomain) { domain = domain2 as ICodedValueDomain; num = 0; while (num < domain.CodeCount) { if (str == domain.get_Value(num).ToString()) { return(domain.get_Name(num)); } num++; } } return(str); } string name = (irow_0.Table as IDataset).Name; CodeDomainEx codeDomainEx = CodeDomainManage.GetCodeDomainEx(ifield_0.Name, name); if (codeDomainEx == null) { return(str); } if ((codeDomainEx.ParentIDFieldName == null) || (codeDomainEx.ParentIDFieldName.Length == 0)) { NameValueCollection codeDomain = codeDomainEx.GetCodeDomain(); for (num = 0; num < codeDomain.Count; num++) { string str3 = codeDomain.Keys[num]; if (str == codeDomain[str3]) { str = str3; } } return(str); } return(codeDomainEx.FindName(str)); }
public DomainWrap1(CodeDomainEx codeDomainEx_1) { this.idomain_0 = null; this.codeDomainEx_0 = null; this.codeDomainEx_0 = codeDomainEx_1; }
public DomainWrap1(IDomain idomain_1) { this.idomain_0 = null; this.codeDomainEx_0 = null; this.idomain_0 = idomain_1; }
public DomainWrap1() { this.idomain_0 = null; this.codeDomainEx_0 = null; }