public int Edit_Authority_Codes(sys_authority_code entity) { StringBuilder sql = new StringBuilder(); sql.Append("UPDATE dbo.sys_authority_code SET code=@code,title=@title,status=@status WHERE id =@id"); using (LocalDB db = new LocalDB()) { return(db.Current_Conn.Execute(sql.ToString(), entity)); } }
public IHttpActionResult Edit_AuthCodes(sys_authority_code data) { try { BaseInfo_Service bis = new BaseInfo_Service(); int cnt = bis.Edit_Authority_Codes(data); return(cnt > 0 ? Json(new { code = 1, msg = "ok" }) : Json(new { code = 0, msg = "error" })); } catch (Exception e) { return(Json(new { code = 0, msg = e.Message })); } }
public int Save_Authority_Codes(sys_authority_code entity) { StringBuilder sql = new StringBuilder(); sql.Append("INSERT INTO dbo.sys_authority_code \n"); sql.Append(" ( code, title, status, add_time ) \n"); sql.Append("SELECT @code, -- code - nvarchar(50) \n"); sql.Append(" @title, -- title - nvarchar(500) \n"); sql.Append(" @status, -- status - int \n"); sql.Append(" GETDATE() -- add_time - datetime \n"); sql.Append("WHERE NOT EXISTS (SELECT * FROM dbo.sys_authority_code WHERE code=@code)"); using (LocalDB db = new LocalDB()) { return(db.Current_Conn.Execute(sql.ToString(), entity)); } }