/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { lbErr.Visible = false; if (string.IsNullOrEmpty(tbRoleName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色名不能为空!"); tbRoleName.Focus(); } else if (string.IsNullOrEmpty(tbRoleDetails.Text.Trim())) { Common.JShelper.JSAlert(this.Page,"err","角色描述不能为空!"); } else { LabMS.BLL.RoleTable BRT = new LabMS.BLL.RoleTable(); LabMS.Model.RoleTable Mrt = new LabMS.Model.RoleTable(); Mrt.RoleName = tbRoleName.Text.Trim(); Mrt.RoleDetails = tbRoleDetails.Text.Trim(); try { int iRid = BRT.Add(Mrt); if (iRid == 0) { lbErr.Visible = true; lbErr.Text = "角色添加失败"; return; } List<string> liststrFunction = GetPrivaily(); LabMS.BLL.RoleFucntion brf = new LabMS.BLL.RoleFucntion(); LabMS.Model.RoleFucntion mrf = new LabMS.Model.RoleFucntion(); for (int i = 0; i < liststrFunction.Count; ++i) { mrf.FCode = liststrFunction[i].ToString(); mrf.RoleID = iRid; brf.Add(mrf); } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('新增角色成功!');window.location.href='RoleList.aspx';</script>"); } catch { } } }
/// <summary> /// 保存修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbRoleName.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色名不能为空!"); tbRoleName.Focus(); } else if (string.IsNullOrEmpty(tbRoleDetails.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "err", "角色描述不能为空!"); } else { LabMS.BLL.RoleTable BRT = new LabMS.BLL.RoleTable(); LabMS.Model.RoleTable Mrt = new LabMS.Model.RoleTable(); int RoleId = int.Parse(Request.QueryString["RoleId"].ToString()); Mrt.RoleId = RoleId; Mrt.RoleName = EBrt.GetRoleNameByRoleID(RoleId); Mrt.RoleName = tbRoleName.Text.Trim(); Mrt.RoleDetails = tbRoleDetails.Text.Trim(); try { BRT.Update(Mrt); ExtendBLL.RoleFucntion erf = new ExtendBLL.RoleFucntion(); erf.delbyWhere("RoleID=" + RoleId.ToString()); List<string> liststrFunction = GetPrivaily(); LabMS.BLL.RoleFucntion brf = new LabMS.BLL.RoleFucntion(); LabMS.Model.RoleFucntion mrf = new LabMS.Model.RoleFucntion(); for (int i = 0; i < liststrFunction.Count; ++i) { mrf.FCode = liststrFunction[i].ToString(); mrf.RoleID = RoleId; brf.Add(mrf); } //Common.JShelper.JSAlert(this.Page, "", "修改角色成功!"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('修改角色成功!');window.location.href='RoleList.aspx';</script>"); } catch { } } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.RoleFucntion GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,RoleID,FCode from RoleFucntion "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.RoleFucntion model=new LabMS.Model.RoleFucntion(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if(ds.Tables[0].Rows[0]["RoleID"].ToString()!="") { model.RoleID=int.Parse(ds.Tables[0].Rows[0]["RoleID"].ToString()); } model.FCode=ds.Tables[0].Rows[0]["FCode"].ToString(); return model; } else { return null; } }