📄 officepay1.pas
字号:
DisableBtn;
btn_save.Enabled :=true;
btn_cancel.Enabled :=true;
//给下面审核栏默认值:
//日期:
Present:= Now;
qmpc.fieldbyname('录入日期').AsString :=datetimetostr(present);
//人名:
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 主管,审核,录入 from pub_z_monthpaycheck');
prepare;
open;
last;
qmpc.fieldbyname('主管').AsString:=fieldbyname('主管').AsString;
qmpc.fieldbyname('审核').AsString:=fieldbyname('审核').AsString;
qmpc.fieldbyname('录入').AsString:=fieldbyname('录入').AsString;
end;
end;
procedure TFrm_officepay.btn_saveClick(Sender: TObject);
begin
//判断是否存在该办事处名称,没有则给出出错信息,有则保存。
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 办事处名称 from pub_z_office where 办事处名称=:bscmc');
parambyname('bscmc').AsString:=qmpc.fieldbyname('办事处名称').asstring;
open;
//没有,给出信息:
if not findfirst then begin
application.MessageBox('不存在该办事处名称,请重新输入!','提示',MB_OK);
DBComboBox6.SetFocus;
end;
//有,保存到数据库中:
if findfirst then begin
with data.zxjxdata do begin
if not DatabaseJxw.intransaction then DatabaseJxw.starttransaction;
try
qmpc.ApplyUpdates ;
DatabaseJxw.commit;
qmpc.CommitUpdates ;
//使编辑框和按钮有反应:
LockEdit;
EnableBtn ;
btn_save.Enabled :=false;
btn_cancel.Enabled :=false;
except
DatabaseJxw.Rollback;
raise;
end;
end;
end;
end;
{ qmpc.Close ;
qmpc.Open ;
}
end;
procedure TFrm_officepay.btn_editClick(Sender: TObject);
begin
qmpc.Edit ;
//让文本框可以编辑
UnlockEdit;
//使一些按钮失效
DisableBtn;
btn_save.Enabled :=true;
btn_cancel.Enabled :=true;
end;
procedure TFrm_officepay.btn_cancelClick(Sender: TObject);
begin
qmpc.Cancel ;
lockedit;
enablebtn;
btn_cancel.Enabled :=false;
btn_save.Enabled :=false;
end;
procedure TFrm_officepay.btn_deleteClick(Sender: TObject);
begin
qmpc.Delete ;
qmpc.ApplyUpdates ;
lockedit;
enablebtn;
btn_delete.Enabled :=false;
btn_save.Enabled :=false;
end;
//***************以上是按纽操作。*********************
//***************打开数据集********************
procedure TFrm_officepay.FormCreate(Sender: TObject);
begin
lockedit;
enablebtn;
if not qmpc.Active then qmpc.Open;
if not qmpc_var.Active then qmpc_var.Open;
// if not tbcontra.active then tbcontra.open;
//通过queryuse读出办事处名称列表
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select distinct 办事处名称 from pub_z_office');
prepare;
open;
while not eof do begin
DBComboBox6.Items.Add(fieldbyname('办事处名称').AsString);
next;
end;
end;
end;
procedure TFrm_officepay.btn_brsClick(Sender: TObject);
begin
//自动更新数据
if qmpc_var.active then qmpc_var.close;
if not qmpc_var.active then qmpc_var.open;
qmpc_var.Filtered :=false;
DBGrid1.DataSource :=dsmpc_var;
end;
procedure TFrm_officepay.btn_qryClick(Sender: TObject);
var
qitem,q1,q2,q3,q4:string;
begin
q1 :=cbhth.Text;
q2 :=cbbsc.Text;
q3 :=cbyear.Text;
q4 :=cbmonth.Text;
//如果没有设置条件,给出提示:
if (q1='') and (q2='') and (q3='') and (q4='')
then application.MessageBox('您还没有设置查询条件呢!','提示',MB_OK)
else begin //将输入加工成条件段
if not(cbhth.Text='') then
begin
q1:=cbhth.Text;
q1:=' 合同号='''+q1+''' ';
end
else
q1:='';
if not(cbbsc.Text='') then
begin
q2:=cbbsc.Text;
q2:=' 办事处名称='''+q2+''' ';
end
else
q2:='';
if not(cbyear.Text='') then
begin
q3:=cbyear.Text;
q3:=' 年='''+q3+''' ';
end
else
q3:='';
if not(cbmonth.Text='') then
begin
q4:=cbmonth.Text;
q4:=' 月='''+q4+''' ';
end
else
q4:='';
//将条件累加成子句
if q1<>'' then qitem:=q1 else qitem:='';
if qitem='' then
if q2<>'' then qitem:=q2;
if qitem<>'' then
if q2<>'' then qitem:=qitem+' and '+q2 ;
if qitem='' then
if q3<>'' then qitem:=q3;
if qitem<>'' then
if q3<>'' then qitem:=qitem+' and '+q3;
if qitem='' then
if q4<>'' then qitem:=q4;
if qitem<>'' then
if q4<>'' then qitem:=qitem+' and '+q4;
//根据条件过滤
with qmpc_var do begin
filter:=qitem;
filtered:=true;
if not findfirst then begin
application.MessageBox('没有您要的信息!','提示',MB_OK);
btn_clrClick(btn_clr);
end ;
end;
end;
end;
procedure TFrm_officepay.btn_clrClick(Sender: TObject);
begin
cbhth.Text :='';
cbbsc.Text :='';
cbyear.Text :='';
cbmonth.Text :='';
end;
//本月和从前的货款调整系数,以及是否异地销售字段的判断。
procedure TFrm_officepay.getcoefficient;
var
total1,total2:real;//分别是,该合同到本月总共收到的回款,该合同在本月总共收到的回款。total1-total2:该合同在本月前总共收到的回款。
htjk,hkhlv:real;
Year, Month, Day: Word;
begin
saleout:=1; //默认为非异地销售。
total1:=0;
total2:=0;
coefficientnew:=0;
coefficientold:=0;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 付款额,日期 from pub_z_contract_payment_record where 合同号=:hth');
parambyname('hth').asstring:=qmpc_var.fieldbyname('合同号').Asstring;
prepare;
open;
if findfirst then begin
first;
while not eof do
begin
DecodeDate(fieldbyname('日期').AsDateTime, Year, Month, Day);
if (year<=qmpc_var.fieldbyname('年').AsInteger) or ((year=qmpc_var.fieldbyname('年').AsInteger) and (Month<=qmpc_var.fieldbyname('月').AsInteger)) then
total1:=total1+fieldbyname('付款额').Asfloat ;
if (year=qmpc_var.fieldbyname('年').AsInteger) and (Month=qmpc_var.fieldbyname('月').AsInteger) then
total2:=total2+fieldbyname('付款额').Asfloat ;
next;
end;
end;
//根据合同号得到合同总的价款 htjk。
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select 合计价款_数值表达,是否异地销售 from pub_z_contract where 合同号=:hth');
parambyname('hth').asstring:=qmpc_var.fieldbyname('合同号').Asstring;
prepare;
open;
htjk:=fieldbyname('合计价款_数值表达').Asfloat;
if fieldbyname('是否异地销售').Asstring='是' then saleout:=0.5;
end;
//计算当月的调整系数 coefficientnew
hkhlv:=total1/htjk;
with queryuse do begin
if active then close;
unprepare;
sql.Clear;
sql.Add('select * from std_pay_coefficient');
prepare;
open;
last;
while not bof do begin
if hkhlv >= fieldbyname('货款回笼率').Asfloat then
coefficientnew:= fieldbyname('调整系数').Asfloat;
Prior;
end;
end;
//计算前月的调整系数 coefficientold
hkhlv:=(total1-total2)/htjk;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -