private void btnOpen_Click(object sender, EventArgs e)
        {
            try
            {
                DBInfo info = new DBInfo();
                info.type     = comboDBType.Text.ToString();
                info.ip       = textDBIP.Text.ToString();
                info.dbname   = textDBName.Text.ToString();
                info.username = textDBAdmin.Text.ToString();
                info.password = textDBPwd.Text.ToString();
                info.port     = 3306;
                Global.LogServer.Add(new LogInfo("ParamSet-Debug", "main->InitDatabase param value" +
                                                 Global.iniPath + " " + info.type + " " + info.ip + " " + info.dbname + " " + info.username + " " + info.password, (int)EnumLogLevel.DEBUG));
                Global.mysqlHelper = new MysqlHelper(info);
                if (!Global.mysqlHelper.ConnectDB())
                {
                    MessageBox.Show("数据库连接失败!");
                    return;
                }
                GetMainParam();
                Global.LogServer.Add(new LogInfo("ParamSet-Debug", "main->btnOpen_Click->GetMainParam done", (int)EnumLogLevel.DEBUG));
                treeMain.Nodes[0].Nodes.Clear();
                GetParamFromDB();
                foreach (ClsNVRInfo nvr in Global.nvrList)
                {
                    TreeNode nvrTree = new TreeNode(nvr.nvrName);
                    treeMain.Nodes[0].Nodes.Add(nvrTree);
                }

                treeMain.Enabled    = true;
                groupBoxSet.Enabled = true;
                btnClose.Enabled    = true;
                btnOpen.Enabled     = false;
                btnSetInfo.Enabled  = true;
                lblStationName.Text = Global.stationInfo.stationName;

                if (Global.nVideoRecogType == 0)
                {
                    group_wentong.Enabled = true;
                }
                else if (Global.nVideoRecogType == 1 && Global.videoList.Count > 0)
                {
                    InitHKGroupBoard();
                }
            }
            catch (System.Exception ex)
            {
                Global.LogServer.Add(new LogInfo("ParamSet-Error", "Main:InitDatabase 初始化数据库失败:" + ex.Message, (int)EnumLogLevel.ERROR));
                MessageBox.Show("数据库连接失败!");
            }
        }
示例#2
0
 public void SetDBInfo(DBInfo info)
 {
     this.LocalDB = info;
 }
示例#3
0
 public MysqlHelper(DBInfo dbinfo)
 {
     this.LocalDB = dbinfo;
     //ConnectDB();
 }