Пример #1
0
        //按钮的click事件
        public override void OnClick()
        {
            string pSysName    = "";  //数据中心管理子系统Name
            string pSysCaption = "";  //数据中心管理子系统Caption

            pSysName = "GeoSysUpdate.ControlSysUpdate";
            //根据Name获得子系统的caption
            XmlDocument sysXml = new XmlDocument();

            sysXml.Load(ModuleData.m_SysXmlPath);
            XmlNode sysNode = sysXml.SelectSingleNode("//Main//System[@Name='" + pSysName + "']");

            if (sysNode == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在Name为" + pSysName + "的系统");
                return;
            }
            pSysCaption = (sysNode as XmlElement).GetAttribute("Caption").Trim();  //caption

            //进入数据中心管理子系统界面
            ModDBOperate.InitialForm(pSysName, pSysCaption);

            //功能日志 enter feature Db Log
            if (ModuleData.v_SysLog != null)
            {
                List <string> Pra = new List <string>();
                ModuleData.v_SysLog.Write("进入数据库管理子系统", Pra, DateTime.Now);
            }
        }
Пример #2
0
        void Plugin.Interface.ICommandRef.OnClick()
        {
            //==================================================================================
            //  chenayfei  modify 20110215  返回主界面修改
            //
            //
            //执行返回主界面操作
            string pSysName    = ""; //子系统名称
            string pSysCaption = ""; //子系统标题

            //根据Name获得子系统的caption

            pSysName = "GeoDBIntegration.ControlDBIntegrationTool";    //Name

            XmlDocument sysXml = new XmlDocument();

            sysXml.Load(ModuleData.m_SysXmlPath);
            XmlNode sysNode = sysXml.SelectSingleNode("//Main//System[@Name='" + pSysName + "']");

            if (sysNode == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在Name为" + pSysName + "的系统");
                return;
            }
            pSysCaption = (sysNode as XmlElement).GetAttribute("Caption").Trim();  //caption

            //进入子系统界面
            ModDBOperate.InitialForm(pSysName, pSysCaption);

            //========================================================================
        }
Пример #3
0
        //进入子系统界面的函数//
        #region 进入子系统界面的函数
        /// <summary>
        /// 进入框架要素库子系统
        /// </summary>
        /// <param name="in_lFeaDataBaseID"></param>
        /// <param name="DBInfoEle"></param>
        public void EnterFeaDataBase(long in_lFeaDataBaseID, string pDBFormatID)
        {
            //string pDBID = in_lFeaDataBaseID.ToString();  //当前要启动的工程ID
            ////将当前数据库ID写入xml中
            //SaveIDToXml(pDBID, ModuleData.v_feaProjectXML, ModuleData.v_feaProjectXMLTemp);

            //==============================================================================================================================================
            //chenyafei  modify 20100215 解决系统插件加载的问题
            string pSysName    = ""; //子系统名称
            string pSysCaption = ""; //子系统标题

            // XmlElement pElem = advTreeProject.SelectedNode.Nodes[i].Tag as XmlElement;  //数据库平台节点
            //XmlElement pElem =DBInfoEle;
            //string ptStr = pElem.GetAttribute("数据库平台");   //数据库平台信息
            if (pDBFormatID == enumInterDBFormat.ARCGISGDB.GetHashCode().ToString() || pDBFormatID == enumInterDBFormat.ARCGISPDB.GetHashCode().ToString() || pDBFormatID == enumInterDBFormat.ARCGISSDE.GetHashCode().ToString())
            {
                //启动ArcGIs平台
                pSysName = "GeoDBATool.ControlDBATool";    //Name
            }
            else if (pDBFormatID == enumInterDBFormat.GEOSTARACCESS.GetHashCode().ToString() || pDBFormatID == enumInterDBFormat.GEOSTARORACLE.GetHashCode().ToString() || pDBFormatID == enumInterDBFormat.GEOSTARORSQLSERVER.GetHashCode().ToString())
            {
                //启动Geostar平台
                pSysName = "GeoStarTest.ControlTest";       //Name
            }
            else if (pDBFormatID == enumInterDBFormat.ORACLESPATIAL.GetHashCode().ToString())
            {
                //启动oraclespatial平台
                pSysName = "OracleSpatialDBTool.ControlOracleSpatialDBTool";    //Name
            }

            //根据Name获得子系统的caption
            XmlDocument sysXml = new XmlDocument();

            sysXml.Load(ModuleData.m_SysXmlPath);
            XmlNode sysNode = sysXml.SelectSingleNode("//Main//System[@Name='" + pSysName + "']");

            if (sysNode == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在Name为" + pSysName + "的系统");
                return;
            }
            pSysCaption = (sysNode as XmlElement).GetAttribute("Caption").Trim();  //caption

            //进入子系统界面
            ModDBOperate.InitialForm(pSysName, pSysCaption);

            //===================================================================================================================================================
            //*********************************************************************
            //guozheng added enter feature Db Log
            if (ModuleData.v_SysLog != null)
            {
                List <string> Pra = new List <string>();
                //Pra.Add(pElem.GetAttribute("数据库工程名"));
                //Pra.Add(pElem.GetAttribute("数据库平台"));
                //Pra.Add(pElem.GetAttribute("数据库类型"));
                //Pra.Add(pElem.GetAttribute("数据库连接信息"));
                ModuleData.v_SysLog.Write("进入框架要素库", Pra, DateTime.Now);
            }
            //*********************************************************************
        }
Пример #4
0
        /// <summary>
        /// 进入DEM高程数据库子系统
        /// </summary>
        /// <param name="in_lDemDataBaseID"></param>
        /// <param name="DBInfoEle"></param>
        public void EnterDemDataBase(long in_lDemDataBaseID)
        {
            //将当前数据库ID写入xml中
            //string pDBID = in_lDemDataBaseID.ToString();
            ////cyf 201106058 modify
            ////SaveIDToXml(pDBID, ModuleData.v_DEMProjectXml, ModuleData.v_DEMProjectXmlTemp);
            //SaveIDToXml(pDBID, ModuleData.v_feaProjectXML, ModuleData.v_feaProjectXMLTemp);
            //end
            //高程数据库界面
            //==================================================================================
            //  chenayfei  modify 20110215  进入子系统界面修改
            string pSysName    = ""; //子系统名称
            string pSysCaption = ""; //子系统标题

            //根据Name获得子系统的caption
            pSysName = "GeoDBATool.ControlDBATool";// "GeoDBContour.ControlDBContourTool";    //Name
            XmlDocument sysXml = new XmlDocument();

            sysXml.Load(ModuleData.m_SysXmlPath);
            XmlNode sysNode = sysXml.SelectSingleNode("//Main//System[@Name='" + pSysName + "']");

            if (sysNode == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在Name为" + pSysName + "的系统");
                return;
            }
            pSysCaption = (sysNode as XmlElement).GetAttribute("Caption").Trim();  //caption

            //进入子系统界面
            ModDBOperate.InitialForm(pSysName, pSysCaption);
            //==========================================================================================
        }
Пример #5
0
        public override void OnClick()
        {
            //changed by chulili20110718 先将目录管理界面不可见,再响应界面切换
            ModDBOperate.WriteLog("ControlDBIntergration_OnClick");
            for (int i = 0; i < _hook.MainForm.Controls.Count; i++)
            {
                if (_hook.MainForm.Controls[i].Name.Equals("UCDataSourceManger"))
                {
                    if (_hook.MainForm.Controls[i].Enabled)
                    {
                        _hook.MainForm.Controls[i].Enabled = false;
                    }
                    break;
                }
            }
            //end added by chulili

            if (ModuleData.v_AppDBIntegra == null)
            {
                return;
            }
            if (ucCtl == null)
            {
                ucCtl = ModuleData.v_AppDBIntegra.MainUserControl;
            }

            ucCtl.Visible = true;
            ucCtl.Enabled = true;
            _hook.MainForm.Controls.SetChildIndex(ucCtl, 0);
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志
            }
            ModDBOperate.WriteLog("ControlDBIntergration_OnClick");
        }
Пример #6
0
        /// <summary>
        /// 加载栅格库体
        /// </summary>
        /// <param name="m_Hook">主程序hook</param>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddRasterLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, out Exception ex)
        {
            ex = null;
            try
            {
                IGroupLayer pGroupLayer = new GroupLayerClass();
                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                // string rasterDBType = (m_Hook.ProjectTree.SelectedNode.Tag as XmlElement).GetAttribute("存储类型");
                // string rasterDBType = DbEleInfo.GetAttribute("存储类型");
                string     rasterDBType = string.Empty;
                XmlElement RasterEle    = DbEleInfo.SelectSingleNode(".//栅格数据库") as XmlElement;
                rasterDBType = RasterEle.GetAttribute("存储类型").Trim();
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//栅格数据库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失发生异常");
                    return;
                }
                IRasterWorkspaceEx pRasterWS = TempWorkSpace as IRasterWorkspaceEx;
                if (pRasterWS == null)
                {
                    return;
                }
                string feaclsName = (elementTemp.FirstChild as XmlElement).GetAttribute("名称");
                if (rasterDBType.Trim() == "栅格编目")
                {
                    //栅格编目数据加载
                    IRasterCatalog         pRasterCatalog = pRasterWS.OpenRasterCatalog(feaclsName);
                    IGdbRasterCatalogLayer pGDBRCLayer    = new GdbRasterCatalogLayerClass();
                    if (!pGDBRCLayer.Setup(pRasterCatalog as ITable))
                    {
                        return;
                    }
                    IFeatureLayer mFeaLayer = pGDBRCLayer as IFeatureLayer;
                    pGroupLayer.Add(mFeaLayer as ILayer);
                }
                else if (rasterDBType.Trim() == "栅格数据集")
                {
                    //栅格数据集加载

                    IRasterDataset pRasterDataset = pRasterWS.OpenRasterDataset(feaclsName);
                    IRasterLayer   pRasterLayer   = new RasterLayerClass();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    if (pRasterLayer == null)
                    {
                        return;
                    }
                    pGroupLayer.Add(pRasterLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }
Пример #7
0
        public SubMainForm(string xmlPath)
        {
            InitializeComponent();

            //ModuleData.v_MainForm = pForm;
            ModuleData.v_SubForm = this;

            ModDBOperate.IntialSysFrm(xmlPath, this);
        }
Пример #8
0
        /// <summary>
        /// 初始化列表框
        /// </summary>
        private void InitialForm()
        {
            Exception outError = null;                 //异常

            SysCommon.DataBase.SysTable pSysDB = null; //连接数据库类
            //连接数据库
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                return;
            }
            string str = "";              //查询字符串

            if (m_BeRole)
            {
                //查询角色基本信息表
                // str = "select * from rolebaseinfo";  //定义查询字符串  3为系统管理员
                str = "select * from rolebaseinfo r join (select roletypeid from roletypeinfo ) t on (r.roletypeid=t.roletypeid) where t.roletypeid<> 3";
            }
            else
            {
                //查询用户基本信息表
                // str = "select * from userbaseinfo";//定义查询字符串  3为系统管理员
                str = "select * from userbaseinfo u join  userrolerelationinfo r on (u.userid=r.userid) join (select roleid,roletypeid from rolebaseinfo) b on (r.roleid=b.roleid) where b.roletypeid<>3";
            }
            //查询角色信息表
            DataTable pTable = pSysDB.GetSQLTable(str, out outError);

            if (outError != null || pTable == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色信息表失败");
                pSysDB.CloseDbConnection();
                m_beSuccedd = false;
                return;
            }
            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                int          pRoleID   = Convert.ToInt32(pTable.Rows[i][0].ToString().Trim()); //角色ID
                string       pRoleName = pTable.Rows[i][1].ToString().Trim();                  //角色名称
                ListViewItem pItem     = new ListViewItem();
                pItem.Text    = pRoleName;
                pItem.Tag     = pRoleID;
                pItem.Checked = false;
                if (!LstViewRole.Items.Contains(pItem))
                {
                    LstViewRole.Items.Add(pItem);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// 进入文件库子系统  cyf 20110627 modify
        /// </summary>
        /// <param name="in_lDemDataBaseID"></param>
        /// <param name="DBInfoEle"></param>
        public void EnterFTPDataBase(long in_lDemDataBaseID, string in_sDBName)
        {
            //将当前数据库ID写入xml中
            Exception ex      = null;
            string    pDBID   = in_lDemDataBaseID.ToString();
            string    sDBName = in_sDBName;

            if (pDBID == "System.Data.DataRowView" || sDBName == "System.Data.DataRowView")
            {
                return;
            }
            clsFTPOper FTPOper = new clsFTPOper();

            FTPOper.SaveProjectXML(pDBID, sDBName, out ex);
            if (ex != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                return;
            }
            //进入文件库界面
            //==================================================================================
            //  chenayfei  modify 20110215  进入子系统界面修改
            string pSysName    = ""; //子系统名称
            string pSysCaption = ""; //子系统标题

            //根据Name获得子系统的caption
            pSysName = "FileDBTool.ControlFileDBTool";    //Name
            XmlDocument sysXml = new XmlDocument();

            sysXml.Load(ModuleData.m_SysXmlPath);
            XmlNode sysNode = sysXml.SelectSingleNode("//Main//System[@Name='" + pSysName + "']");

            if (sysNode == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在Name为" + pSysName + "的系统");
                return;
            }
            pSysCaption = (sysNode as XmlElement).GetAttribute("Caption").Trim();  //caption
            //进入子系统界面
            ModDBOperate.InitialForm(pSysName, pSysCaption);

            //========================================================================
        }
Пример #10
0
        /// <summary>
        /// guozheng 2011-3-24 added 判断是不是第一次登陆(第一次登陆只有系统管理员,将系统管理员账号显示在界面上)
        /// </summary>
        private void JudgeInitialize()
        {
            Exception outError = null;

            SysCommon.DataBase.SysTable pSysDB = null;
            //连接数据库
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接Oracle数据库异常:" + outError.Message + "请检查Oracle数据库运行状态");
                return;
            }
            /////读取用户表,若只有一条记录则认为是系统管理员/////
            string    sSQL         = "SELECT * FROM userbaseinfo";
            DataTable GetUserTable = pSysDB.GetTable("userbaseinfo", out outError);

            if (GetUserTable.Rows.Count == 1)
            {
                ////////将系统管理员的信息显示在界面上////////
                this.txtUser.Text     = GetUserTable.Rows[0]["USERNAME"].ToString();
                this.txtPassword.Text = GetUserTable.Rows[0]["PASSWORD"].ToString();
            }
        }
Пример #11
0
        /////////该类实现将各种ArcGis图层加载至数据库集成管理界面的图层控件当中来////////
        /// <summary>
        /// 加载矢量库体
        /// </summary>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="in_MXDFile">符号化mxd文件路径</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddFeaLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, string in_MXDFile, out Exception ex)
        {
            ex = null;
            try
            {
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//现势库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失败!");
                    return;
                }
                ILayer player = ModDBOperate.GetGroupLayer(m_Hook.MapControl, m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text);
                if (player != null)
                {
                    m_Hook.MapControl.Map.DeleteLayer(player);
                    m_Hook.TOCControl.Update();
                }

                IGroupLayer pGroupLayer = new GroupLayerClass();
                SysCommon.Gis.SysGisDataSet sysGisDataset  = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
                IFeatureDataset             featureDataset = sysGisDataset.GetFeatureDataset((elementTemp.FirstChild as XmlElement).GetAttribute("名称"), out ex);
                if (ex != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据失败!");
                    ex = new Exception("获取数据发生异常:" + ex.Message);
                    return;
                }

                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                List <IDataset> lstDataset = sysGisDataset.GetFeatureClass(featureDataset);
                //遍历要素类,加载图层
                string dbType   = "";
                string userName = "";//用户名

                userName = elementTemp.GetAttribute("用户");
                dbType   = elementTemp.GetAttribute("类型");
                foreach (IDataset dataset in lstDataset)
                {
                    IFeatureClass pFeatureClass = dataset as IFeatureClass;
                    if (pFeatureClass == null)
                    {
                        continue;
                    }
                    IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                    if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        pFeatureLayer = new FDOGraphicsLayerClass();
                    }
                    pFeatureLayer.FeatureClass = pFeatureClass;
                    if (dbType.Trim().ToUpper() == "SDE")
                    {
                        if (dataset.Name.ToUpper().Contains(userName.Trim().ToUpper()))
                        {
                            //SDE用户图层名去掉用户名
                            pFeatureLayer.Name = dataset.Name.Substring(userName.Trim().Length + 1);
                        }
                        else
                        {
                            pFeatureLayer.Name = dataset.Name;
                        }
                    }
                    else
                    {
                        pFeatureLayer.Name = dataset.Name;
                    }
                    pFeatureLayer.Visible = false;
                    pGroupLayer.Add(pFeatureLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
                SysCommon.Gis.ModGisPub.LayersCompose(m_Hook.MapControl);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }
Пример #12
0
        /// <summary>
        /// 初始化角色类型列表框
        /// </summary>
        private void intialForm()
        {
            SysCommon.DataBase.SysTable pSysDB = null;
            Exception outError = null;

            //连接数据库
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                m_beSucced = false;
                return;
            }
            #region 初始化角色类型列表
            string selStr = "";                                         //初始化角色类型列表的字符串
            selStr = "select * from roletypeinfo WHERE ROLETYPEID<> 3"; //查询角色类型表,3为系统管理员
            DataTable pTable = pSysDB.GetSQLTable(selStr, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败,原因:" + outError.Message);
                pSysDB.CloseDbConnection();
                m_beSucced = false;
                return;
            }

            //遍历表格记录,将角色类型信息加载到ComboBox中
            for (int j = 0; j < pTable.Rows.Count; j++)
            {
                string roleID   = "";   //角色ID
                string roleName = "";   //角色类型名称
                roleID   = pTable.Rows[j][0].ToString().Trim();
                roleName = pTable.Rows[j][2].ToString().Trim();
                ComboBoxItem pItem = new ComboBoxItem(roleName, roleID);
                cmbGroupType.Items.Add(pItem);
            }
            if (cmbGroupType.Items.Count > 0)
            {
                cmbGroupType.SelectedIndex = 0;
            }
            #endregion

            if (m_BeUpdate)
            {
                #region 修改,初始化角色名列表框
                string    str       = "select * from rolebaseinfo where roletypeid<>3"; //查询角色类型表 3为系统管理员,不能修改
                DataTable RoleTable = pSysDB.GetSQLTable(str, out outError);
                if (outError != null || RoleTable == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败!");
                    pSysDB.CloseDbConnection();
                    m_beSucced = false;
                    return;
                }
                if (RoleTable.Rows.Count == 0)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "还未添加过角色,请检查");
                    pSysDB.CloseDbConnection();
                    m_beSucced = false;
                    return;
                }
                for (int i = 0; i < RoleTable.Rows.Count; i++)
                {
                    int    pRoleID     = -1; //角色ID
                    string pRoleName   = ""; //角色名称
                    int    pRoleTypeID = -1; //角色类型ID
                    pRoleID     = Convert.ToInt32(RoleTable.Rows[i][0].ToString().Trim());
                    pRoleName   = RoleTable.Rows[i][1].ToString().Trim();
                    pRoleTypeID = Convert.ToInt32(RoleTable.Rows[i][2].ToString().Trim());
                    ComboBoxItem pItem = new ComboBoxItem(pRoleName, pRoleID);
                    cmbRoleName.Items.Add(pItem);
                }
                if (cmbRoleName.Items.Count > 0)
                {
                    cmbRoleName.SelectedIndex = 0;
                }
                #endregion
            }
            //else
            //{

            //}
            pSysDB.CloseDbConnection();
        }
