|
|
unit u_rp_dui_auto;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, ExtCtrls, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl,
|
|
|
dxDBGrid, DB, ADODB, StdCtrls, Mask, DBCtrls, dxDBTLCl, dxGrClms,
|
|
|
RxLookup, wwdbdatetimepicker, Menus, XPMenu, ComCtrls, bsSkinTabs,
|
|
|
RxMemDS, wwdbedit, Wwdotdot, Wwdbcomb, Grids, DBGrids, wwdblook,
|
|
|
kbmMemTable, bsdbctrls, DBCtrlsEh,ComObj;
|
|
|
|
|
|
type
|
|
|
Tfrm_rp_dui_auto = class(TForm)
|
|
|
Panel1: TPanel;
|
|
|
bsSkinPanel2: TbsSkinPanel;
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
bsSkinButton4: TbsSkinButton;
|
|
|
bsSkinButton3: TbsSkinButton;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
bsSkinButton11: TbsSkinButton;
|
|
|
Notebook1: TNotebook;
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
t_ch_dui: TADOQuery;
|
|
|
t_ch_dui1: TDataSource;
|
|
|
dxDBGrid1Column4: TdxDBGridMaskColumn;
|
|
|
dxDBGrid1Column6: TdxDBGridMaskColumn;
|
|
|
dxDBGrid1Column7: TdxDBGridMaskColumn;
|
|
|
dxDBGrid1Column8: TdxDBGridMaskColumn;
|
|
|
dxDBGrid1Column9: TdxDBGridDateColumn;
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
bsSkinPanel6: TbsSkinPanel;
|
|
|
Label2: TLabel;
|
|
|
DBEdit2: TDBEdit;
|
|
|
DBEdit5: TDBEdit;
|
|
|
Label5: TLabel;
|
|
|
Label6: TLabel;
|
|
|
DBEdit6: TDBEdit;
|
|
|
Label3: TLabel;
|
|
|
RxDBLookupCombo1: TRxDBLookupCombo;
|
|
|
Label4: TLabel;
|
|
|
DBEdit4: TDBEdit;
|
|
|
t_ch_dui_bill: TADOQuery;
|
|
|
v_dui_bill: TADOQuery;
|
|
|
t_dui_bill1: TDataSource;
|
|
|
bsSkinButton6: TbsSkinButton;
|
|
|
PopupMenu2: TPopupMenu;
|
|
|
N5: TMenuItem;
|
|
|
XPMenu1: TXPMenu;
|
|
|
Panel3: TPanel;
|
|
|
dxDBGrid5: TdxDBGrid;
|
|
|
dxDBGrid5Column1: TdxDBGridMaskColumn;
|
|
|
dxDBGrid5Column2: TdxDBGridMaskColumn;
|
|
|
dxDBGrid5Column6: TdxDBGridMaskColumn;
|
|
|
dxDBGrid5Column7: TdxDBGridColumn;
|
|
|
dxDBGrid5Column8: TdxDBGridColumn;
|
|
|
dxDBGrid5Column9: TdxDBGridColumn;
|
|
|
dxDBGrid6: TdxDBGrid;
|
|
|
dxDBGrid6Column2: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6RMB: TdxDBGridColumn;
|
|
|
dxDBGrid6Column20: TdxDBGridColumn;
|
|
|
dxDBGrid6Column21: TdxDBGridColumn;
|
|
|
dxDBGrid6USD: TdxDBGridColumn;
|
|
|
dxDBGrid6Column4: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6Column5: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6Column6: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6Column7: TdxDBGridDateColumn;
|
|
|
dxDBGrid6Column15: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6Column16: TdxDBGridMaskColumn;
|
|
|
dxDBGrid6Column17: TdxDBGridMaskColumn;
|
|
|
PopupMenu3: TPopupMenu;
|
|
|
N2: TMenuItem;
|
|
|
dxDBGrid5Column10: TdxDBGridColumn;
|
|
|
wwDBComboBox2: TwwDBComboBox;
|
|
|
Label23: TLabel;
|
|
|
dxDBGrid5Column11: TdxDBGridColumn;
|
|
|
bsSkinButton38: TbsSkinButton;
|
|
|
Splitter1: TSplitter;
|
|
|
EXCEL1: TMenuItem;
|
|
|
EXCEL2: TMenuItem;
|
|
|
DBEdit1: TDBEdit;
|
|
|
Label1: TLabel;
|
|
|
Label7: TLabel;
|
|
|
DBEdit3: TDBEdit;
|
|
|
Label8: TLabel;
|
|
|
DBEdit7: TDBEdit;
|
|
|
dxDBGrid6Column13: TdxDBGridCheckColumn;
|
|
|
dxDBGrid6Column14: TdxDBGridColumn;
|
|
|
dxDBGrid6Column18: TdxDBGridColumn;
|
|
|
dxDBGrid6Column19: TdxDBGridColumn;
|
|
|
OpenDialog1: TOpenDialog;
|
|
|
bsSkinButton7: TbsSkinButton;
|
|
|
bsSkinButton8: TbsSkinButton;
|
|
|
t_ch_balance: TADOQuery;
|
|
|
t_ch_balanceDSDesigner: TStringField;
|
|
|
t_ch_balanceDSDesigner2: TStringField;
|
|
|
t_ch_balanceDSDesigner3: TStringField;
|
|
|
t_ch_balanceDSDesigner4: TStringField;
|
|
|
t_ch_balanceDSDesigner5: TStringField;
|
|
|
t_ch_balanceDSDesigner6: TStringField;
|
|
|
t_ch_balanceDSDesigner7: TBCDField;
|
|
|
t_ch_balanceDSDesigner8: TBCDField;
|
|
|
t_ch_balanceDSDesigner9: TBCDField;
|
|
|
t_ch_balanceDSDesigner10: TStringField;
|
|
|
t_ch_balanceDSDesigner11: TStringField;
|
|
|
t_ch_balanceDSDesigner12: TStringField;
|
|
|
t_ch_balanceDSDesigner13: TDateTimeField;
|
|
|
t_ch_balanceDSDesigner14: TBooleanField;
|
|
|
t_ch_balanceDSDesigner15: TStringField;
|
|
|
t_ch_balanceDSDesigner16: TStringField;
|
|
|
t_ch_balanceDSDesigner17: TDateTimeField;
|
|
|
t_ch_balanceDSDesigner18: TStringField;
|
|
|
t_ch_balanceDSDesigner19: TStringField;
|
|
|
t_ch_balanceDSDesigner20: TDateTimeField;
|
|
|
t_ch_balanceDSDesigner21: TStringField;
|
|
|
t_ch_balanceDSDesigner22: TBooleanField;
|
|
|
t_ch_balanceDSDesigner23: TStringField;
|
|
|
t_ch_balanceDSDesigner24: TBCDField;
|
|
|
t_ch_balanceDSDesigner25: TBCDField;
|
|
|
t_ch_balanceDSDesigner26: TStringField;
|
|
|
t_ch_balanceDSDesigner27: TStringField;
|
|
|
t_ch_balanceDSDesigner28: TStringField;
|
|
|
t_ch_balanceDSDesigner29: TStringField;
|
|
|
t_ch_balanceDSDesigner30: TBCDField;
|
|
|
t_ch_balanceDSDesigner31: TStringField;
|
|
|
t_ch_balanceDSDesigner32: TStringField;
|
|
|
t_ch_balanceDSDesigner33: TStringField;
|
|
|
t_ch_balanceDSDesigner34: TDateTimeField;
|
|
|
t_ch_balanceDSDesigner35: TSmallintField;
|
|
|
t_ch_balanceField: TStringField;
|
|
|
t_ch_balanceField2: TFloatField;
|
|
|
t_ch_balanceField3: TFloatField;
|
|
|
t_ch_balanceField4: TStringField;
|
|
|
t_ch_balanceField5: TStringField;
|
|
|
t_ch_fee_do: TADOQuery;
|
|
|
dxDBGrid1Column10: TdxDBGridColumn;
|
|
|
dxDBGrid1Column11: TdxDBGridColumn;
|
|
|
dxDBGrid1Column12: TdxDBGridColumn;
|
|
|
dxDBGrid6Column22: TdxDBGridColumn;
|
|
|
dxDBGrid6Column23: TdxDBGridColumn;
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure bsSkinPanel2Resize(Sender: TObject);
|
|
|
procedure t_ch_duiAfterInsert(DataSet: TDataSet);
|
|
|
procedure t_ch_duiBeforePost(DataSet: TDataSet);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
|
procedure bsSkinButton3Click(Sender: TObject);
|
|
|
procedure bsSkinButton11Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure dxDBGrid1ColumnSorting(Sender: TObject;
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
procedure dxDBGrid6ColumnSorting(Sender: TObject;
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
procedure bsSkinButton38Click(Sender: TObject);
|
|
|
procedure bsSkinButton6Click(Sender: TObject);
|
|
|
procedure EXCEL2Click(Sender: TObject);
|
|
|
procedure t_ch_dui_billAfterInsert(DataSet: TDataSet);
|
|
|
procedure bsSkinButton7Click(Sender: TObject);
|
|
|
procedure bsSkinButton4Click(Sender: TObject);
|
|
|
procedure t_ch_balanceAfterInsert(DataSet: TDataSet);
|
|
|
procedure t_ch_balanceBeforePost(DataSet: TDataSet);
|
|
|
procedure bsSkinButton8Click(Sender: TObject);
|
|
|
procedure N5Click(Sender: TObject);
|
|
|
private
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
procedure Autofee();
|
|
|
procedure Autostl();
|
|
|
function GetInvoiceAmt:boolean;
|
|
|
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_rp_dui_auto: Tfrm_rp_dui_auto;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_main, my_sys_function, u_data_share, u_rp_dui_auto_addstl;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
function Tfrm_rp_dui_auto.GetInvoiceAmt:boolean;
|
|
|
begin
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.FormClose(Sender: TObject;
|
|
|
var Action: TCloseAction);
|
|
|
begin
|
|
|
savereggrid(dxdbgrid6,caption+'6');
|
|
|
|
|
|
frm_rp_dui_auto.Hide;
|
|
|
frm_rp_dui_auto.ManualFloat(frm_rp_dui_auto.BoundsRect );
|
|
|
frm_main.freeTabs('frm_rp_dui_auto');
|
|
|
action:=cafree;
|
|
|
frm_rp_dui_auto:=nil;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinPanel2Resize(Sender: TObject);
|
|
|
var
|
|
|
i:integer;
|
|
|
begin
|
|
|
i:=round(bsSkinPanel2.width/12);
|
|
|
bsSkinButton10.width:=i;
|
|
|
bsSkinButton1.width:=i;
|
|
|
bsSkinButton2.width:=i;
|
|
|
bsSkinButton4.width:=i;
|
|
|
bsSkinButton3.width:=i;
|
|
|
bsSkinButton11.width:=i;
|
|
|
bsSkinButton6.width:=i;
|
|
|
bsSkinButton38.width:=i;
|
|
|
// bsSkinButton13.width:=i;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.t_ch_duiAfterInsert(DataSet: TDataSet);
|
|
|
begin
|
|
|
t_ch_dui['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=date;
|
|
|
t_ch_dui['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=employee;
|
|
|
// t_ch_dui['<27>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>']:='ȫ<><C8AB>';
|
|
|
t_ch_dui['<27><><EFBFBD>÷<EFBFBD>Χ']:='<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.t_ch_duiBeforePost(DataSet: TDataSet);
|
|
|
begin
|
|
|
table_before_post(t_ch_dui,'<27><><EFBFBD>ʿͻ<CABF>');
|
|
|
|
|
|
if t_ch_dui.State=dsinsert then
|
|
|
begin
|
|
|
t_ch_dui['<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>']:=get_no(date,'D1');
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton1Click(Sender: TObject);
|
|
|
begin
|
|
|
t_ch_dui.insert;
|
|
|
Notebook1.PageIndex:=1;
|
|
|
bsSkinButton11.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>';
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
table_post(t_ch_dui);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton3Click(Sender: TObject);
|
|
|
begin
|
|
|
table_cancel(t_ch_dui);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton11Click(Sender: TObject);
|
|
|
var
|
|
|
answer:TModalResult;
|
|
|
begin
|
|
|
if bsSkinButton11.Caption='<27>༭<EFBFBD><EFBFBD>' then
|
|
|
begin
|
|
|
Notebook1.PageIndex:=1;
|
|
|
bsSkinButton11.Caption:='<27><><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>';
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
if (t_ch_dui.State=dsinsert)or(t_ch_dui.State=dsedit) then
|
|
|
BEGIN
|
|
|
answer:=messagedlg( '<27><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE>ģ<DEB8><C4A3>Ƿ棿',mtWarning,mbYesNoCancel,0);
|
|
|
if answer=mrYes then
|
|
|
begin
|
|
|
t_ch_dui.post;
|
|
|
end;
|
|
|
if answer=mrNo then
|
|
|
begin
|
|
|
t_ch_dui.cancel;
|
|
|
end;
|
|
|
if answer=mrCancel then
|
|
|
begin
|
|
|
exit;
|
|
|
end;
|
|
|
END;
|
|
|
Notebook1.PageIndex:=0;
|
|
|
bsSkinButton11.Caption:='<27>༭<EFBFBD><EFBFBD>';
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.FormShow(Sender: TObject);
|
|
|
var
|
|
|
str:widestring;
|
|
|
begin
|
|
|
Notebook1.PageIndex:=0;
|
|
|
loadreggrid(dxdbgrid6,false,caption+'6');
|
|
|
|
|
|
str:='select top 50 * from t_ch_dui_auto ';
|
|
|
|
|
|
str:=str+' where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+employee+''''+' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> desc';
|
|
|
t_ch_dui.close;
|
|
|
t_ch_dui.SQL.clear;
|
|
|
t_ch_dui.sql.Add(str);
|
|
|
t_ch_dui.open;
|
|
|
|
|
|
t_ch_dui_bill.open;
|
|
|
|
|
|
// v_dui_bill.open;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.dxDBGrid1ColumnSorting(Sender: TObject;
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
begin
|
|
|
Column_sort(Column,t_ch_dui,'<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.dxDBGrid6ColumnSorting(Sender: TObject;
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
begin
|
|
|
Column_sort(column,v_dui_bill,'ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton38Click(Sender: TObject);
|
|
|
var
|
|
|
book1:Tbookmark;
|
|
|
begin
|
|
|
book1:=t_ch_dui.GetBookmark;
|
|
|
t_ch_dui.Requery;
|
|
|
t_ch_dui.GotoBookmark(book1);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton6Click(Sender: TObject);
|
|
|
var
|
|
|
filesName,s,s1:String;
|
|
|
ExcelTemplet:Variant;
|
|
|
j,i,r,T,m:integer;
|
|
|
|
|
|
begin
|
|
|
r:=0;
|
|
|
if t_ch_dui.State in [dsedit,dsinsert] then t_ch_dui.Post;
|
|
|
if (not t_ch_dui_bill.Active) then t_ch_dui_bill.open;
|
|
|
|
|
|
|
|
|
if OpenDialog1.Execute then begin
|
|
|
filesName:=ExtractFileName(OpenDialog1.FileName);
|
|
|
ExcelTemplet:= CreateOleObject('Excel.Application');
|
|
|
try
|
|
|
ExcelTemplet.Visible := FALSE;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ
|
|
|
ExcelTemplet.Workbooks.Open(OpenDialog1.FileName);
|
|
|
m:=0;
|
|
|
J:=2;
|
|
|
while VartoStr(ExcelTemplet.Worksheets[1].Cells[J,1].Value)<>'' do begin
|
|
|
t_ch_dui_bill.Insert;
|
|
|
t_ch_dui_bill['<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>']:=VartoStr(ExcelTemplet.Worksheets[1].Cells[J,1].Value);
|
|
|
S:=VarToStr(ExcelTemplet.Worksheets[1].Cells[J,2].Value);
|
|
|
if StrToFloatDef(S,0)<>0 then
|
|
|
begin
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=s_w(2,StrToFloatDef(S,0));
|
|
|
end else begin
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
end;
|
|
|
S:=VarToStr(ExcelTemplet.Worksheets[1].Cells[J,3].Value);
|
|
|
if StrToFloatDef(S,0)<>0 then
|
|
|
begin
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat:=s_w(2,StrToFloatDef(S,0));
|
|
|
end else begin
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
end;
|
|
|
t_ch_dui_bill.Post;
|
|
|
m:=m+1;
|
|
|
J:=J+1;
|
|
|
|
|
|
end;
|
|
|
finally
|
|
|
ExcelTemplet.DisplayAlerts := false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
|
|
ExcelTemplet.Quit;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
|
|
|
end;
|
|
|
end;
|
|
|
t_ch_dui_bill.Close;
|
|
|
t_ch_dui_bill.Open;
|
|
|
Autofee;
|
|
|
showmessage('<27>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>'+inttostr(m)+'Ʊҵ<C6B1><D2B5><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.EXCEL2Click(Sender: TObject);
|
|
|
begin
|
|
|
grid_save_xls(dxDBGrid6);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.t_ch_dui_billAfterInsert(DataSet: TDataSet);
|
|
|
begin
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
t_ch_dui_bill.FieldByName('RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
t_ch_dui_bill.FieldByName('USD<53><44><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
t_ch_dui_bill.FieldByName('˵<><CBB5>').AsString:='δƥ<CEB4><C6A5>';
|
|
|
t_ch_dui_bill['һ<><D2BB>']:=0;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton7Click(Sender: TObject);
|
|
|
begin
|
|
|
Autofee;
|
|
|
ShowMessage('ƥ<><C6A5><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD>');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton4Click(Sender: TObject);
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
begin
|
|
|
if application.MessageBox('<27><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?','<27><><EFBFBD><EFBFBD>:',MB_OKCANCEL)<>IDOK then
|
|
|
exit;
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;sql.Clear;
|
|
|
sql.Add('delete from t_ch_dui_auto_bill where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+'''');
|
|
|
ExecSQL;
|
|
|
end;
|
|
|
t_ch_dui.Delete;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.t_ch_balanceAfterInsert(DataSet: TDataSet);
|
|
|
begin
|
|
|
t_ch_balance['<27>ʵ<EFBFBD>״̬']:='¼<><C2BC>״̬';
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:='<27><><EFBFBD><EFBFBD>';
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=employee;
|
|
|
if Logininfo.endday+1>now then
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=Logininfo.endday+1
|
|
|
else
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=now;
|
|
|
t_ch_balance['<27>Զ<EFBFBD>']:=1;
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>']:=0;
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD>']:='<27><>';
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD>']:=0;
|
|
|
t_ch_balance['<27><><EFBFBD>㷽ʽ']:='֧Ʊ';
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=1;
|
|
|
t_ch_balance['<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>']:=get_no(date,'BP');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.t_ch_balanceBeforePost(DataSet: TDataSet);
|
|
|
begin
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=s_w(strtoint(apointnum),t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
|
|
|
t_ch_balance['ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=s_w(strtoint(apointnum),t_ch_balance['ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=s_w(strtoint(apointnum),t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']);
|
|
|
t_ch_balance['<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>']:=s_w(strtoint(apointnum),t_ch_balance['<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>']);
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>']:=s_w(strtoint(apointnum),t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>']);
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+t_ch_balance['Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']-t_ch_balance['ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.Autofee;
|
|
|
var
|
|
|
aQuery,aQuery2:TADOQuery;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
aQuery2:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' update t_ch_dui_auto_bill set <20><><EFBFBD><EFBFBD>=b.<2E><><EFBFBD><EFBFBD>,ί<>е<EFBFBD>λ=b.[ί<>е<EFBFBD>λ],<2C><><EFBFBD><EFBFBD>=b.[<5B><><EFBFBD><EFBFBD>],<2C><><EFBFBD><EFBFBD>=b.[<5B><><EFBFBD><EFBFBD>]');
|
|
|
sql.Add(',<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=b.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],<2C><><EFBFBD><EFBFBD>Ա=b.[<5B><><EFBFBD><EFBFBD>Ա],<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=b.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>] from t_op_seae b');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill d on (d.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>=b.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>) ');
|
|
|
sql.Add(' where isnull(d.<2E><><EFBFBD><EFBFBD>,'''')='''' and d.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+''' ');
|
|
|
ExecSQL;
|
|
|
aQuery2.Close;aQuery2.SQL.Clear;
|
|
|
aQuery2.SQL.Add('select * from t_ch_dui_auto_bill where <20><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+'''');
|
|
|
aQuery2.Open;
|
|
|
aQuery2.First;
|
|
|
while aQuery2.Eof do begin
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' insert into t_ch_dui_auto_bill_detail(DB_ID,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>)');
|
|
|
sql.Add(' select '+aQuery2.fieldbyname('DB_ID').AsString+',B.<2E><><EFBFBD><EFBFBD>,'''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+''' from t_op_seae b');
|
|
|
sql.Add(' where b.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5> like '''+aQuery2.fieldbyname('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString+'%''');
|
|
|
ExecSQL;
|
|
|
|
|
|
aQuery2.Next;
|
|
|
end;
|
|
|
{
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' insert into t_ch_dui_auto_bill_detail(DB_ID,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>)');
|
|
|
sql.Add(' select d.DB_ID,B.<2E><><EFBFBD><EFBFBD>,d.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD> from t_op_seae b');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill d on (d.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>=b.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>) ');
|
|
|
sql.Add(' where d.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+''' ');
|
|
|
ExecSQL;
|
|
|
}
|
|
|
|
|
|
t_ch_dui_bill.close;
|
|
|
t_ch_dui_bill.open;
|
|
|
if (t_ch_dui.FieldByName('<27><><EFBFBD>÷<EFBFBD>Χ').AsString='<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') then begin
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' SELECT d.DB_ID,isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (CASE <20>ұ<EFBFBD> WHEN ''RMB'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0)-ISNULL(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ELSE 0 END) ELSE 0 END),0) RMBCR');
|
|
|
sql.Add(',isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (CASE <20>ұ<EFBFBD> WHEN ''USD'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0)-ISNULL(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ELSE 0 END) ELSE 0 END),0) USDCR ');
|
|
|
sql.Add(' from t_ch_fee f ');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill_detail d on (d.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD>) ');
|
|
|
sql.Add(' where f.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʿͻ<CABF>').AsString+''' and isnull(d.<2E><><EFBFBD><EFBFBD>,'''')<>'''' and d.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+''' ');
|
|
|
sql.Add(' and f.<2E><><EFBFBD><EFBFBD>״̬ in (''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'',''<27><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') and f.<2E><><EFBFBD><EFBFBD><>f.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
end else begin
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' SELECT d.DB_ID,isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (CASE <20>ұ<EFBFBD> WHEN ''RMB'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) ELSE 0 END) ELSE 0 END),0) RMBCR');
|
|
|
sql.Add(',isnull(SUM(CASE <20><><EFBFBD><EFBFBD> WHEN ''<27><>'' THEN (CASE <20>ұ<EFBFBD> WHEN ''USD'' THEN ISNULL(<28><><EFBFBD><EFBFBD>,0) ELSE 0 END) ELSE 0 END),0) USDCR ');
|
|
|
sql.Add(' from t_ch_fee f ');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill_detail d on (d.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD>) ');
|
|
|
sql.Add(' where f.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʿͻ<CABF>').AsString+''' and isnull(d.<2E><><EFBFBD><EFBFBD>,'''')<>'''' and d.<2E><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>').AsString+''' ');
|
|
|
sql.Add(' and f.<2E><><EFBFBD><EFBFBD>״̬ in (''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'',''<27><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>'',''<27><>ֹɾ<D6B9><C9BE>'',''<27><>ֹ<EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') ');
|
|
|
|
|
|
end;
|
|
|
|
|
|
sql.Add(' GROUP BY d.DB_ID ');
|
|
|
open;
|
|
|
if not IsEmpty then begin
|
|
|
First;
|
|
|
while not Eof do begin
|
|
|
if t_ch_dui_bill.Locate('DB_ID',fieldbyname('DB_ID').asstring,[]) then begin
|
|
|
t_ch_dui_bill.Edit;
|
|
|
t_ch_dui_bill['<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>']:=Fieldbyname('RMBCR').AsFloat;
|
|
|
t_ch_dui_bill['<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>']:=Fieldbyname('USDCR').AsFloat;
|
|
|
t_ch_dui_bill['RMB<4D><42><EFBFBD><EFBFBD>']:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat-t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat;
|
|
|
t_ch_dui_bill['USD<53><44><EFBFBD><EFBFBD>']:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat-t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat;
|
|
|
if (t_ch_dui_bill.FieldByName('RMB<4D><42><EFBFBD><EFBFBD>').AsFloat=0) and (t_ch_dui_bill.FieldByName('USD<53><44><EFBFBD><EFBFBD>').AsFloat=0) THEN
|
|
|
t_ch_dui_bill['һ<><D2BB>']:=1
|
|
|
else t_ch_dui_bill['һ<><D2BB>']:=0;
|
|
|
if (t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat>t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat) then
|
|
|
t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat
|
|
|
else t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat;
|
|
|
if (t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat>t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat) then
|
|
|
t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat
|
|
|
else t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat:=t_ch_dui_bill.fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
|
t_ch_dui_bill.Post;
|
|
|
end;
|
|
|
Next;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
FreeAndNil(aQuery2);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.Autostl;
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
stlrmbcr,stlusdcr,ttlrmbcr,ttlusdcr,tmpcr,ttlrmb,ttlusd:Double;
|
|
|
begin
|
|
|
|
|
|
ttlrmb:=0;
|
|
|
ttlusd:=0;
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
|
|
|
if (not t_ch_fee_do.Active) then t_ch_fee_do.Open;
|
|
|
t_ch_dui_bill.First;
|
|
|
while not t_ch_dui_bill.Eof do begin
|
|
|
if (t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat<>0) or (t_ch_dui_bill.FieldByName('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat<>0) THEN begin
|
|
|
if (t_ch_dui.FieldByName('<27><><EFBFBD>÷<EFBFBD>Χ').AsString='<27><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>') then begin
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' SELECT f.<2E><><EFBFBD><EFBFBD>,f.CH_ID,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,<2C>ұ<EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>');
|
|
|
sql.Add(',ISNULL(<28><><EFBFBD><EFBFBD>,0)-ISNULL(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) BALANCECR ');
|
|
|
sql.Add(' from t_ch_fee f ');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill_detail d on (d.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD>) ');
|
|
|
sql.Add(' where f.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʿͻ<CABF>').AsString+''' and d.DB_ID='+t_ch_dui_bill.fieldbyname('DB_ID').AsString);
|
|
|
sql.Add(' and f.<2E><><EFBFBD><EFBFBD>״̬ in (''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'',''<27><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') and f.<2E><><EFBFBD><EFBFBD><>f.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and f.<2E><><EFBFBD><EFBFBD>=''<27><>'' ');
|
|
|
end else begin
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' SELECT f.<2E><><EFBFBD><EFBFBD>,f.CH_ID,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,<2C>ұ<EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>');
|
|
|
sql.Add(',ISNULL(<28><><EFBFBD><EFBFBD>,0)-ISNULL(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) BALANCECR ');
|
|
|
sql.Add(' from t_ch_fee f ');
|
|
|
sql.Add(' left join t_ch_dui_auto_bill_detail d on (d.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD>) ');
|
|
|
sql.Add(' where f.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+t_ch_dui.fieldbyname('<27><><EFBFBD>ʿͻ<CABF>').AsString+''' and d.DB_ID='+t_ch_dui_bill.fieldbyname('DB_ID').AsString);
|
|
|
sql.Add(' and f.<2E><><EFBFBD><EFBFBD>״̬ in (''<27><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>'',''<27><><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>'',''<27><>ֹɾ<D6B9><C9BE>'',''<27><>ֹ<EFBFBD><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'') and f.<2E><><EFBFBD><EFBFBD>=''<27><>'' ');
|
|
|
end;
|
|
|
Open;
|
|
|
if (t_ch_dui_bill.FieldByName('һ<><D2BB>').AsBoolean) THEN begin
|
|
|
First;
|
|
|
while not eof do begin
|
|
|
t_ch_fee_do.Insert;
|
|
|
t_ch_fee_do.FieldByName('<27>ұ<EFBFBD>').asstring:=fieldbyname('<27>ұ<EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=t_ch_balance.fieldbyname('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=fieldbyname('<27><><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('CH_ID').asinteger:=fieldbyname('CH_ID').asinteger;
|
|
|
t_ch_fee_do.FieldByName('ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>').asfloat:=fieldbyname('BALANCECR').AsFloat;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asfloat:=fieldbyname('BALANCECR').AsFloat;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:='4';
|
|
|
t_ch_fee_do.Post;
|
|
|
Setfee(0,fieldbyname('CH_ID').AsInteger,fieldbyname('BALANCECR').AsFloat);
|
|
|
if (fieldbyname('<27>ұ<EFBFBD>').asstring='USD')then begin
|
|
|
ttlrmb:=ttlrmb+fieldbyname('BALANCECR').AsFloat;
|
|
|
end;
|
|
|
if (fieldbyname('<27>ұ<EFBFBD>').asstring='RMB') then begin
|
|
|
ttlusd:=ttlusd+fieldbyname('BALANCECR').AsFloat;
|
|
|
end;
|
|
|
|
|
|
Next;
|
|
|
end;
|
|
|
|
|
|
end else begin
|
|
|
stlrmbcr:=t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat;
|
|
|
if (t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat<stlrmbcr) then stlrmbcr:=t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>RMB<4D><42><EFBFBD><EFBFBD>').AsFloat;
|
|
|
stlusdcr:=t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat;
|
|
|
if (t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat<stlusdcr) then stlusdcr:=t_ch_dui_bill.Fieldbyname('<27><><EFBFBD><EFBFBD>USD<53><44><EFBFBD><EFBFBD>').AsFloat;
|
|
|
ttlrmbcr:=0;
|
|
|
ttlusdcr:=0;
|
|
|
tmpcr:=0;
|
|
|
First;
|
|
|
while not eof do begin
|
|
|
if (fieldbyname('<27>ұ<EFBFBD>').asstring='USD') and (ttlusdcr<stlusdcr) then begin
|
|
|
if (ttlusdcr+fieldbyname('BALANCECR').AsFloat)>stlusdcr then begin
|
|
|
tmpcr:=stlusdcr-ttlusdcr;
|
|
|
end else begin
|
|
|
tmpcr:=fieldbyname('BALANCECR').AsFloat
|
|
|
end;
|
|
|
ttlusdcr:=ttlusdcr+tmpcr;
|
|
|
t_ch_fee_do.Insert;
|
|
|
t_ch_fee_do.FieldByName('<27>ұ<EFBFBD>').asstring:=fieldbyname('<27>ұ<EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=t_ch_balance.fieldbyname('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=fieldbyname('<27><><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('CH_ID').asinteger:=fieldbyname('CH_ID').asinteger;
|
|
|
t_ch_fee_do.FieldByName('ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>').asfloat:=tmpcr;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asfloat:=tmpcr;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:='4';
|
|
|
t_ch_fee_do.Post;
|
|
|
Setfee(0,fieldbyname('CH_ID').AsInteger,tmpcr);
|
|
|
|
|
|
end;
|
|
|
if (fieldbyname('<27>ұ<EFBFBD>').asstring='RMB') and (ttlrmbcr<stlrmbcr) then begin
|
|
|
if (ttlrmbcr+fieldbyname('BALANCECR').AsFloat)>stlrmbcr then begin
|
|
|
tmpcr:=stlrmbcr-ttlrmbcr;
|
|
|
end else begin
|
|
|
tmpcr:=fieldbyname('BALANCECR').AsFloat
|
|
|
end;
|
|
|
ttlrmbcr:=ttlrmbcr+tmpcr;
|
|
|
t_ch_fee_do.Insert;
|
|
|
t_ch_fee_do.FieldByName('<27>ұ<EFBFBD>').asstring:=fieldbyname('<27>ұ<EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=t_ch_balance.fieldbyname('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=fieldbyname('<27><><EFBFBD><EFBFBD>').asstring;
|
|
|
t_ch_fee_do.FieldByName('CH_ID').asinteger:=fieldbyname('CH_ID').asinteger;
|
|
|
t_ch_fee_do.FieldByName('ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>').asfloat:=tmpcr;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asfloat:=tmpcr;
|
|
|
t_ch_fee_do.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:='4';
|
|
|
t_ch_fee_do.Post;
|
|
|
Setfee(0,fieldbyname('CH_ID').AsInteger,tmpcr);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
Next;
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
t_ch_dui_bill.Next;
|
|
|
end;
|
|
|
t_ch_dui.Edit;
|
|
|
t_ch_dui.FieldByName('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').AsString:=t_ch_balance.fieldbyname('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
t_ch_dui['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=date;
|
|
|
t_ch_dui.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=employee;
|
|
|
t_ch_dui.Post;
|
|
|
|
|
|
Close;SQL.Clear;
|
|
|
sql.Add(' select ISNULL(sum(CASE WHEN <20>ұ<EFBFBD>=''USD'' THEN <20><><EFBFBD><EFBFBD> ELSE 0 END),0) USD,ISNULL(sum(CASE WHEN <20>ұ<EFBFBD>=''RMB'' THEN <20><><EFBFBD><EFBFBD> ELSE 0 END),0) RMB ');
|
|
|
sql.Add(' from t_ch_fee_do where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+t_ch_balance.fieldbyname('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').AsString+''' ');
|
|
|
open;
|
|
|
|
|
|
|
|
|
t_ch_balance.Edit;
|
|
|
t_ch_balance['<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>']:=fieldbyname('RMB').AsFloat;
|
|
|
t_ch_balance['<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>']:=fieldbyname('USD').AsFloat;
|
|
|
t_ch_balance.Post;
|
|
|
// ShowMessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>');
|
|
|
END;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.bsSkinButton8Click(Sender: TObject);
|
|
|
begin
|
|
|
if (t_ch_dui.FieldByName('<27>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>').AsString<>'') then begin
|
|
|
ShowMessage('<27>ѽ<EFBFBD><D1BD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
exit;
|
|
|
end;
|
|
|
try
|
|
|
frm_rp_dui_auto_addstl:=tfrm_rp_dui_auto_addstl.Create (self);
|
|
|
frm_rp_dui_auto_addstl.ShowModal;
|
|
|
finally
|
|
|
frm_rp_dui_auto_addstl.Free;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_dui_auto.N5Click(Sender: TObject);
|
|
|
var
|
|
|
i:integer;
|
|
|
str_list:Tstringlist;
|
|
|
begin
|
|
|
if t_ch_dui_bill.isempty then
|
|
|
exit;
|
|
|
if application.MessageBox('<27><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?','<27><><EFBFBD><EFBFBD>:',MB_OKCANCEL)<>IDOK then
|
|
|
exit;
|
|
|
try
|
|
|
str_list:=Tstringlist.create;
|
|
|
for i:=0 to dxDBGrid6.SelectedCount-1 do
|
|
|
begin
|
|
|
t_ch_dui_bill.GotoBookmark(pointer(dxDBGrid6.selectedrows[i]));
|
|
|
str_list.Add(t_ch_dui_bill.fieldbyname('DB_ID').AsString);
|
|
|
|
|
|
end;
|
|
|
for i:=0 to str_list.Count-1 do
|
|
|
begin
|
|
|
if t_ch_dui_bill.locate('DB_ID',str_list[i],[]) then
|
|
|
t_ch_dui_bill.Delete;
|
|
|
end;
|
|
|
finally
|
|
|
str_list.free;
|
|
|
end;
|
|
|
|
|
|
t_ch_dui_bill.Refresh;
|
|
|
end;
|
|
|
|
|
|
end.
|