protected void btnSave_Click(object sender, EventArgs e) { try { if (new Rc.BLL.Resources.BLL_DictRelation().GetRecordCount("HeadDict_Id='" + ddlHead.SelectedValue + "' and SonDict_Id='" + ddlSon.SelectedValue + "'") > 0) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改失败:关系已存在。', {icon: 2})})})</script>"); return; } else { Rc.Model.Resources.Model_DictRelation dic = new Rc.Model.Resources.Model_DictRelation(); Rc.BLL.Resources.BLL_DictRelation blldic = new Rc.BLL.Resources.BLL_DictRelation(); dic = blldic.GetModel(Id); dic.HeadDict_Id = ddlHead.SelectedValue; dic.SonDict_Id = ddlSon.SelectedValue; dic.CreateTime = DateTime.Now; dic.CreateUser = loginUser.SysUser_ID; if (new Rc.BLL.Resources.BLL_DictRelation().Update(dic)) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改成功', { time: 1000, icon: 1},function(){parent.loadData();parent.layer.close(index)})})})</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('修改失败', {icon: 2})})})</script>"); return; } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>$(function(){layer.ready(function(){layer.msg('异常', {icon: 2})})})</script>"); return; } }
public static string GetLastData(string Id, string DictRelation_Id) { try { Rc.Model.Resources.Model_DictRelation dic = new Rc.Model.Resources.Model_DictRelation(); dic = new Rc.BLL.Resources.BLL_DictRelation().GetModel(DictRelation_Id); DataTable dt = new DataTable(); string Temp = "<label><input type=\"checkbox\" value=\"{0}\" {2} />{1}</label> "; string Str = string.Empty; string title = string.Empty; string sqlTitle = "select * from Common_Dict where Common_Dict_Id='" + dic.SonDict_Id + "'"; DataTable dtT = Rc.Common.DBUtility.DbHelperSQL.Query(sqlTitle).Tables[0]; title = dtT.Rows[0]["D_Name"].ToString(); string sql = @"select dc.*,dr.Parent_Id from Common_Dict dc left join DictRelation_Detail dr on dr.Dict_Id=dc.Common_Dict_Id and Parent_Id='" + Id + @"' where dc.D_Type=(select D_Value from Common_Dict where Common_Dict_Id='" + dic.SonDict_Id + "') order by D_Order"; dt = Rc.Common.DBUtility.DbHelperSQL.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Str += string.Format(Temp, dt.Rows[i]["Common_Dict_ID"].ToString(), dt.Rows[i]["D_name"].ToString(), string.IsNullOrEmpty(dt.Rows[i]["Parent_Id"].ToString()) ? "" : "checked"); } } if (dt.Rows.Count > 0) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { err = "成功", title = title, StrCode = Str })); } else { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { err = "异常" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { err = ex.Message.ToString() })); } }
public void LoadData() { try { Rc.Model.Resources.Model_DictRelation dic = new Rc.Model.Resources.Model_DictRelation(); Rc.BLL.Resources.BLL_DictRelation blldic = new Rc.BLL.Resources.BLL_DictRelation(); dic = blldic.GetModel(Id); if (dic != null) { ddlHead.SelectedValue = dic.HeadDict_Id; ddlSon.SelectedValue = dic.SonDict_Id; } } catch (Exception) { } }