Пример #13
0
        private void cmbRoleName_SelectedIndexChanged(object sender, EventArgs e)
        {
            //根据角色名称初始化角色类型

            txtRole.Text = cmbRoleName.Text.Trim();
            SysCommon.DataBase.SysTable pSysDB = null;
            Exception outError = null;

            //连接数据库
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                return;
            }

            string selStr = "";                                                                                                                                                                                                       //初始化角色类型列表的字符串

            selStr = "select * from roletypeinfo inner join rolebaseinfo on rolebaseinfo.ROLETYPEID=roletypeinfo.ROLETYPEID and rolebaseinfo.ROLEID=" + Convert.ToInt32((cmbRoleName.SelectedItem as ComboBoxItem).Value.ToString()); //查询角色类型表
            DataTable pTable = pSysDB.GetSQLTable(selStr, out outError);

            if (outError != null || pTable == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色类型表失败,原因:" + outError.Message);
                pSysDB.CloseDbConnection();
                return;
            }
            if (pTable.Rows.Count == 0)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色类型表失败,原因:" + outError.Message);
                pSysDB.CloseDbConnection();
                return;
            }
            //遍历表格记录,将角色类型信息加载到ComboBox中
            //for (int j = 0; j < pTable.Rows.Count; j++)
            //{
            string roleTypeID   = "";       //角色类型ID
            string roleTypeName = "";       //角色类型

            roleTypeID   = pTable.Rows[0]["ROLETYPEID"].ToString().Trim();
            roleTypeName = pTable.Rows[0]["ROLEREMARK"].ToString().Trim();
            //ComboBoxItem pItem = new ComboBoxItem(roleTypeName, roleTypeID);
            //cmbGroupType.SelectedItem = pItem;
            cmbGroupType.Text = roleTypeName;
            //cmbGroupType.Items.Add(pItem);
            //}
            //if (cmbGroupType.Items.Count > 0)
            //{
            //    cmbGroupType.SelectedIndex = 0;
            //}

            //初始化备注列表框
            selStr = "select * from rolebaseinfo where ROLEID=" + Convert.ToInt32((cmbRoleName.SelectedItem as ComboBoxItem).Value.ToString().Trim());
            pTable = pSysDB.GetSQLTable(selStr, out outError);
            if (outError != null || pTable == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色类型表失败,原因:" + outError.Message);
                pSysDB.CloseDbConnection();
                return;
            }
            if (pTable.Rows.Count == 0)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "该用户不存在!");
                pSysDB.CloseDbConnection();
                return;
            }
            txtComment.Text = pTable.Rows[0][3].ToString().Trim();

            pSysDB.CloseDbConnection();
        }
