Пример #1
0
        //<summary>
        //读取数据库里的HVAC的设置,将所有数据读取缓存
        //</summary>
        public void ReadInfoForDB(int id)
        {
            //read all channels information save them to the buffer
            string          str = "select * from dbHVAC where DIndex=" + id.ToString();
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    bytAutoRun = dr.GetByte(1);

                    bytModeONDelay  = dr.GetByte(2); // 模式,风速开关延迟
                    bytModeOFFDelay = dr.GetByte(3);
                    bytFanONDelay   = dr.GetByte(4);
                    bytFanOFFDelay  = dr.GetByte(5);

                    bytCOrP = dr.GetByte(6); //电压还是电流输出
                    bytHigh = dr.GetByte(7);
                    bytMid  = dr.GetByte(8);
                    bytLow  = dr.GetByte(9);

                    bytSteps = (byte[])dr[10];
                }
            }
            dr.Close();
        }
Пример #2
0
        public static void SaveAllGroupCommandsFrmDatabase()
        {
            string str = string.Format("delete * from dbGrpRemark");

            DataModule.ExecuteSQLDatabase(str);

            str = string.Format("delete * from dbGrpCMD");
            DataModule.ExecuteSQLDatabase(str);

            if (CsConst.myTemplates == null)
            {
                return;
            }

            ////read keys commands to buffer
            foreach (ControlTemplates oTmp in CsConst.myTemplates)
            {
                if (oTmp.GpCMD != null)
                {
                    string strsql = string.Format("Insert into dbGrpRemark(GrpID,Remark,bytType,bytGpID) values ({0},'{1}',{2},{3})", oTmp.ID, oTmp.Name, oTmp.bytType, oTmp.bytGpID);
                    DataModule.ExecuteSQLDatabase(strsql);
                    for (int i = 0; i < oTmp.GpCMD.Count; i++)
                    {
                        UVCMD.ControlTargets TmpCmds = oTmp.GpCMD[i];
                        ///// insert into all commands to database
                        strsql = string.Format("Insert into dbGrpCMD(GrpID,objID,KeyFunType,SubNetID,DeviceID,FirstParameter,"
                                               + "SecondParameter,RunTimeMinute,RunTimeSecond,strHint,Default1) values ({0},{1},{2},{3},{4},{5},{6},{7},{8},'{9}',{10})",
                                               oTmp.ID, TmpCmds.ID, TmpCmds.Type, TmpCmds.SubnetID, TmpCmds.DeviceID, TmpCmds.Param1,
                                               TmpCmds.Param2, TmpCmds.Param3, TmpCmds.Param4, TmpCmds.Hint, oTmp.bytType);
                        DataModule.ExecuteSQLDatabase(strsql);
                    }
                }
            }
        }
Пример #3
0
        public static bool SaveDatatoDB()
        {
            bool result = true;
            int  test   = -1;

            try
            {
                if (CsConst.WholeTextsList == null || CsConst.WholeTextsList.Count <= 0)
                {
                    return(true);
                }

                string strsql = "";
                foreach (FormDisplayTextList temp in CsConst.WholeTextsList)
                {
                    // check if it has already exist, if yes ,save to ini
                    #region
                    test   = temp.iIndexInWholeList;
                    strsql = string.Format("insert into dbLanguaText(TextIndex,TextLength,English) values ({0},{1},'{2}')",
                                           temp.iIndexInWholeList, temp.sMaxLimit, temp.sDisplayName);

                    DataModule.ExecuteSQLDatabase(strsql);
                    #endregion
                }
            }
            catch
            {
                MessageBox.Show(test.ToString());
                result = false;
            }
            return(result);
        }
Пример #4
0
        public static void LoadButtonCoontrolTypeFromDatabaseToPublicClass()
        {
            CsConst.WholeTextsList = new List <FormDisplayTextList>();
            try
            {
                string          strsql = string.Format("select * from dbLanguaText order by TextIndex");
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath);

                if (dr != null)
                {
                    while (dr.Read())
                    {
                        FormDisplayTextList TmpButtonMode = new FormDisplayTextList();
                        TmpButtonMode.iIndexInWholeList = dr.GetInt32(0);
                        TmpButtonMode.sMaxLimit         = dr.GetInt32(1);
                        if (dr.GetString(CsConst.iLanguageId + 2) != null)
                        {
                            TmpButtonMode.sDisplayName = dr.GetString(CsConst.iLanguageId + 2);
                        }
                        CsConst.WholeTextsList.Add(TmpButtonMode);
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #5
0
        //<summary>
        //读取数据库里的调光模块的设置,将所有数据读取缓存
        //</summary>
        public void ReadInfoForDB(int id)
        {
            Chans = new List <Chn>();

            //read all channels information save them to the buffer
            string          str = "select * from dbTempSensor where DIndex=" + id.ToString() + " order by ChnID";
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Chn Tmp = new Chn();
                    Tmp.bytTheType = dr.GetByte(2);

                    Tmp.bytRValue    = new byte[6];
                    Tmp.bytRValue[0] = byte.Parse((dr.GetInt16(3) / 256).ToString());
                    Tmp.bytRValue[1] = byte.Parse((dr.GetInt16(3) % 256).ToString());
                    Tmp.bytRValue[2] = byte.Parse((dr.GetInt16(4) / 256).ToString());
                    Tmp.bytRValue[3] = byte.Parse((dr.GetInt16(4) % 256).ToString());
                    Tmp.bytRValue[4] = byte.Parse((dr.GetInt16(5) / 256).ToString());
                    Tmp.bytRValue[5] = byte.Parse((dr.GetInt16(5) % 256).ToString());

                    Tmp.blnBroadTemp = dr.GetBoolean(6);
                    Tmp.bytSubID     = dr.GetByte(7);
                    Tmp.bytDevID     = dr.GetByte(8);
                    Tmp.byAdjustVal  = dr.GetByte(9);

                    Chans.Add(Tmp);
                }
            }
            dr.Close();
        }
Пример #6
0
        private void btnReName_Click(object sender, EventArgs e)
        {
            if (tvEdit.SelectedNode == null)
            {
                return;
            }
            if (tvEdit.SelectedNode.Level == 0)
            {
                return;
            }
            if (tbRemark1.Text == null || tbRemark1.Text == "")
            {
                return;
            }

            string strDevice    = tvEdit.SelectedNode.Parent.Text;
            string strOldRemark = tvEdit.SelectedNode.Text;
            string strNewRemark = tbRemark1.Text;

            //更新到数据库

            string strsql = string.Format("update tblRemoteCode set Remark='{0}' where ID={1} and RemoteDeviceID = {2} and Remark='{3}'", strNewRemark,
                                          tvEdit.SelectedNode.Name, tvEdit.SelectedNode.Parent.Name, strOldRemark);

            DataModule.ExecuteSQLDatabase(strsql);
        }
Пример #7
0
 //<summary>
 //读取数据信息
 //</summary>
 public void ReadDataFrmDBTobuf(int DIndex)
 {
     try
     {
         #region
         string strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 0);
         OleDbDataReader dr = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
         myACSetting = new List<ThirdPartAC>();
         if (dr != null)
         {
             while (dr.Read())
             {
                 ThirdPartAC temp = new ThirdPartAC();
                 string str = dr.GetValue(5).ToString();
                 temp.ID = Convert.ToByte(str.Split('-')[0].ToString());
                 temp.Enable = Convert.ToByte(str.Split('-')[1].ToString());
                 temp.ACNO = Convert.ToByte(str.Split('-')[2].ToString());
                 temp.CoolMasterAddress = Convert.ToByte(str.Split('-')[3].ToString());
                 temp.GroupID = Convert.ToByte(str.Split('-')[4].ToString());
                 temp.arayACinfo = (byte[])dr[6];
                 temp.Remark = dr.GetValue(4).ToString();
                 myACSetting.Add(temp);
             }
             dr.Close();
         }
         #endregion
     }
     catch
     {
     }
 }
Пример #8
0
        public String ModeName; //中文

        public static void LoadButtonModeFromDatabaseToPublicClass()
        {
            CsConst.myPublicButtonMode = new List <ButtonMode>();

            string          strsql = string.Format("select * from defKeyMode order by KeyModeNO");
            OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath);

            if (dr != null)
            {
                while (dr.Read())
                {
                    ButtonMode TmpButtonMode = new ButtonMode();
                    TmpButtonMode.ModeOrder  = (Byte)(dr.GetInt16(0));
                    TmpButtonMode.ModeSaveID = (Byte)(dr.GetInt16(1));
                    if (CsConst.iLanguageId == 0) //
                    {
                        TmpButtonMode.ModeName = dr.GetString(3);
                    }
                    else
                    {
                        TmpButtonMode.ModeName = dr.GetString(2);
                    }
                    CsConst.myPublicButtonMode.Add(TmpButtonMode);
                }
                dr.Close();
            }
        }
Пример #9
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (tvEdit.SelectedNode == null)
            {
                return;
            }
            TreeNode oTmp = tvEdit.SelectedNode;

            if (oTmp.Level == 0 && (oTmp.Nodes == null || oTmp.Nodes.Count == 0))  // 如果是设备 而且本身没有任何红外码 可以直接移除
            {
                oTmp.Remove();
                // 删除当前全部类
                string strsql = string.Format("Delete from tblRemoteDevice where ID = {0}", oTmp.Name);
                DataModule.ExecuteSQLDatabase(strsql);
            }
            else if (oTmp.Level == 1)  // 如果设备中的其中一个红外码 可以直接删除
            {
                string strDevice    = oTmp.Parent.Text;
                string strOldRemark = oTmp.Text;

                string strInsert = string.Format("Delete from tblRemoteCode where ID = {0} and RemoteDeviceID = {1} and Remark = '{2}'", oTmp.Name, oTmp.Parent.Name, strOldRemark);
                DataModule.ExecuteSQLDatabase(strInsert);

                oTmp.Remove();
            }
        }
Пример #10
0
        //<summary>
        //保存数据库面板设置,将所有数据保存
        //</summary>
        public override void SaveSendIRToDB(int intDeviceType)
        {
            base.SaveSendIRToDB(intDeviceType);

            int wdMaxValue = DeviceTypeList.GetMaxValueFromPublicModeGroup(intDeviceType);

            Chans = new List <DimmerChannelGenerationTwo>();

            for (int i = 0; i < wdMaxValue; i++)
            {
                DimmerChannel oChan = Chans[i];
                string        str = "";
                string        chid = "", remark = "", loadType = "", MinValue = "", MaxValue = "", MaxLevel = "";
                string        temp = "", Belongs = "";
                if (Chans == null)
                {
                    return;
                }
                temp = "-";


                chid     += "1" + temp;
                remark   += oChan.remark + temp;
                loadType += oChan.loadType.ToString() + temp;
                MinValue += oChan.minValue.ToString() + temp;
                MaxValue += oChan.maxValue.ToString() + temp;
                MaxLevel += oChan.maxLevel.ToString() + temp;
                Belongs  += oChan.belongArea.ToString() + temp;

                str = "insert into dbDevChnsDR(ID,ChannelID,Remark,LoadType,Low,High,MaxValue,AreaID) values(" + "1".ToString() + ",'" + chid
                      + "','" + remark + "','" + loadType + "','" + MinValue + "','" + MaxValue + "','" + MaxLevel + "','" + Belongs + "')";

                DataModule.ExecuteSQLDatabase(str);
            }
        }
