public bool Add(Model.role userroler) { try { string sqldep = string.Format("select * from system where id='{0}'", userroler.system); DataSet dps = SqliteHelper.ExecuteDataSet(con, sqldep, CommandType.Text); if (dps != null && dps.Tables.Count > 0) { system system = DataTableToList.GetList <system>(dps.Tables[0]).FirstOrDefault(); if (system != null) { userroler.system = system.guid; } } string sql = string.Format ( "INSERT INTO role(roleName,system_id,roleDM,comment,guid) VALUES('{0}','{1}','{2}','{3}','{4}') ;select last_insert_rowid()", userroler.roleName, userroler.system, userroler.roleDM, userroler.comment, userroler.guid ); var ds = SqliteHelper.ExecuteScalar(con, sql, CommandType.Text); if (Convert.ToInt32(ds) > 0) { return(true); } return(false); } catch { return(false); } }
public bool Update(Model.role userrole) { try { string contation = string.Format("where guid='{0}'", userrole.guid); string strsql = string.Format("roleName='{0}',system_id='{1}',roleDM='{2}',comment='{3}' ", userrole.roleName, userrole.system, userrole.roleDM, userrole.comment); string sql = "update role set " + strsql + contation; var ds = SqliteHelper.ExecuteNonQuery(con, sql, CommandType.Text); if (Convert.ToInt32(ds) > 0) { return(true); } return(false); } catch { return(false); } }
public bool Del(Model.role role) { try { string contation = string.Format(" where guid='{0}'", role.guid); string sql = "delete from role " + contation; var ds = SqliteHelper.ExecuteNonQuery(con, sql, CommandType.Text); if (Convert.ToInt32(ds) > 0) { return(true); } return(false); } catch { return(false); } }
protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { DataTable dt = bll.GetList("roleId<>1").Tables[0]; rptList.DataSource = dt; rptList.DataBind(); } if (RequsetAjax("add")) { //添加 try { string roleName = Request.Form["roleName"].ToString(); Model.role model = new Model.role(); model.roleName = roleName; bll.Add(model); Response.Write("{\"status\":1,\"msg\":\"添加成功!\"}"); } catch { Response.Write("{\"status\":0,\"msg\":\"添加失败!\"}"); } Response.End(); } if (RequsetAjax("editshow")) { //编辑 try { string roleId = Request.Form["roleId"].ToString(); Model.role model = bll.GetModel(int.Parse(roleId)); Response.Write("{\"status\":1,\"msg\":\"成功!\",\"roleName\":\"" + model.roleName + "\"}"); } catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); } Response.End(); } if (RequsetAjax("editsubmit")) { //编辑 try { string roleId = Request.Form["roleId"].ToString(); string roleName = Request.Form["roleName"].ToString(); Model.role model = bll.GetModel(int.Parse(roleId)); model.roleName = roleName; bll.Update(model); Response.Write("{\"status\":1,\"msg\":\"成功!\"}"); } catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); } Response.End(); } if (RequsetAjax("del")) { //编辑 try { string roleId = Request.Form["roleId"].ToString(); bll.Delete(int.Parse(roleId)); Response.Write("{\"status\":1,\"msg\":\"成功!\"}"); } catch { Response.Write("{\"status\":0,\"msg\":\"失败!\"}"); } Response.End(); } }
public string AddRole(Model.role r) { return(RoleRepository.AddRole(r)); }