Пример #14
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            Exception exError = null;

            try
            {
                #region 进行界面控制
                if (txtComment.Text.Length > 200)
                {
                    ErrorHandle.ShowInform("提示", "备注内容太长!");
                    txtComment.Focus();
                    return;
                }
                if (txtTrueName.Text.IndexOf(" ") != -1)
                {
                    errorProvider.SetError(txtTrueName, "用户名不能有空格");
                    return;
                }
                //验证
                if (string.IsNullOrEmpty(this.txtTrueName.Text))
                {
                    errorProvider.SetError(txtTrueName, "用户真实名不能为空!");
                    return;
                }
                else if (string.IsNullOrEmpty(this.txtPassword.Text))
                {
                    errorProvider.SetError(txtPassword, "密码不能为空!");
                    return;
                }
                else if (this.comboSex.Text == "")
                {
                    errorProvider.SetError(comboSex, "请选择用户角色!");
                    return;
                }
                else if (this.comboSex.Text == "请选择")
                {
                    errorProvider.SetError(comboSex, "请选择性别!");
                    return;
                }
                else if (string.IsNullOrEmpty(this.txtPosition.Text))
                {
                    errorProvider.SetError(txtPosition, "姓名不能为空!");
                    return;
                }
                if (txtTrueName.Text == "Admin")
                {
                    ErrorHandle.ShowInform("提示", "此用户已存在,请重新输入!");
                    txtTrueName.Focus();
                    return;
                }
                #endregion

                //l连接系统维护库
                SysCommon.DataBase.SysTable pSysDB = null;
                ModDBOperate.ConnectDB(out pSysDB, out exError);
                if (exError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", exError.Message);
                    return;
                }

                #region 首先要判断用户名不能重复

                //用户名不能与超级管理员同名
                string[] arr = ModuleData.v_AppConnStr.Split(';');
                if (arr.Length != 3)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接字符串不正确!");
                    return;
                }

                if (txtTrueName.Text.Trim() == arr[1].Substring(arr[1].IndexOf('=') + 1))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的用户!");
                    pSysDB.CloseDbConnection();
                    return;
                }

                //不能与数据库中的用户同名
                string    str        = "select * from userbaseinfo where USERNAME='******'";
                DataTable pUserTable = pSysDB.GetSQLTable(str, out exError);
                if (exError != null || pUserTable == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户基本信息表失败!");
                    pSysDB.CloseDbConnection();
                    return;
                }

                #endregion

                //判断是更新还是添加
                if (_user != null)
                {
                    // (修改用户) 判断是否存在同名用户
                    if (pUserTable.Rows.Count > 1)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的用户!");
                        pSysDB.CloseDbConnection();
                        return;
                    }

                    #region 用户修改,1、需要修改用户基本信息表,2、需要修改用户角色关系表,3、更新用户登录信息
                    pSysDB.StartTransaction();
                    //更新用户信息

                    #region 更新用户信息表
                    //若用户的基本信息发生了变更,则更新用户基本信息表
                    int    pUserID     = _user.ID; //用户ID
                    int    pRoleTypeID = _user.RoleTypeID;
                    string updateStr   = "";
                    if (m_UserName != txtTrueName.Text.Trim() || m_Password != txtPassword.Text.Trim() || comboSex.Text.Trim() != m_Sex || txtPosition.Text.Trim() != m_Position || txtComment.Text.Trim() != m_Remark)
                    {
                        //只要其中有一项基本信息发生了变化,就更injiben信息表
                        updateStr = "update userbaseinfo set UserName='******', Password='******', Sex='" + comboSex.Text.Trim() + "', Job='" + txtPosition.Text.Trim() + "', Remark='" + txtComment.Text.Trim() + "' where UserID=" + pUserID;
                        pSysDB.UpdateTable(updateStr, out exError);
                        if (exError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "更新用户信息表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                    }
                    #endregion
                    if (cmbRole.Text.Trim() != m_OldRoleName)
                    {
                        //说明用户对应的角色也进行了更新
                        #region 更新用户角色关系表
                        if ((cmbRole.SelectedItem as ComboBoxItem).Value == null || (cmbRole.SelectedItem as ComboBoxItem).Value.ToString().Trim() == "")
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色ID失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        int       pRoleID = -1; //角色ID  Convert.ToInt32((cmbRole.SelectedItem as ComboBoxItem).Value.ToString().Trim());
                        string    mStr    = "select * from rolebaseinfo where ROLENAME='" + cmbRole.Text.Trim() + "'";
                        DataTable tTable  = pSysDB.GetSQLTable(mStr, out exError);
                        if (exError != null || tTable == null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色信息表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        if (tTable.Rows.Count == 0)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色ID失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        pRoleID = Convert.ToInt32(tTable.Rows[0][0].ToString().Trim());
                        //首先查询用户角色关系表,看是否存在这个记录
                        //******************************************************************
                        //guozheng added 2011-3-24
                        string    sSQL     = "SELECT ROLEID FROM rolebaseinfo WHERE ROLETYPEID=" + _user.RoleTypeID;
                        DataTable GetTable = pSysDB.GetSQLTable(sSQL, out exError);
                        if (exError != null || GetTable == null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        if (GetTable.Rows.Count < 0)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "没有找到该用户对应的角色信息"); return;
                        }
                        //******************************************************************
                        string    tempStr  = "select * from userrolerelationinfo where ROLEID=" + GetTable.Rows[0][0].ToString() + " and USERID=" + pUserID;
                        DataTable temTable = pSysDB.GetSQLTable(tempStr, out exError);
                        if (exError != null || temTable == null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        if (temTable.Rows.Count == 0)
                        {
                            //若不存在,则插入关系记录
                            updateStr = "insert into userrolerelationinfo(USERID,ROLEID) values (" + pUserID + "," + pRoleID + ")";
                        }
                        else
                        {
                            //若存在,则更新关系记录
                            updateStr = "update userrolerelationinfo set ROLEID=" + pRoleID + " where USERID=" + pUserID;
                        }

                        pSysDB.UpdateTable(updateStr, out exError);
                        if (exError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "更新用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        #endregion

                        //获得角色类型
                        tempStr  = "select * from rolebaseinfo where ROLEID=" + pRoleID;
                        temTable = pSysDB.GetSQLTable(tempStr, out exError);
                        if (exError != null || temTable == null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        if (temTable.Rows.Count == 0)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在该角色");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        pRoleTypeID = Convert.ToInt32(temTable.Rows[0][2].ToString().Trim());
                    }

                    pSysDB.EndTransaction(true);
                    pSysDB.CloseDbConnection();
                    #region 更新用户登录信息
                    ModuleData.m_User            = new User();
                    ModuleData.m_User.ID         = pUserID;
                    ModuleData.m_User.Name       = txtTrueName.Text.Trim();
                    ModuleData.m_User.Password   = txtPassword.Text.Trim();
                    ModuleData.m_User.Sex        = comboSex.Text.Trim();
                    ModuleData.m_User.Position   = txtPosition.Text.Trim();
                    ModuleData.m_User.Remark     = txtComment.Text.Trim();
                    ModuleData.m_User.Role       = cmbRole.Text.Trim();
                    ModuleData.m_User.RoleTypeID = pRoleTypeID;
                    #endregion
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "修改用户信息成功!");
                    #endregion
                }
                else
                {
                    //(新增用户)判断是否存在同名用户
                    if (pUserTable.Rows.Count > 0)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的用户!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    //添加用户信息
                    #region 添加用户,1、需要添加用户基本信息表,2、需要添加用户角色关系表
                    pSysDB.StartTransaction();

                    #region 获得用户ID
                    int       pUserID   = -1;
                    string    seleStr   = "select Max(UserID) from userbaseinfo";
                    DataTable tempTable = pSysDB.GetSQLTable(seleStr, out exError);
                    if (exError != null || tempTable == null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户信息表失败!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    if (tempTable.Rows.Count == 0)
                    {
                        pUserID = 1;
                    }
                    else
                    {
                        if (tempTable.Rows[0][0].ToString().Trim() == "")
                        {
                            pUserID = 1;
                        }
                        else
                        {
                            pUserID = Convert.ToInt32(tempTable.Rows[0][0].ToString().Trim()) + 1;
                        }
                    }
                    if (pUserID == -1)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取用户ID失败!");
                        return;
                    }
                    #endregion

                    #region 更新用户基本信息表
                    string insertStr = "insert into userbaseinfo(UserID,UserName,Password,Sex,Job,Remark) values(" + pUserID + ",'" + txtTrueName.Text.Trim() + "','" + txtPassword.Text.Trim() + "','" + comboSex.Text.Trim() + "','" + txtPosition.Text.Trim() + "','" + txtComment.Text.Trim() + "')";

                    pSysDB.UpdateTable(insertStr, out exError);
                    if (exError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "更新用户表信息失败!");
                        pSysDB.EndTransaction(false);
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    #endregion
                    #region 更新用户角色表

                    //获得角色ID
                    int pRoleID = -1;   //角色ID
                    if ((cmbRole.SelectedItem as ComboBoxItem).Value == null || (cmbRole.SelectedItem as ComboBoxItem).Value.ToString().Trim() == "")
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色ID失败!");
                        pSysDB.EndTransaction(false);
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    pRoleID = Convert.ToInt32((cmbRole.SelectedItem as ComboBoxItem).Value.ToString().Trim());

                    //插入数据到角色关系表里面
                    string inseStr = "insert into userrolerelationinfo(UserID,RoleID) values(" + pUserID + "," + pRoleID + ")";
                    pSysDB.UpdateTable(inseStr, out exError);
                    if (exError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "更新用户角色关系表失败!");
                        pSysDB.EndTransaction(false);
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    #endregion
                    pSysDB.EndTransaction(true);
                    pSysDB.CloseDbConnection();

                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示 ", "添加用户信息成功!");

                    #endregion
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                exError = ex;
            }
        }
Пример #15
0
        public override void OnClick()
        {
            Exception ex = null;

            if (ModuleData.v_DataBaseProPanel != null)
            {
                //清空界面图标
                ModuleData.v_DataBaseProPanel.RemoveAllDataBasePro();
                //清空树图
                m_Hook.ProjectTree.SelectedNode.Nodes.Clear();
                //重新加载界面
                clsAddAppDBConnection addAppDB = new clsAddAppDBConnection();
                //判断系统维护库的连接信息是否正确
                addAppDB.JudgeAppDbConfiguration(out ex);
                if (ex != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "界面刷新化失败,\n原因:" + ex.Message);
                    return;
                }
                #region cyf 20110627 add:初始化工程树图
                IFeatureWorkspace pFeaWS = ModuleData.TempWks as IFeatureWorkspace;
                if (pFeaWS == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接系统维护库失败!");
                    return;
                }
                string  pTableName  = "DATABASETYPEMD";
                string  pFieldNames = "DATABASETYPE";
                ICursor pCursor     = ModDBOperate.GetCursor(pFeaWS, pTableName, pFieldNames, "", out ex);
                if (ex != null || pCursor == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询数据库系统维护库中的数据库类型表失败!");
                    return;
                }
                IRow pRow = pCursor.NextRow();
                //遍历行,将树节点加载在树图上
                while (pRow != null)
                {
                    string pDBType = pRow.get_Value(0).ToString();  //数据库类型
                    DevComponents.AdvTree.Node pNode = new DevComponents.AdvTree.Node();
                    pNode.Expanded  = true;
                    pNode.Name      = "node2";
                    pNode.TagString = "Database";
                    pNode.Text      = pDBType;
                    pNode.Image     = m_Hook.ProjectTree.ImageList.Images[1]; //cyf 20110711 添加图标
                    m_Hook.ProjectTree.SelectedNode.Nodes.Add(pNode);
                    pRow = pCursor.NextRow();
                }
                //释放游标
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                m_Hook.ProjectTree.Refresh();
                #endregion

                //刷新界面
                while (!addAppDB.refurbish(out ex))
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "界面初始化化失败,\n原因:" + ex.Message);
                    return;
                }
            }
        }
