📄 frmpayout.pas
字号:
DrawText(Canvas.Handle,PChar(s),Length(s),r,DT_CENTER or DT_SINGLELINE or DT_VCENTER);
end;
end;
procedure TPayoutFm.Btn_DelClick(Sender: TObject);
var
strDeleteConfimInfo:string;
intResult:Integer;
begin
if PayoutFm.NowDataStatus=[ndsNormal] then
begin
strDeleteConfimInfo:='真的删除吗?';
intResult:=MessageBox(Application.Handle,pchar(strDeleteConfimInfo),'确认',32+4);
if intResult=mrYes then
dataFm.Tbl_Payout.Delete;
end
else
begin
PayoutFm.ChangeDisplayStatus([ndsNormal]);
dataFm.Tbl_Payout.Cancel;
end;
end;
procedure TPayoutFm.Btn_DisplayClick(Sender: TObject);
begin
Payout_stat;
end;
procedure TPayoutFm.Btn_EditClick(Sender: TObject);
begin
if PayoutFm.NowDataStatus=[ndsNormal] then
begin
ChangeDisplayStatus([ndsModify]);
dataFm.Tbl_Payout.Edit;
end
else
begin
if (PayoutFm.CmbBx_Riqi.Text='')
or (PayoutFm.CmbBx_Renyuan.Text='')
or (PayoutFm.CmbBx_Xiangmu.Text='')
or (PayoutFm.Edit_Jine.Text='') then
begin
showmessage('数据信息不全');
end
else
begin
ChangeDisplayStatus([ndsNormal]);
dataFm.Tbl_Payout.Post;
end;
end;
end;
procedure TPayoutFm.Btn_NewClick(Sender: TObject);
begin
if PayoutFm.NowDataStatus=[ndsNormal] then
begin
ChangeDisplayStatus([ndsAppend]);
dataFm.Tbl_Payout.Append;
end
else
begin
if (PayoutFm.CmbBx_Riqi.Text='')
or (PayoutFm.CmbBx_Renyuan.Text='')
or (PayoutFm.CmbBx_Xiangmu.Text='')
or (PayoutFm.Edit_Jine.Text='') then
begin
showmessage('数据信息不全');
end
else
begin
ChangeDisplayStatus([ndsNormal]);
dataFm.Tbl_Payout.Post;
end;
end;
end;
procedure TPayoutFm.cmdCloseClick(Sender: TObject);
begin
panChild.Parent:=PayoutFm;
PayoutFm.Close;
end;
procedure TPayoutFm.Btn_AddMuchClick(Sender: TObject);
var
CurrentTableRecordNum,i: Integer;
begin
Screen.Cursor := crHourGlass;
if Btn_Del.Caption='撤销' then Btn_Del.Click;
Pnl_MuchMiddle.Enabled:=true;
Btn_SaveMuch.Enabled:=true;
Btn_AddMuch.Enabled:=false;
StrGrd_AddMuch.ColCount:=3;
StrGrd_AddMuch.RowCount:=2;
StrGrd_AddMuch.Cells[0,0]:='项目';
StrGrd_AddMuch.Cells[1,0]:='金额';
StrGrd_AddMuch.Cells[2,0]:='备注';
with datafm.Qry_Payout_Xiangmu do //加入收入项目到下拉列表
begin
close;
sql.clear;
sql.Add('select * from payout_option where display=True');
open;
if RecordCount>0 then
begin
CurrentTableRecordNum :=RecNo;
i:=0;
StrGrd_AddMuch.RowCount:=datafm.Qry_Payout_Xiangmu.RecordCount+1;
First;
while not EOF do
begin
i:=i+1;
StrGrd_AddMuch.Cells[0,i]:=FieldByName('xiangmu').AsString;
Next;
end;
MoveBy(CurrentTableRecordNum);
end;
end;
Screen.Cursor := crDefault;
end;
procedure TPayoutFm.Btn_SaveMuchClick(Sender: TObject);
var Rowx,Coly,Rowy:integer;
begin
Screen.Cursor := crHourGlass;
Pnl_MuchMiddle.Enabled:=false;
Btn_SaveMuch.Enabled:=false;
Btn_AddMuch.Enabled:=true;
if StrGrd_AddMuch.Cells[0,1]<>'' then
begin
if (Cmb_Date.Text='')
or (Cmb_Renyuan.Text='')
or (CheckStrGrdInfo(StrGrd_AddMuch)=false) then
begin
showmessage('数据信息不全');
end
else
begin
for Rowx := 1 to StrGrd_AddMuch.RowCount-1 do
begin
if Formatvalue(StrGrd_AddMuch.Cells[1,Rowx])<>0 then
begin
with DataFm.Tbl_Payout do
begin
append;
DataFm.Tbl_Payout.FieldByName('riqi').AsDateTime:=strtodate(Cmb_Date.Text);
DataFm.Tbl_Payout.FieldByName('renyuan').AsString:=Cmb_Renyuan.Text;
DataFm.Tbl_Payout.FieldByName('xiangmu').AsString:=StrGrd_AddMuch.Cells[0,Rowx];
DataFm.Tbl_Payout.FieldByName('jine').AsFloat :=strtofloat(StrGrd_AddMuch.Cells[1,Rowx]);
DataFm.Tbl_Payout.FieldByName('beizhu').AsString:=StrGrd_AddMuch.Cells[2,Rowx];
post;
end;
end;
end;
end;
end;
Cmb_Date.Text:=''; //清空编辑框
Cmb_Renyuan.Text:=''; //清空编辑框
for Rowy := 0 to StrGrd_AddMuch.RowCount-1 do //清空编辑框
begin
for Coly := 0 to StrGrd_AddMuch.ColCount-1 do
begin
StrGrd_AddMuch.Cells[Coly,Rowy]:='';
end;
end;
StrGrd_AddMuch.ColCount:=3;
StrGrd_AddMuch.RowCount:=2;
StrGrd_AddMuch.Cells[0,0]:='项目';
StrGrd_AddMuch.Cells[1,0]:='金额';
StrGrd_AddMuch.Cells[2,0]:='备注';
Screen.Cursor := crDefault;
end;
procedure TPayoutFm.Payout_stat;//开支统计
var CurrentTableRecordNum,DateX,colx,i,j,x:integer;
PayoutName,SearchData:string;
begin
Screen.Cursor := crHourGlass;
MainFm.RzStatusPane1.Caption:='正在计算,请稍等...';
if datafm.Tbl_Payout.RecordCount<1 then
begin
StrGrd_PayoutDispaly.RowCount:=2;
StrGrd_PayoutDispaly.colcount:=2;
StrGrd_PayoutDispaly.Cells[0,0]:='无统计数据';
end
else
begin
MainFm.RzProgressStatus1.Percent:=5;
ClearStrGrd(StrGrd_PayoutDispaly);
StrGrd_PayoutDispaly.RowCount:=MonthDays(strtoint(SpEdit_Year_lst.Text),strtoint(CmbBx_Month_lst.Text))+2;
i:=StrGrd_PayoutDispaly.RowCount-1;
StrGrd_PayoutDispaly.colcount:=2;
colx:=0;
StrGrd_PayoutDispaly.ColWidths[0]:=100;
StrGrd_PayoutDispaly.Cells[0,0]:='统计日期';
StrGrd_PayoutDispaly.Cells[0,i]:='共计';
if datafm.Tbl_Payout_option.RecordCount>0 then
begin
with datafm.Tbl_Payout_option do
begin
j:=datafm.Tbl_Payout_option.RecordCount;
x:=strtoint(floattostr(trunc(((100-5)/strtofloat(inttostr(j))))));
//showmessage(inttostr(x));
CurrentTableRecordNum :=RecNo;
first;
while not EOF do
begin
MainFm.RzProgressStatus1.Percent:=MainFm.RzProgressStatus1.Percent+x;
//showmessage(inttostr(MainFm.RzProgressStatus1.Percent));
PayoutName:='';
PayoutName:= FieldByName('xiangmu').AsString;
StrGrd_PayoutDispaly.colcount:=StrGrd_PayoutDispaly.colcount+1;
colx:=colx+1;
StrGrd_PayoutDispaly.Cells[colx,0]:= PayoutName;
for DateX := 1 to StrGrd_PayoutDispaly.RowCount-2 do
begin
SearchData:=SpEdit_Year_lst.Text+'-'+CmbBx_Month_lst.Text+'-'+FormatMonth(DateX);
//showmessage(SearchData);
with datafm.Qry_Payout_stat2 do
begin
close;
sql.Clear;
sql.add('select * from payout where xiangmu='+''''+PayoutName+''''+'and riqi like'+'''%'+SearchData+ '%''');
open;
StrGrd_PayoutDispaly.Cells[0,DateX]:= SpEdit_Year_lst.Text+'年'+CmbBx_Month_lst.Text+'月'+FormatMonth(DateX)+'日';
StrGrd_PayoutDispaly.Cells[colx,DateX]:=SumField(dataFm.Qry_Payout_stat2,'jine');
close;
end;
end;
next;
end;
MoveBy(CurrentTableRecordNum);
MainFm.RzProgressStatus1.Percent:=100;
Timer1.Enabled:=true;
colx:=colx+1;
StrGrd_PayoutDispaly.Cells[colx,0]:='共计' ;
StrGrdSum(StrGrd_PayoutDispaly);
end;
end;
//MainFm.RzProgressStatus1.Percent:=0;
end;
MainFm.RzStatusPane1.Caption:='就绪';
MainFm.RzProgressStatus1.Percent:=100;
Screen.Cursor := crDefault;
end;
procedure TPayoutFm.Timer1Timer(Sender: TObject);
begin
Timer1.Tag:=Timer1.Tag+1;
if Timer1.Tag>0 then
begin
MainFm.RzProgressStatus1.Percent:=0;
Timer1.Enabled:=false;
Timer1.Tag:=0;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -