Example #1
0
 //修改数据库中数据
 public void EditSql(string data1, string data2)
 {
     try
     {
         AnalyseDataToArray(data1);
         GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
         string mypath = dIndex.GetDbInfo();
         string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
         string strExp = string.Format("select ID from 数据编码表 where 业务大类代码='{0}' and 年度='{1}' and 业务小类代码='{2}'and 行政代码='{3}' and 比例尺='{4}' and 图层代码='{5}' and 数据源名称='6'",
                                       array[0], array[1], array[2], array[3], array[4], array[5], comboBoxSource.Text.Trim());
         GeoDataCenterDbFun dDbFun = new GeoDataCenterDbFun();
         int id1 = dDbFun.GetIDFromMdb(strCon, strExp);
         AnalyseDataToArray(data2);
         if (id1 != 0)
         {
             strExp = string.Format("update 数据编码表 set 业务大类代码='{0}',年度='{1}',业务小类代码='{2}',行政代码='{3}',比例尺='{4}',图层代码='{5}' where ID={6}",
                                    array[0], array[1], array[2], array[3], array[4], array[5], id1);
         }
         dDbFun.ExcuteSqlFromMdb(strCon, strExp);                                     //更新数据编码表
         dDbFun.UpdateMdbInfoTable(array[0], array[1], array[2], array[3], array[4]); //更新地图入库信息表
     }
     catch (System.Exception e)
     {
         MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private void frmRasterDataReduction_Load(object sender, EventArgs e)
        {
            SysCommon.CProgress vProgress = new SysCommon.CProgress("正在加载数据");
            vProgress.EnableCancel    = false;
            vProgress.ShowDescription = true;
            vProgress.FakeProgress    = true;
            vProgress.TopMost         = true;
            vProgress.ShowProgress();
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             strExp   = "select 数据源名称 from 物理数据源表";
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            List <string>      list     = db.GetDataReaderFromMdb(strCon, strExp);

            for (int i = 0; i < list.Count; i++)
            {
                comboBoxSource.Items.Add(list[i]);//加载数据源列表框
            }
            if (list.Count > 0)
            {
                comboBoxSource.SelectedIndex = 0;//默认选择第一个
            }
            vProgress.Close();
            this.Activate();
        }
Example #3
0
        private void comboBoxArea_Click(object sender, EventArgs e)
        {
            GeoDataCenterDbFun   dbfun  = new GeoDataCenterDbFun();
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string          mypath      = dIndex.GetDbInfo();
            string          strCon      = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            frmDataUnitTree frm         = new frmDataUnitTree();                                                                                                    //初始化数据单元树窗体

            frm.Location = new Point(this.Location.X + 45, this.Location.Y + 140);
            frm.flag     = 2;
            frm.ShowDialog();
            if (Node != null)//传回的Node不是NULL
            {
                if (Convert.ToInt32(Node.Tag) != 0)
                {
                    string strExp = "select 行政代码 from 数据单元表 where 行政名称='" + Node.Text + "'  and 数据单元级别='" + Node.Tag + "'";
                    string code   = dbfun.GetInfoFromMdbByExp(strCon, strExp);
                    comboBoxArea.Text = Node.Text + "(" + code + ")";//为数据单元box显示数据
                }
                else
                {
                    comboBoxArea.Text = Node.Text;//为数据单元box显示数据
                }
            }
        }
Example #4
0
        private void ChangeComboxSub()
        {
            comboBoxSub.Items.Clear();
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             strExp   = "";
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();

            comboBoxSub.Items.Add("所有小类业务");
            if (m_state[3] != 0)
            {
                string   strall   = comboBoxBig.Items[m_state[3]].ToString();
                string[] BigClass = strall.Split('(', ')');
                strExp = "select 描述,业务小类代码 from 业务小类代码表 where 业务大类代码='" + BigClass[1] + "'";
                DataTable dt = db.GetDataTableFromMdb(strCon, strExp);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    comboBoxSub.Items.Add(dt.Rows[i]["描述"] + "(" + dt.Rows[i]["业务小类代码"] + ")");
                }
            }
            if (comboBoxSub.Items.Count > 0)
            {
                comboBoxSub.SelectedIndex = 0;
            }
        }
Example #5
0
        /// <summary>
        ///  加载列表框text
        /// </summary>
        /// <param name="cb">列表框</param>
        /// <param name="str">需要执行的SQL语句</param>
        private void LoadComboxText(ComboBox cb, string str)
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            DataTable          dt       = db.GetDataTableFromMdb(strCon, str);

            cb.Text = dt.Rows[0][0] + "(" + dt.Rows[0][1] + ")";
        }
Example #6
0
        //------------------------------------------
        //功能:根据传递的值更新地图入库信息表
        //作者:席胜
        //时间:2011-03-10
        //实现:
        //-------------------------------------------
        public void UpdateMdbInfoTable(string strBusness, string strYear, string strType, string strArea, string strScale)
        {
            string Layers = "";
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string mypath = dIndex.GetDbInfo();
            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
            string strExp = "";

            strExp = string.Format("select 图层代码 from 数据编码表 where 业务大类代码='{0}' and 年度='{1}' and 行政代码='{2}' and 比例尺='{3}'",
                                   strBusness, strYear, strArea, strScale);
            DataTable dt1 = GetDataTableFromMdb(strCon, strExp);

            strExp = "select * from 标准专题信息表";
            DataTable dt2 = GetDataTableFromMdb(strCon, strExp);

            for (int i = 0; i < dt2.Rows.Count; i++)//第一层循环标准图层
            {
                Layers = "";
                for (int j = 0; j < dt1.Rows.Count; j++)                                                         //第二层循环循环判断入库图层代码中有没有是关键图层的
                {
                    if (dt2.Rows[i]["关键图层"].ToString().Equals("") || dt1.Rows[j][0].Equals(dt2.Rows[i]["关键图层"])) //若是关键图层
                    {
                        for (int k = 0; k < dt1.Rows.Count; k++)                                                 //第三层循环入库图层中包含在该专题图层组成中的
                        {
                            if (GetExists(dt1.Rows[k][0].ToString(), dt2.Rows[i]["图层组成"].ToString()))
                            {
                                Layers += dt1.Rows[k][0].ToString() + "/";
                            }
                        }
                        j = dt1.Rows.Count; //终止第二层循环
                    }
                }
                if (Layers != "")
                {
                    Layers = Layers.Substring(0, Layers.LastIndexOf("/"));
                }
                //判断地图入库信息表 中是否存在该记录 存在就更新 不存在就填写
                strExp = string.Format("select * from 地图入库信息表 where 专题类型='{0}' and 年度='{1}' and 行政代码='{2}' and 比例尺='{3}'", dt2.Rows[i]["专题类型"].ToString(), strYear, strArea, strScale);
                int iReturn = ExcuteSqlFromMdbEx(strCon, strExp);
                if (iReturn == -1)
                {
                    string strBuffer = "select 行政名称 from 数据单元表 where 行政代码 ='" + strArea + "'";
                    string strXzName = GetInfoFromMdbByExp(strCon, strBuffer);

                    strExp = string.Format("insert into 地图入库信息表(专题类型,年度,行政代码,行政名称,比例尺,图层组成) values('{0}','{1}','{2}','{3}','{4}','{5}')", dt2.Rows[i]["专题类型"].ToString(), strYear, strArea, strXzName, strScale, Layers);
                }
                else
                {
                    strExp = "update 地图入库信息表 set 图层组成='" + Layers + "' where 专题类型='" + dt2.Rows[i]["专题类型"].ToString() + "' And 行政代码 ='" + strArea + "' And 年度='" +
                             strYear + "'And  比例尺='" + strScale + "'";
                }

                ExcuteSqlFromMdb(strCon, strExp);  //执行更新
            }
        }
Example #7
0
        //删除文档
        private void btn_Del_Click(object sender, EventArgs e)
        {
            bool flag = false;
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            string             strExp   = "select 路径 from 文档数据源信息表 where 虚拟目录名='" + comboBoxCatalog.Text + "'";
            string             path     = db.GetInfoFromMdbByExp(strCon, strExp);

            foreach (DataGridViewRow row in datagwSource.Rows)
            {
                if ((bool)row.Cells[0].EditedFormattedValue == true)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                MessageBox.Show("没有选中行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                string cellvalue = "";
                foreach (DataGridViewRow row in datagwSource.Rows)
                {
                    if ((bool)row.Cells[0].EditedFormattedValue == true)
                    {
                        cellvalue = row.Cells[1].Value.ToString().Trim();
                        strExp    = "select * from 文档入库信息表 where 文档名称='" + cellvalue + "' and 文档虚拟目录='" + comboBoxCatalog.Text + "'";
                        DataTable dt  = db.GetDataTableFromMdb(strCon, strExp);
                        string    dir = path + "\\" + dt.Rows[0]["年度"] + dt.Rows[0]["专题类型"] + dt.Rows[0]["行政代码"] + "\\" + cellvalue + "." + dt.Rows[0]["文档类型"];
                        if (File.Exists(dir))
                        {
                            File.Delete(dir);
                            dir = dir.Substring(0, dir.LastIndexOf("\\"));
                            if (Directory.GetFiles(dir).Length == 0)//如果该目录中没有其他文档,则删除该目录
                            {
                                Directory.Delete(dir);
                            }
                            strExp = "delete * from 文档入库信息表 where 文档名称='" + cellvalue + "' and 文档虚拟目录='" + comboBoxCatalog.Text + "'";
                            db.ExcuteSqlFromMdb(strCon, strExp);
                        }
                    }
                }
                datagwSource.Rows.Clear();
                LoadGridView();//重新加载数据
                MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #8
0
        public string GetDescrib(string str)
        {
            GetDataTreeInitIndex dIndex  = new GetDataTreeInitIndex();
            string             mypath    = dIndex.GetDbInfo();
            string             strCon    = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp    = "select 描述 from 标准图层信息表 where 代码='" + str + "'";
            GeoDataCenterDbFun db        = new GeoDataCenterDbFun();
            string             strreturn = db.GetInfoFromMdbByExp(strCon, strExp);

            return(strreturn);
        }
Example #9
0
        //加载列表框
        private void LoadCombox()
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             str_Exp  = "select 年度 from 数据编码表";
            GeoDataCenterDbFun dbfun    = new GeoDataCenterDbFun();
            List <string>      list     = dbfun.GetDataReaderFromMdb(strCon, str_Exp);

            comboBoxYear.Items.Add("所有年度");
            for (int i = 0; i < list.Count; i++)
            {
                if (!comboBoxYear.Items.Contains(list[i]))
                {
                    comboBoxYear.Items.Add(list[i]);
                }
            }
            if (comboBoxYear.Items.Count > 0)
            {
                comboBoxYear.SelectedIndex = 0;
            }
            //str_Exp = "select 行政名称,行政代码 from 数据单元表";
            //DataTable dt = dbfun.GetDataTableFromMdb(strCon, str_Exp);
            //comboBoxArea.Items.Add("所有行政区");
            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    comboBoxArea.Items.Add(dt.Rows[i]["行政名称"] + "(" + dt.Rows[i]["行政代码"] + ")");
            //}
            //if (comboBoxArea.Items.Count > 0)
            //    comboBoxArea.SelectedIndex = 0;
            str_Exp = "select 描述,代码 from 比例尺代码表";
            DataTable dt = dbfun.GetDataTableFromMdb(strCon, str_Exp);

            comboBoxScale.Items.Add("所有比例尺");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBoxScale.Items.Add(dt.Rows[i]["描述"] + "(" + dt.Rows[i]["代码"] + ")");
            }
            if (comboBoxScale.Items.Count > 0)
            {
                comboBoxScale.SelectedIndex = 0;
            }
            str_Exp = "select 描述,专题类型 from 标准专题信息表";
            dt      = dbfun.GetDataTableFromMdb(strCon, str_Exp);
            comboBoxSub.Items.Add("所有专题类型");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBoxSub.Items.Add(dt.Rows[i]["描述"] + "(" + dt.Rows[i]["专题类型"] + ")");
            }
            if (comboBoxSub.Items.Count > 0)
            {
                comboBoxSub.SelectedIndex = 0;
            }
        }
Example #10
0
        //删除数据库中数据
        public void DeleteSql(string data)
        {
            try
            {
                AnalyseDataToArray(data);
                GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
                string mypath = dIndex.GetDbInfo();
                string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
                string strExp = string.Format("delete from 数据编码表 where 业务大类代码='{0}' and 年度='{1}' and 业务小类代码='{2}'and 行政代码='{3}' and 比例尺='{4}' and 图层代码='{5}' and 数据源名称='{6}'",
                                              array[0], array[1], array[2], array[3], array[4], array[5], comboBoxSource.Text.Trim());
                GeoDataCenterDbFun dDbFun = new GeoDataCenterDbFun();
                dDbFun.ExcuteSqlFromMdb(strCon, strExp);

                //从数据编码表更新入库信息表
                dDbFun.UpdateMdbInfoTable(array[0], array[1], array[2], array[3], array[4]);

                //从代码更新入库信息表
                #region
                //strExp = "select 图层组成 from 地图入库信息表 where 业务大类代码='" + array[0] + "' And 行政代码 ='" + array[3] + "' And 年度='" +
                //    array[1] + "'And  比例尺='" + array[4] + "'And 业务小类代码='" + array[2] + "'";
                //string layers = dDbFun.GetInfoFromMdbByExp(strCon, strExp);
                //if (!layers.Contains('/'.ToString()))
                //{
                //    if (layers.Trim() != array[5])
                //        return;
                //    else
                //        layers = "";
                //}
                //else
                //{
                //    string[] layer = layers.Split('/');
                //    for (int i = 0; i < layer.Length; i++)
                //    {
                //        if (layer[i].Trim() == array[5])
                //        {
                //            if (i == 0)
                //            {
                //                layers = layers.Substring(array[5].Length + 1);
                //            }
                //            else
                //                layers = layers.Replace('/' + layer[i], "");
                //        }
                //    }
                //}
                //strExp = "update 地图入库信息表 set 图层组成='" + layers + "' where 业务大类代码='" + array[0] + "' And 行政代码 ='" + array[3] + "' And 年度='" +
                //    array[1] + "'And  比例尺='" + array[4] + "'And 业务小类代码='" + array[2] + "'";
                //dDbFun.ExcuteSqlFromMdb(strCon, strExp);
                #endregion
            }
            catch (System.Exception e)
            {
                //  MessageBox.Show(e.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #11
0
 private void comboBoxSource_TextChanged(object sender, EventArgs e)
 {
     textBoxPath.Text = "";
     if (comboBoxSource.Text.Trim() != "")
     {
         GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
         string             strExp   = "select 路径 from 文档数据源信息表 where 虚拟目录名='" + comboBoxSource.Text + "'";
         string             mypath   = dIndex.GetDbInfo();
         string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
         GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
         textBoxPath.Text = db.GetInfoFromMdbByExp(strCon, strExp);
     }
 }
Example #12
0
        //
        private void btnApply_Click(object sender, EventArgs e)
        {
            frmDataUpload frm = new frmDataUpload();

            if (textBoxDescri.Text.Trim() == "")
            {
                MessageBox.Show("图层描述不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             strExp   = "";
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();

            strExp = string.Format("insert into 标准图层信息表(代码,描述,业务大类代码,业务小类代码) values('{0}','{1}','{2}','{3}')",
                                   comboBoxCode.Text, textBoxDescri.Text, GetCode(comboBoxBig.Text), GetCode(comboBoxSub.Text));
            db.ExcuteSqlFromMdb(strCon, strExp);
            comboBoxCode.Items.Remove(comboBoxCode.Text);
            if (comboBoxCode.Items.Count == 0)
            {
                comboBoxCode.Text = "";
                btnApply.Enabled  = false;
            }
            else
            {
                comboBoxCode.SelectedIndex = 0;
            }
            textBoxDescri.Text = "";

            foreach (ListViewItem item in m_listview.Items)
            {
                string strName = item.SubItems[1].Text;
                if (strName.Length > 15)
                {
                    string strforward = strName.Substring(0, 15);
                    strName = strName.Substring(15);
                    item.SubItems[1].Text = frm.GetForwadName(strforward, strName);
                }
                string strdescri = GetDescrib(strName);
                if (strdescri.Trim() != "")
                {
                    item.SubItems[2].Text = strdescri;
                }
                else
                {
                    item.SubItems[2].Text = "需要新增";
                }
            }
            m_listview.Refresh();
        }
Example #13
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                string strtype     = "";
                string stryear     = "";
                string strareaname = "";
                string strscale    = "";
                string sourepath   = "";

                for (int i = 0; i < dataGridView.Rows.Count; i++)
                {
                    sourepath = dataGridView.Rows[i].Cells["Column5"].Value.ToString();//数据源
                    if (sourepath == "")
                    {
                        continue;
                    }
                    strtype     = dataGridView.Rows[i].Cells["Column1"].Value.ToString(); //专题类型
                    stryear     = dataGridView.Rows[i].Cells["Column2"].Value.ToString(); //年度
                    strareaname = dataGridView.Rows[i].Cells["Column4"].Value.ToString(); //行政单元
                    strscale    = dataGridView.Rows[i].Cells["Column7"].Value.ToString(); //比例尺

                    if (index == 0)
                    {
                        GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
                        string mypath = dIndex.GetDbInfo();
                        string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
                        string strExp = string.Format("update 地图入库信息表 set 影像库='{0}' where 专题类型='{1}' and 年度='{2}' and 行政名称='{3}' and 比例尺='{4}' ",
                                                      sourepath, strtype, stryear, strareaname, strscale);
                        GeoDataCenterDbFun db = new GeoDataCenterDbFun();
                        db.ExcuteSqlFromMdb(strCon, strExp);
                    }
                    else
                    {
                        GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
                        string mypath = dIndex.GetDbInfo();
                        string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
                        string strExp = string.Format("update 地图入库信息表 set 文档库='{0}' where 专题类型='{1}' and 年度='{2}' and 行政名称='{3}' and 比例尺='{4}' ",
                                                      sourepath, strtype, stryear, strareaname, strscale);
                        GeoDataCenterDbFun db = new GeoDataCenterDbFun();
                        db.ExcuteSqlFromMdb(strCon, strExp);
                    }
                }
                MessageBox.Show("信息已保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #14
0
        private void LoadGridView()
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select * from 文档入库信息表";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            DataTable          dt       = db.GetDataTableFromMdb(strCon, strExp);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                datagwSource.Rows.Add(new object[] { true, dt.Rows[i]["文档名称"] });
            }
        }
Example #15
0
 //得到数据库用户
 private string GetSourceUser(string str)
 {
     try
     {
         GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
         string             mypath   = dIndex.GetDbInfo();
         string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
         string             strExp   = "select 用户 from 物理数据源表 where 数据源名称='" + str + "'";
         GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
         string             strname  = db.GetInfoFromMdbByExp(strCon, strExp);
         return(strname);
     }
     catch { return(""); }
 }
Example #16
0
        //修改
        private void datagwSource_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex != 1)
            {
                return;
            }
            //IWorkspaceFactory Pwf = new FileGDBWorkspaceFactoryClass();
            //pWorkspace = (IWorkspace)(Pwf.OpenFromFile(GetSourcePath(comboBoxSource.Text), 0));
            pWorkspace = GetWorkspace(comboBoxSource.Text);
            if (pWorkspace != null)
            {
                pWorkspace2 = (IWorkspace2)pWorkspace;
                m_endstr    = datagwSource.Rows[e.RowIndex].Cells[1].Value.ToString();
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_endstr))
                {
                    MessageBox.Show("命名名称已存在,请修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    datagwSource.Rows[e.RowIndex].Cells[1].Value = m_startstr;
                    return;
                }
                if (pWorkspace2.get_NameExists(esriDatasetType.esriDTFeatureClass, m_startstr))
                {
                    IFeatureClass     tmpfeatureclass;
                    IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pWorkspace;
                    tmpfeatureclass = pFeatureWorkspace.OpenFeatureClass(m_startstr);
                    IDataset set = tmpfeatureclass as IDataset;
                    set.Rename(m_endstr);
                    EditSql(m_startstr, m_endstr);

                    //更改代码 实时更新图层描述
                    GetDataTreeInitIndex dIndex   = new GetDataTreeInitIndex();
                    string             mypath     = dIndex.GetDbInfo();
                    string             strCon     = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
                    string             player     = m_endstr.Substring(15);                                                                                                   //图层组成
                    string             strExp     = "select 描述 from 标准图层信息表 where 代码='" + player + "'";
                    GeoDataCenterDbFun db         = new GeoDataCenterDbFun();
                    string             playername = db.GetInfoFromMdbByExp(strCon, strExp);
                    if (playername != "")
                    {
                        datagwSource.Rows[e.RowIndex].Cells[2].Value = playername;
                    }

                    //listBoxDetail.Items.Add("将" + m_startstr);
                    //listBoxDetail.Items.Add("改为" + m_endstr);
                    //listBoxDetail.Items.Add(" ");
                    MessageBox.Show("修改数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Example #17
0
        /// <summary>
        /// 将前缀按照标准表规则化,并组织
        /// </summary>
        /// <param name="str1">前缀</param>
        /// <param name="str2">图层</param>
        /// <returns></returns>
        public string GetForwadName(string str1, string str2)
        {
            AnalyseDataToArray(str1);
            str1 = "";
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select 业务大类代码,业务小类代码 from 标准图层信息表 where 代码='" + str2 + "'";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            DataTable          dt       = db.GetDataTableFromMdb(strCon, strExp);

            if (dt.Rows.Count > 0)
            {
                array[0] = dt.Rows[0]["业务大类代码"].ToString();
                array[2] = dt.Rows[0]["业务小类代码"].ToString();
            }
            strExp = "select 字段名称 from 图层命名规则表";
            string strname = db.GetInfoFromMdbByExp(strCon, strExp);

            string[] arrName = strname.Split('+');//分离字段名称
            for (int i = 0; i < arrName.Length; i++)
            {
                switch (arrName[i])
                {
                case "业务大类代码":
                    str1 += array[0];
                    break;

                case "年度":
                    str1 += array[1];
                    break;

                case "业务小类代码":
                    str1 += array[2];
                    break;

                case "行政代码":
                    str1 += array[3];
                    break;

                case "比例尺":
                    str1 += array[4];
                    break;
                }
            }
            str1 += str2;
            return(str1);
        }
Example #18
0
        //列表框状态改变
        private void ChangeGridView()
        {
            datagwSource.Rows.Clear();
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             str_Exp  = "select 文档名称 from 文档入库信息表 where 文档虚拟目录='" + comboBoxCatalog.Text + "' ";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();

            if (Node != null && Convert.ToInt32(Node.Tag) != 0)//如果选择的不是所有行政区
            {
                switch (Convert.ToInt32(Node.Tag))
                {
                case 1:
                    string code = GetCode(comboBoxArea.Text).Substring(0, 3);
                    str_Exp += "and 行政代码 like '" + code + "___'";
                    break;

                case 2:
                    code     = GetCode(comboBoxArea.Text).Substring(0, 4);
                    str_Exp += "and 行政代码 like '" + code + "__'";
                    break;

                case 3:
                    str_Exp += "and 行政代码='" + GetCode(comboBoxArea.Text) + "'";
                    break;
                }
            }
            if (comboBoxScale.SelectedIndex > 0)//如果选择的不是所有比例尺
            {
                str_Exp += "and 比例尺 ='" + GetCode(comboBoxScale.Text) + "'";
            }
            if (comboBoxSub.SelectedIndex > 0)//如果选择的不是所有专题类型
            {
                str_Exp += "and 专题类型='" + GetCode(comboBoxSub.Text) + "'";
            }
            if (comboBoxYear.SelectedIndex > 0)//如果选择的不是所有年度
            {
                str_Exp += "and 年度='" + comboBoxYear.Text + "'";
            }

            List <string> list = db.GetDataReaderFromMdb(strCon, str_Exp);

            for (int i = 0; i < list.Count; i++)
            {
                datagwSource.Rows.Add(new object[] { true, list[i] });
            }
        }
Example #19
0
        /// <summary>
        /// 将数据分析成字符串数组
        /// </summary>
        /// <param name="filename">数据名称</param>
        public void AnalyseDataToArray(string filename)
        {
            if (filename.Contains("."))//针对SDE 用户名.图层名格式的
            {
                filename = filename.Substring(filename.LastIndexOf(".") + 1);
            }
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select 字段名称 from 图层命名规则表";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            string             strname  = db.GetInfoFromMdbByExp(strCon, strExp);

            string[] arrName = strname.Split('+');//分离字段名称
            for (int i = 0; i < arrName.Length; i++)
            {
                switch (arrName[i])
                {
                case "业务大类代码":
                    array[0] = filename.Substring(0, 2);    //业务大类代码
                    filename = filename.Remove(0, 2);
                    break;

                case "年度":
                    array[1] = filename.Substring(0, 4);    //年度
                    filename = filename.Remove(0, 4);
                    break;

                case "业务小类代码":
                    array[2] = filename.Substring(0, 2);    //业务小类代码
                    filename = filename.Remove(0, 2);
                    break;

                case "行政代码":
                    array[3] = filename.Substring(0, 6);    //行政代码
                    filename = filename.Remove(0, 6);
                    break;

                case "比例尺":
                    array[4] = filename.Substring(0, 1);    //比例尺
                    filename = filename.Remove(0, 1);
                    break;
                }
            }
            array[5] = filename;//图层组成
        }
Example #20
0
        /// <summary>
        /// 加载列表框,名称在前,代码在后
        /// </summary>
        /// <param name="cb">列表框</param>
        /// <param name="str">需要执行的SQL语句</param>
        private void LoadData2(ComboBox cb, string str)
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            DataTable          dt       = db.GetDataTableFromMdb(strCon, str);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                cb.Items.Add(dt.Rows[i][0] + "(" + dt.Rows[i][1] + ")");
            }
            if (cb.Items.Count != 0)
            {
                cb.SelectedIndex = 0;
            }
        }
Example #21
0
        private void LoadGirdViewRatster()
        {
            GetDataTreeInitIndex dIndex   = new GetDataTreeInitIndex();
            string                 mypath = dIndex.GetDbInfo();
            string                 strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串
            string                 strExp = "select * from 地图入库信息表";
            GeoDataCenterDbFun     db     = new GeoDataCenterDbFun();
            DataTable              dt     = db.GetDataTableFromMdb(strCon, strExp);
            DataGridViewButtonCell cell   = new DataGridViewButtonCell();

            cell.Value = "...";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strExp = "select 描述 from  标准专题信息表 where 专题类型='" + dt.Rows[i]["专题类型"].ToString() + "'";
                string name = db.GetInfoFromMdbByExp(strCon, strExp);
                dataGridView.Rows.Add(new object[] { dt.Rows[i]["专题类型"].ToString(), name, dt.Rows[i]["年度"].ToString(), dt.Rows[i]["行政名称"].ToString(), dt.Rows[i]["比例尺"].ToString(), dt.Rows[i]["影像库"].ToString(), cell });
            }
        }
Example #22
0
        private void LoadComboBox()
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             strExp   = "select 虚拟目录名 from 文档数据源信息表";
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            List <string>      list     = db.GetDataReaderFromMdb(strCon, strExp);

            for (int i = 0; i < list.Count; i++)
            {
                comboBoxSource.Items.Add(list[i]);//加载数据源列表框
            }
            if (list.Count > 0)
            {
                comboBoxSource.SelectedIndex = 0;//默认选择第一个
            }
        }