Пример #16
0
        /// <summary>
        /// chenyafei 20110311 add content:初始化界面
        /// </summary>
        private void InitilComboBox()
        {
            Exception outError = null;

            #region 初始化性别列表框
            ComboBoxItem item = new ComboBoxItem("男", 0);
            this.comboSex.Items.Add(item);
            item = new ComboBoxItem("女", 1);
            this.comboSex.Items.Add(item);
            this.comboSex.SelectedIndex = 0;
            #endregion

            #region 初始化角色列表框
            //连接系统维护库
            SysCommon.DataBase.SysTable pSysDB = null;
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                m_BeSuccedd = false;
                return;
            }
            //查询角色基本信息表
            string selStr = string.Empty;
            if (this._user == null)
            {
                selStr = "select * from rolebaseinfo WHERE rolebaseinfo.ROLETYPEID<>3";   //查询角色字符串,3为系统管理员角色,系统管理员角色不能添加
            }
            else
            {
                //cyf 20110602 delete
                //if (this._user.RoleTypeID==EnumRoleType.系统管理员.GetHashCode())
                //    selStr = "select * from rolebaseinfo";
                //else
                //    selStr = "select * from rolebaseinfo WHERE rolebaseinfo.ROLETYPEID<>3";
                //end
            }
            DataTable pTable = pSysDB.GetSQLTable(selStr, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败,原因:" + outError.Message);
                m_BeSuccedd = false;
                pSysDB.CloseDbConnection();
                return;
            }
            pSysDB.CloseDbConnection();
            //遍历表格记录,将角色信息加载到ComboBox中
            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string roleID   = "";   //角色ID
                string roleName = "";   //角色名称
                roleID   = pTable.Rows[i][0].ToString().Trim();
                roleName = pTable.Rows[i][1].ToString().Trim();
                ComboBoxItem pItem = new ComboBoxItem(roleName, roleID);
                cmbRole.Items.Add(pItem);
            }
            if (cmbRole.Items.Count > 0)
            {
                cmbRole.SelectedIndex = 0;
            }
            #endregion
        }