Пример #11
0
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public override void ReadMS04FrmDBTobuf(int DIndex, int wdMaxValue)
        {
            base.ReadMS04FrmDBTobuf(DIndex, wdMaxValue);

            Chans = new List <RelayChannel>();
            #region
            //read all channels information save them to the buffer
            string          strsql = "select * from dbDevChnsDR where ID=" + DIndex.ToString() + " order by ChannelID";
            OleDbDataReader drChns = DataModule.SearchAResultSQLDB(strsql);
            if (drChns != null && drChns.HasRows)
            {
                drChns.Read();

                string[] chanID   = drChns.GetString(1).Split('-');
                string[] remark   = drChns.GetString(2).Split('-');
                string[] loadType = drChns.GetString(3).Split('-');
                string[] MinValue = drChns.GetString(4).Split('-');
                string[] MaxValue = drChns.GetString(5).Split('-');
                string[] MaxLevel = drChns.GetString(6).Split('-');
                string[] Belongs  = drChns.GetString(7).Split('-');
                //回路
                for (int i = 0; i < chanID.Length; i++)
                {
                    RelayChannel Ch = new RelayChannel();
                    Ch.Remark       = remark[0];
                    Ch.LoadType     = int.Parse(loadType[0]);
                    Ch.OnDelay      = int.Parse(MinValue[0]);
                    Ch.ProtectDelay = int.Parse(MaxValue[0]);
                    Chans.Add(Ch);
                    drChns.Close();
                }
            }
            #endregion
        }
Пример #12
0
        public String ControlTypeName; //中文

        public static void LoadButtonCoontrolTypeFromDatabaseToPublicClass()
        {
            CsConst.myDryGroupControlType = new List <DryControlType>();

            string          strsql = string.Format("select * from defGroupMemberType order by ID");
            OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath);

            if (dr != null)
            {
                while (dr.Read())
                {
                    DryControlType TmpButtonMode = new DryControlType();
                    TmpButtonMode.ControlTypeSaveID = (Byte)dr.GetInt32(0);
                    if (CsConst.iLanguageId == 1)
                    {
                        TmpButtonMode.ControlTypeName = dr.GetString(1);
                    }
                    else
                    {
                        TmpButtonMode.ControlTypeName = dr.GetString(2);
                    }
                    CsConst.myDryGroupControlType.Add(TmpButtonMode);
                }
                dr.Close();
            }
        }
Пример #13
0
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public override void ReadMS04FrmDBTobuf(int DIndex, int wdMaxValue)
        {
            base.ReadMS04FrmDBTobuf(DIndex, wdMaxValue);

            Chans = new List <DimmerChannelGenerationTwo>();
            #region
            //read all channels information save them to the buffer
            string          strsql = "select * from dbDevChnsDR where ID=" + DIndex.ToString() + " order by ChannelID";
            OleDbDataReader drChns = DataModule.SearchAResultSQLDB(strsql);
            if (drChns != null && drChns.HasRows)
            {
                drChns.Read();

                string[] chanID   = drChns.GetString(1).Split('-');
                string[] remark   = drChns.GetString(2).Split('-');
                string[] loadType = drChns.GetString(3).Split('-');
                string[] MinValue = drChns.GetString(4).Split('-');
                string[] MaxValue = drChns.GetString(5).Split('-');
                string[] MaxLevel = drChns.GetString(6).Split('-');
                string[] Belongs  = drChns.GetString(7).Split('-');

                drChns.Close();
            }
            #endregion
        }
Пример #14
0
        //<summary>
        //保存数据库面板设置,将所有数据保存
        //</summary>
        public override void SaveSendIRToDB(int intDeviceType)
        {
            base.SaveSendIRToDB(intDeviceType);

            //insert new channel information
            if (Chans != null)
            {
                #region
                string str = "";
                string chid = "", remark = "", loadType = "", MinValue = "", MaxValue = "", MaxLevel = "";
                string temp = "", Belongs = "";
                byte   bytI = 0;
                foreach (RelayChannel ch in Chans)
                {
                    chid     += bytI.ToString() + temp;
                    remark   += ch.Remark + temp;
                    loadType += ch.LoadType.ToString() + temp;
                    MinValue += ch.OnDelay.ToString() + temp;
                    MaxValue += ch.ProtectDelay.ToString() + temp;
                    bytI++;
                }

                str = "insert into dbDevChnsDR(ID,ChannelID,Remark,LoadType,Low,High,MaxValue,AreaID) values(" + DIndex.ToString() + ",'" + chid
                      + "','" + remark + "','" + loadType + "','" + MinValue + "','" + MaxValue + "','" + MaxLevel + "','" + Belongs + "')";

                DataModule.ExecuteSQLDatabase(str);
                #endregion
            }
        }
Пример #15
0
        //<summary>
        //读取IP设置,将所有数据读至缓存
        //</summary>
        public void ReadCurtainFrmDBTobuf(int intDIndex)
        {
            // read current device type new or old one
            string          str = "select * from dbIPModule where DIndex=" + intDIndex.ToString();
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);

            if (dr == null)
            {
                return;
            }
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    bytWorkType = dr.GetByte(5); //0 局域网,1 p2p, 2 server
                    strGroup    = dr.GetString(6);
                    strPrjName  = dr.GetString(7);
                    strUser     = dr.GetString(8);
                    strPWD      = dr.GetString(9);
                    strServer1  = dr.GetString(10);
                    intPort1    = dr.GetInt32(11);
                    strServer2  = dr.GetString(12);
                    intPort2    = dr.GetInt32(13);
                    bytTimer    = dr.GetByte(14);
                    bytEnDHCP   = dr.GetByte(15);
                }
                dr.Close();
            }
        }
Пример #16
0
        ///<summary>
        ///保存数据库面板设置,将所有数据保存
        ///</summary>
        public void SaveDevieceInfoToDB()
        {
            /// delete all old information and refresh the database
            string strsql = string.Format("delete from dbBasicBac where  DIndex={0}", DIndex);

            DataModule.ExecuteSQLDatabase(strsql);

            strsql = string.Format("delete from dbBackNet where  DIndex={0}", DIndex);
            DataModule.ExecuteSQLDatabase(strsql);

            ///save save basic setup of EIB
            #region
            strsql = string.Format("insert into dbBasicBac(DIndex,Remark,strIP,strRouterIP,strMAC,strMaskIP,bytPort,bytSwitch,bytDevID) values({0},'{1}','{2}','{3}','{4}','{5}',{6},{7},{8})",
                                   DIndex, DeviceName, "", "", "", ValidCount.ToString(), intPort, Convert.ToByte(blnSwitch), Address);
            DataModule.ExecuteSQLDatabase(strsql);
            #endregion

            //save bus to EIB command
            #region

            if (otherInfo == null)
            {
                return;
            }
            byte bytI = 0;
            for (int i = 0; i < otherInfo.Count; i++)
            {
                bytI++;
                OtherInfo temp = otherInfo[i];
                System.Diagnostics.Debug.WriteLine(otherInfo[1].Param4);
                string sql = "insert into dbBackNet(DIndex,CurNo,BackNetIDAry,Type,strDevName,Param1,Param2,Param3,Param4,Remark) values(@DIndex,@CurNo,@BackNetIDAry,@Type,@strDevName,@Param1,@Param2,@Param3,@Param4,@Remark)";
                //创建一个OleDbConnection对象
                OleDbConnection conn;
                conn = new OleDbConnection(DataModule.ConString + CsConst.mstrDefaultPath);
                conn.Open();
                OleDbCommand cmdTmp = new OleDbCommand(sql, conn);
                ((OleDbParameter)cmdTmp.Parameters.Add("@DIndex", OleDbType.Integer)).Value      = DIndex;
                ((OleDbParameter)cmdTmp.Parameters.Add("@CurNo", OleDbType.Char)).Value          = temp.ID;
                ((OleDbParameter)cmdTmp.Parameters.Add("@BackNetIDAry", OleDbType.Binary)).Value = temp.BackNetIDAry;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Type", OleDbType.Integer)).Value        = temp.Type;
                ((OleDbParameter)cmdTmp.Parameters.Add("@strDevName", OleDbType.VarChar)).Value  = temp.strDevName;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param1", OleDbType.Char)).Value         = temp.Param1;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param2", OleDbType.Char)).Value         = temp.Param2;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param3", OleDbType.Char)).Value         = temp.Param3;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param4", OleDbType.Char)).Value         = temp.Param4;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Remark", OleDbType.VarChar)).Value      = temp.Remark;
                try
                {
                    cmdTmp.ExecuteNonQuery();
                }
                catch (OleDbException exp)
                {
                    MessageBox.Show(exp.ToString());
                }
                conn.Close();
            }
            #endregion
        }
Пример #17
0
        ///<summary>
        ///保存数据库面板设置,将所有数据保存
        ///</summary>
        public void SaveDevieceInfoToDB(int DIndex)
        {
            /// delete all old information and refresh the database
            string strsql = string.Format("delete from dbDeviceInfo where  DIndex={0}", DIndex);

            DataModule.ExecuteSQLDatabase(strsql);

            strsql = string.Format("delete from dbEIBDev where  DIndex={0}", DIndex);
            DataModule.ExecuteSQLDatabase(strsql);

            ///save save basic setup of EIB
            #region
            strsql = string.Format("insert into dbDeviceInfo(DIndex,Devname,Address) values({0},'{1}','{2}')", DIndex, Devname, Address);
            DataModule.ExecuteSQLDatabase(strsql);
            #endregion

            //save bus to EIB command
            #region

            if (otherInfo == null)
            {
                return;
            }
            byte bytI = 0;
            for (int i = 0; i < otherInfo.Count; i++)
            {
                bytI++;
                OtherInfo temp = otherInfo[i];
                System.Diagnostics.Debug.WriteLine(otherInfo[1].Param4);
                string sql = "insert into dbEIBDev(DIndex,CurNo,GroupAddress,ControlType,Type,Param1,Param2,Param3,Param4,DestDev) values(@DIndex,@CurNo,@GroupAddress,@ControlType,@Type,@Param1,@Param2,@Param3,@Param4,@DestDev)";
                //创建一个OleDbConnection对象
                OleDbConnection conn;
                conn = new OleDbConnection(DataModule.ConString + CsConst.mstrDefaultPath);
                conn.Open();
                OleDbCommand cmdTmp = new OleDbCommand(sql, conn);
                ((OleDbParameter)cmdTmp.Parameters.Add("@DIndex", OleDbType.Integer)).Value       = DIndex;
                ((OleDbParameter)cmdTmp.Parameters.Add("@CurNo", OleDbType.Char)).Value           = i;
                ((OleDbParameter)cmdTmp.Parameters.Add("@GroupAddress", OleDbType.VarChar)).Value = temp.GroupAddress;
                ((OleDbParameter)cmdTmp.Parameters.Add("@ControlType", OleDbType.Char)).Value     = temp.ControlType;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Type", OleDbType.Char)).Value            = temp.Type;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param1", OleDbType.Char)).Value          = temp.Param1;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param2", OleDbType.Char)).Value          = temp.Param2;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param3", OleDbType.Char)).Value          = temp.Param3;
                ((OleDbParameter)cmdTmp.Parameters.Add("@Param4", OleDbType.Char)).Value          = temp.Param4;
                ((OleDbParameter)cmdTmp.Parameters.Add("@DestDev", OleDbType.VarChar)).Value      = temp.strDevName;
                try
                {
                    cmdTmp.ExecuteNonQuery();
                }
                catch (OleDbException exp)
                {
                    MessageBox.Show(exp.ToString());
                }
                conn.Close();
            }
            #endregion
        }
