예제 #1
0
        void ucCoorSystem1_OnPrjSelected(object Project)
        {
            //throw new NotImplementedException();
            if (Project == null)
            {
                return;
            }
            CoordProjClass projClass = Project as CoordProjClass;

            gridView1.ActiveFilterString = string.Format(" (sou_wkid = {1} or tar_wkid = {1}) ", _countryFilter, projClass.WKID);
            paraCountLbl.Text            = string.Format("共有{0}条记录", gridView1.RowCount);
        }
예제 #2
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            TreeListNode currNode = treeList1.FocusedNode;

            if (currNode == null || currNode.HasChildren)
            {
                return;
            }
            CoordProjClass projClass = new CoordProjClass();

            projClass.NAME       = currNode.GetValue("NAME").ToString();
            projClass.WKID       = Convert.ToInt32(currNode.GetValue("WKID"));
            projClass.DEFINITION = currNode.GetValue("DEFINITION").ToString();
            if (this.OnPrjSelected != null)
            {
                OnPrjSelected(projClass);
            }
        }
예제 #3
0
        void frmPrj_OnPrjSelected1(object Project)
        {
            ClearMidProj();
            ShowMidProj(false);
            //throw new NotImplementedException();
            btnEditTarPrj.EditValue = Project;
            this.cmbTransPara.Properties.Items.Clear();
            this.cmbTransPara2.Properties.Items.Clear();
            DataTable coorParaTable = AccessHelper.ExecuteDataTable(string.Format("select * from CoordinatePara where ( SOU_WKID ={0} and TAR_WKID = {1} ) OR ( SOU_WKID ={1} and TAR_WKID = {0} )",
                                                                                  (btnEditSouPrj.EditValue as CoordProjClass).WKID, (btnEditTarPrj.EditValue as CoordProjClass).WKID), null);

            if (coorParaTable == null || coorParaTable.Rows.Count == 0)//没有直接转换关系,则尝试中转
            {
                coorParaTable = AccessHelper.ExecuteDataTable(string.Format("select sou_wkid , tar_wkid from CoordinatePara where ( SOU_WKID ={0}  ) OR ( TAR_WKID = {0} )",
                                                                            (btnEditSouPrj.EditValue as CoordProjClass).WKID), null);
                if (coorParaTable == null || coorParaTable.Rows.Count == 0)
                {
                    return;
                }
                string wkids = string.Empty;
                for (int i = 0; i < coorParaTable.Rows.Count; i++)
                {
                    if ((btnEditSouPrj.EditValue as CoordProjClass).WKID.ToString() == coorParaTable.Rows[i]["sou_wkid"].ToString())
                    {
                        wkids += coorParaTable.Rows[i]["tar_wkid"].ToString() + ",";
                    }
                    else
                    {
                        wkids += coorParaTable.Rows[i]["sou_wkid"].ToString() + ",";
                    }
                }
                wkids         = wkids.Trim(',');
                coorParaTable = AccessHelper.ExecuteDataTable(string.Format("select sou_wkid , tar_wkid from CoordinatePara where ( SOU_WKID in ({0} ) and TAR_WKID = {1} ) OR ( SOU_WKID ={1} and TAR_WKID in ( {0} ) )",
                                                                            wkids, (btnEditTarPrj.EditValue as CoordProjClass).WKID), null);
                if (coorParaTable == null || coorParaTable.Rows.Count == 0)
                {
                    return;
                }
                string midProjid = coorParaTable.Rows[0]["sou_wkid"].ToString() == (btnEditTarPrj.EditValue as CoordProjClass).WKID.ToString() ?
                                   coorParaTable.Rows[0]["tar_wkid"].ToString() : coorParaTable.Rows[0]["sou_wkid"].ToString();
                //获取第一条,作为中转坐标系统
                DataTable      midProjdt    = CommonClass.GetCoorSystemTable("wkid = " + midProjid);
                CoordProjClass souprojClass = new CoordProjClass();
                souprojClass.NAME       = midProjdt.Rows[0]["NAME"].ToString();
                souprojClass.WKID       = Convert.ToInt32(midProjid);
                souprojClass.DEFINITION = midProjdt.Rows[0]["DEFINITION"].ToString();
                this.txtMidProj.Text    = souprojClass.NAME;
                this.txtMidProj.Tag     = souprojClass;

                coorParaTable = AccessHelper.ExecuteDataTable(string.Format("select * from CoordinatePara where ( SOU_WKID ={0} and TAR_WKID = {1} ) OR ( SOU_WKID ={1} and TAR_WKID = {0} )",
                                                                            (btnEditSouPrj.EditValue as CoordProjClass).WKID, midProjid), null);
                DataTable coorParaTable2 = AccessHelper.ExecuteDataTable(string.Format("select * from CoordinatePara where ( SOU_WKID ={0} and TAR_WKID = {1} ) OR ( SOU_WKID ={1} and TAR_WKID = {0} )",
                                                                                       (btnEditTarPrj.EditValue as CoordProjClass).WKID, midProjid), null);

                for (int i = 0; i < coorParaTable2.Rows.Count; i++)
                {
                    this.cmbTransPara2.Properties.Items.Add(new CoordTrancParamClass(coorParaTable2.Rows[i]));
                }
                ShowMidProj(true);
            }
            for (int i = 0; i < coorParaTable.Rows.Count; i++)
            {
                this.cmbTransPara.Properties.Items.Add(new CoordTrancParamClass(coorParaTable.Rows[i]));
            }
            //buttonEdit1.Tag = Project;
            //btnEditSou.Text = (Project as CoordProjClass).NAME;
        }