Пример #17
0
        //cyf 20110602 modify:系统维护库连接方式
        public override void OnClick()
        {
            //执行卸载数据库操作
            //XmlDocument XmlDoc = new XmlDocument();
            //string sConnect = string.Empty;
            string    sDBtype = string.Empty;
            string    sDBName = string.Empty;
            Exception ex      = null;
            long      lDBid   = -1;

            #region 原有代码
            //if (File.Exists(ModuleData.v_AppDBConectXml))
            //{
            //    XmlDoc.Load(ModuleData.v_AppDBConectXml);
            //    XmlElement ele = XmlDoc.SelectSingleNode(".//系统维护库连接信息") as XmlElement;
            //if (ele != null)
            //{
            try
            {
                //sConnect = ele.GetAttribute("连接字符串");
                XmlElement eleinfo = m_Hook.ProjectTree.SelectedNode.Tag as XmlElement;
                lDBid   = Convert.ToInt64(eleinfo.GetAttribute("数据库ID"));
                sDBtype = eleinfo.GetAttribute("数据库类型");
                //cyf 20110626 modify:
                sDBName = m_Hook.ProjectTree.SelectedNode.Text;        // eleinfo.GetAttribute("数据库工程名");
                //end
            } catch
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据库信息失败");
                return;
            }
            //}
            //else { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取系统维护库连接信息失败"); return; }
            //}
            //else
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "缺失系统维护库连接信息文件:" + ModuleData.v_AppDBConectXml);
            //    return;
            //}
            /////

            #endregion
            bool bInLayerTree = ModDBOperate.IsDbSourceInLayerTree(lDBid);          //added by chulili 20111118 判断当前图层目录中是否存在该数据源
            if (bInLayerTree)
            {
                if (!SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "当前图层目录中已引用该数据源,确定卸载数据源:" + sDBName + "?"))
                {
                    return;
                }
            }
            else
            {
                if (!SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "确定卸载数据源:" + sDBName + "?"))
                {
                    return;
                }
            }
            ///////
            //clsDBAdd DBdeloper = new clsDBAdd(SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, sConnect);
            //cyf 20110602 modify
            clsDBAdd DBdeloper = new clsDBAdd();
            //end
            ////////执行删除////////////
            if (!DBdeloper.DelDB(lDBid, out ex))
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库卸载失败,\n原因:" + ex.Message);
                return;
            }

            m_Hook.ProjectTree.SelectedNode.Remove();//////删除树节点
            //cyf 20110627 modify
            //if (sDBtype == enumInterDBType.成果文件数据库.ToString())
            //{
            //    ///////guozheng added ,若是卸载文件库,将文件库的XMl文件v_FTPCoonectionInfoXML 删除,这一文件会在重新选择文件库工程时会自动生成
            //    try
            //    {
            //        System.IO.File.Delete(ModuleData.v_FTPCoonectionInfoXML);
            //    }
            //    catch
            //    {
            //    }
            //}
            //end
            /////////刷新界面//////////////
            /////////////子数据库Combox刷新
            //clsRefurbishDBinfo RefOper = new clsRefurbishDBinfo(SysCommon.enumDBConType.ORACLE, SysCommon.enumDBType.ORACLE, sConnect);
            //cyf 20110602 modify
            //clsRefurbishDBinfo RefOper = new clsRefurbishDBinfo();
            //end
            //cyf 20110602 delete:界面修改后,没有combobox列表框
            //RefOper.UpDataComBox(sDBtype, out ex);
            //if (ex != null)
            //{
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库卸载成功,界面刷新失败,\n原因:" + ex.Message);
            //    return;
            //}
            //else
            //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据库卸载:" + sDBName + " 成功!");
            //end

            //刷新xml  chenyafei  20110222  modify
            //if (sDBtype != enumInterDBType.成果文件数据库.ToString())
            //{
            //DeleteXmlNode(sDBtype, lDBid);  cyf 20110626 delete:不对工程树图XML做更新
            //}
            ////////////////////按钮处理////////////
            if (this.WriteLog)
            {
                Plugin.LogTable.Writelog(Caption);//xisheng 2011.07.09 增加日志
            }
            try
            {
                ModuleData.v_DataBaseProPanel.RemoveDataBasePro(sDBtype, lDBid);
            }
            catch
            {
            }
        }
