Ejemplo n.º 1
0
        /// <summary>
        /// 从数据库里读取装置信息
        /// </summary>
        public void SYSSQL()
        {
            SYSConnString     = "";
            SYS_DATABASETable = "";
            INI_IO ini_io = new INI_IO();

            if (ini_io.IniFiles(StartupPath + "\\sys_setting.ini"))
            {
                string sysA           = ini_io.ReadString("Section", "SYSSERVER_ADDRESS", "");
                string sysport        = ini_io.ReadString("Section", "SYS_PORT", "");
                string sysuser        = ini_io.ReadString("Section", "SYS_USERNAME", "");
                string syspwd         = ini_io.ReadString("Section", "SYS_PASSWORD", "");
                string IsSYSSqlServer = ini_io.ReadString("Section", "SYS_SQLSERVER", "");
                string strSYSDatabase = "";
                if (IsSYSSqlServer == "1")
                {
                    strSYSDatabase    = ini_io.ReadString("Section", "SYS_DATABASENAME", "");
                    SYS_DATABASETable = ini_io.ReadString("Section", "SYS_DATABASETable", "");
                }
                else if (IsSYSSqlServer == "0")
                {
                    strSYSDatabase = ini_io.ReadString("Section", "SYS_DATABASEFILENAME", "");
                }
                SYSConnString = "Provider=SQLOLEDB;Server=" + sysA + "," + sysport + ";Database=" +
                                strSYSDatabase + ";Persist Security Info=False;uid=" + sysuser + ";pwd=" + syspwd + ";";
            }
            else
            {
                //MessageBox.Show("没有配置文件!");
            }
        }
Ejemplo n.º 2
0
        public void ReadFromDataBase(string EquipmentName)
        {
            INI_IO ini_io = new INI_IO();

            //if (ini_io.IniFiles(Application.StartupPath + "\\sys_setting.ini"))
            //{
            //string  sysA = ini_io.ReadString("Section", "SYSSERVER_ADDRESS", "");
            //string sysport = ini_io.ReadString("Section", "SYS_PORT", "");
            //string sysuser = ini_io.ReadString("Section", "SYS_USERNAME", "");
            //string syspwd = ini_io.ReadString("Section", "SYS_PASSWORD", "");
            //string  IsSYSSqlServer = ini_io.ReadString("Section", "SYS_SQLSERVER", "");
            //string strSYSDatabase="";
            //if (IsSYSSqlServer == "1")
            //    strSYSDatabase = ini_io.ReadString("Section", "SYS_DATABASENAME", "");
            // else if (IsSYSSqlServer == "0")
            //    strSYSDatabase = ini_io.ReadString("Section", "SYS_DATABASEFILENAME", "");
            //string SYSConnString = "Provider=SQLOLEDB;Server=" + sysA + "," + sysport + ";Database=" +
            //                   strSYSDatabase + ";Persist Security Info=False;uid=" + sysuser + ";pwd=" + syspwd + ";";
            SYSSQL();
            Conn = new OleDbConnection(SYSConnString);
            Conn.Open();
            if (Conn.State == ConnectionState.Open)
            {
                string          Sqlstr  = string.Format("select * from {0} where EquipName= '{1}'", SYS_DATABASETable, EquipmentName);
                OleDbCommand    command = new OleDbCommand(Sqlstr, Conn);
                OleDbDataReader reader  = command.ExecuteReader();
                int             count   = 0;
                while (reader.Read())
                {
                    count++;
                    strRDatabase = (string)reader["DataBaseName_RTResEx"];
                    strDatabase  = (string)reader["DataBaseName_Soft_Qdrise"];
                    PesFileName  = (string)reader["PesFileName"];
                    break;
                }
                if (count == 0)
                {
                    //MessageBox.Show("数据库没有该装置!");
                    count = 0;
                    return;
                }
                ReadINI();
            }

            else
            {
                //Show("获取装置失败!");
                return;
            }
            Conn.Close();
        }
Ejemplo n.º 3
0
        public void ReadINI()
        {
            INI_IO ini_io = new INI_IO();

            if (ini_io.IniFiles(StartupPath + "\\sys_setting.ini"))
            {
                strServer   = ini_io.ReadString("Section", "SERVER_ADDRESS", "");
                strPort     = ini_io.ReadString("Section", "DB_PORT", "");
                struid      = ini_io.ReadString("Section", "DB_USERNAME", "");
                strpwd      = ini_io.ReadString("Section", "DB_PASSWORD", "");
                IsSqlServer = ini_io.ReadString("Section", "IS_SQLSERVER", "");
                if (IsSqlServer == "1")
                {
                }
                //strDatabase = ini_io.ReadString("Section", "DB_DATABASENAME", "");
                else if (IsSqlServer == "0")
                {
                    strDatabase = ini_io.ReadString("Section", "DB_DATABASEFILENAME", "");
                }
                strRServer   = ini_io.ReadString("Section", "RSERVER_ADDRESS", "");
                strRPort     = ini_io.ReadString("Section", "RDB_PORT", "");
                strRuid      = ini_io.ReadString("Section", "RDB_USERNAME", "");
                strRpwd      = ini_io.ReadString("Section", "RDB_PASSWORD", "");
                IsRSqlServer = ini_io.ReadString("Section", "RIS_SQLSERVER", "");
                if (IsRSqlServer == "1")
                {
                }
                //strRDatabase = ini_io.ReadString("Section", "RDB_DATABASENAME", "");
                else if (IsRSqlServer == "0")
                {
                    strRDatabase = ini_io.ReadString("Section", "RDB_DATABASEFILENAME", "");
                }
            }
            else
            {
                //MessageBox.Show("没有配置文件!");
            }
        }
Ejemplo n.º 4
0
        public int ReadID()
        {
            INI_IO ini_io = new INI_IO();

            if (ini_io.IniFiles(CommonStr.physicalPath + "\\sys_setting.ini"))
            {
                string strID = ini_io.ReadString("Section", "ID", "");
                if (strID == "")
                {
                    return(-1);
                }
                else
                {
                    int ID = Int32.Parse(strID);
                    ID += 1;
                    ini_io.WriteString("Section", "ID", "" + ID);
                    return(ID);
                }
            }
            else
            {
                return(-1);
            }
        }