You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
461 lines
14 KiB
Plaintext
461 lines
14 KiB
Plaintext
unit u_ch_custbefbal_do;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
ComCtrls, bsSkinTabs, DB, ADODB, dxExEdtr, dxCntner, dxTL, dxDBCtrl,
|
|
dxDBGrid, dxDBTLCl, dxGrClms, Menus, StdCtrls, XPMenu, Grids, DBGridEh,
|
|
bsSkinCtrls, RxMemDS;
|
|
|
|
type
|
|
Tfra_ch_custbefbal_do = class(TFrame)
|
|
do_ban1: TDataSource;
|
|
PopupMenu1: TPopupMenu;
|
|
N1: TMenuItem;
|
|
XPMenu1: TXPMenu;
|
|
t_ch_cust_befbal_sum: TADOQuery;
|
|
t_ch_cust_befbal_sum1: TDataSource;
|
|
t_ch_cust_befbal1: TDataSource;
|
|
t_ch_cust_befbal: TADOQuery;
|
|
PopupMenu2: TPopupMenu;
|
|
MenuItem1: TMenuItem;
|
|
PopupMenu3: TPopupMenu;
|
|
N7: TMenuItem;
|
|
t_ch_cust_befbalnew: TADOQuery;
|
|
t_rate: TRxMemoryData;
|
|
N2: TMenuItem;
|
|
N3: TMenuItem;
|
|
bsSkinGroupBox2: TbsSkinGroupBox;
|
|
dxDBGrid12: TdxDBGrid;
|
|
dxDBGridMaskColumn59: TdxDBGridMaskColumn;
|
|
dxDBGridMaskColumn60: TdxDBGridMaskColumn;
|
|
dxDBGridMaskColumn61: TdxDBGridMaskColumn;
|
|
dxDBGridMaskColumn63: TdxDBGridMaskColumn;
|
|
dxDBGridColumn28: TdxDBGridColumn;
|
|
dxDBGrid12Column6: TdxDBGridColumn;
|
|
dxDBGrid12Column7: TdxDBGridColumn;
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
dxDBGrid11: TdxDBGrid;
|
|
dxDBGrid11Column1: TdxDBGridColumn;
|
|
dxDBGrid11Column4: TdxDBGridColumn;
|
|
dxDBGrid11Column2: TdxDBGridColumn;
|
|
dxDBGrid11Column3: TdxDBGridColumn;
|
|
bs_text: TEdit;
|
|
procedure MenuItem1Click(Sender: TObject);
|
|
procedure N7Click(Sender: TObject);
|
|
procedure N3Click(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses u_main, my_sys_function, u_fee_do_fen;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure Tfra_ch_custbefbal_do.MenuItem1Click(Sender: TObject);
|
|
var
|
|
i:integer;
|
|
delete_num:real;
|
|
usddelete_num:real;
|
|
rmbdelete_num:real;
|
|
RE:Boolean;
|
|
begin
|
|
RE:=TRUE;
|
|
if (bs_text.Text='3') then begin
|
|
if (do_ban1.DataSet.FieldByName('结算类别').asstring='流程') then begin
|
|
showmessage('当前业务操作的状态不允许更改');
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
do_ban1.DataSet.Edit;
|
|
|
|
delete_num:=0;
|
|
|
|
|
|
if t_ch_cust_befbal.IsEmpty then
|
|
exit;
|
|
if_ch_delete_do:=true;
|
|
delete_do_type_num:=1;
|
|
delete_num:=delete_num+t_ch_cust_befbal.fieldbyname('核销金额').asfloat;
|
|
t_ch_cust_befbal.Delete;
|
|
if (delete_num<>0) then
|
|
begin
|
|
do_ban1.DataSet.edit;
|
|
do_ban1.DataSet['预结金额']:=do_ban1.DataSet['预结金额']-delete_num;
|
|
do_ban1.DataSet.post;
|
|
end;
|
|
t_ch_cust_befbal.Requery();
|
|
t_ch_cust_befbal_sum.Requery();
|
|
|
|
end;
|
|
|
|
procedure Tfra_ch_custbefbal_do.N7Click(Sender: TObject);
|
|
var
|
|
do_num:real;
|
|
i:integer;
|
|
jia_num:real;
|
|
rate_num:real;
|
|
if_hexiao:boolean;
|
|
begin
|
|
if t_ch_cust_befbal_sum.IsEmpty then
|
|
exit;
|
|
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if (do_ban1.DataSet.FieldByName('结算类别').asstring='流程')then
|
|
begin
|
|
if (do_ban1.DataSet.FieldByName('帐单状态').asstring<>'确认核销')then
|
|
begin
|
|
showmessage('当前业务操作的状态不允许更改');
|
|
exit;
|
|
end;
|
|
if_hexiao:=true;
|
|
end
|
|
else
|
|
if_hexiao:=false;
|
|
if (do_ban1.DataSet.FieldByName('帐单状态').asstring='审核通过')then
|
|
begin
|
|
showmessage('当前业务操作的状态不允许更改');
|
|
exit;
|
|
end;
|
|
if not do_ban1.DataSet.FieldByName('结算日期').IsNull then
|
|
if Logininfo.endday>do_ban1.DataSet.FieldByName('结算日期').AsDateTime then begin
|
|
MessageDlg('此票结算单已月末结账,如果修改或删除请先反结账!',mtError,[mbok],0);
|
|
exit;
|
|
end;
|
|
|
|
end;
|
|
end;
|
|
if (do_ban1.DataSet.State=dsinsert)or(do_ban1.DataSet.State=dsedit)then
|
|
begin
|
|
end else begin
|
|
do_ban1.DataSet.edit;
|
|
end;
|
|
jia_num:=0;
|
|
|
|
if not t_ch_cust_befbalnew.Active then t_ch_cust_befbalnew.Open;
|
|
t_rate.open;
|
|
|
|
t_ch_cust_befbalnew.Insert;
|
|
t_ch_cust_befbalnew['方式']:='结算核销';
|
|
t_ch_cust_befbalnew['状态']:='录入状态';
|
|
t_ch_cust_befbalnew['录入人']:=employee;
|
|
t_ch_cust_befbalnew['录入日期']:=date;
|
|
t_ch_cust_befbalnew['核销人']:=do_ban1.DataSet['核销人'];
|
|
t_ch_cust_befbalnew['核销日期']:=do_ban1.DataSet['核销日期'];
|
|
t_ch_cust_befbalnew['帐单编号']:=do_ban1.DataSet['帐单编号'];
|
|
t_ch_cust_befbalnew['结算方式']:=do_ban1.DataSet['结算方式'];
|
|
t_ch_cust_befbalnew['客户名称']:=do_ban1.DataSet['客户名称'];
|
|
t_ch_cust_befbalnew['银行']:=do_ban1.DataSet['银行'];
|
|
t_ch_cust_befbalnew['类型']:=do_ban1.DataSet['类型'];
|
|
t_ch_cust_befbalnew['银行代码']:=do_ban1.DataSet['银行代码'];
|
|
t_ch_cust_befbalnew['预收金额']:=0;
|
|
t_ch_cust_befbalnew['核销金额']:=0;
|
|
|
|
|
|
if do_ban1.DataSet.FieldByName('币别').asstring=t_ch_cust_befbal_sum.fieldbyname('币别').asstring then
|
|
begin
|
|
t_ch_cust_befbalnew['币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['核销币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['预收金额']:=t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
t_ch_cust_befbalnew['核销金额']:=t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
case strtoint(bs_text.Text) of
|
|
3:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='收'then
|
|
jia_num:=jia_num+t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat
|
|
else
|
|
jia_num:=jia_num-t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
end;
|
|
4:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='付'then
|
|
jia_num:=jia_num+t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat
|
|
else
|
|
jia_num:=jia_num-t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
rate_num:=get_zh_cur(t_rate,t_ch_cust_befbal_sum.fieldbyname('币别').asstring,do_ban1.DataSet.FieldByName('币别').asstring);
|
|
if rate_num=-1 then
|
|
begin
|
|
t_ch_cust_befbalnew.Cancel;
|
|
do_ban1.DataSet['预结金额']:=jia_num;
|
|
do_ban1.dataset.post;
|
|
// update_table(bs_text,do_ban1,nil,t_ch_fee,t_ch_fee_sum,2,jia_num,str1,str2,add_fee,add_bill);
|
|
t_ch_cust_befbal.Requery();
|
|
t_ch_cust_befbal_sum.Requery();
|
|
exit;
|
|
end
|
|
else
|
|
begin
|
|
t_ch_cust_befbalnew['币别']:=t_ch_cust_befbal_sum['币别'];
|
|
t_ch_cust_befbalnew['核销币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['预收金额']:=t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
t_ch_cust_befbalnew['核销金额']:=s_w(strtoint(apointnum),t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat*rate_num);
|
|
case strtoint(bs_text.Text) of
|
|
3:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='收'then
|
|
jia_num:=jia_num+s_w(strtoint(apointnum),t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat*rate_num)
|
|
else
|
|
jia_num:=jia_num-s_w(strtoint(apointnum),t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat*rate_num);
|
|
end;
|
|
4:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='付'then
|
|
jia_num:=jia_num+s_w(strtoint(apointnum),t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat*rate_num)
|
|
else
|
|
jia_num:=jia_num-s_w(strtoint(apointnum),t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat*rate_num);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
t_ch_cust_befbalnew.post;
|
|
do_ban1.DataSet['预结金额']:=jia_num;
|
|
do_ban1.dataset.post;
|
|
t_ch_cust_befbal.Requery();
|
|
t_ch_cust_befbal_sum.Requery();
|
|
|
|
|
|
|
|
end;
|
|
|
|
procedure Tfra_ch_custbefbal_do.N3Click(Sender: TObject);
|
|
var
|
|
can_do_num,do_num:real;
|
|
rate_num,jia_num:real;
|
|
if_hexiao:boolean;
|
|
str1,str2:Tstringlist;
|
|
bk:TBookmark;
|
|
|
|
begin
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if (do_ban1.DataSet.FieldByName('结算类别').asstring='流程')then
|
|
begin
|
|
if (do_ban1.DataSet.FieldByName('帐单状态').asstring<>'确认核销')then
|
|
begin
|
|
showmessage('当前业务操作的状态不允许更改');
|
|
exit;
|
|
end;
|
|
if_hexiao:=true;
|
|
end
|
|
else
|
|
if_hexiao:=false;
|
|
if (do_ban1.DataSet.FieldByName('帐单状态').asstring='审核通过')then
|
|
begin
|
|
showmessage('当前业务操作的状态不允许更改');
|
|
exit;
|
|
end;
|
|
if not do_ban1.DataSet.FieldByName('结算日期').IsNull then
|
|
if Logininfo.endday>do_ban1.DataSet.FieldByName('结算日期').AsDateTime then begin
|
|
MessageDlg('此票结算单已月末结账,如果修改或删除请先反结账!',mtError,[mbok],0);
|
|
exit;
|
|
end;
|
|
|
|
end;
|
|
end;
|
|
if t_ch_cust_befbal_sum.IsEmpty then
|
|
exit;
|
|
|
|
if (do_ban1.DataSet.State=dsinsert)or(do_ban1.DataSet.State=dsedit)then
|
|
begin
|
|
end else begin
|
|
do_ban1.DataSet.edit;
|
|
end;
|
|
|
|
jia_num:=0;
|
|
|
|
if not t_ch_cust_befbalnew.Active then t_ch_cust_befbalnew.Open;
|
|
t_rate.open;
|
|
|
|
t_ch_cust_befbalnew.Insert;
|
|
t_ch_cust_befbalnew['方式']:='结算核销';
|
|
t_ch_cust_befbalnew['状态']:='录入状态';
|
|
t_ch_cust_befbalnew['录入人']:=employee;
|
|
t_ch_cust_befbalnew['录入日期']:=date;
|
|
t_ch_cust_befbalnew['核销人']:=do_ban1.DataSet['核销人'];
|
|
t_ch_cust_befbalnew['核销日期']:=do_ban1.DataSet['核销日期'];
|
|
t_ch_cust_befbalnew['帐单编号']:=do_ban1.DataSet['帐单编号'];
|
|
t_ch_cust_befbalnew['结算方式']:=do_ban1.DataSet['结算方式'];
|
|
t_ch_cust_befbalnew['客户名称']:=do_ban1.DataSet['客户名称'];
|
|
t_ch_cust_befbalnew['银行']:=do_ban1.DataSet['银行'];
|
|
t_ch_cust_befbalnew['类型']:=do_ban1.DataSet['类型'];
|
|
t_ch_cust_befbalnew['银行代码']:=do_ban1.DataSet['银行代码'];
|
|
t_ch_cust_befbalnew['预收金额']:=0;
|
|
t_ch_cust_befbalnew['核销金额']:=0;
|
|
|
|
if do_ban1.DataSet.FieldByName('币别').asstring=t_ch_cust_befbal_sum.fieldbyname('币别').asstring then
|
|
begin
|
|
try
|
|
frm_fee_do_fen:=Tfrm_fee_do_fen.Create(application);
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if not do_ban1.DataSet.FieldByName('自动').asboolean then
|
|
begin
|
|
if can_do_num>t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat then
|
|
frm_fee_do_fen.Edit2.text:=floattostr(t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)
|
|
else
|
|
frm_fee_do_fen.Edit2.text:=floattostr(can_do_num);
|
|
end
|
|
else
|
|
frm_fee_do_fen.Edit2.text:=floattostr(t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat);
|
|
end;
|
|
end;
|
|
frm_fee_do_fen.ShowModal;
|
|
if frm_fee_do_fen.ModalResult = mrOk then
|
|
begin
|
|
do_num:=strtofloat(frm_fee_do_fen.Edit1.text);
|
|
end
|
|
else
|
|
begin
|
|
do_num:=0;
|
|
end;
|
|
finally
|
|
frm_fee_do_fen.Free;
|
|
frm_fee_do_fen:=nil;
|
|
end;
|
|
|
|
if do_num=0 then
|
|
begin
|
|
t_ch_cust_befbalnew.Cancel;
|
|
exit;
|
|
end;
|
|
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if ((t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat>0) and(do_num>t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)) or ((t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat<0) and(do_num<t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)) then
|
|
begin
|
|
showmessage('部分结算的金额不能大于所有的金额!');
|
|
t_ch_cust_befbalnew.Cancel;
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
t_ch_cust_befbalnew['币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['核销币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['预收金额']:=t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
t_ch_cust_befbalnew['核销金额']:=t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat;
|
|
|
|
case strtoint(bs_text.Text) of
|
|
3:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='收'then
|
|
jia_num:=jia_num+do_num
|
|
else
|
|
jia_num:=jia_num-do_num;
|
|
end;
|
|
4:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='付'then
|
|
jia_num:=jia_num+do_num
|
|
else
|
|
jia_num:=jia_num-do_num;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
rate_num:=get_zh_cur(t_rate,t_ch_cust_befbal_sum.fieldbyname('币别').asstring,do_ban1.DataSet.FieldByName('币别').asstring);
|
|
if rate_num=-1 then
|
|
begin
|
|
t_ch_cust_befbalnew.Cancel;
|
|
exit;
|
|
end
|
|
else
|
|
begin
|
|
try
|
|
frm_fee_do_fen:=Tfrm_fee_do_fen.Create(application);
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if not do_ban1.DataSet.FieldByName('自动').asboolean then
|
|
begin
|
|
if can_do_num/rate_num>t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat then
|
|
frm_fee_do_fen.Edit2.text:=floattostr(t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)
|
|
else
|
|
frm_fee_do_fen.Edit2.text:=floattostr(can_do_num/rate_num);
|
|
end
|
|
else
|
|
frm_fee_do_fen.Edit2.text:=floattostr(t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat);
|
|
end;
|
|
end;
|
|
frm_fee_do_fen.ShowModal;
|
|
if frm_fee_do_fen.ModalResult = mrOk then
|
|
begin
|
|
do_num:=strtofloat(frm_fee_do_fen.Edit1.text);
|
|
end
|
|
else
|
|
begin
|
|
do_num:=0;
|
|
end;
|
|
finally
|
|
frm_fee_do_fen.Free;
|
|
frm_fee_do_fen:=nil;
|
|
end;
|
|
|
|
if do_num=0 then
|
|
begin
|
|
t_ch_cust_befbalnew.Cancel;
|
|
exit;
|
|
end;
|
|
|
|
case strtoint(bs_text.Text) of
|
|
3,4:
|
|
begin
|
|
if ((t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat>0) and(do_num>t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)) or ((t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat<0) and(do_num<t_ch_cust_befbal_sum.fieldbyname('预收金额').asfloat)) then
|
|
begin
|
|
showmessage('部分结算的金额不能大于所有的金额!');
|
|
t_ch_cust_befbalnew.Cancel;
|
|
exit;
|
|
end;
|
|
end;
|
|
end;
|
|
t_ch_cust_befbalnew['币别']:=t_ch_cust_befbal_sum['币别'];
|
|
t_ch_cust_befbalnew['核销币别']:=do_ban1.DataSet['币别'];
|
|
t_ch_cust_befbalnew['预收金额']:=do_num;
|
|
t_ch_cust_befbalnew['核销金额']:=do_num*rate_num;
|
|
case strtoint(bs_text.Text) of
|
|
3:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='收'then
|
|
jia_num:=jia_num+do_num*rate_num
|
|
else
|
|
jia_num:=jia_num-do_num*rate_num;
|
|
end;
|
|
4:
|
|
begin
|
|
if t_ch_cust_befbal_sum.fieldbyname('类型').asstring='付'then
|
|
jia_num:=jia_num+do_num*rate_num
|
|
else
|
|
jia_num:=jia_num-do_num*rate_num;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
t_ch_cust_befbalnew.Post;
|
|
do_ban1.DataSet['预结金额']:=jia_num;
|
|
do_ban1.dataset.post;
|
|
t_ch_cust_befbal.Requery();
|
|
t_ch_cust_befbal_sum.Requery();
|
|
|
|
|
|
|
|
end;
|
|
|
|
end.
|