Пример #18
0
        public String sSimpleFunctionList; // 简易功能分解列表

        public static void LoadButtonCoontrolTypeFromDatabaseToPublicClass()
        {
            CsConst.myDeviceTypeLists = new List <DeviceTypeList>();
            try
            {
                string          strsql = string.Format("select * from defDeviceType order by DeviceType");
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrDefaultPath);

                if (dr != null)
                {
                    while (dr.Read())
                    {
                        DeviceTypeList TmpButtonMode = new DeviceTypeList();
                        TmpButtonMode.DeviceType = dr.GetInt32(0);
                        if (dr.GetString(1) != null)
                        {
                            TmpButtonMode.sModelChn = dr.GetString(1);
                        }
                        if (dr.GetString(2) != null)
                        {
                            TmpButtonMode.sModelEng = dr.GetString(2);
                        }
                        if (CsConst.iLanguageId == 1)
                        {
                            TmpButtonMode.DeviceName = dr.GetString(3);
                            if (TmpButtonMode.DeviceName.Contains('('))
                            {
                                TmpButtonMode.DeviceName = TmpButtonMode.DeviceName.Split('(')[0].ToString();
                            }
                        }
                        else
                        {
                            TmpButtonMode.DeviceName = dr.GetString(4);
                        }
                        TmpButtonMode.iMaxValue = dr.GetInt32(5);
                        if (TmpButtonMode.DeviceType >= 60000)
                        {
                            dr.Close();
                            return;
                        }
                        else
                        {
                            if (dr.GetString(13) != null)
                            {
                                TmpButtonMode.sSimpleFunctionList = (String)dr.GetString(13);
                            }
                        }
                        CsConst.myDeviceTypeLists.Add(TmpButtonMode);
                    }
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #19
0
        ///<summary>
        ///读取数据库面板设置,将所有数据读至缓存
        ///</summary>
        public void ReadDevieceInfoFromDB(int intDIndex)
        {
            //read basic information of bacnet
            #region
            string          str = "select * from dbBasicBac where DIndex=" + intDIndex.ToString();
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);

            if (dr == null)
            {
                return;
            }
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    DeviceName = dr.GetString(1);

                    ValidCount = Convert.ToInt32(dr.GetValue(5).ToString());
                    intPort    = dr.GetInt16(6);
                    blnSwitch  = (dr.GetByte(7) == 1);
                    Address    = dr.GetInt16(8);
                }
                dr.Close();
            }
            #endregion

            //read bacnet to bus
            #region

            str       = string.Format("select * from dbBackNet where DIndex={0}", intDIndex);
            dr        = DataModule.SearchAResultSQLDB(str, CsConst.mstrCurPath);
            otherInfo = new List <OtherInfo>();
            if (dr == null)
            {
                return;
            }
            while (dr.Read())
            {
                OtherInfo tmp = new OtherInfo();
                tmp.ID           = dr.GetByte(1);
                tmp.BackNetIDAry = (byte[])dr[2];
                tmp.Type         = dr.GetInt32(3);
                tmp.strDevName   = dr.GetString(4);
                tmp.Param1       = dr.GetByte(5);
                tmp.Param2       = dr.GetByte(6);
                tmp.Param3       = dr.GetByte(7);
                tmp.Param4       = dr.GetByte(8);
                tmp.Remark       = dr.GetString(9);
                otherInfo.Add(tmp);
            }
            dr.Close();
            #endregion
        }
Пример #20
0
        //<summary>
        //保存IP设置,将所有数据保存
        //</summary>
        public void SaveCurtainToDB()
        {
            //// delete all old information and refresh the database
            string strsql = string.Format("delete * from dbIPModule where DIndex=" + DIndex.ToString());

            DataModule.ExecuteSQLDatabase(strsql);

            //// insert curtain Type
            //strsql = string.Format("insert into dbIPModule(DIndex,strIP,strRouterIP,strMaskIP,strMAC,bytWorkType,strGroup,strPrjName,strUser,strPWD,strServer1,intPort1,strServer2,intPort2,"
            //       + "bytTimer,bytEnDHCP ) values({0},'{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}','{9}','{10}',{11},'{12}',{13},{14},{15})", DIndex,strIP,strRouterIP,strMaskIP,strMAC,
            //         bytWorkType,strGroup,strPrjName,strUser,strPWD,strServer1,intPort1,strServer2,intPort2,bytTimer,bytEnDHCP);
            //DataModule.ExecuteSQLDatabase(strsql);
        }
