S
softlong
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmDZ.CheckBox2Click(Sender: TObject);<br>var<br> i:integer;<br> totalamount,notdzamount,dzamount:real;<br>begin<br> if cxGridDBBandedTableView2.DataController.GetRecordCount<0 then<br> exit;<br> dzamount:=0;<br> notdzamount:=0;<br> totalamount:=0;<br> adoquery1.DisableControls;<br> cxGridDBBandedTableView2.DataController.PostEditingData;<br> if CheckBox2.Checked then<br> begin<br> adoquery1.First;<br> for i :=0 to cxGridDBBandedTableView2.DataController.GetRecordCount-1 do //<br> begin<br> try<br> adoquery1.edit;<br> adoquery1.FieldByName('mx_dz').AsString:='1';<br> adoquery1.FieldByName('mx_dzman').asstring:=getusername;<br> adoquery1.FieldByName('mx_dzdate').asstring:=formatdatetime('yyyy-mm-dd',getserverdatetime);<br> adoquery1.post;<br> adoquery1.Next;<br> totalamount:=totalamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br> dzamount:=dzamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br> finally<br><br> end;<br> end;<br> adoquery1.First;<br> adoquery1.EnableControls;<br> end else<br> begin<br> adoquery1.First;<br> for i :=0 to cxGridDBBandedTableView2.DataController.GetRecordCount-1 do<br> begin<br> try<br> adoquery1.edit;<br> adoquery1.FieldByName('mx_dz').AsString:='0';<br> adoquery1.FieldByName('mx_dzman').asstring:='';<br> adoquery1.FieldByName('mx_dzdate').asstring:='';<br> adoquery1.Post;<br> adoquery1.Next;<br> except<br><br> end;<br> end;<br> adoquery1.First;<br> adoquery1.EnableControls;<br> totalamount:=totalamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br> notdzamount:=notdzamount+strtofloat(cxGridDBBandedTableView2.DataController.Values[i,cxGridDBBandedTableView2mx_amount.Index]);<br><br> end;<br><br> edit1.Text:=floattostr(totalamount);<br> edit2.Text:=floattostr(dzamount);<br> edit3.Text:=floattostr(notdzamount);<br><br><br>代码很简单,执行时,就是checkbox.checked=false时,抱:RecordIndex out of range.错误.或许adoquery1.next不该写,但不知怎么写.<br>在线等...谢谢!!!!!!!