
// http://127.0.0.1:8080/deleteBug?DeleteID=2119 删除一条,并显示 所有数据 procedure TWebModule1.WebModule1WebActionItem12Action(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean); var S: string; aHTMLtext: TStringList; j:integer; begin s:= Request.QueryFields.Values['DeleteID']; if trim(s)<> '' then begin FDQuery1.SQL.Text:='delete from bugtb where BugID = ' + s ; FDQuery1.ExecSQL; end; FDQuery1.Open('select * from bugtb ' ); //参数为空,返回所有记录 //============================================================================== aHTMLtext := TstringList.Create; aHTMLtext.Add('<style> table{margin:0 auto;border:1px solid #000000;border-collapse:collapse;}th,td{border: 1px solid #000000;text-align:center;}' // 画 实细线 +'th {background-color: #007bff; color: #fff; font-weight: bold; text-align: center; padding: 10px; } </style>' ); //表头 样式 aHTMLtext.Add(' <table border="1"; width=1000px; > ' ); aHTMLtext.Add(' <tr > '); for j := 1 to FDQuery1.FieldCount do begin aHTMLtext.Add('<th>'); aHTMLtext.Add(FDQuery1.Fields.FieldByNumber(j).FieldName); // 列 名 aHTMLtext.Add('</th>'); end; aHTMLtext.Add('<th>操作栏</th>'); aHTMLtext.Add(' </tr> '); FDQuery1.First; while not(FDQuery1.Eof) do begin aHTMLtext.Add(' <tr > '); for j := 1 to FDQuery1.FieldCount do begin aHTMLtext.Add('<td>'); aHTMLtext.Add(FDQuery1.Fields.FieldByNumber(j).AsString); // 所有 值 aHTMLtext.Add('</td>'); end; aHTMLtext.Add('<td> <a onclick="return confirm(''确认删除?'')" href ="/deleteBug?DeleteID='+ FDQuery1.Fields.FieldByNumber(1).AsString +'">删除</a> </td> '); aHTMLtext.Add(' </tr> '); FDQuery1.Next; end; aHTMLtext.Add('</table> '); S:= aHTMLtext.Text; aHTMLtext.Free ; //-------------------------------------------------------------------------- s:='<input type="button" name="Submit" value="返回到主页" onclick="location.href=''http://127.0.0.1:8080/''" /> ' + s; Response.ContentType := 'text/html; charset="UTF-8"'; Response.Content := S; Handled := True; end;
浙公网安备 33010602011771号