Пример #21
0
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public void ReadIRcodesFrmDBTobuf(int DIndex)
        {
            try
            {
                #region
                string          strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 0);
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);

                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string str = dr.GetValue(5).ToString();
                        RemoteEnable = Convert.ToByte(str.Split('-')[0].ToString());
                        mbytOne      = Convert.ToByte(str.Split('-')[1].ToString());
                        mbytTwo      = Convert.ToByte(str.Split('-')[2].ToString());
                        string strRemark = dr.GetValue(4).ToString();
                        strName = strName.Split('\\')[0].ToString() + "\\"
                                  + strRemark;
                    }
                    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);
                IRCodes = new List <UVCMD.IRCode>();
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string       strRemark = dr.GetValue(4).ToString();
                        string       str       = dr.GetValue(5).ToString();
                        UVCMD.IRCode temp      = new UVCMD.IRCode();
                        temp.KeyID     = Convert.ToInt32(str.Split('-')[0].ToString());
                        temp.IRLength  = Convert.ToInt32(str.Split('-')[1].ToString());
                        temp.IRLoation = Convert.ToInt32(str.Split('-')[2].ToString());
                        temp.Enable    = Convert.ToByte(str.Split('-')[3].ToString());
                        temp.Codes     = str.Split('-')[4].ToString();
                        temp.Remark1   = strRemark;
                        IRCodes.Add(temp);
                    }
                    dr.Close();
                }
                #endregion
            }
            catch
            {
            }
        }
Пример #22
0
        //<summary>
        //读取数据库面板设置,将所有数据读至缓存
        //</summary>
        public void ReadCurtainFrmDBTobuf(int intDIndex)
        {
            try
            {
                #region
                string          strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 0);
                OleDbDataReader dr     = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        string str = dr.GetValue(5).ToString();
                        bytCurType     = Convert.ToByte(str.Split('-')[0].ToString());
                        intJogTime     = Convert.ToByte(str.Split('-')[1].ToString());
                        intJogTime1    = Convert.ToByte(str.Split('-')[2].ToString());
                        bytInvert      = Convert.ToByte(str.Split('-')[3].ToString());
                        bytAutoMeasure = Convert.ToByte(str.Split('-')[4].ToString());
                        bytDragMode    = Convert.ToByte(str.Split('-')[5].ToString());
                        intDragLong    = Convert.ToByte(str.Split('-')[6].ToString());
                        intDragShort   = Convert.ToByte(str.Split('-')[7].ToString());
                        intDragSafe    = Convert.ToByte(str.Split('-')[8].ToString());
                    }
                    dr.Close();
                }
                #endregion

                #region
                Curtains = new List <BasicCurtain>();
                strsql   = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 1);
                dr       = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath);
                if (dr != null)
                {
                    while (dr.Read())
                    {
                        BasicCurtain temp = new BasicCurtain();
                        string       str  = dr.GetValue(5).ToString();
                        temp.runTime  = Convert.ToByte(str.Split('-')[0].ToString());
                        temp.onDelay  = Convert.ToByte(str.Split('-')[1].ToString());
                        temp.offDelay = Convert.ToByte(str.Split('-')[2].ToString());
                        temp.remark   = dr.GetValue(4).ToString();
                        Curtains.Add(temp);
                    }
                    dr.Close();
                }
                #endregion
            }
            catch
            {
            }
        }
Пример #23
0
        //<summary>
        //保存数据库面板设置,将所有数据保存
        //</summary>
        public override void SaveSendIRToDB(int intDeviceType)
        {
            base.SaveSendIRToDB(intDeviceType);

            //insert new channel information
            if (Chans != null)
            {
                #region
                String strParam = Chans.runTime.ToString() + "-" + Chans.onDelay.ToString()
                                  + "-" + Chans.offDelay.ToString();
                String strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')",
                                              DIndex, 1, 0, 0, Chans.remark, strParam);
                DataModule.ExecuteSQLDatabase(strsql);
                #endregion
            }
        }
Пример #24
0
        ///<summary>
        ///读取数据库面板设置,将所有数据读至缓存
        ///</summary>
        public void ReadDevieceInfoFromDB(int DIndex)
        {
            //read basic information of EIB
            #region
            string          str = "select * from dbDeviceInfo where DIndex=" + DIndex.ToString();
            OleDbDataReader dr  = DataModule.SearchAResultSQLDB(str);

            if (dr == null)
            {
                return;
            }
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Address = dr.GetString(2);
                }
                dr.Close();
            }
            #endregion

            //read EIB to bus
            #region

            str       = string.Format("select * from dbEIBDev where DIndex={0}", DIndex);
            dr        = DataModule.SearchAResultSQLDB(str);
            otherInfo = new List <OtherInfo>();
            if (dr == null)
            {
                return;
            }
            while (dr.Read())
            {
                OtherInfo tmp = new OtherInfo();
                tmp.GroupAddress = dr.GetString(2);
                tmp.ControlType  = dr.GetByte(3);
                tmp.Type         = dr.GetByte(4);
                tmp.Param1       = dr.GetByte(5);
                tmp.Param2       = dr.GetByte(6);
                tmp.Param3       = dr.GetByte(7);
                tmp.Param4       = dr.GetByte(8);
                tmp.strDevName   = dr.GetString(9);
                otherInfo.Add(tmp);
            }
            dr.Close();
            #endregion
        }
