public ActionResult UpdateChannelSubjectType() { SWfsChannelService service = new SWfsChannelService(); int currType = Convert.ToInt32(Request.Params["CurrentType"]); string subjectNoFalse = Request.Params["subjectNoFalse"]; string subjectNoTrue = Request.Params["subjectNoTrue"]; string channelNo = Request.Params["currChannel"]; string[] subjectNoTrues = subjectNoTrue.TrimEnd(',').Split(',');//勾选的 foreach (string item in subjectNoTrues) { if (!string.IsNullOrEmpty(item)) { IList <SWfsSubjectLableType> list = service.GetSubjectLableTypeList(currType, channelNo, item); if (list == null || list.Count == 0) //执行写入操作 { SWfsSubjectLableType labletype = new SWfsSubjectLableType(); labletype.ChannelNo = channelNo; labletype.SubjectNo = item; labletype.Type = currType; try { service.InsertSubjectLabelType(labletype); } catch (Exception ex) { return(Json(new { result = "0", message = ex.Message })); } } } } string[] subjectNoFalses = subjectNoFalse.TrimEnd(',').Split(',');//没勾选的 foreach (string item in subjectNoFalses) { if (!string.IsNullOrEmpty(item)) { IList <SWfsSubjectLableType> list = service.GetSubjectLableTypeList(currType, channelNo, item); if (list != null && list.Count > 0) //执行删除操作 { try { service.DeleteSubjectLableType(currType, channelNo, item); //return Json(new { result = "1", message = "保存成功" }); } catch (Exception ex) { return(Json(new { result = "0", message = ex.Message })); } } } } return(Json(new { result = "1", message = "保存成功" })); }
public int InsertSubjectLabelType(SWfsSubjectLableType labeltype) { return(DapperUtil.Insert(labeltype, false)); }