Пример #18
0
        // 登录系统
        private void btnOK_Click(object sender, EventArgs e)
        {
            Exception outError = null;

            //界面控制
            if (txtUser.Text.Trim() == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "用户名不能为空");
                return;
            }
            else if (txtPassword.Text.Trim() == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "密码不能为空");
                return;
            }

            if (ModuleData.v_AppConnStr.Trim() == "")
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接字符串为空!");
                return;
            }
            string[] arr = ModuleData.v_AppConnStr.Split(';');
            if (arr.Length != 3)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接字符串不正确!");
                return;
            }
            ///////////////////////获取登陆的用户信息///////////////////
            #region 连接数据库
            SysCommon.DataBase.SysTable pSysDB = null;
            //连接数据库
            ModDBOperate.ConnectDB(out pSysDB, out outError);
            if (outError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                return;
            }
            #endregion

            #region 查询用户基本信息表,用户和密码判断
            string    selStr    = "select * from userbaseinfo where UserName='******' and PASSWORD='******'";
            DataTable UserTable = pSysDB.GetSQLTable(selStr, out outError);
            if (outError != null || UserTable == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户基本信息表失败!");
                pSysDB.CloseDbConnection();
                return;
            }
            if (UserTable.Rows.Count == 0)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "无效的用户或者密码!");
                pSysDB.CloseDbConnection();
                return;
            }
            #endregion
            int    pUserID     = -1; //用户ID
            string pSex        = ""; //性别
            string pJob        = ""; //职称
            string pRemark     = ""; //备注
            string pRoleName   = ""; //角色名称
            int    pRoleTypeID = -1; //角色类型:1管理员、2作业员

            pUserID = Convert.ToInt32(UserTable.Rows[0][0].ToString().Trim());
            pSex    = UserTable.Rows[0][3].ToString().Trim();
            pJob    = UserTable.Rows[0][4].ToString().Trim();
            pRemark = UserTable.Rows[0][5].ToString().Trim();

            #region 查询用户角色
            string str = "select * from userrolerelationinfo inner join rolebaseinfo on UserID=" + pUserID + " and userrolerelationinfo.RoleID=rolebaseinfo.RoleID";
            //string str = "select * from userrolerelationinfo a inner join (select * from rolebaseinfo inner join roletypeinfo on rolebaseinfo.roletypeid=roletypeinfo.roletypeid) b on a.UserID=" + pUserID + "and a.RoleID=b.RoleID";

            DataTable pRoleRelTable = pSysDB.GetSQLTable(str, out outError);
            if (outError != null || pRoleRelTable == null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询用户角色关系表失败!");
                pSysDB.CloseDbConnection();
                return;
            }
            if (pRoleRelTable.Rows.Count == 0)
            {
                pRoleName   = "";
                pRoleTypeID = -1;
            }
            else
            {
                pRoleName   = pRoleRelTable.Rows[0]["ROLENAME"].ToString().Trim();
                pRoleTypeID = Convert.ToInt32(pRoleRelTable.Rows[0]["ROLETYPEID"].ToString().Trim());  //角色类型ID
            }

            #endregion

            pSysDB.CloseDbConnection();

            //若用户和密码正确,则登录系统,保存用户相关信息

            m_User            = new SysCommon.Authorize.User();
            m_User.ID         = pUserID;
            m_User.Name       = this.txtUser.Text.Trim();
            m_User.Password   = this.txtPassword.Text.Trim();
            m_User.Sex        = pSex;
            m_User.Position   = pJob;
            m_User.Remark     = pRemark;
            m_User.Role       = pRoleName;
            m_User.RoleTypeID = pRoleTypeID;
            /////////////////////////////////////////////////////////////
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #19
0
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            Exception pError = null;

            try
            {
                #region 对界面进行控制
                if (txtComment.Text.Length >= 200)
                {
                    ErrorHandle.ShowFrmErrorHandle("提示", "备注内容太长!");
                    return;
                }
                if (string.IsNullOrEmpty(this.txtRole.Text.Trim()))
                {
                    ErrorHandle.ShowFrmErrorHandle("提示", "用户组名不能为空!");
                    return;
                }
                if (txtRole.Text.IndexOf(" ") != -1)
                {
                    errorProvider1.SetError(txtRole, "组名不能有空格");
                    return;
                }

                #endregion

                SysCommon.DataBase.SysTable pSysDB = null;
                //连接系统维护库
                ModDBOperate.ConnectDB(out pSysDB, out pError);
                if (pError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", pError.Message);
                    return;
                }
                int pRoleID     = -1;   //角色ID
                int pRoleTypeID = -1;   //角色类型ID
                pRoleTypeID = Convert.ToInt32((cmbGroupType.SelectedItem as ComboBoxItem).Value.ToString());
                if (pRoleTypeID == -1)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色类型ID失败!");
                    pSysDB.CloseDbConnection();
                    return;
                }

                //判断是否存在同名的角色
                string    tempStr = "select * from rolebaseinfo where ROLENAME='" + txtRole.Text.Trim() + "'";
                DataTable mTable  = pSysDB.GetSQLTable(tempStr, out pError);
                if (pError != null || mTable == null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败");
                    pSysDB.CloseDbConnection();
                    return;
                }


                if (m_BeUpdate)
                {
                    //判断是否存在同名角色
                    if (mTable.Rows.Count > 1)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的角色!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    #region 对界面进行控制,角色名称保护
                    if (string.IsNullOrEmpty(cmbRoleName.Text.Trim()))
                    {
                        ErrorHandle.ShowFrmErrorHandle("提示", "用户组名不能为空!");
                        return;
                    }
                    if (cmbRoleName.Text.Trim().IndexOf(" ") != -1)
                    {
                        errorProvider1.SetError(txtRole, "组名不能有空格");
                        return;
                    }

                    #endregion

                    //判断是否存在同名的角色
                    //if (cmbRoleName.Items.Contains(txtRole.Text.Trim()))
                    //{
                    //    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的角色!");
                    //    pSysDB.CloseDbConnection();
                    //    return;
                    //}

                    #region 修改角色信息,更新角色基本信息表

                    pRoleID = Convert.ToInt32((cmbRoleName.SelectedItem as ComboBoxItem).Value.ToString().Trim());
                    string updateStr = "update rolebaseinfo set ROLENAME='" + txtRole.Text.Trim() + "', ROLETYPEID=" + pRoleTypeID + ", REMARK='" + txtComment.Text.Trim() + "' where ROLEID=" + pRoleID;
                    pSysDB.UpdateTable(updateStr, out pError);
                    if (pError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "修改角色基本信息表失败!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    pSysDB.CloseDbConnection();

                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "修改角色信息成功!");
                    #endregion
                }
                else
                {
                    //判断是否存在同名角色
                    if (mTable.Rows.Count > 0)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "存在同名的角色!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    #region 添加角色信息,往角色表里面插入记录

                    //查询角色ID的最大值
                    string    selStr    = "select Max(ROLEID) from rolebaseinfo";
                    DataTable tempTable = pSysDB.GetSQLTable(selStr, out pError);
                    if (pError != null || tempTable == null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询角色基本信息表失败");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    if (tempTable.Rows.Count == 0)
                    {
                        pRoleID = 1;
                    }
                    else
                    {
                        if (tempTable.Rows[0][0].ToString().Trim() == "")
                        {
                            //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色类型ID失败!");
                            //pSysDB.CloseDbConnection();
                            //return;
                            pRoleID = 1;
                        }
                        else
                        {
                            pRoleID = Convert.ToInt32(tempTable.Rows[0][0].ToString()) + 1;
                        }
                    }
                    if (pRoleID == -1)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取角色ID失败!");
                        return;
                    }
                    string str = "insert into rolebaseinfo(ROLEID,ROLENAME,ROLETYPEID,REMARK) values (";
                    str += pRoleID + ",'" + txtRole.Text.Trim() + "'," + pRoleTypeID + ",'" + txtComment.Text.Trim() + "')";
                    //更新数据库
                    pSysDB.UpdateTable(str, out pError);
                    if (pError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "更新角色基本信息表失败!");
                        pSysDB.CloseDbConnection();
                        return;
                    }
                    pSysDB.CloseDbConnection();

                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "添加角色成功!");
                    #endregion
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
            }
        }