Пример #25
0
        //<summary>
        //将缓存里所有HVAC的设置存在数据库
        //</summary>
        public void SaveInfoToDb()
        {
            //// delete all old information and refresh the database
            string strsql = string.Format("delete from dbHVAC where DIndex=" + DIndex.ToString());

            DataModule.ExecuteSQLDatabase(strsql);

            strsql = @"Insert into dbHVAC(DIndex,bytAutoRun,bytModeONDelay,bytModeOFFDelay,bytFanONDelay,bytFanOFFDelay,bytCOrP,bytHigh,"
                     + "bytMid,bytLow,bytSteps) values(@DIndex,@bytAutoRun,@bytModeONDelay,@bytModeOFFDelay,@bytFanONDelay,@bytFanOFFDelay,"
                     + "@bytCOrP,@bytHigh,@bytMid,@bytLow,@bytSteps)";
            //创建一个OleDbConnection对象
            OleDbConnection conn;

            conn = new OleDbConnection(DataModule.ConString + CsConst.mstrDefaultPath);
            conn.Open();

            if (bytSteps == null)
            {
                bytSteps = new byte[12];
            }

            OleDbCommand cmd = new OleDbCommand(strsql, conn);

            ((OleDbParameter)cmd.Parameters.Add("@DIndex", OleDbType.Integer)).Value          = DIndex;
            ((OleDbParameter)cmd.Parameters.Add("@bytAutoRun", OleDbType.VarChar)).Value      = bytAutoRun;
            ((OleDbParameter)cmd.Parameters.Add("@bytModeONDelay", OleDbType.VarChar)).Value  = bytModeONDelay;
            ((OleDbParameter)cmd.Parameters.Add("@bytModeOFFDelay", OleDbType.VarChar)).Value = bytModeOFFDelay;
            ((OleDbParameter)cmd.Parameters.Add("@bytFanONDelay", OleDbType.VarChar)).Value   = bytFanONDelay;
            ((OleDbParameter)cmd.Parameters.Add("@bytFanOFFDelay", OleDbType.VarChar)).Value  = bytFanOFFDelay;

            ((OleDbParameter)cmd.Parameters.Add("@bytCOrP", OleDbType.VarChar)).Value = bytCOrP;
            ((OleDbParameter)cmd.Parameters.Add("@bytHigh", OleDbType.VarChar)).Value = bytHigh;
            ((OleDbParameter)cmd.Parameters.Add("@bytMid", OleDbType.VarChar)).Value  = bytMid;
            ((OleDbParameter)cmd.Parameters.Add("@bytLow", OleDbType.VarChar)).Value  = bytLow;
            ((OleDbParameter)cmd.Parameters.Add("@bytSteps", OleDbType.Binary)).Value = bytSteps;

            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (OleDbException exp)
            {
                MessageBox.Show(exp.ToString());
            }
            conn.Close();
        }
Пример #26
0
        public static void ReadAllGroupCommandsFrmDatabase()
        {
            CsConst.myTemplates = new List <ControlTemplates>();

            ////read keys commands to buffer
            string          str       = string.Format("select * from dbGrpRemark order by GrpID");
            OleDbDataReader drKeyCmds = DataModule.SearchAResultSQLDB(str);

            if (drKeyCmds != null)
            {
                while (drKeyCmds.Read())
                {
                    ControlTemplates oTmpGrp = new ControlTemplates();
                    oTmpGrp.ID      = drKeyCmds.GetInt16(0);
                    oTmpGrp.Name    = drKeyCmds.GetString(1);
                    oTmpGrp.bytType = drKeyCmds.GetByte(2);
                    oTmpGrp.bytGpID = drKeyCmds.GetByte(3);
                    oTmpGrp.GpCMD   = new List <UVCMD.ControlTargets>();

                    str = string.Format("select * from dbGrpCMD where GrpID = {0} order by objID", oTmpGrp.ID);

                    OleDbDataReader drKeyCmds1 = DataModule.SearchAResultSQLDB(str);

                    if (drKeyCmds1 != null)
                    {
                        while (drKeyCmds1.Read())
                        {
                            UVCMD.ControlTargets TmpCmd = new UVCMD.ControlTargets();
                            TmpCmd.ID       = drKeyCmds1.GetByte(1);
                            TmpCmd.Type     = drKeyCmds1.GetByte(2);
                            TmpCmd.SubnetID = drKeyCmds1.GetByte(3);
                            TmpCmd.DeviceID = drKeyCmds1.GetByte(4);
                            TmpCmd.Param1   = drKeyCmds1.GetByte(5);
                            TmpCmd.Param2   = drKeyCmds1.GetByte(6);
                            TmpCmd.Param3   = drKeyCmds1.GetByte(7);
                            TmpCmd.Param4   = drKeyCmds1.GetByte(8);

                            oTmpGrp.GpCMD.Add(TmpCmd);
                        }
                        drKeyCmds1.Close();
                    }
                    CsConst.myTemplates.Add(oTmpGrp);
                }
                drKeyCmds.Close();
            }
        }
Пример #27
0
 //<summary>
 //保存数据
 //</summary>
 public void SaveDataToDB()
 {
     try
     {
         #region
         string strsql = string.Format("delete * from dbClassInfomation where DIndex={0}", DIndex);
         DataModule.ExecuteSQLDatabase(strsql);
         if (myACSetting != null)
         {
             for (int i = 0; i < myACSetting.Count; i++)
             {
                 ThirdPartAC temp = myACSetting[i];
                 string strParam = temp.ID.ToString() + "-" + temp.Enable.ToString() + "-" + temp.ACNO.ToString() + "-" +
                                   temp.CoolMasterAddress.ToString() + "-" + temp.GroupID.ToString();
                 strsql = @"Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1,byteAry1)"
                           + " values(@DIndex,@ClassID,@ObjectID,@SenNum,@Remark,@strParam1,@byteAry1)";
                 OleDbConnection conn;
                 conn = new OleDbConnection(DataModule.ConString + CsConst.mstrDefaultPath);
                 //OleDbConnection conn = new OleDbConnection(DataModule.ConString + CsConst.mstrCurPath);
                 conn.Open();
                 OleDbCommand cmd = new OleDbCommand(strsql, conn);
                 ((OleDbParameter)cmd.Parameters.Add("@DIndex", OleDbType.Integer)).Value = DIndex;
                 ((OleDbParameter)cmd.Parameters.Add("@ClassID", OleDbType.Integer)).Value = 0;
                 ((OleDbParameter)cmd.Parameters.Add("@ObjectID", OleDbType.Integer)).Value = 0;
                 ((OleDbParameter)cmd.Parameters.Add("@SenNum", OleDbType.Integer)).Value = i;
                 ((OleDbParameter)cmd.Parameters.Add("@Remark", OleDbType.VarChar)).Value = temp.Remark;
                 ((OleDbParameter)cmd.Parameters.Add("@strParam1", OleDbType.VarChar)).Value = strParam;
                 ((OleDbParameter)cmd.Parameters.Add("@byteAry1", OleDbType.Binary)).Value = temp.arayACinfo;
                 try
                 {
                     cmd.ExecuteNonQuery();
                 }
                 catch
                 {
                     conn.Close();
                 }
                 conn.Close();
             }
         }
         #endregion
     }
     catch
     {
     }
 }
