예제 #1
0
 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;
     }
 }
예제 #2
0
 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;
                 }
             }
         }
     }
 }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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));
        }