begin
Table1.Edit; //数据处于编辑状态
BitBtn1.Caption:='保存[&S]';
BitBtn2.Caption:='取消[&U]';
BitBtn3.Enabled:=False;
BitBtn4.Enabled:=False;
BitBtn6.Enabled:=True;
DBNavigator1.Enabled:=False;
GroupBox1.Enabled:=True;
DBEdit2.Setfocus;
End
Else //取消操作
begin
BitBtn1.Caption:='添加[&I]';
BitBtn2.Caption:='修改[&E]';
BitBtn3.Enabled:=True;
BitBtn4.Enabled:=True;
BitBtn6.Enabled:=False;
DBNavigator1.Enabled:=True;
GroupBox1.Enabled:=False;
Table1.Cancel;
end;
end;
procedure TWXDJ.BitBtn3Click(Sender: TObject); //删除文修数据
begin
If Table1.RecordCount <> 0 Then
if MessageDlg('是否删除当前记录?',mtCustom,[mbYes,mbNo],0)=mrYes then
Table1.Delete;
end;
procedure TWXDJ.BitBtn4Click(Sender: TObject); //浏览文修数据
begin
If Not Assigned(WXXXLL) Then
begin
WXXXLL:=TWXXXLL.Create(Self);
WXXXLL.ShowModal;
end;
end;
procedure TWXDJ.BitBtn6Click(Sender: TObject); //添加或选择响应投诉信息
begin
If Not Assigned(TSDJ) Then
begin
TSDJ:=TTSDJ.Create(Self);
TSDJ.ShowModal;
end;
end;
procedure TWXDJ.BitBtn5Click(Sender: TObject); //退出
begin
Close;
end;
procedure TWXDJ.FormClose(Sender: TObject; var Action: TCloseAction);
begin
WXDJ.Release;
WXDJ:=Nil;
end;
end.
打印相关数据功能代码:
procedure TGCBSJDY.FormClose(Sender: TObject; var Action: TCloseAction);
begin
GCBSJDY.Release;
GCBSJDY:=Nil;
end;
procedure TGCBSJDY.BitBtn5Click(Sender: TObject);
begin
Close;
end;
procedure TGCBSJDY.BitBtn1Click(Sender: TObject);
begin
if not Assigned(ZXDDY) then
begin
ZXDDY:=TZXDDY.Create(Self);
ZXDDY.ShowModal;
end;
end;
procedure TGCBSJDY.BitBtn2Click(Sender: TObject);
begin
if not Assigned(ZXXXDY) then
begin
ZXXXDY:=TZXXXDY.Create(Self);
ZXXXDY.showModal;
end;
end;
procedure TGCBSJDY.BitBtn3Click(Sender: TObject);
begin
if Not Assigned(WZXXDY) then
begin
WZXXDY:=TWZXXDY.Create(Self);
WZXXDY.ShowModal;
end;
end;
procedure TGCBSJDY.BitBtn4Click(Sender: TObject);
begin
if Not Assigned(WXDY) then
begin
WXDY:=TWXDY.Create(Self);
WXDY.ShowModal;
end;
end;
end.
两个模块间连接,并读取相应的数据:
procedure TFYSQXZ.BitBtn1Click(Sender: TObject);
var ZD: String;
ZDZ: Array of String;
a:integer;
begin
if ListBox1.Items.Count=0 then
begin
ShowMessage('请选择要浏览的大楼.');
end
else
begin
if not Assigned(SDFSQ) then
begin
SDFSQ:=TSDFSQ.Create(Self);
SetLength(ZDZ,ListBox1.Items.Count);//分配动态变量,记得释放掉
ZD:='大楼名';
SDFSQ.Query2.Close;
SDFSQ.Query2.SQL.Clear;
SDFSQ.Query2.SQL.Add('Select * From 水费 ');
SDFSQ.Query2.SQL.Add('Where 水表编号 in (');
SDFSQ.Query2.SQL.Add('Select 房间编号 From 房屋信息表 ');
SDFSQ.Query2.SQL.Add('Where 房间编号=:A ');
SDFSQ.Query2.ParamByName('A').AsString:=ListBox1.Items.Strings[0];
For a:=1 to ListBox1.Items.Count-1 do
begin
ZDZ[a]:=ListBox1.Items.Strings[a];
SDFSQ.Query2.SQL.Add(' or 房间编号='''+ZDZ[a]+'''');
end;
SDFSQ.Query2.SQL.Add(')');
SDFSQ.Query2.Open;
SDFSQ.StringGrid1.RowCount:=SDFSQ.Query2.RecordCount+1;
a:=1;
While Not SDFSQ.Query2.Eof do
begin
SDFSQ.StringGrid1.Cells[1,a]:=SDFSQ.Query2.FieldByName('水表编号').AsString;
SDFSQ.StringGrid1.Cells[2,a]:=SDFSQ.Query2.FieldByName('户主姓名').AsString;
SDFSQ.StringGrid1.Cells[3,a]:=SDFSQ.Query2.FieldByName('收费金额').AsString;
SDFSQ.StringGrid1.Cells[4,a]:=SDFSQ.Query2.FieldByName('计费起始日期').AsString;
SDFSQ.StringGrid1.Cells[5,a]:=SDFSQ.Query2.FieldByName('计费终止日期').AsString;
SDFSQ.StringGrid1.Cells[6,a]:=SDFSQ.Query2.FieldByName('上月读数').AsString;
SDFSQ.StringGrid1.Cells[7,a]:=SDFSQ.Query2.FieldByName('本月读数').AsString;
SDFSQ.StringGrid1.Cells[8,a]:=SDFSQ.Query2.FieldByName('使用数').AsString;
SDFSQ.StringGrid1.Cells[9,a]:=SDFSQ.Query2.FieldByName('应收金额').AsString;
SDFSQ.StringGrid1.Cells[10,a]:=SDFSQ.Query2.FieldByName('实收金额').AsString;
SDFSQ.StringGrid1.Cells[11,a]:=SDFSQ.Query2.FieldByName('本月余额').AsString;
a:=a+1;
SDFSQ.Query2.Next;
end;
把数据写入相应的数据库表中:
SDFSQ.Query2.Close;
SDFSQ.Query2.SQL.Clear;
SDFSQ.Query2.SQL.Add('Select * From 电费 Where');
SDFSQ.Query2.SQL.Add('电表编号 in (');
SDFSQ.Query2.SQL.Add('Select 房间编号 From 房屋信息表 Where 房间编号=:A');
SDFSQ.Query2.ParamByName('A').AsString:=ListBox1.Items.Strings[0];
For a:=1 to ListBox1.Items.Count-1 do
begin
ZDZ[a]:=ListBox1.Items.Strings[a];
SDFSQ.Query2.SQL.Add(' or 房间编号='''+ZDZ[a]+'''');
end;
SDFSQ.Query2.SQL.Add(')');
SDFSQ.Query2.Open;
通过一个相关数据计算出别的相关数据:
procedure TSDFSQ.StringGrid1KeyUp(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
x:=StringGrid1.Row;
y:=StringGrid1.Col;
If y = 7 Then begin
Try
StringGrid1.Cells[8,x]:=IntToStr(StrToInt(StringGrid1.Cells[7,x])-StrToInt(StringGrid1.Cells[6,x]));
StringGrid1.Cells[9,x]:=FloatToStr(StrToInt(StringGrid1.Cells[8,x])*StrToFloat(StringGrid1.Cells[3,x]));
Except
begin
Abort;
end;
end;
end;
运用当前的数据更新数据库,使别的模块显示现在的数据:
begin
if MessageDlg('是否更新水费信息?',mtCustom,[mbYes,mbNo],0)=mrYes then
begin
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Update 水费 Set 计费终止日期=:A,本月读数=:B,使用数=:C,应收金额=:D,实收金额=:E,本月余额=:G');
Query2.SQL.Add('Where 水表编号=:F');
For a:=1 to StringGrid1.RowCount-1 do
begin
Query2.Close;
Try //更新水费
Query2.ParamByName('F').AsString:=StringGrid1.Cells[1,a];
Query2.ParamByName('A').AsDateTime:=StrToDate(StringGrid1.Cells[5,a]);
Query2.ParamByName('B').AsInteger:=StrToInt(StringGrid1.Cells[7,a]);
Query2.ParamByName('C').AsInteger:=StrToInt(StringGrid1.Cells[8,a]);
Query2.ParamByName('D').AsFloat:=StrToFloat(StringGrid1.Cells[9,a]);
Query2.ParamByName('E').AsFloat:=StrToFloat(StringGrid1.Cells[10,a]);
Query2.ParamByName('G').AsFloat:=StrToFloat(StringGrid1.Cells[11,a]);
Query2.ExecSQL;
Except
ShowMessage('编号为['+StringGrid1.Cells[1,a]+']的费用信息数据有误,没有保存!');
Abort;
End;
end;
end;
end;
上一页 [1] [2] [3] [4] [5] [6] [7] [8]