Example #23
0
        private void LoadComBig()
        {
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             strExp   = "";
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();

            strExp = "select 描述,代码 from 业务大类代码表";
            DataTable dt = db.GetDataTableFromMdb(strCon, strExp);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                comboBoxBig.Items.Add(dt.Rows[i]["描述"] + "(" + dt.Rows[i]["代码"] + ")");
            }
            if (comboBoxBig.Items.Count > 0)
            {
                comboBoxBig.SelectedIndex = 0;
            }
        }
Example #24
0
        /// <summary>
        /// 得到数据库空间 Added by xisheng 2011.04.28
        /// </summary>
        /// <param name="str">数据源名称</param>
        /// <returns>工作空间</returns>
        private IWorkspace GetWorkspace(string str)
        {
            try
            {
                IWorkspace           pws    = null;
                GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
                string             mypath   = dIndex.GetDbInfo();
                string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
                string             strExp   = "select * from 物理数据源表 where 数据源名称='" + str + "'";
                GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
                DataTable          dt       = db.GetDataTableFromMdb(strCon, strExp);
                string             type     = dt.Rows[0]["数据源类型"].ToString();
                if (type.Trim() == "GDB")
                {
                    IWorkspaceFactory pWorkspaceFactory;
                    pWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
                    pws = pWorkspaceFactory.OpenFromFile(dt.Rows[0]["数据库"].ToString(), 0);
                }
                else if (type.Trim() == "SDE")
                {
                    IWorkspaceFactory pWorkspaceFactory;
                    pWorkspaceFactory = new SdeWorkspaceFactoryClass();

                    //PropertySet
                    IPropertySet pPropertySet;
                    pPropertySet = new PropertySetClass();
                    pPropertySet.SetProperty("Server", dt.Rows[0]["服务器"].ToString());
                    pPropertySet.SetProperty("Database", dt.Rows[0]["数据库"].ToString());
                    pPropertySet.SetProperty("Instance", "5151");//"port:" + txtService.Text
                    pPropertySet.SetProperty("user", dt.Rows[0]["用户"].ToString());
                    pPropertySet.SetProperty("password", dt.Rows[0]["密码"].ToString());
                    pPropertySet.SetProperty("version", "sde.DEFAULT");
                    pws = pWorkspaceFactory.Open(pPropertySet, 0);
                }
                return(pws);
            }
            catch
            {
                return(null);
            }
        }
