Ejemplo n.º 1
0
 void IEditTableView.DbConnectOccur()
 {
     _isConnected = true;
     if (this._tableName == "")
     {
         return;
     }
     SdeConnection conn = new SdeConnection();
     ISdeConnectionInfo sdeConn = (ISdeConnectionInfo)conn;
     IFeatureWorkspace fw = (IFeatureWorkspace)sdeConn.Workspace;
     ITable table = null;
     try
     {
         table = fw.OpenTable(this._tableName);
         loadData(this._tableName);
     }
     catch (Exception e)
     {
         MessageBox.Show(string.Format("Không tìm thấy bảng {0}", this._tableName));
         return;
     }
     this._sdeEditor = new SDETable(table, sdeConn.Workspace);
 }
Ejemplo n.º 2
0
        void ILandprice.LoadPrice()
        {
            _conn = new SdeConnection();
            _sdeConn = (ISdeConnectionInfo)_conn;
            _fw = (IFeatureWorkspace)_sdeConn.Workspace;
            IQueryFilter qrf = new QueryFilterClass();
            _fcName=new TnFeatureClassName(_sdeConn.Workspace);
            _nameOfThuaGiaDat=string.Format("{0}_{1}",_tableName,_conf.NamApDung);
            _nameOfThua=string.Format("{0}_{1}",DataNameTemplate.Thua,_conf.NamApDung);
            try
            {
                _thuaGiaDatFc = _fw.OpenFeatureClass(_nameOfThuaGiaDat);
                _thuaGiaDatTable = (ITable)_thuaGiaDatFc;
            }
            catch { MessageBox.Show(string.Format("Không tìm thấy bảng {0}", _nameOfThuaGiaDat)); return; }

            try
            {
                _thuaFc = _fw.OpenFeatureClass(_nameOfThua);
                _thuaTable = (ITable)_thuaFc;
            }
            catch { MessageBox.Show(string.Format("Không tìm thấy bảng {0}", _nameOfThua)); return; }

            _fcName.FC_THUA_GIADAT.NAME = _nameOfThuaGiaDat;
            _fcName.FC_THUA_GIADAT.InitIndex();
            _fcName.FC_THUA.NAME = _nameOfThua;
            _fcName.FC_THUA.InitIndex();

            _editorThua = new SDETable(_thuaTable, _sdeConn.Workspace);
            _editorTgd = new SDETable(_thuaGiaDatTable, _sdeConn.Workspace);

            List<ThuaGiaDatInfo> thuaGiaDat = new List<ThuaGiaDatInfo>();
            if (this._mathua != null)
            {
                //object giadat;
                //object dongia;
                //object dientich;
                //object dientichpl;
                //object giadatTheoDientich;
                int khoaGia;
                //int khoaGiaTay;
                //int khoaGiaTuDong;
                //object khoaViTri;
                //object soMatTien;
                //object soMatHem;
                //object cachtinh;
                qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_THUA.MA_THUA, _mathua);
                IFeatureCursor thuaFcur = _thuaFc.Search(qrf, false);
                IFeature thuaFt = null;
                int khoavitri = 0;
                bool result = false;
                try
                {
                    if ((thuaFt = thuaFcur.NextFeature()) != null)
                    {
                        result = int.TryParse(thuaFt.get_Value(thuaFt.Fields.FindField(_fcName.FC_THUA.LOCKED)).ToString(), out khoavitri);
                        if (!result)
                        {
                            khoavitri = 0;
                        }
                    }
                }
                catch (Exception e1) { MessageBox.Show(string.Format("Line 172 - GLandprice - {0}", e1)); }
                finally { Marshal.ReleaseComObject(thuaFcur); }

                qrf.WhereClause = string.Format("{0}='{1}'", _fcName.FC_THUA_GIADAT.MA_THUA, _mathua);
                //MessageBox.Show(string.Format("line 139 {0}", qrf.WhereClause));
                IFeatureCursor fcur=_thuaGiaDatFc.Search(qrf, false);
                IFeature ft = null;

                try
                {
                    int i = 0;

                    while ((ft = fcur.NextFeature()) != null)
                    {
                        thuaGiaDat.Add(new ThuaGiaDatInfo());
                        //MessageBox.Show(string.Format("line 147 - {0}_{1}",thuaGiaDat.Count,i));
                        thuaGiaDat[i].Mathua = this._mathua;
                        thuaGiaDat[i].Oid = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.OID));
                        thuaGiaDat[i].Dongia = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.DON_GIA));
                        thuaGiaDat[i].Giadat = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.GIA_DAT));
                        result=int.TryParse(ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.LOCKED)).ToString(),out khoaGia);
                        if(!result)
                        {
                            khoaGia=0;
                        }
                        thuaGiaDat[i].Khoagia = khoaGia;
                        thuaGiaDat[i].Hesovitri = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.HE_SO_K));
                        thuaGiaDat[i].Cachtinh = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.CACH_TINH));
                        thuaGiaDat[i].Dientich = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.DIEN_TICH));
                        thuaGiaDat[i].Dientichpl = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.DIEN_TICH_PHAP_LY));
                        thuaGiaDat[i].Maduong = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.MA_DUONG));
                        thuaGiaDat[i].Mahem = ft.get_Value(ft.Fields.FindField(_fcName.FC_THUA_GIADAT.MA_HEM));
                        thuaGiaDat[i].KhoaVitri = khoavitri;
                        i++;

                    }
                    //MessageBox.Show(string.Format("line 157 - {0}_{1}", thuaGiaDat.Count, i));
                    //if (thuaGiaDat.Count > 0)
                    //{
                        _view.UpDate(thuaGiaDat);
                    //}

                }
                catch (Exception e1) { MessageBox.Show(string.Format("Line 167 - GLandprice - {0}", e1)); }
                finally { Marshal.ReleaseComObject(fcur); }
            }
        }