/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">分组实体类</param> /// <returns></returns> public bool UpdateGroup(RedGlovePermission.Model.RGP_Groups model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update RGP_Groups set "); strSql.Append("GroupName=?GroupName,"); strSql.Append("GroupOrder=?GroupOrder,"); strSql.Append("GroupDescription=?GroupDescription"); strSql.Append(" where GroupID=?GroupID "); MySqlParameter[] parameters = { new MySqlParameter("?GroupID", MySqlDbType.Int32, 11), new MySqlParameter("?GroupName", MySqlDbType.VarChar, 30), new MySqlParameter("?GroupOrder", MySqlDbType.Int32, 11), new MySqlParameter("?GroupDescription", MySqlDbType.VarChar, 50) }; parameters[0].Value = model.GroupID; parameters[1].Value = model.GroupName; parameters[2].Value = model.GroupOrder; parameters[3].Value = model.GroupDescription; if (RedGlovePermission.DBUtility.MySqlHelper.ExecuteSql(strSql.ToString(), parameters) >= 1) { return(true); } else { return(false); } }
/// <summary> /// 得到一个分组实体 /// </summary> /// <param name="GroupID">分组ID</param> /// <returns></returns> public RedGlovePermission.Model.RGP_Groups GetGroupModel(int GroupID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select GroupID,GroupName,GroupOrder,GroupDescription from RGP_Groups "); strSql.Append(" where GroupID=?GroupID "); MySqlParameter[] parameters = { new MySqlParameter("?GroupID", MySqlDbType.Int32, 11) }; parameters[0].Value = GroupID; RedGlovePermission.Model.RGP_Groups model = new RedGlovePermission.Model.RGP_Groups(); DataSet ds = RedGlovePermission.DBUtility.MySqlHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["GroupID"].ToString() != "") { model.GroupID = int.Parse(ds.Tables[0].Rows[0]["GroupID"].ToString()); } model.GroupName = ds.Tables[0].Rows[0]["GroupName"].ToString(); if (ds.Tables[0].Rows[0]["GroupOrder"].ToString() != "") { model.GroupOrder = int.Parse(ds.Tables[0].Rows[0]["GroupOrder"].ToString()); } model.GroupDescription = ds.Tables[0].Rows[0]["GroupDescription"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一个分组 /// </summary> /// <param name="model">分组实体类</param> /// <returns></returns> public bool CreateGroup(RedGlovePermission.Model.RGP_Groups model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into RGP_Groups("); strSql.Append("GroupName,GroupOrder,GroupDescription)"); strSql.Append(" values ("); strSql.Append("?GroupName,?GroupOrder,?GroupDescription)"); MySqlParameter[] parameters = { new MySqlParameter("?GroupName", MySqlDbType.VarChar, 30), new MySqlParameter("?GroupOrder", MySqlDbType.Int32, 11), new MySqlParameter("?GroupDescription", MySqlDbType.VarChar, 50) }; parameters[0].Value = model.GroupName; parameters[1].Value = model.GroupOrder; parameters[2].Value = model.GroupDescription; 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_order.Text.Trim() != "" || Lib.TypeParse.IsUnsign(txt_order.Text.Trim())) { RedGlovePermission.Model.RGP_Groups model = new RedGlovePermission.Model.RGP_Groups(); model.GroupName = txt_Name.Text.Trim(); model.GroupDescription = txt_Description.Text.Trim(); model.GroupOrder = int.Parse(txt_order.Text.Trim()); if (!bll.Exists(txt_Name.Text.Trim())) { if (bll.CreateGroup(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_Description.Text = ""; txt_order.Text = ""; BindOrder(); } else { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_Isgroup") + "')", true); } } }
/// <summary> /// 更新数据 /// </summary> protected void GroupsLists_RowUpdating(object sender, GridViewUpdateEventArgs e) { RedGlovePermission.Model.RGP_Groups model = new RedGlovePermission.Model.RGP_Groups(); model.GroupID = int.Parse(GroupsLists.DataKeys[e.RowIndex].Values[0].ToString()); model.GroupName = ((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_name")).Text.Trim(); model.GroupDescription = ((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_Description")).Text.Trim(); model.GroupOrder = int.Parse(((TextBox)GroupsLists.Rows[e.RowIndex].FindControl("txt_order")).Text); if (!bll.UpdateGroup(model)) { ScriptManager.RegisterClientScriptBlock(CustomPanel1, this.GetType(), "MsgBox", "alert('" + ResourceManager.GetString("Pub_Msg_update_false") + "')", true); } //返回浏览狀態 GroupsLists.EditIndex = -1; BindOrder(); }
/// <summary> /// 得到一个分组实体 /// </summary> /// <param name="GroupID">分组ID</param> /// <returns></returns> public RedGlovePermission.Model.RGP_Groups GetGroupModel(int GroupID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 GroupID,GroupName,GroupOrder,GroupDescription from RGP_Groups "); strSql.Append(" where GroupID=@GroupID "); SqlParameter[] parameters = { new SqlParameter("@GroupID", SqlDbType.Int,4)}; parameters[0].Value = GroupID; RedGlovePermission.Model.RGP_Groups model=new RedGlovePermission.Model.RGP_Groups(); DataSet ds=SqlServerHelper.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["GroupID"].ToString()!="") { model.GroupID=int.Parse(ds.Tables[0].Rows[0]["GroupID"].ToString()); } model.GroupName=ds.Tables[0].Rows[0]["GroupName"].ToString(); if(ds.Tables[0].Rows[0]["GroupOrder"].ToString()!="") { model.GroupOrder=int.Parse(ds.Tables[0].Rows[0]["GroupOrder"].ToString()); } model.GroupDescription=ds.Tables[0].Rows[0]["GroupDescription"].ToString(); return model; } else { return null; } }