Example #25
0
        //窗口加载
        private void frmAnalyseInLibMap_Load(object sender, EventArgs e)
        {
            checkBoxDelold.Checked = true;
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string mypath = dIndex.GetDbInfo();

            m_con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据库字符串
            GeoDataCenterDbFun db     = new GeoDataCenterDbFun();
            string             strExp = "select 数据源名称 from 物理数据源表";
            List <string>      list   = db.GetDataReaderFromMdb(m_con, strExp);

            for (int i = 0; i < list.Count; i++)
            {
                comboBoxSource.Items.Add(list[i]);//加载数据源列表框
            }
            if (list.Count > 0)
            {
                comboBoxSource.SelectedIndex = 0;//默认选择第一个
            }
            //m_path = GetSourcePath(comboBoxSource.Text.Trim());
        }
Example #26
0
        /// <summary>
        /// 加载列表框,年度,数据源
        /// </summary>
        /// <param name="cb">列表框</param>
        /// <param name="str">需要执行的SQL语句</param>
        private void LoadData(ComboBox cb, string str)
        {
            List <string>        list   = new List <string>();
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string mypath = dIndex.GetDbInfo();
            string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据

            GeoDataCenterDbFun db = new GeoDataCenterDbFun();

            list = db.GetDataReaderFromMdb(strCon, str);
            for (int i = 0; i < list.Count; i++)
            {
                if (!cb.Items.Contains(list[i]))
                {
                    cb.Items.Add(list[i]);
                }
            }
            if (cb.Items.Count != 0)
            {
                cb.SelectedIndex = 0;
            }
        }
