public void UpdateByID(string id, string ClockTime, string Deviceid, string Content, string Repeat, string RepeatDate, string Frequency, string Interval, string AlarmType, string State) { if (!id.Equals(null) || id != "" && Deviceid != "") { AlarmClocks acls = new AlarmClocks(); AlarmClocks acl = new AlarmClocks(); acl.DeviceId = Deviceid; acls = AlarmClocksLogic.getAllgoodID(Convert.ToInt32(id)); if (ClockTime.Equals(null) || ClockTime == "") { acl.ClockTime = acls.ClockTime; } else { acl.ClockTime = ClockTime; } if (Content.Equals(null) || Content == "") { acl.Content = acls.Content; } else { acl.Content = Content; } if (Repeat.Equals(null) || Repeat == "") { acl.Repeat = acls.Repeat; } else { acl.Repeat = Repeat; } if (RepeatDate.Equals(null) || RepeatDate == "") { acl.RepeatDate = acls.RepeatDate; } else { acl.RepeatDate = RepeatDate; } if (Frequency.Equals(null) || Frequency == "") { acl.Frequency = acls.Frequency; } else { acl.Frequency = Convert.ToInt32(Frequency); } if (Interval.Equals(null) || Interval == "") { acl.Interval = acls.Interval; } else { acl.Interval = Convert.ToInt32(Interval); } if (AlarmType.Equals(null) || AlarmType == "") { acl.AlarmType = acls.AlarmType; } else { acl.AlarmType = AlarmType; } if (State.Equals(null) || State == "") { acl.State = acls.State; } else { acl.State = Convert.ToInt32(State); } acl.Id = Convert.ToInt32(id); if (AlarmClocksLogic.UpdateByID(acl)) { Write("{\"code\":200,\"messge\":\"修改成功\"}"); } else { Write("{\"code\":201,\"messge\":\"修改失败\"}"); } } else { Write("{\"code\":202,\"messge\":\"输入参数有误\"}"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["tj"])) { stat = "true"; } else { Response.Write(" <script type=\"text/javascript\">window.alert = function(name){var iframe = document.createElement(\"IFRAME\");iframe.style.display=\"none\"; iframe.setAttribute(\"src\", 'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);}</script>"); if (Session["DeviceId"] != null) { string DeviceId = Context.Session["DeviceId"].ToString(); //"o_w1Kw8Uxh4dEoRDCe-HNYnyYlhY";// if (!string.IsNullOrEmpty(Request.QueryString["id"])) //判断上个页面参数是否为空 { ID = Convert.ToInt32(Request.QueryString["id"]); AlarmClocks mis = AlarmClocksLogic.getAllgoodID(ID); //根据deviceid和闹钟名字查询闹钟信息 闹钟名字唯一 if (mis.Id != 0) { Text_ClockTime.Value = mis.ClockTime; //Text_ClockTime.Value = mis.ClockTime; //给文本框添加数据库查询到的值 Text_content.Value = mis.Content; string type = mis.AlarmType.ToString(); if (type.Equals("起床") || type.Equals("吃饭") || type.Equals("上学") || type.Equals("午休") || type.Equals("运动") || type.Equals("做作业") || type.Equals("洗澡") || type.Equals("睡觉")) { Drop_type.SelectedValue = type; } else { Drop_type.SelectedValue = "自定义"; Text_zidingyi.Text = type; } if (mis.Repeat == "0") { Drop_repater.Items.FindByValue("0").Selected = true; } else { Drop_repater.Items.FindByValue("1").Selected = true; } string arroy = Convert.ToString(mis.RepeatDate); string[] weekArr = arroy.Split(',');//分割字符串 for (int i = 0; i < Chbke_Week.Items.Count; i++) { if (weekArr[i].Equals("0")) { Chbke_Week.Items[i].Selected = false; } else { Chbke_Week.Items[i].Selected = true; } } } } } else { Response.Write(" <script type=\"text/javascript\"> alert(\"登录过期,请重新登录\");</script>"); Response.Write(" <script type=\"text/javascript\">history.go(-2);</script>"); } } } Response.Write(" <script type=\"text/javascript\">window.alert = function(name){var iframe = document.createElement(\"IFRAME\");iframe.style.display=\"none\"; iframe.setAttribute(\"src\", 'data:text/plain,');document.documentElement.appendChild(iframe);window.frames[0].window.alert(name);iframe.parentNode.removeChild(iframe);}</script>"); }