Beispiel #1
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            string strFileName = HDLPF.OpenFileDialog("mdb files (*.mdb)|*.mdb", "mdb Files");

            if (strFileName == null)
            {
                return;
            }
            this.strPath        = strFileName;
            CsConst.mstrCurPath = strPath;
            // lbPathValue.Text = strFileName;
            dgOnline.Rows.Clear();
            try
            {
                string          strsql = "select * from dbBasicInfo";
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, strPath);

                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string   strname    = dr.GetValue(1).ToString();
                        int      DeviceType = Convert.ToInt32(dr.GetValue(2).ToString());
                        object[] obj        = new object[] { false,
                                                             strname.Split('\\')[0].ToString().Split('-')[0].ToString(),
                                                             strname.Split('\\')[0].ToString().Split('-')[1].ToString(),
                                                             strname.Split('\\')[1].ToString(),
                                                             CsConst.mstrINIDefault.IniReadValue("DeviceType" + DeviceType.ToString(), "Description", ""),
                                                             CsConst.mstrINIDefault.IniReadValue("DeviceType" + DeviceType.ToString(), "Model", ""),
                                                             CsConst.mstrINIDefault.IniReadValue("Public", "99933", ""),
                                                             dr.GetValue(0).ToString(), DeviceType.ToString() };
                        dgOnline.Rows.Add(obj);
                    }
                    dr.Close();
                }
            }
            catch
            {
            }
        }
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public override void ReadMS04FrmDBTobuf(int DIndex, int wdMaxValue)
        {
            base.ReadMS04FrmDBTobuf(DIndex, wdMaxValue);

            Chans = new BasicCurtain();
            #region
            String          strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 1);
            OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
            if (dr != null)
            {
                while (dr.Read())
                {
                    string str = dr.GetValue(5).ToString();
                    Chans.runTime  = Convert.ToByte(str.Split('-')[0].ToString());
                    Chans.onDelay  = Convert.ToByte(str.Split('-')[1].ToString());
                    Chans.offDelay = Convert.ToByte(str.Split('-')[2].ToString());
                    Chans.remark   = dr.GetValue(4).ToString();
                }
                dr.Close();
            }
            #endregion
        }
Beispiel #3
0
        ///<summary>
        ///读取数据库面板设置,将所有数据读至缓存
        ///</summary>
        public void ReadHaiInfoFromDB(int DIndex)
        {
            //read HAI Unit inofomation
            units = new List <Unit>();
            #region
            string          str       = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} order by objID", DIndex, 1);
            OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str);
            if (drKeyCmds != null)
            {
                while (drKeyCmds.Read())
                {
                    Unit oTmp = new Unit();
                    oTmp.bytID = drKeyCmds.GetByte(2);
                    UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                    oTmp.Command    = "^A" + String.Format("{0:D3} ", drKeyCmds.GetByte(2));
                    TmpCmd.ID       = 1;
                    TmpCmd.Type     = drKeyCmds.GetByte(3);
                    TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                    TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                    TmpCmd.Param1   = drKeyCmds.GetByte(6);
                    TmpCmd.Param2   = drKeyCmds.GetByte(7);
                    TmpCmd.Param3   = drKeyCmds.GetByte(8);
                    TmpCmd.Param4   = drKeyCmds.GetByte(9);
                    oTmp.oUnit      = TmpCmd;
                    units.Add(oTmp);
                }
            }
            #endregion

            scen = new List <Scene>();
            //read HAI Scene infomation
            #region
            str       = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} order by objID", DIndex, 2);
            drKeyCmds = DataModule.SearchAResultSQLDB(str);
            if (drKeyCmds != null)
            {
                while (drKeyCmds.Read())
                {
                    Scene oTmp = new Scene();
                    oTmp.bytID = drKeyCmds.GetByte(2);
                    UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                    oTmp.Command    = "^C" + String.Format("{0:D3} ", drKeyCmds.GetByte(2));
                    TmpCmd.ID       = 1;
                    TmpCmd.Type     = drKeyCmds.GetByte(3);
                    TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                    TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                    TmpCmd.Param1   = drKeyCmds.GetByte(6);
                    TmpCmd.Param2   = drKeyCmds.GetByte(7);
                    TmpCmd.Param3   = drKeyCmds.GetByte(8);
                    TmpCmd.Param4   = drKeyCmds.GetByte(9);
                    oTmp.oUnit      = TmpCmd;
                    scen.Add(oTmp);
                }
            }
            #endregion

            buttonstatus = new List <ButtonStatus>();
            ///read HAI buttonstatus infomation
            #region
            str       = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} order by objID", DIndex, 3);
            drKeyCmds = DataModule.SearchAResultSQLDB(str);
            if (drKeyCmds != null)
            {
                while (drKeyCmds.Read())
                {
                    ButtonStatus oTmp = new ButtonStatus();
                    oTmp.bytID = drKeyCmds.GetByte(2);
                    UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                    oTmp.Command    = String.Format("{0:D3} ", drKeyCmds.GetByte(2)) + " Button Tab/Press<-->OFF/ON";
                    TmpCmd.ID       = 1;
                    TmpCmd.Type     = drKeyCmds.GetByte(3);
                    TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                    TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                    TmpCmd.Param1   = drKeyCmds.GetByte(6);
                    TmpCmd.Param2   = drKeyCmds.GetByte(7);
                    TmpCmd.Param3   = drKeyCmds.GetByte(8);
                    TmpCmd.Param4   = drKeyCmds.GetByte(9);

                    oTmp.oUnit = TmpCmd;
                    buttonstatus.Add(oTmp);
                }
            }
            #endregion
        }
Beispiel #4
0
        //<summary>
        //读取数据信息
        //</summary>
        public void ReadDataFrmDBTobuf(int DIndex)
        {
            try
            {
                #region
                string          strsql = string.Format("select * from dbBasicInfo where DIndex={0}", DIndex);
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string str = dr.GetValue(1).ToString();
                        DeviceName = DeviceName.Split('\\')[0].ToString() + "\\"
                                     + str.Split('\\')[1].ToString();
                    }
                    dr.Close();
                }
                #endregion

                #region
                strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID=0 order by SenNum", DIndex);
                dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string str = dr.GetValue(5).ToString();
                        Backlight             = Convert.ToByte(str.Split('-')[0].ToString());
                        Ledlight              = Convert.ToByte(str.Split('-')[1].ToString());
                        arayButtonColor       = (byte[])dr[6];
                        arayButtonBalance     = (byte[])dr[7];
                        arayButtonSensitiVity = (byte[])dr[8];
                        arayHotel             = (byte[])dr[9];
                    }
                    dr.Close();
                }
                #endregion

                #region
                strsql       = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 1);
                dr           = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
                myKeySetting = new List <Key>();
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        Key    temp = new Key();
                        string str  = dr.GetValue(5).ToString();
                        temp.ID     = Convert.ToByte(str.Split('-')[0].ToString());
                        temp.Mode   = Convert.ToByte(str.Split('-')[1].ToString());
                        temp.Delay  = Convert.ToByte(str.Split('-')[2].ToString());
                        temp.Remark = dr.GetValue(4).ToString();
                        str         = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} and Ms04State = {2}", DIndex, temp.ID, 0);
                        OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
                        temp.KeyTargets = new List <UVCMD.ControlTargets>();
                        while (drKeyCmds.Read())
                        {
                            UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                            TmpCmd.ID       = drKeyCmds.GetByte(2);
                            TmpCmd.Type     = drKeyCmds.GetByte(3);
                            TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                            TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                            TmpCmd.Param1   = drKeyCmds.GetByte(6);
                            TmpCmd.Param2   = drKeyCmds.GetByte(7);
                            TmpCmd.Param3   = drKeyCmds.GetByte(8);
                            TmpCmd.Param4   = drKeyCmds.GetByte(9);
                            temp.KeyTargets.Add(TmpCmd);
                        }
                        drKeyCmds.Close();
                        myKeySetting.Add(temp);
                    }
                    dr.Close();
                }
                #endregion
            }
            catch
            {
            }
        }
Beispiel #5
0
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public void ReadSecurityFrmDBTobuf(int DIndex)
        {
            if (LogicPos == null)
            {
                LogicPos = new byte[50];                   //存储位置经纬度
            }
            if (MyDesign == null)
            {
                MyDesign = new LogicBlock[12];                   //十二个逻辑块设置
            }
            //读取经纬度
            #region
            string          str = string.Format("select * from dbLogic where DIndex={0}", DIndex);
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str);
            if (dr != null)
            {
                while (dr.Read())
                {
                    LogicPos        = (byte[])dr[1];
                    LogicSummerTime = (byte[])dr[2];
                    DateTimeAry     = (byte[])dr[3];
                    isBroadcastTime = (bool)dr[4];
                }
                dr.Close();
            }
            #endregion

            for (int intI = 1; intI <= 12; intI++)
            {
                MyDesign[intI - 1] = new LogicBlock();
                //读取基本信息
                #region
                str = string.Format("select * from dbLogicTable where DIndex={0}", DIndex);
                dr  = DataModule.SearchAResultSQLDB(str);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        MyDesign[intI - 1].Remark   = dr.GetString(1);
                        MyDesign[intI - 1].TableIDs = (byte[])dr[2];
                        MyDesign[intI - 1].MyPins   = new List <byte[]>();
                        MyDesign[intI - 1].Remarks  = (string[])dr[3];
                        for (byte bytI = 0; bytI < 12; bytI++)
                        {
                            byte[] Tmp = (byte[])dr[4 + bytI];
                            if (Tmp != null)
                            {
                                MyDesign[intI - 1].MyPins.Add(Tmp);
                            }
                        }
                    }
                }
                #endregion

                //读取目标设置
                #region
                MyDesign[intI - 1].ArmCmds = new List <UVCMD.ControlTargets> [20];
                str = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} and  Ms04State >= 1 and Ms04State <= 20 order by objID", DIndex, intI);
                OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str);
                if (drKeyCmds != null)
                {
                    while (drKeyCmds.Read())
                    {
                        int intIndex = drKeyCmds.GetInt16(10); //对应逻辑表号
                        UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                        TmpCmd.ID       = drKeyCmds.GetByte(2);
                        TmpCmd.Type     = drKeyCmds.GetByte(3);
                        TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                        TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                        TmpCmd.Param1   = drKeyCmds.GetByte(6);
                        TmpCmd.Param2   = drKeyCmds.GetByte(7);
                        TmpCmd.Param3   = drKeyCmds.GetByte(8);
                        TmpCmd.Param4   = drKeyCmds.GetByte(9);
                        TmpCmd.Hint     = drKeyCmds.GetString(11);

                        if (MyDesign[intI - 1].ArmCmds[intIndex - 1] == null)
                        {
                            MyDesign[intI - 1].ArmCmds[intIndex - 1] = new List <UVCMD.ControlTargets>();
                        }
                        MyDesign[intI - 1].ArmCmds[intIndex - 1].Add((UVCMD.ControlTargets)TmpCmd);
                    }
                    drKeyCmds.Close();
                }
                #endregion
            }
        }
Beispiel #6
0
        ///<summary>
        ///读取数据库面板设置,将所有数据读至缓存
        ///</summary>
        public void ReadSensorInfoFromDB(int DIndex)
        {
            //read GPRS Info
            #region
            string          str = string.Format("select * from dbGPRSbasic where DIndex={0}", DIndex);
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
            if (dr == null)
            {
                return;
            }
            while (dr.Read())
            {
                strIP        = dr.GetString(1);
                strRouterIP  = dr.GetString(2);
                strMAC       = dr.GetString(3);
                strSevCentre = dr.GetString(4);
                strCode      = dr.GetString(5);
                strIMEI      = dr.GetString(6);
                blnTo485     = dr.GetBoolean(7);
            }
            dr.Close();
            #endregion

            //read GPRS Control Info
            #region
            MyControls = new List <SMSControls>();
            str        = string.Format("select * from dbGPRSControls where DIndex={0} order by SenNum", DIndex);
            dr         = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
            if (dr != null)
            {
                while (dr.Read())
                {
                    SMSControls temp = new SMSControls();
                    temp.MyVerify      = new List <PhoneInF>();
                    temp.MyTargets     = new List <UVCMD.ControlTargets>();
                    temp.ID            = dr.GetInt16(1);
                    temp.strRemark     = dr.GetString(2);
                    temp.strSMSContent = dr.GetString(3);
                    temp.blnIsVerify   = dr.GetBoolean(4);
                    temp.blnReply      = dr.GetBoolean(5);

                    #region
                    if (temp.blnIsVerify == true)
                    {
                        str = string.Format("select * from dbGPRSVerify where DIndex={0} and SenNum ={1} order by VerifyNum", DIndex, temp.ID);
                        OleDbDataReader drVerify = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
                        if (drVerify != null)
                        {
                            while (drVerify.Read())
                            {
                                PhoneInF tmp = new PhoneInF();
                                tmp.ID       = drVerify.GetInt16(2);
                                tmp.Remark   = drVerify.GetString(3);
                                tmp.PhoneNum = drVerify.GetString(4);
                                temp.MyVerify.Add(tmp);
                            }
                            drVerify.Close();
                        }
                    }
                    #endregion

                    str = string.Format("select * from dbKeyTargets where DIndex ={0} and KeyIndex = {1} order by objID", DIndex, temp.ID);
                    OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
                    if (drKeyCmds != null)
                    {
                        while (drKeyCmds.Read())
                        {
                            UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                            TmpCmd.ID       = drKeyCmds.GetByte(2);
                            TmpCmd.Type     = drKeyCmds.GetByte(3);
                            TmpCmd.SubnetID = drKeyCmds.GetByte(4);
                            TmpCmd.DeviceID = drKeyCmds.GetByte(5);
                            TmpCmd.Param1   = drKeyCmds.GetByte(6);
                            TmpCmd.Param2   = drKeyCmds.GetByte(7);
                            TmpCmd.Param3   = drKeyCmds.GetByte(8);
                            TmpCmd.Param4   = drKeyCmds.GetByte(9);
                            temp.MyTargets.Add(TmpCmd);
                        }
                        drKeyCmds.Close();
                        MyControls.Add(temp);
                    }
                }
                dr.Close();
            }
            #endregion

            //read GPRS SMS Send Info
            #region
            MySendSMS = new List <SendSMS>();
            str       = string.Format("select * from dbGPRSSendSMS where DIndex = {0} order by SenNum", DIndex);
            dr        = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
            if (dr != null)
            {
                while (dr.Read())
                {
                    SendSMS temp = new SendSMS();
                    temp.MyGuests  = new List <PhoneInF>();
                    temp.ID        = dr.GetInt16(1);
                    temp.strRemark = dr.GetString(2);

                    str = string.Format("select * from dbGPRSSendSMSInfo where DIndex={0} and SenNum ={1} order by TargetNum", DIndex, temp.ID);
                    OleDbDataReader drSend = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
                    if (drSend != null)
                    {
                        while (drSend.Read())
                        {
                            PhoneInF tmp = new PhoneInF();
                            tmp.ID       = drSend.GetInt16(2);
                            tmp.Remark   = drSend.GetString(3);
                            tmp.PhoneNum = drSend.GetString(4);
                            tmp.strSMS   = drSend.GetString(5);
                            temp.MyGuests.Add(tmp);
                        }
                        drSend.Close();
                    }
                    MySendSMS.Add(temp);
                }
                dr.Close();
            }
            #endregion
        }