![]()
<a target="_blank" href="http://127.0.0.1:8080/deleteBug">删除/编辑一条记录</a>
![]()
![]()
aHTMLtext.Add('<td> '
+ '<input type="button" value="编辑" onclick="location.href=''http://127.0.0.1:8080/editBug?aID='
+ FDQuery1.Fields.FieldByNumber(1).AsString + '&b=' + FDQuery1.Fields.FieldByNumber(2).AsString + '&c=' + FDQuery1.Fields.FieldByNumber(3).AsString +'''" />'
+'</td> ');
![]()
// http://127.0.0.1:8080/editBug 编辑一 条 前端
procedure TWebModule1.WebModule1WebActionItem13Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var aHTMLtext: TStringList;
begin
aHTMLtext:= TStringList.Create;
aHTMLtext.add('<FORM action = EditBugToDB method= “GET">');
aHTMLtext.add('<BR><input type="hidden" name="aID" value="'+ Request.QueryFields.Values['aID']+'">问题ID:'+ Request.QueryFields.Values['aID']
+'<br> <INPUT type = "TEXT" name = "aSummary" value="'+Request.QueryFields.Values['b']+'" maxlength="100" size = "50">');
aHTMLtext.add('<p>细节:<BR><TEXTAREA name="aDetails" rows=5 cols=50>'+Request.QueryFields.Values['c']+'</TEXTAREA>');
aHTMLtext.add('<p><INPUT type = "SUBMIT" value="提交编辑"> <INPUT type = "RESET"> </p>');
aHTMLtext.add('</form>');
Response.Content := aHTMLtext.Text;
aHTMLtext.Free;
end;
![]()
// /EditBugToDB
procedure TWebModule1.WebModule1WebActionItem14Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var aHTMLtext: TStringList; j:integer;
begin
FDQuery1.SQL.Text:='update bugtb set UserNameLookUp='''+ Request.QueryFields.Values['aSummary'] +''' ,AssignedToLookUp ='''+ Request.QueryFields.Values['aDetails']
+''' where BugID = ' + Request.QueryFields.Values['aID'] ;
FDQuery1.ExecSQL;
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;}' // 画 实细线
+'th {background-color: #007bff; color: #fff; font-weight: bold; text-align: center; padding: 10px; } ' //表头 样式
+ 'tr:nth-child(odd) { background-color: #f2f2f2;} tr:nth-child(even) {background-color: #ffffff;}' // 正文 隔行 变色
+' </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
if FDQuery1.Fields.FieldByNumber(1).AsString = Request.QueryFields.Values['aID'] then aHTMLtext.Add(' <tr style="background-color:lightblue;" > ')
else
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(''确认删除'+FDQuery1.Fields.FieldByNumber(2).AsString +'?'')" href ="/deleteBug?DeleteID='
+ FDQuery1.Fields.FieldByNumber(1).AsString +'">删除</a>'
// + ' <form action="editBug" method="get"> <button type="submit">ddd面</button></form>'
+ ' <input type="button" value="编辑" onclick="location.href=''http://127.0.0.1:8080/editBug?aID='
+ FDQuery1.Fields.FieldByNumber(1).AsString + '&b=' + FDQuery1.Fields.FieldByNumber(2).AsString + '&c=' + FDQuery1.Fields.FieldByNumber(3).AsString +'''" />'
+'</td> ');
aHTMLtext.Add(' </tr> ');
FDQuery1.Next;
end;
aHTMLtext.Add('</table> ');
Response.Content := aHTMLtext.Text;
aHTMLtext.Free ;
//--------------------------------------------------------------------------
Handled:=true;
end;