Пример #28
0
        public static void WriteIni()
        {
            // wirte all to ini
            string strsql = "select * from defDeviceType order by DeviceType";

            OleDbDataReader drPrj = DataModule.SearchAResultSQLDB(strsql);

            if (drPrj != null)
            {
                while (drPrj.Read())
                {
                    int intDevType = drPrj.GetInt32(0);
                    if (intDevType != 0)
                    {
                        CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "Model", drPrj.GetValue(2).ToString());
                        if (CsConst.iLanguageId == 0)
                        {
                            CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "Description", drPrj.GetValue(4).ToString());
                        }
                        else if (CsConst.iLanguageId == 1)
                        {
                            string str = drPrj.GetValue(3).ToString();
                            if (str.Contains("("))
                            {
                                str = str.Split('(')[0].ToString();
                            }
                            CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "Description", str);
                        }
                        CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "MaxValue", drPrj.GetInt32(5).ToString());
                        CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "IsOnlist", drPrj.GetBoolean(7).ToString());
                        string   strTmp  = Convert.ToString(drPrj[8]);
                        string[] ArayTmp = strTmp.Split(';');
                        if (strTmp != null)
                        {
                            foreach (string strVersion in ArayTmp)
                            {
                                CsConst.mstrINIDefault.IniWriteValue("DeviceType" + intDevType.ToString(), "Version", strTmp);
                            }
                        }
                    }
                }
            }
        }
Пример #29
0
        //<summary>
        //保存数据库面板设置,将所有数据保存
        //</summary>
        public void SaveCurtainToDB()
        {
            try
            {
                #region
                string strsql = string.Format("delete * from dbClassInfomation where DIndex={0}", DIndex);
                DataModule.ExecuteSQLDatabase(strsql);

                string strDeviceRemark = "";
                if (DeviceName.Contains("\\"))
                {
                    strDeviceRemark = DeviceName.Split('\\')[1].ToString();
                }
                string strParam = bytCurType.ToString() + "-" + intJogTime.ToString()
                                  + "-" + intJogTime1.ToString() + "-" + bytInvert.ToString()
                                  + "-" + bytAutoMeasure.ToString() + "-" + bytDragMode.ToString()
                                  + "-" + intDragLong.ToString() + "-" + intDragShort.ToString()
                                  + "-" + intDragSafe.ToString();
                strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')",
                                       DIndex, 0, 0, 0, strDeviceRemark, strParam);
                DataModule.ExecuteSQLDatabase(strsql);
                #endregion

                #region
                if (Curtains != null)
                {
                    for (int i = 0; i < Curtains.Count; i++)
                    {
                        BasicCurtain temp = Curtains[i];
                        strParam = temp.runTime.ToString() + "-" + temp.onDelay.ToString()
                                   + "-" + temp.offDelay.ToString();
                        strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')",
                                               DIndex, 1, 0, 0, temp.remark, strParam);
                        DataModule.ExecuteSQLDatabase(strsql);
                    }
                }
                #endregion
            }
            catch
            {
            }
        }
Пример #30
0
        //<summary>
        //保存数据库面板设置,将所有数据保存
        //</summary>
        public void SaveSendIRToDB()
        {
            try
            {
                string strsql = string.Format("delete * from dbClassInfomation where DIndex={0}", DIndex);
                DataModule.ExecuteSQLDatabase(strsql);

                #region
                string strDeviceRemark = "";
                if (strName.Contains("\\"))
                {
                    strDeviceRemark = strName.Split('\\')[1].ToString();
                }
                string strBasic = RemoteEnable.ToString() + "-" + mbytOne.ToString()
                                  + "-" + mbytTwo.ToString();
                strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')",
                                       DIndex, 0, 0, 0, strDeviceRemark, strBasic);
                DataModule.ExecuteSQLDatabase(strsql);
                #endregion

                #region
                if (IRCodes != null)
                {
                    for (int i = 0; i < IRCodes.Count; i++)
                    {
                        UVCMD.IRCode temp     = IRCodes[i];
                        string       strParam = temp.KeyID.ToString() + "-" + temp.IRLength.ToString()
                                                + "-" + temp.IRLoation.ToString() + "-" + temp.Enable.ToString()
                                                + "-" + temp.Codes.ToString();
                        strsql = string.Format("Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1) values ({0},{1},{2},{3},'{4}','{5}')",
                                               DIndex, 1, 0, i, temp.Remark1, strParam);
                        DataModule.ExecuteSQLDatabase(strsql);
                    }
                }
                #endregion
            }
            catch
            {
            }
        }