예제 #4
0
        void FormLoad()
        {
            //参数类型绑定值
            string[] typeName = { "三参", "七参", "十参" };
            paraTypeCmb.Properties.Items.AddRange(typeName);
            paraTypeCmb.SelectedIndex = 0;

            object ds = null;
            object z0 = null;

            if (this.Text.Contains("编辑"))
            {
                foreach (DataColumn colum in focusRow.Table.Columns)
                {
                    foreach (Control control in this.Controls)
                    {
                        if (control.HasChildren)
                        {
                            foreach (Control item in control.Controls)
                            {
                                if (item.Tag != null && item.Tag.ToString().ToUpper().Equals(colum.ColumnName.ToUpper()))
                                {
                                    if (item is TextEdit)
                                    {
                                        (item as TextEdit).EditValue = focusRow[colum.ColumnName];
                                    }
                                    if (item is CalcEdit)
                                    {
                                        (item as CalcEdit).EditValue = focusRow[colum.ColumnName];
                                    }
                                    if (item is TextBox)
                                    {
                                        (item as TextBox).Text = focusRow[colum.ColumnName].ToString();
                                    }
                                    if (colum.ColumnName.ToUpper().Equals("DS"))
                                    {
                                        ds = focusRow[colum.ColumnName];
                                    }
                                    if (colum.ColumnName.ToUpper().Equals("Z0"))
                                    {
                                        z0 = focusRow[colum.ColumnName];
                                    }
                                }
                            }
                        }
                    }
                }
                if (!(ds is System.DBNull || ds is System.DBNull))
                {
                    paraTypeCmb.SelectedIndex = 1;
                }
                if (!(ds is System.DBNull) && (ds is System.DBNull))
                {
                    paraTypeCmb.SelectedIndex = 2;
                }
            }
            if (this.Text.Contains("查看"))
            {
                foreach (DataColumn colum in focusRow.Table.Columns)
                {
                    foreach (Control control in this.Controls)
                    {
                        if (control.HasChildren)
                        {
                            foreach (Control item in control.Controls)
                            {
                                if (item.Tag != null && item.Tag.ToString().ToUpper().Equals(colum.ColumnName.ToUpper()))
                                {
                                    if (item is TextEdit)
                                    {
                                        (item as TextEdit).EditValue           = focusRow[colum.ColumnName];
                                        (item as TextEdit).Properties.ReadOnly = true;
                                    }
                                    if (item is TextBox)
                                    {
                                        (item as TextBox).Text     = focusRow[colum.ColumnName].ToString();
                                        (item as TextBox).ReadOnly = true;
                                    }
                                    if (item is CalcEdit)
                                    {
                                        (item as CalcEdit).EditValue           = focusRow[colum.ColumnName];
                                        (item as CalcEdit).Properties.ReadOnly = true;
                                    }

                                    if (colum.ColumnName.ToUpper().Equals("DS"))
                                    {
                                        ds = focusRow[colum.ColumnName];
                                    }
                                    if (colum.ColumnName.ToUpper().Equals("Z0"))
                                    {
                                        z0 = focusRow[colum.ColumnName];
                                    }
                                }
                            }
                        }
                    }
                }
                if (!(ds is System.DBNull || ds is System.DBNull))
                {
                    paraTypeCmb.SelectedIndex = 1;
                }
                if (!(ds is System.DBNull) && (ds is System.DBNull))
                {
                    paraTypeCmb.SelectedIndex = 2;
                }

                paraTypeCmb.Properties.ReadOnly = true;
                saveBtn.Enabled = false;
            }
            if (this.Text.Contains("新增"))
            {
                object maxId = AccessHelper.ExecuteScalar("select max(wkid) + 1 from CoordinatePara", null);
                WKIDCalcEdit.EditValue = maxId;
            }
            //初始化坐标系统
            CoordProjClass souprojClass = new CoordProjClass();

            souprojClass.NAME         = this.focusRow["SOU_PRJ"].ToString();
            souprojClass.WKID         = Convert.ToInt32(this.focusRow["SOU_WKID"]);
            this.btnEditSou.EditValue = souprojClass;

            CoordProjClass tarprojClass = new CoordProjClass();

            tarprojClass.NAME         = this.focusRow["TAR_PRJ"].ToString();
            tarprojClass.WKID         = Convert.ToInt32(this.focusRow["TAR_WKID"]);
            this.btnEditTar.EditValue = tarprojClass;
        }