Пример #20
0
        private void btnDelSel_Click(object sender, EventArgs e)
        {
            if (LstViewRole.CheckedItems.Count == 0)
            {
                return;
            }
            if (m_BeRole)
            {
                #region  除角色及其相关信息,1、删除角色用户关系表,2、删除角色表
                if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "是否删除选中角色及其对应的所有用户?"))
                {
                    //删除
                    SysCommon.DataBase.SysTable pSysDB = null;
                    Exception outError = null;
                    //连接数据库
                    ModDBOperate.ConnectDB(out pSysDB, out outError);
                    if (outError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                        return;
                    }

                    //开启事物
                    pSysDB.StartTransaction();
                    //遍历列表框,执行删除操作
                    for (int i = 0; i < LstViewRole.Items.Count; i++)
                    {
                        int pRoleID = -1;//角色ID
                        //***********************************//
                        //guozheng added
                        if (pRoleID == 3)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "系统管理员角色:" + LstViewRole.Items[i].Text + " 不能删除"); continue;
                        }
                        ListViewItem pItem = new ListViewItem();
                        pItem = LstViewRole.Items[i];
                        if (!pItem.Checked)
                        {
                            continue;
                        }
                        pRoleID = Convert.ToInt32(pItem.Tag.ToString());
                        string delStr = "";   //删除字符串

                        //删除角色用户关系表
                        delStr = "delete from userrolerelationinfo where ROLEID=" + pRoleID;
                        pSysDB.UpdateTable(delStr, out outError);
                        if (outError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }

                        //删除角色信息表
                        delStr = "delete from rolebaseinfo where ROLEID=" + pRoleID;
                        pSysDB.UpdateTable(delStr, out outError);
                        if (outError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除角色信息表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                    }

                    pSysDB.EndTransaction(true);
                    pSysDB.CloseDbConnection();

                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除成功!");
                }
                #endregion
            }
            else
            {
                #region  除用户及其相关信息,1、删除角色用户关系表,2、删除用户基本信息表
                if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "是否删除选中用户?"))
                {
                    //删除
                    SysCommon.DataBase.SysTable pSysDB = null;
                    Exception outError = null;
                    //连接数据库
                    ModDBOperate.ConnectDB(out pSysDB, out outError);
                    if (outError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", outError.Message);
                        return;
                    }

                    //开启事物
                    pSysDB.StartTransaction();
                    //遍历列表框,执行删除操作
                    for (int i = 0; i < LstViewRole.Items.Count; i++)
                    {
                        int          pUserID = -1;//角色ID
                        ListViewItem pItem   = new ListViewItem();
                        pItem = LstViewRole.Items[i];
                        if (!pItem.Checked)
                        {
                            continue;
                        }
                        pUserID = Convert.ToInt32(pItem.Tag.ToString());
                        string delStr = "";   //删除字符串

                        //删除角色用户关系表
                        delStr = "delete from userrolerelationinfo where USERID=" + pUserID;
                        pSysDB.UpdateTable(delStr, out outError);
                        if (outError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                        //删除该用户的作业分配区域
                        delStr = "delete from UPDATEINFO where USERID=" + pUserID;
                        pSysDB.UpdateTable(delStr, out outError);
                        if (outError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除用户角色关系表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }

                        //删除角色信息表
                        delStr = "delete from userbaseinfo where USERID=" + pUserID;
                        pSysDB.UpdateTable(delStr, out outError);
                        if (outError != null)
                        {
                            SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除角色信息表失败!");
                            pSysDB.EndTransaction(false);
                            pSysDB.CloseDbConnection();
                            return;
                        }
                    }

                    pSysDB.EndTransaction(true);
                    pSysDB.CloseDbConnection();
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "删除成功!");
                }
                #endregion
            }

            this.Close();
        }