Beispiel #1
0
        /// <summary>
        /// 增加设备数据
        /// </summary>
        public bool Add(EccmPlanDeviceModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" insert into eccm_plan_device(plan_id, equCode, community_id) values ");
            foreach (string s in model.equCode.Split(','))
            {
                strSql.Append("(" + model.plan_id + ",'" + s + "'," + model.community_id + "),");
            }
            int rows = MySQLHelper.ExecuteNonQuery(strSql.ToString().Substring(0, strSql.Length - 1));

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 添加计划
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddPlan(HttpContext context)
        {
            var jr = new JsonResultModel <int>()
            {
                IsSucceed   = false,
                Data        = 0,
                Msg         = "添加失败",
                RedirectUrl = string.Empty
            };

            #region  递参数处理为对象
            //获取传递参数
            string        plancycle          = context.Request.Params["plancycle"];
            string        planrole           = context.Request.Params["planrole"];
            string        executionfrequency = context.Request.Params["executionfrequency"];
            string        term_day           = context.Request.Params["term_day"];
            string        planstime          = context.Request.Params["planstime"];
            string        planetime          = context.Request.Params["planetime"];
            string        communityID        = context.Request.Params["communityID"];
            string        planstats          = context.Request.Params["planstats"];
            string        choosetype         = context.Request.Params["choosetype"];
            string        plantype           = context.Request.Params["plantype"];
            string        Codes = context.Request.Params["Codes"];
            EccmPlanModel model = new EccmPlanModel();
            model.plan_cycle          = int.Parse(plancycle);
            model.plan_role           = planrole;
            model.execution_frequency = int.Parse(executionfrequency);
            model.term_day            = int.Parse(term_day);
            model.plan_stime          = DateTime.Parse(planstime);
            if (planetime != "")
            {
                model.plan_etime = DateTime.Parse(planetime);
            }
            model.communityID     = int.Parse(communityID);
            model.plan_stats      = int.Parse(planstats);
            model.choose_type     = int.Parse(choosetype);
            model.plan_type       = int.Parse(plantype);
            model.plan_creat_time = DateTime.Now;
            model.is_delete       = 0;
            #endregion
            HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"];
            if (cook != null)
            {
                //解密Cookie
                HttpCookie decodeCookie = HttpSecureCookie.Decode(cook);
                string     uid          = decodeCookie.Values["userid"];
                //给对象赋值
                model.uid = int.Parse(uid);
            }
            EccmPlanBLL bll = new EccmPlanBLL();
            int         id  = bll.Add(model); //添加计划并获取id
            if (id > 0)                       //添加计划成功
            {
                if (model.choose_type == 0)   //设备类型
                {
                    EccmPlanDevicetypeModel pdt_model = new EccmPlanDevicetypeModel();
                    pdt_model.community_id     = model.communityID;
                    pdt_model.plan_id          = id;
                    pdt_model.system_type_code = Codes;

                    EccmPlanDevicetypeBLL pdt_bll = new EccmPlanDevicetypeBLL();
                    if (pdt_bll.Add(pdt_model))
                    {
                        jr.IsSucceed = true;
                        jr.Msg       = "添加成功";
                    }
                }
                else if (model.choose_type == 1)//设备
                {
                    EccmPlanDeviceModel pd_model = new EccmPlanDeviceModel();
                    pd_model.community_id = model.communityID;
                    pd_model.plan_id      = id;
                    pd_model.equCode      = Codes;

                    EccmPlanDeviceBLL pd_bll = new EccmPlanDeviceBLL();
                    if (pd_bll.Add(pd_model))
                    {
                        jr.IsSucceed = true;
                        jr.Msg       = "添加成功";
                    }
                }
            }

            return(JsonConvert.SerializeObject(jr));
        }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(EccmPlanDeviceModel model)
 {
     return(dal.Add(model));
 }