|
|
unit u_ch_invoice_expitems;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
BusinessSkinForm, bsSkinCtrls, ExtCtrls, dxExEdtr, dxCntner, dxTL,Dialogs,
|
|
|
dxDBCtrl, dxDBGrid, dxDBTLCl, dxGrClms, DB, ADODB, Grids, Wwdbigrd,
|
|
|
Wwdbgrid, StdCtrls, wwdblook;
|
|
|
|
|
|
type
|
|
|
Tfrm_ch_invoice_expitems = class(TForm)
|
|
|
Panel1: TPanel;
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
bsSkinButton4: TbsSkinButton;
|
|
|
bsSkinButton3: TbsSkinButton;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
|
dsrt_ch_invoice_expitem: TDataSource;
|
|
|
t_ch_invoice_expitem: TADOQuery;
|
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
|
wwDBGrid2: TwwDBGrid;
|
|
|
bsSkinButton8: TbsSkinButton;
|
|
|
t_ch_invoice_expitem_sum: TADOQuery;
|
|
|
Label1: TbsSkinLabel;
|
|
|
bsSkinButton6: TbsSkinButton;
|
|
|
bsSkinButton7: TbsSkinButton;
|
|
|
bsSkinLabel1: TbsSkinLabel;
|
|
|
bsSkinButton9: TbsSkinButton;
|
|
|
t_crm_client_Invoice: TADOQuery;
|
|
|
t_crm_client_Invoice1: TDataSource;
|
|
|
wwDBLookupCombo2: TwwDBLookupCombo;
|
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure bsSkinButton3Click(Sender: TObject);
|
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
|
procedure bsSkinButton4Click(Sender: TObject);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
procedure bsSkinButton6Click(Sender: TObject);
|
|
|
procedure bsSkinButton7Click(Sender: TObject);
|
|
|
procedure bsSkinButton8Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure t_ch_invoice_expitemBeforeEdit(DataSet: TDataSet);
|
|
|
procedure t_ch_invoice_expitemAfterInsert(DataSet: TDataSet);
|
|
|
procedure t_ch_invoice_expitemAfterDelete(DataSet: TDataSet);
|
|
|
procedure t_ch_invoice_expitemAfterEdit(DataSet: TDataSet);
|
|
|
procedure t_ch_invoice_expitemAfterPost(DataSet: TDataSet);
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
procedure bsSkinButton9Click(Sender: TObject);
|
|
|
private
|
|
|
function GetIsClose():Boolean;
|
|
|
procedure ComputeAmount;
|
|
|
procedure invtitlecharge(Sender:TField);
|
|
|
|
|
|
{ Private declarations }
|
|
|
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
end;
|
|
|
|
|
|
|
|
|
var
|
|
|
frm_ch_invoice_expitems: Tfrm_ch_invoice_expitems;
|
|
|
invduino,invduicust,invcurr:string;
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_data_share, my_sys_function, u_main;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.FormCloseQuery(Sender: TObject;
|
|
|
var CanClose: Boolean);
|
|
|
begin
|
|
|
CanClose:=frm_close_query(t_ch_invoice_expitem);
|
|
|
if (invduicust<>'') then
|
|
|
CanClose:=GetIsClose();
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton3Click(Sender: TObject);
|
|
|
begin
|
|
|
table_cancel(t_ch_invoice_expitem);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
table_post(t_ch_invoice_expitem);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton4Click(Sender: TObject);
|
|
|
var
|
|
|
i:integer;
|
|
|
str_list:Tstringlist;
|
|
|
begin
|
|
|
|
|
|
if wwDBGrid2.SelectedList.Count>1 then
|
|
|
begin
|
|
|
try
|
|
|
str_list:=Tstringlist.create;
|
|
|
for i:=0 to wwDBGrid2.SelectedList.Count-1 do
|
|
|
begin
|
|
|
t_ch_invoice_expitem.GotoBookmark(pointer(wwDBGrid2.SelectedList[i]));
|
|
|
str_list.Add(t_ch_invoice_expitem.fieldbyname('ITEMID').asstring);
|
|
|
end;
|
|
|
for i:=0 to str_list.Count-1 do
|
|
|
begin
|
|
|
if t_ch_invoice_expitem.locate('ITEMID',str_list[i],[]) then
|
|
|
t_ch_invoice_expitem.Delete;
|
|
|
end;
|
|
|
finally
|
|
|
str_list.free;
|
|
|
end;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
table_delete(t_ch_invoice_expitem);
|
|
|
end;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton1Click(Sender: TObject);
|
|
|
begin
|
|
|
t_ch_invoice_expitem.Insert;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton6Click(Sender: TObject);
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
mblstr:string;
|
|
|
begin
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
close;SQL.Text:='SELECT distinct dbo.v_op_bscard_all.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5> '
|
|
|
+' FROM dbo.t_ch_dui_bill INNER JOIN '
|
|
|
+' dbo.v_op_bscard_all ON dbo.t_ch_dui_bill.<2E><><EFBFBD><EFBFBD> = dbo.v_op_bscard_all.<2E><><EFBFBD><EFBFBD> '
|
|
|
+' WHERE dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+'''';
|
|
|
open;
|
|
|
if not IsEmpty then begin
|
|
|
First;
|
|
|
while not eof do begin
|
|
|
|
|
|
mblstr:=mblstr+' '+aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
next;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
end;
|
|
|
t_ch_invoice_expitem.Edit;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>ע').AsString:=mblstr;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton7Click(Sender: TObject);
|
|
|
var
|
|
|
invtitle:string;
|
|
|
begin
|
|
|
// if sender.DataSet.State in [dsedit,dsinsert] then begin
|
|
|
invtitle:=t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString;
|
|
|
while not t_ch_invoice_expitem.Eof do begin
|
|
|
t_ch_invoice_expitem.Edit;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString:=invtitle;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
t_ch_invoice_expitem.Next;
|
|
|
end;
|
|
|
// end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton8Click(Sender: TObject);
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
custfullname:string;
|
|
|
begin
|
|
|
{
|
|
|
if t_ch_invoice_expitem.RecordCount<>0 then begin
|
|
|
if MessageDlg('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȷʵҪ<CAB5><D2AA><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
Exit;
|
|
|
end;
|
|
|
}
|
|
|
|
|
|
custfullname:=invduicust;
|
|
|
if frm_data_share.t_crm_client_all.Locate('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>',invduicust,[]) then
|
|
|
custfullname:=frm_data_share.t_crm_client_all.fieldbyname('<27>ͻ<EFBFBD>ȫ<EFBFBD><C8AB>').AsString;
|
|
|
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
close;SQL.Text:='SELECT dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>, dbo.v_op_bscard_all.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>, dbo.v_op_bscard_all.<2E><><EFBFBD><EFBFBD> '
|
|
|
+',allduifee.RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>,allduifee.USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> FROM dbo.t_ch_dui_bill INNER JOIN '
|
|
|
+' dbo.v_op_bscard_all ON dbo.t_ch_dui_bill.<2E><><EFBFBD><EFBFBD> = dbo.v_op_bscard_all.<2E><><EFBFBD><EFBFBD> INNER JOIN '
|
|
|
+' (select <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>,SUM(case when <20>ұ<EFBFBD>=''RMB'' THEN <20><><EFBFBD><EFBFBD>-<2D><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> else 0 end) RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> '
|
|
|
+' ,SUM(case when <20>ұ<EFBFBD>=''USD'' THEN <20><><EFBFBD><EFBFBD>-<2D><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> else 0 end) USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> '
|
|
|
+' from v_dui_fee where <20><><EFBFBD><EFBFBD>=''<27><>'' GROUP BY <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>) allduifee '
|
|
|
+' ON dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> = allduifee.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> '
|
|
|
+' AND dbo.t_ch_dui_bill.<2E><><EFBFBD><EFBFBD> = allduifee.<2E><><EFBFBD><EFBFBD> WHERE dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+'''';
|
|
|
open;
|
|
|
if not IsEmpty then begin
|
|
|
First;
|
|
|
while not eof do begin
|
|
|
if aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat<>0 then begin
|
|
|
if (t_ch_invoice_expitem.Locate('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>;<3B><><EFBFBD>ʱұ<CAB1>',VarArrayOf([aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString,'RMB']),[])) then begin
|
|
|
t_ch_invoice_expitem.Edit;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat+aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat:=t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat+aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
|
|
|
end else begin
|
|
|
t_ch_invoice_expitem.Insert;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString:=custfullname;
|
|
|
t_ch_invoice_expitem.FieldByName('<27>ұ<EFBFBD>').AsString:='RMB';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱұ<CAB1>').AsString:='RMB';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat:=aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD>';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>ע').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
end;
|
|
|
end;
|
|
|
{
|
|
|
if aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat<>0 then begin
|
|
|
t_ch_invoice_expitem.Insert;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString:=custfullname;
|
|
|
t_ch_invoice_expitem.FieldByName('<27>ұ<EFBFBD>').AsString:='USD';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>ע').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
end;
|
|
|
}
|
|
|
next;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.FormShow(Sender: TObject);
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
begin
|
|
|
t_ch_invoice_expitem.close;
|
|
|
t_ch_invoice_expitem.SQL.Clear;
|
|
|
t_ch_invoice_expitem.SQL.Add('select * from t_ch_invoice_expitem where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+''' ');
|
|
|
if invcurr<>'' then
|
|
|
t_ch_invoice_expitem.SQL.Add(' and <20>ұ<EFBFBD>='''+invcurr+''' ');
|
|
|
t_ch_invoice_expitem.SQL.Add(' order by ITEMID ');
|
|
|
|
|
|
// t_ch_invoice_expitem.Parameters.ParamByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Value:=invduino;
|
|
|
t_ch_invoice_expitem.Open;
|
|
|
|
|
|
t_crm_client_Invoice.Close;
|
|
|
t_crm_client_Invoice.Parameters.ParamByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').Value:=invduicust;
|
|
|
t_crm_client_Invoice.Open;
|
|
|
|
|
|
ComputeAmount;
|
|
|
|
|
|
if invduicust='' then begin
|
|
|
bsSkinButton8.Enabled:=false;
|
|
|
bsSkinButton1.Enabled:=false;
|
|
|
bsSkinButton2.Enabled:=false;
|
|
|
bsSkinButton3.Enabled:=false;
|
|
|
bsSkinButton4.Enabled:=false;
|
|
|
end;
|
|
|
// loadwwgrid(wwDBGrid2,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.ComputeAmount;
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
rmbamt,usdamt,cermb,ceusd:Double;
|
|
|
bok:Tbookmark;
|
|
|
begin
|
|
|
rmbamt:=0;
|
|
|
usdamt:=0;
|
|
|
Label1.Caption:='';
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
with aQuery do
|
|
|
begin
|
|
|
Close;
|
|
|
SQL.Clear;
|
|
|
SQL.Add('select a.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>, b.USDAmount,a.RMBAmount from (select t.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>,sum(t.RMB) AS RMBAmount from '
|
|
|
+' (select <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>, case when <20><><EFBFBD>ʱұ<CAB1>=''RMB'' THEN <20><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD> else 0 end as RMB FROM t_ch_invoice_expitem '
|
|
|
+' where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+''') t '
|
|
|
+' group by t.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>) a inner join (select s.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>,sum(s.USD) AS USDAmount from (select <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>,'
|
|
|
+' case when <20><><EFBFBD>ʱұ<CAB1>=''USD'' THEN <20><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD> else 0 end as USD FROM t_ch_invoice_expitem where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''
|
|
|
+invduino+''') s group by s.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>) b on a.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>=b.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> ') ;
|
|
|
Open;
|
|
|
Label1.Caption:='<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>:'+fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Asstring+' RMB<4D>ϼ<EFBFBD>:'+fieldbyname('RMBAmount').Asstring+'Ԫ'
|
|
|
+' USD<53>ϼ<EFBFBD>:'+ fieldbyname('USDAmount').Asstring+'<27><>Ԫ';
|
|
|
|
|
|
Close;
|
|
|
SQL.Clear;
|
|
|
SQL.Add('select SUM(CASE WHEN <20><><EFBFBD>ʱұ<CAB1>=''RMB'' THEN <20><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD> ELSE 0 END) RMB,SUM(CASE WHEN <20><><EFBFBD>ʱұ<CAB1>=''USD'' THEN <20><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD> ELSE 0 END) USD from '
|
|
|
+' t_ch_invoice_expitem '
|
|
|
+' where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+''' ') ;
|
|
|
Open;
|
|
|
rmbamt:=fieldbyname('RMB').AsFloat;
|
|
|
usdamt:=fieldbyname('USD').AsFloat;
|
|
|
|
|
|
end;
|
|
|
aQuery.Free;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t_ch_invoice_expitem_sum.Close;
|
|
|
t_ch_invoice_expitem_sum.Parameters.ParamByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Value:=invduino;
|
|
|
t_ch_invoice_expitem_sum.Open;
|
|
|
cermb:=t_ch_invoice_expitem_sum.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat-rmbamt;
|
|
|
ceusd:=t_ch_invoice_expitem_sum.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat-usdamt;
|
|
|
|
|
|
bsSkinLabel1.Caption:='<27><>Ʊ<EFBFBD>ϼ<EFBFBD> RMB<4D>ϼ<EFBFBD>:'+floattostr(rmbamt)+'Ԫ'
|
|
|
+' USD<53>ϼ<EFBFBD>:'+ floattostr(usdamt)+'<27><>Ԫ <20><><EFBFBD>RMB<4D>ϼ<EFBFBD>:'+floattostr(cermb)+'Ԫ'
|
|
|
+' USD<53>ϼ<EFBFBD>:'+ floattostr(ceusd)+'<27><>Ԫ';
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.t_ch_invoice_expitemBeforeEdit(
|
|
|
DataSet: TDataSet);
|
|
|
begin
|
|
|
if (invduicust='') then Abort;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_ch_invoice_expitems.GetIsClose: Boolean;
|
|
|
var
|
|
|
rmbamt,usdamt,cermb,ceusd:Double;
|
|
|
bok:Tbookmark;
|
|
|
begin
|
|
|
rmbamt:=0;
|
|
|
usdamt:=0;
|
|
|
result:=True;
|
|
|
bok:=t_ch_invoice_expitem.GetBookmark;
|
|
|
try
|
|
|
t_ch_invoice_expitem.DisableControls;
|
|
|
|
|
|
t_ch_invoice_expitem.First;
|
|
|
while not t_ch_invoice_expitem.Eof do begin
|
|
|
if t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱұ<CAB1>').AsString='RMB' THEN begin
|
|
|
rmbamt:=rmbamt+t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat;
|
|
|
end;
|
|
|
if t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱұ<CAB1>').AsString='USD' THEN begin
|
|
|
usdamt:=usdamt+t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat;
|
|
|
end;
|
|
|
t_ch_invoice_expitem.Next;
|
|
|
end;
|
|
|
finally
|
|
|
t_ch_invoice_expitem.EnableControls;
|
|
|
t_ch_invoice_expitem.GotoBookmark(bok);
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
t_ch_invoice_expitem_sum.Close;
|
|
|
t_ch_invoice_expitem_sum.Parameters.ParamByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').Value:=invduino;
|
|
|
t_ch_invoice_expitem_sum.Open;
|
|
|
{
|
|
|
cermb:=t_ch_invoice_expitem_sum.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat-rmbamt;
|
|
|
ceusd:=t_ch_invoice_expitem_sum.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat-usdamt;
|
|
|
|
|
|
bsSkinLabel1.Caption:='<27><>Ʊ<EFBFBD>ϼ<EFBFBD> RMB<4D>ϼ<EFBFBD>:'+floattostr(rmbamt)+'Ԫ'
|
|
|
+' USD<53>ϼ<EFBFBD>:'+ floattostr(usdamt)+'<27><>Ԫ <20><><EFBFBD>RMB<4D>ϼ<EFBFBD>:'+floattostr(cermb)+'Ԫ'
|
|
|
+' USD<53>ϼ<EFBFBD>:'+ floattostr(ceusd)+'<27><>Ԫ';
|
|
|
}
|
|
|
|
|
|
if ((rmbamt-0.1)>t_ch_invoice_expitem_sum.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat) then begin
|
|
|
ShowMessage('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>Ϊ:'+floattostr(rmbamt)+',RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>'+t_ch_invoice_expitem_sum.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsString);
|
|
|
result:=false;
|
|
|
end;
|
|
|
if ((usdamt-0.1)>t_ch_invoice_expitem_sum.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat) then begin
|
|
|
ShowMessage('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>Ϊ:'+floattostr(usdamt)+',USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>'+t_ch_invoice_expitem_sum.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsString);
|
|
|
result:=false;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.t_ch_invoice_expitemAfterInsert(
|
|
|
DataSet: TDataSet);
|
|
|
begin
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=invduino;
|
|
|
ComputeAmount;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.t_ch_invoice_expitemAfterDelete(
|
|
|
DataSet: TDataSet);
|
|
|
begin
|
|
|
ComputeAmount;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.t_ch_invoice_expitemAfterEdit(
|
|
|
DataSet: TDataSet);
|
|
|
begin
|
|
|
ComputeAmount;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.t_ch_invoice_expitemAfterPost(
|
|
|
DataSet: TDataSet);
|
|
|
begin
|
|
|
ComputeAmount;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.invtitlecharge(Sender: TField);
|
|
|
|
|
|
begin
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.FormClose(Sender: TObject;
|
|
|
var Action: TCloseAction);
|
|
|
begin
|
|
|
savewwgrid(wwDBGrid2,'<27><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_ch_invoice_expitems.bsSkinButton9Click(Sender: TObject);
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
custfullname:string;
|
|
|
begin
|
|
|
{
|
|
|
if t_ch_invoice_expitem.RecordCount<>0 then begin
|
|
|
if MessageDlg('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ȷʵҪ<CAB5><D2AA><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
Exit;
|
|
|
end;
|
|
|
}
|
|
|
|
|
|
custfullname:=invduicust;
|
|
|
if frm_data_share.t_crm_client_all.Locate('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>',invduicust,[]) then
|
|
|
custfullname:=frm_data_share.t_crm_client_all.fieldbyname('<27>ͻ<EFBFBD>ȫ<EFBFBD><C8AB>').AsString;
|
|
|
// if (not t_crm_client_Invoice.IsEmpty) then custfullname:=t_crm_client_Invoice.fieldbyname('<27><>Ʊ̧ͷ').AsString;
|
|
|
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
close;SQL.Text:='SELECT dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>, dbo.v_op_bscard_all.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>, dbo.v_op_bscard_all.<2E><><EFBFBD><EFBFBD> '
|
|
|
+',allduifee.RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>,allduifee.USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> FROM dbo.t_ch_dui_bill INNER JOIN '
|
|
|
+' dbo.v_op_bscard_all ON dbo.t_ch_dui_bill.<2E><><EFBFBD><EFBFBD> = dbo.v_op_bscard_all.<2E><><EFBFBD><EFBFBD> INNER JOIN '
|
|
|
+' (select <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>,SUM(case when <20>ұ<EFBFBD>=''RMB'' THEN <20><><EFBFBD><EFBFBD>-<2D><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> else 0 end) RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> '
|
|
|
+' ,SUM(case when <20>ұ<EFBFBD>=''USD'' THEN <20><><EFBFBD><EFBFBD>-<2D><>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> else 0 end) USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD> '
|
|
|
+' from v_dui_fee where <20><><EFBFBD><EFBFBD>=''<27><>'' GROUP BY <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>) allduifee '
|
|
|
+' ON dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> = allduifee.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> '
|
|
|
+' AND dbo.t_ch_dui_bill.<2E><><EFBFBD><EFBFBD> = allduifee.<2E><><EFBFBD><EFBFBD> WHERE dbo.t_ch_dui_bill.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+invduino+'''';
|
|
|
open;
|
|
|
if not IsEmpty then begin
|
|
|
First;
|
|
|
while not eof do begin
|
|
|
{
|
|
|
if aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat<>0 then begin
|
|
|
t_ch_invoice_expitem.Insert;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString:=custfullname;
|
|
|
t_ch_invoice_expitem.FieldByName('<27>ұ<EFBFBD>').AsString:='RMB';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱұ<CAB1>').AsString:='RMB';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat:=aQuery.FieldByName('RMB<4D><42>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӷ<EFBFBD>';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>ע').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
end;
|
|
|
}
|
|
|
|
|
|
if aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat<>0 then begin
|
|
|
|
|
|
if (t_ch_invoice_expitem.Locate('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>;<3B><><EFBFBD>ʱұ<CAB1>',VarArrayOf([aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString,'USD']),[])) then begin
|
|
|
t_ch_invoice_expitem.Edit;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat+aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat:=t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat+aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
t_ch_invoice_expitem.Insert;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>Ʊ̧ͷ').AsString:=custfullname;
|
|
|
t_ch_invoice_expitem.FieldByName('<27>ұ<EFBFBD>').AsString:='USD';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʱұ<CAB1>').AsString:='USD';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>').AsFloat:=aQuery.FieldByName('USD<53><44>Ʊ<EFBFBD><C6B1><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_invoice_expitem.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD>';
|
|
|
t_ch_invoice_expitem.FieldByName('<27><>ע').AsString:=aQuery.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
t_ch_invoice_expitem.Post;
|
|
|
END;
|
|
|
end;
|
|
|
|
|
|
next;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end.
|