/// <summary> /// 更新指定的权限 /// </summary> /// <param name="model">权限实体类</param> /// <returns></returns> public bool UpdateAuthority(RedGlovePermission.Model.RGP_AuthorityDir model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RGP_AuthorityDir set "); strSql.Append("AuthorityName=?AuthorityName,"); strSql.Append("AuthorityTag=?AuthorityTag,"); strSql.Append("AuthorityDescription=?AuthorityDescription,"); strSql.Append("AuthorityOrder=?AuthorityOrder"); strSql.Append(" where AuthorityID=?AuthorityID "); MySqlParameter[] parameters = { new MySqlParameter("?AuthorityID", MySqlDbType.Int32, 11), new MySqlParameter("?AuthorityName", MySqlDbType.VarChar, 30), new MySqlParameter("?AuthorityTag", MySqlDbType.VarChar, 50), new MySqlParameter("?AuthorityDescription", MySqlDbType.VarChar, 50), new MySqlParameter("?AuthorityOrder", MySqlDbType.Int32, 11) }; parameters[0].Value = model.AuthorityID; parameters[1].Value = model.AuthorityName; parameters[2].Value = model.AuthorityTag; parameters[3].Value = model.AuthorityDescription; parameters[4].Value = model.AuthorityOrder; if (RedGlovePermission.DBUtility.MySqlHelper.ExecuteSql(strSql.ToString(), parameters) >= 1) { return(true); } else { return(false); } }
/// <summary> /// 得到一个权限实体 /// </summary> /// <param name="AuthorityID">权限ID</param> /// <returns></returns> public RedGlovePermission.Model.RGP_AuthorityDir GetAuthorityModel(int AuthorityID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from RGP_AuthorityDir "); strSql.Append(" where AuthorityID=?AuthorityID "); MySqlParameter[] parameters = { new MySqlParameter("?AuthorityID", MySqlDbType.Int32, 11) }; parameters[0].Value = AuthorityID; RedGlovePermission.Model.RGP_AuthorityDir model = new RedGlovePermission.Model.RGP_AuthorityDir(); DataSet ds = RedGlovePermission.DBUtility.MySqlHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["AuthorityID"].ToString() != "") { model.AuthorityID = int.Parse(ds.Tables[0].Rows[0]["AuthorityID"].ToString()); } model.AuthorityName = ds.Tables[0].Rows[0]["AuthorityName"].ToString(); model.AuthorityTag = ds.Tables[0].Rows[0]["AuthorityTag"].ToString(); model.AuthorityDescription = ds.Tables[0].Rows[0]["AuthorityDescription"].ToString(); if (ds.Tables[0].Rows[0]["AuthorityOrder"].ToString() != "") { model.AuthorityOrder = int.Parse(ds.Tables[0].Rows[0]["AuthorityOrder"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一个权限 /// </summary> /// <param name="model">权限实体类</param> /// <returns></returns> public bool CreateAuthority(RedGlovePermission.Model.RGP_AuthorityDir model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into RGP_AuthorityDir("); strSql.Append("AuthorityName,AuthorityTag,AuthorityDescription,AuthorityOrder)"); strSql.Append(" values ("); strSql.Append("?AuthorityName,?AuthorityTag,?AuthorityDescription,?AuthorityOrder)"); MySqlParameter[] parameters = { new MySqlParameter("?AuthorityName", MySqlDbType.VarChar, 30), new MySqlParameter("?AuthorityTag", MySqlDbType.VarChar, 50), new MySqlParameter("?AuthorityDescription", MySqlDbType.VarChar, 50), new MySqlParameter("?AuthorityOrder", MySqlDbType.Int32, 11) }; parameters[0].Value = model.AuthorityName; parameters[1].Value = model.AuthorityTag; parameters[2].Value = model.AuthorityDescription; parameters[3].Value = model.AuthorityOrder; if (RedGlovePermission.DBUtility.MySqlHelper.ExecuteSql(strSql.ToString(), parameters) >= 1) { return(true); } else { return(false); } }
/// <summary> /// 添加数据 /// </summary> protected void btn_add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim() != "" || txt_Tag.Text.Trim() != "" || txt_order.Text.Trim() != "" || Lib.TypeParse.IsUnsign(txt_order.Text.Trim())) { RedGlovePermission.Model.RGP_AuthorityDir model = new RedGlovePermission.Model.RGP_AuthorityDir(); model.AuthorityName = txt_Name.Text.Trim(); model.AuthorityTag = txt_Tag.Text.Trim(); model.AuthorityDescription = txt_Description.Text.Trim(); model.AuthorityOrder = int.Parse(txt_order.Text.Trim()); if (!bll.Exists(txt_Tag.Text.Trim())) { if (bll.CreateAuthority(model)) { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_true") + "')", true); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_false") + "')", true); } txt_Name.Text = ""; txt_Tag.Text = ""; txt_Description.Text = ""; txt_order.Text = ""; BindOrder(); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_Iscaption") + "')", true); } } }
/// <summary> /// 更新数据 /// </summary> protected void AuthorityLists_RowUpdating(object sender, GridViewUpdateEventArgs e) { RedGlovePermission.Model.RGP_AuthorityDir model = new RedGlovePermission.Model.RGP_AuthorityDir(); model.AuthorityID = int.Parse(AuthorityLists.DataKeys[e.RowIndex].Values[0].ToString()); model.AuthorityName = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_name")).Text.Trim(); model.AuthorityTag = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_tag")).Text.Trim(); model.AuthorityDescription = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_Description")).Text.Trim(); model.AuthorityOrder = int.Parse(((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_order")).Text); if (!bll.UpdateAuthority(model)) { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true); } //返回浏览狀態 AuthorityLists.EditIndex = -1; BindOrder(); }
/// <summary> /// 添加数据 /// </summary> protected void btn_add_Click(object sender, EventArgs e) { if (txt_Name.Text.Trim() != "" || txt_Tag.Text.Trim() != "" || txt_order.Text.Trim() != "" || Lib.TypeParse.IsUnsign(txt_order.Text.Trim())) { RedGlovePermission.Model.RGP_AuthorityDir model = new RedGlovePermission.Model.RGP_AuthorityDir(); model.AuthorityName = txt_Name.Text.Trim(); model.AuthorityTag = txt_Tag.Text.Trim(); model.AuthorityDescription = txt_Description.Text.Trim(); model.AuthorityOrder = int.Parse(txt_order.Text.Trim()); if (!bll.Exists(txt_Tag.Text.Trim())) { if (bll.CreateAuthority(model)) { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_true") + "')", true); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_add_false") + "')", true); } txt_Name.Text = ""; txt_Tag.Text = ""; txt_Description.Text = ""; txt_order.Text = ""; BindOrder(); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_Iscaption") + "')", true); } } }
/// <summary> /// 更新数据 /// </summary> protected void AuthorityLists_RowUpdating(object sender, GridViewUpdateEventArgs e) { RedGlovePermission.Model.RGP_AuthorityDir model = new RedGlovePermission.Model.RGP_AuthorityDir(); model.AuthorityID = int.Parse(AuthorityLists.DataKeys[e.RowIndex].Values[0].ToString()); model.AuthorityName = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_name")).Text.Trim(); model.AuthorityTag = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_tag")).Text.Trim(); model.AuthorityDescription = ((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_Description")).Text.Trim(); model.AuthorityOrder = int.Parse(((TextBox)AuthorityLists.Rows[e.RowIndex].FindControl("txt_order")).Text); if (!bll.UpdateAuthority(model)) { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true); } //返回浏览狀態 AuthorityLists.EditIndex = -1; BindOrder(); }
/// <summary> /// 得到一个权限实体 /// </summary> /// <param name="AuthorityID">权限ID</param> /// <returns></returns> public RedGlovePermission.Model.RGP_AuthorityDir GetAuthorityModel(int AuthorityID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select * from RGP_AuthorityDir "); strSql.Append(" where AuthorityID=?AuthorityID "); MySqlParameter[] parameters = { new MySqlParameter("?AuthorityID", MySqlDbType.Int32,11)}; parameters[0].Value = AuthorityID; RedGlovePermission.Model.RGP_AuthorityDir model=new RedGlovePermission.Model.RGP_AuthorityDir(); DataSet ds=RedGlovePermission.DBUtility.MySqlHelper.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["AuthorityID"].ToString()!="") { model.AuthorityID=int.Parse(ds.Tables[0].Rows[0]["AuthorityID"].ToString()); } model.AuthorityName=ds.Tables[0].Rows[0]["AuthorityName"].ToString(); model.AuthorityTag=ds.Tables[0].Rows[0]["AuthorityTag"].ToString(); model.AuthorityDescription=ds.Tables[0].Rows[0]["AuthorityDescription"].ToString(); if(ds.Tables[0].Rows[0]["AuthorityOrder"].ToString()!="") { model.AuthorityOrder=int.Parse(ds.Tables[0].Rows[0]["AuthorityOrder"].ToString()); } return model; } else { return null; } }