Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        //以比例尺为主
        private void checkBoxScale_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxScale.Checked)
            {
                groupBoxScale.Enabled = true;
                string             str_Exp = "select 描述,代码 from 比例尺代码表";
                GeoDataCenterDbFun dbfun   = new GeoDataCenterDbFun();
                DataTable          dt      = dbfun.GetDataTableFromMdb(m_con, str_Exp);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    comboBoxScale.Items.Add(dt.Rows[i][0] + "(" + dt.Rows[i][1] + ")");
                }
                if (comboBoxScale.Items.Count > 0)
                {
                    comboBoxScale.SelectedIndex = 0;
                }
            }

            else
            {
                groupBoxScale.Enabled = false;

                comboBoxScale.Items.Clear();
                comboBoxScale.Text = "";
            }
        }
Esempio n. 3
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;
            }
        }
Esempio n. 4
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] + ")";
        }
Esempio n. 5
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);
            }
        }
Esempio n. 6
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]["文档名称"] });
            }
        }
Esempio n. 7
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);
        }
Esempio n. 8
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;
            }
        }
Esempio n. 9
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 });
            }
        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
0
        //下载文档
        private void btn_Export_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;
            }
            SysCommon.CProgress vProgress = new SysCommon.CProgress("正在下载选中文档");
            try
            {
                FolderBrowserDialog dlg = new FolderBrowserDialog();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    //初始化进度条

                    vProgress.EnableCancel    = false;
                    vProgress.ShowDescription = true;
                    vProgress.FakeProgress    = true;
                    vProgress.TopMost         = true;
                    vProgress.ShowProgress();

                    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]["文档类型"];
                            string    filepath = dlg.SelectedPath + "\\" + cellvalue + "." + dt.Rows[0]["文档类型"];
                            if (File.Exists(dir))
                            {
                                File.Copy(dir, filepath, true);
                            }
                        }
                    }
                    vProgress.Close();
                    MessageBox.Show("下载成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Activate();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                vProgress.Close();
                this.Activate();
            }
        }
Esempio n. 13
0
        //显示全部数据
        private void LoadGridView(CProgress vprocess)//重载加载数据函数
        {
            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;//默认选择第一个
            }
            string player    = "";
            string sourename = comboBoxSource.Text.Trim();

            strExp = "select * from 数据编码表 where 数据源名称='" + sourename + "'";
            DataTable dt = db.GetDataTableFromMdb(strCon, strExp);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strExp = "select 字段名称 from 图层命名规则表";
                string   strname   = db.GetInfoFromMdbByExp(strCon, strExp);
                string[] arrName   = strname.Split('+');  //分离字段名称
                string   layername = "";
                player = "";
                for (int j = 0; j < arrName.Length; j++)
                {
                    switch (arrName[j])
                    {
                    case "业务大类代码":
                        layername += dt.Rows[i]["业务大类代码"].ToString();        //业务大类代码
                        break;

                    case "年度":
                        layername += dt.Rows[i]["年度"].ToString();        //年度
                        break;

                    case "业务小类代码":
                        layername += dt.Rows[i]["业务小类代码"].ToString();        //业务小类代码
                        break;

                    case "行政代码":
                        layername += dt.Rows[i]["行政代码"].ToString();        //行政代码
                        break;

                    case "比例尺":
                        layername += dt.Rows[i]["比例尺"].ToString();        //比例尺
                        break;
                    }
                }
                layername += dt.Rows[i]["图层代码"].ToString();
                strExp     = "select 描述 from 标准图层信息表 where 代码='" + dt.Rows[i]["图层代码"].ToString() + "'";
                string playername = db.GetInfoFromMdbByExp(strCon, strExp);
                if (playername != "")
                {
                    player = playername;
                }
                else
                {
                    player = dt.Rows[i]["图层代码"].ToString();
                }
                string username = GetSourceUser(comboBoxSource.Text).Trim().ToUpper();;
                if (username != "")
                {
                    layername = username + "." + layername;
                }
                datagwSource.Rows.Add(new object[] { true, layername, player });
            }
            //IWorkspaceFactory Pwf = new FileGDBWorkspaceFactoryClass();
            //pWorkspace = (IWorkspace)(Pwf.OpenFromFile(comboBoxSource.Text, 0));
            //IEnumDataset enumDataset = pWorkspace.get_Datasets(esriDatasetType.esriDTFeatureClass) as IEnumDataset;
            //IDataset dataset = enumDataset.Next();
            ////遍历mdb的每一个独立要素类
            //while (dataset != null)
            //{

            //    IFeatureClass pFeatureClass = dataset as IFeatureClass;
            //    player = pFeatureClass.AliasName.Substring(15);
            //strExp = "select 描述 from 标准图层信息表 where 代码='" + player + "'";
            //string playername = db.GetInfoFromMdbByExp(strCon, strExp);
            //if (playername != "")
            //    player = playername;
            //datagwSource.Rows.Add(new object[] { true, pFeatureClass.AliasName, player });
            //dataset = enumDataset.Next();
            //}
        }