Exemplo n.º 1
0
        public void InsertSource(PMSRefDBConnectionObj source, bool bRecord)
        {
            InsertSource(source);
            if (bRecord)
            {
                string             name         = source.StrName;
                string             description  = source.StrDescription;
                PMSRefDBConnection rc           = source.RefDBConnection;
                s_DBSourceDefine   sourceDefine = new s_DBSourceDefine();
                sourceDefine.Name          = name;
                sourceDefine.Description   = description;
                sourceDefine.DBType        = (int)(rc.RefDBType);
                sourceDefine.DBServer      = rc.StrServerName;
                sourceDefine.DBName        = rc.StrDBName;
                sourceDefine.UserID        = rc.StrUserID;
                sourceDefine.Password      = rc.StrPassWord;
                sourceDefine.Protocol      = rc.EConnectType.ToString();
                sourceDefine.PortID        = rc.StrPortID;
                sourceDefine.ConnectAs     = rc.StrConnectAs;
                sourceDefine.Direct        = rc.BDirect;
                sourceDefine.Path          = rc.StrDBPath;
                sourceDefine.ConnectString = rc.ConnectString;

                PMSDBStructure.PMSCenterDataContext.AddTos_DBSourceDefine(sourceDefine);
                PMSDBStructure.PMSCenterDataContext.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void InsertSource(PMSRefDBConnectionObj source)
        {
            string             name        = source.StrName;
            string             description = source.StrDescription;
            PMSRefDBConnection rc          = source.RefDBConnection;
            ListViewGroup      group       = null;

            switch (rc.RefDBType)
            {
            case RefDBType.MSAccess: group = AddGroup(RefDBType.MSAccess); break;

            case RefDBType.MSSqlServer: group = AddGroup(RefDBType.MSSqlServer); break;

            case RefDBType.Oracle: group = AddGroup(RefDBType.Oracle); break;

            case RefDBType.OleDB: group = AddGroup(RefDBType.OleDB); break;

            default:
                break;
            }
            this.listView1.BeginUpdate();
            ListViewItem lvitem = new ListViewItem(name, group);

            lvitem.SubItems.Add(description);
            lvitem.Tag = rc;
            if (source.BDefault == true)
            {
                lvitem.ForeColor = Color.Purple;
            }
            this.listView1.Items.Add(lvitem);
            this.listView1.EndUpdate();
        }
Exemplo n.º 3
0
        private void toolStripButton_AddNew_Click(object sender, EventArgs e)
        {
            using (DBRefStructForm dbrf = new DBRefStructForm()) {
                if (dbrf.ShowDialog() == DialogResult.OK)
                {
                    NewDBSourceForm form = new NewDBSourceForm();
                    form.SDForm = this;
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        PMSRefDBConnectionObj source = new PMSRefDBConnectionObj();
                        source.StrName         = form.sourceName;
                        source.StrDescription  = form.description;
                        source.RefDBConnection = dbrf.RefDBConnection;
                        switch (dbrf.SelectDBType)
                        {
                        case RefDBType.MSSqlServer:
                            InsertSource(source);
                            break;

                        case RefDBType.MSAccess:
                            InsertSource(source);
                            break;

                        case RefDBType.Oracle:
                            InsertSource(source);
                            break;

                        case RefDBType.OleDB:
                            InsertSource(source);
                            break;

                        default:
                            break;
                        }
                        SetModified();
                    }
                }
            }
        }
Exemplo n.º 4
0
        public bool Save()
        {
            try {
                if (this.IsModified)
                {
                    List <PMSRefDBConnectionObj> obl = new List <PMSRefDBConnectionObj> ();
                    foreach (ListViewItem item in listView1.Items)
                    {
                        PMSRefDBConnection    rc = (PMSRefDBConnection)(item.Tag);
                        PMSRefDBConnectionObj ob = new PMSRefDBConnectionObj();
                        ob.StrName        = item.SubItems [0].Text;
                        ob.StrDescription = item.SubItems [1].Text;
                        if (item.ForeColor == Color.Purple)
                        {
                            ob.BDefault = true;
                        }
                        ob.RefDBConnection = rc;
                        obl.Add(ob);
                    }
                    if (null != _DBDefineManager)
                    {
                        _DBDefineManager.CloseAllDBConnects();
                        _DBDefineManager.DBSourceConfigObjList = obl;
                    }
                    PMS.Libraries.ToolControls.PMSPublicInfo.CurrentPrjInfo.SaveRefDBConnectionObjList(obl);
                    // MES开发器环境 中 应保存数据源定义文件至文件服务器
                    //if (CurrentPrjInfo.CurrentEnvironment == MESEnvironment.MESDeveloper)
                    //    RaiseSomeEvent(this, new SaveCompleteEventArgs(ProjectPathClass.RefDBSourcesFilePath));
                    SetSaved();
                }
            } catch (Exception ex) {
                PMS.Libraries.ToolControls.PMSPublicInfo.Message.Error(PMS.Libraries.ToolControls.PMSPublicInfo.PublicFunctionClass.EnhancedStackTrace(ex));
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 设置数据源参数
        /// </summary>
        /// <param name="strDSName">数据源名</param>
        /// <param name="strParaName">
        /// 参数名:
        /// RefDBType 引用数据库类型 0-MSAccess,1-MSSqlServer,2-Oracle,3-OleDB
        /// StrServerName 服务器名
        /// StrDBName 数据库名
        /// StrUserID 用户名
        /// StrPassWord 密码
        /// StrPort 端口号
        /// StrDBPath 数据库路径
        /// EConnectType 连接协议 0-namepipe,1-tcpip
        /// ConnectString 连接字符串
        /// </param>
        /// <param name="strParaValue">参数值</param>
        /// <returns></returns>
        public int SetDSParameter(String strDSName, String strParaName, String strParaValue)
        {
            if (RefDBConnectionObjList == null)
            {
                return(-1);
            }
            if (!RefDBConnectionObjList.Exists(o => o.StrName == strDSName))
            {
                // 数据源不存在则新增
                PMSRefDBConnectionObj refConnect = new PMSRefDBConnectionObj();
                refConnect.StrName         = strDSName;
                refConnect.RefDBConnection = new PMSRefDBConnection();
                RefDBConnectionObjList.Add(refConnect);
            }

            foreach (PMSPublicInfo.PMSRefDBConnectionObj ob in RefDBConnectionObjList)
            {
                if (string.Compare(ob.StrName, strDSName, true) == 0)
                {
                    switch (strParaName)
                    {
                    case "RefDBType":
                    case "DBType":
                        ob.RefDBConnection.RefDBType = GetRefDBTypeFromString(strParaValue);
                        break;

                    case "StrServerName":
                    case "ServerName":
                        ob.RefDBConnection.StrServerName = strParaValue;
                        break;

                    case "StrDBName":
                    case "DBName":
                        ob.RefDBConnection.StrDBName = strParaValue;
                        break;

                    case "StrUserID":
                    case "UserID":
                        ob.RefDBConnection.StrUserID = strParaValue;
                        break;

                    case "StrPassWord":
                    case "PassWord":
                        ob.RefDBConnection.StrPassWord = strParaValue;
                        break;

                    case "StrPort":
                    case "Port":
                        ob.RefDBConnection.StrPortID = strParaValue;
                        break;

                    case "StrDBPath":
                    case "DBPath":
                        ob.RefDBConnection.StrDBPath = strParaValue;
                        break;

                    case "EConnectType":
                    case "ConnectType":
                        ob.RefDBConnection.EConnectType = GetConnectTypeFromString(strParaValue);
                        break;

                    case "ConnectString":
                    case "OleDBConnectString":
                        ob.RefDBConnection.ConnectString = strParaValue;
                        break;
                    }
                }
            }
#if ReportNewEngine
            this.reportViewer1.Connections = RefDBConnectionObjList;
#else
            this.pmsReportViewer1.Connections = RefDBConnectionObjList;
#endif
            return(0);
        }