예제 #5
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            TreeListNode currNode = treeList1.FocusedNode;

            if (currNode == null || currNode.HasChildren)
            {
                return;
            }

            coorInfoCtrl.Text = string.Empty;
            string coorInfor = currNode.GetValue("DEFINITION").ToString();

            if (string.IsNullOrEmpty(coorInfor))
            {
                return;
            }

            string wkid = currNode.GetValue("WKID").ToString();
            string org  = currNode.GetValue("ORGANIZATION").ToString();

            coorInfor = coorInfor.Replace("[", "").Replace("]", "");

            if (currNode.GetValue("TYPE") == null)
            {
                return;
            }
            //地理坐标系
            if (currNode.GetValue("TYPE").ToString().Trim().Equals("GEOGRAPHIC"))
            {
                string[] separator = { "GEOGCS", "DATUM", "SPHEROID", "PRIMEM", "UNIT" };
                string[] info      = coorInfor.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                string[] name      = { "Geographic Coordinate System: ", "Datum: ", "Spheroid: ", "Prime Meridian: ", "Angular Unit: " };

                coorInfoCtrl.Text = name[0] + info[0].Remove(info[0].Length - 1) + "\t\n" + "WKID: " + wkid + "\t\nOrganization: " + org + "\t\n\n";

                for (int i = 1; i < 5; i++)
                {
                    if (info[i].EndsWith(","))
                    {
                        info[i] = info[i].Remove(info[i].Length - 1);
                    }
                    coorInfoCtrl.Text += name[i] + info[i] + "\t\n";
                }
            }
            //投影坐标系统
            if (currNode.GetValue("TYPE").ToString().Trim().Equals("PROJECTED"))
            {
                string[] separator = { "PROJCS", "GEOGCS", "DATUM", "SPHEROID", "PRIMEM", "UNIT", "PROJECTION", "PARAMETER" };
                string[] info      = coorInfor.Split(separator, StringSplitOptions.RemoveEmptyEntries);
                string[] name      = { "Projected Coordinate System: ", "Geographic Coordinate System: ", "Datum: ", "Spheroid: ",
                                       "Prime Meridian: ",                   "Angular Unit: " };


                coorInfoCtrl.Text = name[0] + info[0].Remove(info[0].Length - 1) + "\t\n" + "WKID: " + wkid + "\t\nOrganization: " + org + "\t\n\n";

                for (int i = 6; i < info.Length; i++)
                {
                    if (info[i].EndsWith(","))
                    {
                        info[i] = info[i].Remove(info[i].Length - 1);
                    }

                    if (i == 6)
                    {
                        coorInfoCtrl.Text += "Projection: " + info[i] + "\t\n";
                    }
                    else if (i == info.Length - 1)
                    {
                        coorInfoCtrl.Text += "Linear Unit: " + info[i] + "\t\n";
                    }
                    else
                    {
                        coorInfoCtrl.Text += info[i].Split(',')[0].Replace("\"", "") + ": " + info[i].Split(',')[1] + "\t\n";
                    }
                }

                coorInfoCtrl.Text += "\t\n";
                for (int i = 1; i < 6; i++)
                {
                    if (info[i].EndsWith(","))
                    {
                        info[i] = info[i].Remove(info[i].Length - 1);
                    }

                    coorInfoCtrl.Text += name[i] + info[i] + "\t\n";
                }
            }
            CoordProjClass projClass = new CoordProjClass();

            projClass.NAME       = currNode.GetValue("NAME").ToString();
            projClass.WKID       = Convert.ToInt32(currNode.GetValue("WKID"));
            projClass.DEFINITION = currNode.GetValue("DEFINITION").ToString();
            if (this.OnPrjSelected != null)
            {
                OnPrjSelected(projClass);
            }
        }