Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LumluxSSYDB.Model.tTimeCtrlInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tTimeCtrlInfoes set ");
            strSql.Append("iID=@iID,");
            strSql.Append("dTime=@dTime,");
            strSql.Append("iEnable=@iEnable,");
            strSql.Append("iState_Command=@iState_Command,");
            strSql.Append("dCreateDate=@dCreateDate,");
            strSql.Append("dUpdateTime=@dUpdateTime,");
            strSql.Append("sHostInfoGUID=@sHostInfoGUID,");
            strSql.Append("sTagGUID=@sTagGUID,");
            strSql.Append("sDesc=@sDesc");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@iID",            SqlDbType.Int,         4),
                new SqlParameter("@dTime",          SqlDbType.DateTime),
                new SqlParameter("@iEnable",        SqlDbType.Int,         4),
                new SqlParameter("@iState_Command", SqlDbType.Float,       8),
                new SqlParameter("@dCreateDate",    SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",    SqlDbType.DateTime),
                new SqlParameter("@sHostInfoGUID",  SqlDbType.Char,       36),
                new SqlParameter("@sTagGUID",       SqlDbType.Char,       36),
                new SqlParameter("@sDesc",          SqlDbType.NVarChar,  500),
                new SqlParameter("@sGUID",          SqlDbType.Char, 36)
            };
            parameters[0].Value = model.iID;
            parameters[1].Value = model.dTime;
            parameters[2].Value = model.iEnable;
            parameters[3].Value = model.iState_Command;
            parameters[4].Value = model.dCreateDate;
            parameters[5].Value = model.dUpdateTime;
            parameters[6].Value = model.sHostInfoGUID;
            parameters[7].Value = model.sTagGUID;
            parameters[8].Value = model.sDesc;
            parameters[9].Value = model.sGUID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public LumluxSSYDB.Model.tTimeCtrlInfoes DataRowToModel(DataRow row)
 {
     LumluxSSYDB.Model.tTimeCtrlInfoes model = new LumluxSSYDB.Model.tTimeCtrlInfoes();
     if (row != null)
     {
         if (row["sGUID"] != null)
         {
             model.sGUID = row["sGUID"].ToString();
         }
         if (row["iID"] != null && row["iID"].ToString() != "")
         {
             model.iID = int.Parse(row["iID"].ToString());
         }
         if (row["dTime"] != null && row["dTime"].ToString() != "")
         {
             model.dTime = DateTime.Parse(row["dTime"].ToString());
         }
         if (row["iEnable"] != null && row["iEnable"].ToString() != "")
         {
             model.iEnable = int.Parse(row["iEnable"].ToString());
         }
         if (row["iState_Command"] != null && row["iState_Command"].ToString() != "")
         {
             model.iState_Command = decimal.Parse(row["iState_Command"].ToString());
         }
         if (row["dCreateDate"] != null && row["dCreateDate"].ToString() != "")
         {
             model.dCreateDate = DateTime.Parse(row["dCreateDate"].ToString());
         }
         if (row["dUpdateTime"] != null && row["dUpdateTime"].ToString() != "")
         {
             model.dUpdateTime = DateTime.Parse(row["dUpdateTime"].ToString());
         }
         if (row["sHostInfoGUID"] != null)
         {
             model.sHostInfoGUID = row["sHostInfoGUID"].ToString();
         }
         if (row["sTagGUID"] != null)
         {
             model.sTagGUID = row["sTagGUID"].ToString();
         }
         if (row["sDesc"] != null)
         {
             model.sDesc = row["sDesc"].ToString();
         }
     }
     return(model);
 }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(LumluxSSYDB.Model.tTimeCtrlInfoes model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tTimeCtrlInfoes(");
            strSql.Append("sGUID,iID,dTime,iEnable,iState_Command,dCreateDate,dUpdateTime,sHostInfoGUID,sTagGUID,sDesc)");
            strSql.Append(" values (");
            strSql.Append("@sGUID,@iID,@dTime,@iEnable,@iState_Command,@dCreateDate,@dUpdateTime,@sHostInfoGUID,@sTagGUID,@sDesc)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID",          SqlDbType.Char,      36),
                new SqlParameter("@iID",            SqlDbType.Int,        4),
                new SqlParameter("@dTime",          SqlDbType.DateTime),
                new SqlParameter("@iEnable",        SqlDbType.Int,        4),
                new SqlParameter("@iState_Command", SqlDbType.Float,      8),
                new SqlParameter("@dCreateDate",    SqlDbType.DateTime),
                new SqlParameter("@dUpdateTime",    SqlDbType.DateTime),
                new SqlParameter("@sHostInfoGUID",  SqlDbType.Char,      36),
                new SqlParameter("@sTagGUID",       SqlDbType.Char,      36),
                new SqlParameter("@sDesc",          SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.sGUID;
            parameters[1].Value = model.iID;
            parameters[2].Value = model.dTime;
            parameters[3].Value = model.iEnable;
            parameters[4].Value = model.iState_Command;
            parameters[5].Value = model.dCreateDate;
            parameters[6].Value = model.dUpdateTime;
            parameters[7].Value = model.sHostInfoGUID;
            parameters[8].Value = model.sTagGUID;
            parameters[9].Value = model.sDesc;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// 页面初始化
 /// </summary>
 /// <param name="shsotGUID"></param>
 private void InitTimeControl(string shsotGUID)
 {
     LumluxSSYDB.BLL.tTimeCtrlInfoes lbt = new LumluxSSYDB.BLL.tTimeCtrlInfoes();
     if (GetTableCount(shsotGUID, 1, 24) == 24)
     {
         #region 加载1-12个时段
         ViewBag.TableOT = GetTimeInterval(shsotGUID, 1, 12);
         #endregion
         #region 加载13-24个时段
         ViewBag.TableTT = GetTimeInterval(shsotGUID, 13, 24);
         #endregion
     }
     else
     {
         int iCount = GetTableCount(shsotGUID, 1, 24) + 1;
         LumluxSSYDB.Model.tTimeCtrlInfoes lmt;
         for (int i = iCount; i <= 24; i++)
         {
             lmt                = new LumluxSSYDB.Model.tTimeCtrlInfoes();
             lmt.sGUID          = Guid.NewGuid().ToString();
             lmt.iID            = i;
             lmt.dTime          = DateTime.Now;
             lmt.iEnable        = 0; //启用:1不启用:0
             lmt.iState_Command = 1; //下放成功:1下放失败:0
             lmt.dCreateDate    = DateTime.Now;
             lmt.dUpdateTime    = DateTime.Now;
             lmt.sHostInfoGUID  = shsotGUID;
             lmt.sTagGUID       = Guid.NewGuid().ToString();//控制对象GUID
             lmt.sDesc          = "自动生成";
             if (lbt.Add(lmt))
             {
                 #region 加载1-12个时段
                 ViewBag.TableOT = GetTimeInterval(shsotGUID, 1, 12);
                 #endregion
                 #region 加载13-24个时段
                 ViewBag.TableTT = GetTimeInterval(shsotGUID, 13, 24);
                 #endregion
             }
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// 点击左菜单加载
        /// </summary>
        /// <param name="sHostGUID"></param>
        /// <returns></returns>
        private List <TimeInterval> LoadTimeControl(string sHostGUID)
        {
            List <TimeInterval> listTime = new List <TimeInterval>();

            LumluxSSYDB.BLL.tTimeCtrlInfoes lbt = new LumluxSSYDB.BLL.tTimeCtrlInfoes();

            if (GetTableCount(sHostGUID, 1, 24) == 24)
            {
                #region 加载1-24个时段
                listTime = GetTimeInterval(sHostGUID, 1, 24);
                #endregion
            }
            else
            {
                int iCount = GetTableCount(sHostGUID, 1, 24) + 1;
                LumluxSSYDB.Model.tTimeCtrlInfoes lmt;
                for (int i = iCount; i <= 24; i++)
                {
                    lmt                = new LumluxSSYDB.Model.tTimeCtrlInfoes();
                    lmt.sGUID          = Guid.NewGuid().ToString();
                    lmt.iID            = i;
                    lmt.dTime          = DateTime.Now;
                    lmt.iEnable        = 0; //启用:1不启用:0
                    lmt.iState_Command = 1; //下放成功:1下放失败:0
                    lmt.dCreateDate    = DateTime.Now;
                    lmt.dUpdateTime    = DateTime.Now;
                    lmt.sHostInfoGUID  = sHostGUID;
                    lmt.sTagGUID       = Guid.NewGuid().ToString();
                    lmt.sDesc          = "自动生成";
                    if (lbt.Add(lmt))
                    {
                        #region 加载1-24个时段
                        listTime = GetTimeInterval(sHostGUID, 1, 24);
                        #endregion
                    }
                }
            }

            return(listTime);
        }
Exemple #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LumluxSSYDB.Model.tTimeCtrlInfoes GetModel(string sGUID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 sGUID,iID,dTime,iEnable,iState_Command,dCreateDate,dUpdateTime,sHostInfoGUID,sTagGUID,sDesc from tTimeCtrlInfoes ");
            strSql.Append(" where sGUID=@sGUID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@sGUID", SqlDbType.Char, 36)
            };
            parameters[0].Value = sGUID;

            LumluxSSYDB.Model.tTimeCtrlInfoes model = new LumluxSSYDB.Model.tTimeCtrlInfoes();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #7
0
 public TimeInterval()
 {
     tct = new LumluxSSYDB.Model.tTimeCtrlInfoes();
 }
Exemple #8
0
        /// <summary>
        /// 保存设置
        /// </summary>
        /// <param name="TimeCtrGUID">时控GUID</param>
        /// <param name="timeset">所设时间</param>
        /// <param name="IsCheckBox">是否启用</param>
        /// <param name="selecttype_time">类型</param>
        /// <param name="selectcircuitinfo_time">所选回路</param>
        /// <param name="modeswitchhl_time">回路状态</param>
        /// <param name="selectlightgroupinfo_time">群组选择</param>
        /// <param name="modeswitch_time">调光选择</param>
        /// <param name="lightswitch">组状态</param>
        /// <param name="slider1_time">调光值</param>
        /// <returns></returns>
        public JsonResult SaveSets(string TimeCtrGUID, string timeset, string IsCheckBox, string selecttype_time, string selectcircuitinfo_time, string modeswitchhl_time, string selectlightgroupinfo_time, string modeswitch_time, string lightswitch, string slider1_time)
        {
            string iSuccess = "0";

            if (selecttype_time == "mr")
            {
                return(Json(iSuccess));
            }
            if (!string.IsNullOrWhiteSpace(selecttype_time))
            {
                if (Convert.ToInt32(selecttype_time) == Convert.ToInt32(EnumClass.HWType.eLoop))//回路
                {
                    LumluxSSYDB.BLL.tTimeCtrlInfoes lbt = new LumluxSSYDB.BLL.tTimeCtrlInfoes();
                    if (!string.IsNullOrWhiteSpace(TimeCtrGUID))
                    {
                        LumluxSSYDB.Model.tTimeCtrlInfoes lmt = lbt.GetModel(TimeCtrGUID);
                        lmt.dTime   = Convert.ToDateTime(timeset);
                        lmt.iEnable = Convert.ToInt32(IsCheckBox);
                        if (lbt.Update(lmt))
                        {
                            LumluxSSYDB.BLL.tCtrlTagInfoes   lbc = new LumluxSSYDB.BLL.tCtrlTagInfoes();
                            LumluxSSYDB.Model.tCtrlTagInfoes lmc = lbc.GetModel(lmt.sTagGUID);
                            if (lmc != null)
                            {
                                lmc.iType           = Convert.ToInt32(selecttype_time); //回路
                                lmc.sRelayState     = modeswitchhl_time;                //回路状态
                                lmc.sRelayInfo_GUID = selectcircuitinfo_time;
                                lbc.Update(lmc);
                            }
                            else
                            {
                                LumluxSSYDB.Model.tCtrlTagInfoes lmcc = new LumluxSSYDB.Model.tCtrlTagInfoes();
                                lmcc.sGUID           = lmt.sTagGUID;
                                lmcc.iType           = Convert.ToInt32(selecttype_time);
                                lmcc.sRelayInfo_GUID = selectcircuitinfo_time;
                                lmcc.sRelayState     = modeswitchhl_time;//回路状态
                                lbc.Add(lmcc);
                            }
                        }
                    }
                }
                else if (Convert.ToInt32(selecttype_time) == Convert.ToInt32(EnumClass.HWType.eGroup))//组
                {
                    LumluxSSYDB.BLL.tTimeCtrlInfoes lbt = new LumluxSSYDB.BLL.tTimeCtrlInfoes();
                    if (!string.IsNullOrWhiteSpace(TimeCtrGUID))
                    {
                        LumluxSSYDB.Model.tTimeCtrlInfoes lmt = lbt.GetModel(TimeCtrGUID);
                        lmt.dTime   = Convert.ToDateTime(timeset);
                        lmt.iEnable = Convert.ToInt32(IsCheckBox);
                        if (lbt.Update(lmt))
                        {
                            LumluxSSYDB.BLL.tCtrlTagInfoes   lbc = new LumluxSSYDB.BLL.tCtrlTagInfoes();
                            LumluxSSYDB.Model.tCtrlTagInfoes lmc = lbc.GetModel(lmt.sTagGUID);
                            if (lmc != null)
                            {
                                lmc.iType = Convert.ToInt32(selecttype_time);                   //回路
                                if (modeswitch_time == "0")                                     //没有调光
                                {
                                    lmc.sLightGroupState = modeswitch_time + "," + lightswitch; //状态
                                }
                                else
                                {
                                    lmc.sLightGroupState = modeswitch_time + "," + lightswitch + "," + slider1_time;//状态
                                }

                                lmc.sLightGroupGUID = selectlightgroupinfo_time;
                                lbc.Update(lmc);
                            }
                            else
                            {
                                LumluxSSYDB.Model.tCtrlTagInfoes lmcc = new LumluxSSYDB.Model.tCtrlTagInfoes();
                                lmcc.sGUID           = lmt.sTagGUID;
                                lmcc.iType           = Convert.ToInt32(selecttype_time);
                                lmcc.sLightGroupGUID = selectlightgroupinfo_time;
                                if (modeswitch_time == "0")                                      //没有调光
                                {
                                    lmcc.sLightGroupState = modeswitch_time + "," + lightswitch; //状态
                                }
                                else
                                {
                                    lmcc.sLightGroupState = modeswitch_time + "," + lightswitch + "," + slider1_time;//状态
                                }
                                lbc.Add(lmcc);
                            }
                        }
                    }
                }
            }

            return(Json(""));
        }