【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,MC_SDFSQ.pas,希望对大家有所帮助!
unit MC_SDFSQ;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, Grids, DBGrids, StdCtrls, Buttons, ComCtrls;
type
TSDFSQ = class(TForm)
DataSource1: TDataSource;
BitBtn2: TBitBtn;
Query2: TQuery;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
BitBtn1: TBitBtn;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StringGrid2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure StringGrid3KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure BitBtn1Click(Sender: TObject);
private
X,Y:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
SDFSQ: TSDFSQ;
implementation
uses MC_MainForm;
{$R *.DFM}
procedure TSDFSQ.FormShow(Sender: TObject);
begin
//定义水费收取表
StringGrid1.Cells[1,0]:='水表编号';
StringGrid1.Cells[2,0]:='户主';
StringGrid1.Cells[3,0]:='标准金额';
StringGrid1.Cells[4,0]:='起始日期';
StringGrid1.Cells[5,0]:='终止日期';
StringGrid1.Cells[6,0]:='上月读数';
StringGrid1.Cells[7,0]:='本月读数';
StringGrid1.Cells[8,0]:='使用数';
StringGrid1.Cells[9,0]:='应收金额';
StringGrid1.Cells[10,0]:='实收金额';
StringGrid1.Cells[11,0]:='本月余额';
//定义电费收取表
StringGrid2.Cells[1,0]:='电表编号';
StringGrid2.Cells[2,0]:='户主';
StringGrid2.Cells[3,0]:='标准金额';
StringGrid2.Cells[4,0]:='起始日期';
StringGrid2.Cells[5,0]:='终止日期';
StringGrid2.Cells[6,0]:='上月读数';
StringGrid2.Cells[7,0]:='本月读数';
StringGrid2.Cells[8,0]:='使用数';
StringGrid2.Cells[9,0]:='应收金额';
StringGrid2.Cells[10,0]:='实收金额';
StringGrid2.Cells[11,0]:='本月余额';
//定义煤气费费收取表
StringGrid3.Cells[1,0]:='煤气表编号';
StringGrid3.Cells[2,0]:='户主';
StringGrid3.Cells[3,0]:='标准金额';
StringGrid3.Cells[4,0]:='起始日期';
StringGrid3.Cells[5,0]:='终止日期';
StringGrid3.Cells[6,0]:='上月读数';
StringGrid3.Cells[7,0]:='本月读数';
StringGrid3.Cells[8,0]:='使用数';
StringGrid3.Cells[9,0]:='应收金额';
StringGrid3.Cells[10,0]:='实收金额';
StringGrid3.Cells[11,0]:='本月余额';
if MainForm.Query1.Locate('使用选项','水电煤气费收取',[loCaseInsensitive]) then
begin
if MainForm.Query1.FieldByName('读写').AsString='读' then
begin
bitbtn1.Enabled:=False;
end;
end;
end;
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;
If y = 10 Then begin //当输入使用水费实收金额时,自动计算本月余额
Try
StringGrid1.Cells[11,x]:=FloatToStr(StrToInt(StringGrid1.Cells[10,x])-StrToFloat(StringGrid1.Cells[9,x]));
Except
Abort;
end;
end;
end;
procedure TSDFSQ.StringGrid2KeyUp(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
x:=StringGrid2.Row;
y:=StringGrid2.Col;
If y = 7 Then begin //当输入电费本月读数时,自动计算电费使用数、应收金额
Try
StringGrid2.Cells[8,x]:=IntToStr(StrToInt(StringGrid2.Cells[7,x])