Example #27
0
        /// <summary>
        /// 组织前缀 added by xs 20110415
        /// </summary>
        /// <param name="str1">业务大类</param>
        /// <param name="str2">年度</param>
        /// <param name="str3">业务小类</param>
        /// <param name="str4">行政代码</param>
        /// <param name="str5">比例尺</param>
        /// <returns></returns>
        public string GetLayerName(string str1, string str2, string str3, string str4, string str5)
        {
            string layername            = "";
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select 字段名称 from 图层命名规则表";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            string             strname  = db.GetInfoFromMdbByExp(strCon, strExp);

            string[] arrName = strname.Split('+');//分离字段名称
            for (int i = 0; i < arrName.Length; i++)
            {
                switch (arrName[i])
                {
                case "业务大类代码":
                    layername += str1;
                    break;

                case "年度":
                    layername += str2;
                    break;

                case "业务小类代码":
                    layername += str3;
                    break;

                case "行政代码":
                    layername += str4;
                    break;

                case "比例尺":
                    layername += str5;
                    break;
                }
            }
            return(layername);
        }
Example #28
0
 //删除数据源
 private void btnDel_Click(object sender, EventArgs e)
 {
     try
     {
         if (!ComBoxName.Items.Contains(ComBoxName.Text))
         {
             MessageBox.Show("虚拟目录名不存在,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         if (!GetVirtualDirectory(constIISWebSiteRoot, ComBoxName.Text))
         {
             MessageBox.Show("虚拟目录名不存在,无法删除", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
         string mypath = dIndex.GetDbInfo();
         string strExp = "";
         string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";  //生成连接数据
         strExp = "delete * from 文档数据源信息表 where 虚拟目录名='" + ComBoxName.Text + "'";
         GeoDataCenterDbFun db = new GeoDataCenterDbFun();
         db.ExcuteSqlFromMdb(strCon, strExp);
         strExp = "delete * from 文档入库信息表 where 文档虚拟目录='" + ComBoxName.Text + "'";
         db.ExcuteSqlFromMdb(strCon, strExp);
         DirectoryEntry deRoot = new DirectoryEntry(constIISWebSiteRoot);
         deRoot.RefreshCache();
         DirectoryEntry Dirport = deRoot.Children.Find(ComBoxName.Text, "IIsWebVirtualDir");
         //deRoot.Invoke("AppDelete", true);
         deRoot.Children.Remove(Dirport);
         deRoot.CommitChanges();
         deRoot.Close();
         ComBoxName.Items.Remove(ComBoxName.Text);
         MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Example #29
0
        public static TreeNode Node;       //数据单元树返回的节点

        private void frmDocRedution_Load(object sender, EventArgs e)
        {
            Node = null;
            //初始化进度条
            SysCommon.CProgress vProgress = new SysCommon.CProgress("正在加载文档数据");
            vProgress.EnableCancel    = false;
            vProgress.ShowDescription = true;
            vProgress.FakeProgress    = true;
            vProgress.TopMost         = true;
            vProgress.ShowProgress();
            m_first = true;

            LoadGridView();
            //加载虚拟目录
            GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
            string             mypath   = dIndex.GetDbInfo();
            string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
            string             strExp   = "select 虚拟目录名 from 文档数据源信息表";
            GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
            List <string>      list     = db.GetDataReaderFromMdb(strCon, strExp);

            for (int i = 0; i < list.Count; i++)
            {
                if (!comboBoxCatalog.Items.Contains(list[i]))
                {
                    comboBoxCatalog.Items.Add(list[i]);
                }
            }
            if (comboBoxCatalog.Items.Count > 0)
            {
                comboBoxCatalog.SelectedIndex = 0;
            }

            vProgress.Close();
            this.Activate();
        }
Example #30
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (comboBoxCode.Text.Trim() != "")
            {
                if (textBoxDescri.Text.Trim() == "")
                {
                    MessageBox.Show("图层描述不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                GetDataTreeInitIndex dIndex = new GetDataTreeInitIndex();
                string             strExp   = "";
                string             mypath   = dIndex.GetDbInfo();
                string             strCon   = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mypath + ";Mode=ReadWrite|Share Deny None;Persist Security Info=False";//生成连接数据库字符串
                GeoDataCenterDbFun db       = new GeoDataCenterDbFun();
                strExp = string.Format("insert into 标准图层信息表(代码,描述,业务大类代码,业务小类代码) values('{0}','{1}','{2}','{3}')",
                                       comboBoxCode.Text, textBoxDescri.Text, GetCode(comboBoxBig.Text), GetCode(comboBoxSub.Text));
                db.ExcuteSqlFromMdb(strCon, strExp);
            }

            this.DialogResult = DialogResult.OK;
            this.Hide();
            this.Dispose(true);
        }