procedure TForm3.CheckBoxMouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
var
checkbox1: TCheckBox;
checkbox2: TCheckBox;
checkbox3:TCheckBox;
checkbox4: TCheckBox;
checkbox5:TCheckBox;
checkbox6:TCheckBox;
checkbox7:TCheckBox;
checkbox8:TCheckBox;
begin
if Not (Sender is TCheckBox) then Exit;//²»ÕýÈ·µÄʼþ¾Í²»×ö´¦Àí
checkbox1 := Sender as TCheckBox;
checkbox2 := Sender as TCheckBox;
checkbox3 := Sender as TCheckBox;
checkbox4:= Sender as TCheckBox;
checkbox5 := Sender as TCheckBox;
checkbox6 := Sender as TCheckBox;
checkbox7 := Sender as TCheckBox;
checkbox8 := Sender as TCheckBox;
if Sender Is TCheckBox then
begin
form3.ADOQuery3.Close;
form3.ADOQuery3.SQL.Clear;
form3.ADOQuery3.Connection:=form3.ADOConnection1;
form3.ADOQuery3.SQL.Add('select kh,xx,xm,xb,bkdm from tyks where kh='''+dbedit1.Text+''' and bkdm ='''+inttostr((Sender as TCheckBox).tag)+''' ') ;
form3.ADOQuery3.open;
form3.ADOQuery3.Active ;
if (form3.ADOQuery3.RecordCount>0) and (checkbox1.Checked=false) then
form3.ADOQuery3.Delete ;//这一句不能删除ASSCEE表中的记录(操作时能看到表中数据被删除,一涮新又在了,删除不了)
if (form3.ADOQuery3.RecordCount=0) and (checkbox1.Checked=true) then
form3.ADOQuery3.Edit;
form3.ADOQuery3.Insert;
form3.ADOQuery3.FieldByName('kh').AsString :=form3.DBEdit1.Text ;
form3.ADOQuery3.FieldByName('xm').AsString :=form3.DBEdit2.Text;
form3.ADOQuery3.FieldByName('xx').AsString :=form3.DBEdit3.Text ;
form3.ADOQuery3.FieldByName('xb').AsString :=form3.DBEdit4.Text ;
form3.ADOQuery3.FieldByName('bkdm').AsString := inttostr((Sender as TCheckBox).tag);
form3.ADOQuery3.Post;
end;
end;
while not form3.ADOQuery3.Eof do
begin
if checkbox1.Checked=false then
form3.ADOQuery3.Delete
end;
if (form3.ADOQuery3.RecordCount>0) and ((Sender as TCheckBox).Checked=false) then form3.ADOQuery3.Delete ;