<td><input type="checkbox" name="adopt" value="@item["id"]" @(item["adopt"].ToString() == "1" ? "checked" : "") lay-filter="switchTest" lay-skin="switch" lay-text="ON|OFF" /></td>
<script type="text/javascript">
layui.use(['table','form'], function () {
layui.form.on('switch(switchTest)', function (obj) {
var onoff = this.checked ? '1' : '0';
$.post('updateNoticeState', { id: obj.value, onoff: onoff }, function (data) {
if (data == "true") {
layer.msg("状态修改成功");
} else {
layer.msg(data);
}
});
});
});
</script>
public string updateNoticeState(string id,string onoff)
{
try
{
aideAccountsFacade.GetScalarBySql("update [QPRecordDB].[dbo].[RecordFeedback] set adopt='" + onoff + "' where id='" + id + "' ");
return "true";
}
catch (Exception e)
{
return e.Message;
}
}