|
|
unit u_rp_sales_profit_lx;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
Dialogs, dxExEdtr, RxMemDS, DB, ADODB, Menus, XPMenu, bsSkinCtrls,
|
|
|
dxDBGrid, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxCntner, ComCtrls,DateUtils,
|
|
|
bsSkinTabs, ExtCtrls, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb,
|
|
|
kbmMemTable, kbmMemBinaryStreamFormat, wwdbdatetimepicker, RxLookup,
|
|
|
bsSkinBoxCtrls, Grids, DBGrids;
|
|
|
|
|
|
type
|
|
|
Tfrm_rp_sales_profit_lx = class(TForm)
|
|
|
Panel1: TPanel;
|
|
|
bsSkinPageControl1: TbsSkinPageControl;
|
|
|
PopupMenu2: TPopupMenu;
|
|
|
N10: TMenuItem;
|
|
|
N11: TMenuItem;
|
|
|
N14: TMenuItem;
|
|
|
N13: TMenuItem;
|
|
|
N12: TMenuItem;
|
|
|
N15: TMenuItem;
|
|
|
N16: TMenuItem;
|
|
|
XPMenu2: TXPMenu;
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
bsSkinPanel3: TbsSkinPanel;
|
|
|
kbmThreadDataSet1: TkbmThreadDataSet;
|
|
|
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
|
|
|
memtblrpt_total: TkbmMemTable;
|
|
|
RxDBLookupCombo3: TRxDBLookupCombo;
|
|
|
Label14: TLabel;
|
|
|
P_SUM: TkbmMemTable;
|
|
|
DataSource1: TDataSource;
|
|
|
P_SUM1: TDataSource;
|
|
|
P_SUMField: TStringField;
|
|
|
P_SUMField14: TFloatField;
|
|
|
pnl1: TPanel;
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
bsSkinButton9: TbsSkinButton;
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
RxDBLookupCombo2: TRxDBLookupCombo;
|
|
|
Label9: TLabel;
|
|
|
Label22: TLabel;
|
|
|
RxDBLookupCombo10: TRxDBLookupCombo;
|
|
|
memtblDetail: TkbmMemTable;
|
|
|
StringField1: TStringField;
|
|
|
FloatField5: TFloatField;
|
|
|
FloatField7: TFloatField;
|
|
|
memtblDetailField: TStringField;
|
|
|
memtblDetailField5: TDateTimeField;
|
|
|
memtblDetailField6: TStringField;
|
|
|
memtblDetailField8: TStringField;
|
|
|
memtblDetailField9: TStringField;
|
|
|
memtblDetail1: TDataSource;
|
|
|
memtblDetailField11: TStringField;
|
|
|
memtblDetailField12: TDateTimeField;
|
|
|
memtblDetailField13: TDateTimeField;
|
|
|
memtblDetailField18: TDateField;
|
|
|
Label1: TLabel;
|
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
|
Edit1: TEdit;
|
|
|
Label4: TLabel;
|
|
|
wwDBDateTimePicker1: TwwDBDateTimePicker;
|
|
|
wwDBDateTimePicker2: TwwDBDateTimePicker;
|
|
|
bsSkinMemo1: TbsSkinMemo;
|
|
|
Label2: TLabel;
|
|
|
Label3: TLabel;
|
|
|
Label5: TLabel;
|
|
|
wwDBDateTimePicker3: TwwDBDateTimePicker;
|
|
|
Label6: TLabel;
|
|
|
wwDBDateTimePicker4: TwwDBDateTimePicker;
|
|
|
Label7: TLabel;
|
|
|
wwDBDateTimePicker5: TwwDBDateTimePicker;
|
|
|
Label8: TLabel;
|
|
|
wwDBDateTimePicker6: TwwDBDateTimePicker;
|
|
|
memtblDetailField2: TStringField;
|
|
|
memtblDetailField3: TStringField;
|
|
|
memtblDetailField4: TStringField;
|
|
|
memtblDetailField7: TStringField;
|
|
|
memtblDetailField10: TStringField;
|
|
|
memtblDetailField14: TStringField;
|
|
|
memtblDetailField15: TStringField;
|
|
|
memtblDetailField16: TStringField;
|
|
|
memtblDetailField17: TIntegerField;
|
|
|
memtblDetailField19: TFloatField;
|
|
|
bsSkinTabSheet1: TbsSkinTabSheet;
|
|
|
bsSkinTabSheet2: TbsSkinTabSheet;
|
|
|
dxDBGrid2: TdxDBGrid;
|
|
|
dxDBGridMaskColumn32: TdxDBGridMaskColumn;
|
|
|
dxDBGrid2Column19: TdxDBGridColumn;
|
|
|
dxDBGrid2Column18: TdxDBGridColumn;
|
|
|
dxDBGridMaskColumn36: TdxDBGridMaskColumn;
|
|
|
dxDBGrid2Column24: TdxDBGridColumn;
|
|
|
dxDBGrid2Column11: TdxDBGridColumn;
|
|
|
dxDBGrid2Column12: TdxDBGridColumn;
|
|
|
dxDBGrid2Column15: TdxDBGridColumn;
|
|
|
dxDBGrid2Column16: TdxDBGridColumn;
|
|
|
dxDBGrid2Column13: TdxDBGridColumn;
|
|
|
dxDBGrid2Column14: TdxDBGridColumn;
|
|
|
dxDBGrid2Column17: TdxDBGridColumn;
|
|
|
dxDBGrid2Column20: TdxDBGridColumn;
|
|
|
dxDBGrid2Column21: TdxDBGridColumn;
|
|
|
dxDBGrid2Column22: TdxDBGridColumn;
|
|
|
dxDBGrid2Column23: TdxDBGridColumn;
|
|
|
dxDBGrid2Column25: TdxDBGridColumn;
|
|
|
dxDBGrid2Column26: TdxDBGridColumn;
|
|
|
dxDBGrid2Column27: TdxDBGridColumn;
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
dxDBGrid1Column1: TdxDBGridColumn;
|
|
|
dxDBGrid1Column2: TdxDBGridColumn;
|
|
|
Label39: TLabel;
|
|
|
wwDBComboBox44: TwwDBComboBox;
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure bsSkinButton9Click(Sender: TObject);
|
|
|
procedure N10Click(Sender: TObject);
|
|
|
procedure N14Click(Sender: TObject);
|
|
|
procedure N16Click(Sender: TObject);
|
|
|
procedure bsSkinButton10Click(Sender: TObject);
|
|
|
private
|
|
|
procedure Getlx;
|
|
|
function GetBetwMonth(aBe,aEe:TDate):Integer;
|
|
|
function issameMonth(aBe,aEe:TDate):Boolean;
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
bdatestr:String;
|
|
|
{ Public declarations }
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_rp_sales_profit_lx: Tfrm_rp_sales_profit_lx;
|
|
|
rp_rp_total_open:boolean;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_main, my_sys_function, u_sys_progress,u_data_share;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.bsSkinButton5Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.FormClose(Sender: TObject;
|
|
|
var Action: TCloseAction);
|
|
|
begin
|
|
|
savereggrid(dxdbgrid2,caption+'2');
|
|
|
frm_rp_sales_profit_lx.Hide;
|
|
|
frm_rp_sales_profit_lx.ManualFloat(frm_rp_sales_profit_lx.BoundsRect );
|
|
|
frm_main.freeTabs('frm_rp_sales_profit_lx');
|
|
|
action:=cafree;
|
|
|
frm_rp_sales_profit_lx:=nil;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.FormShow(Sender: TObject);
|
|
|
begin
|
|
|
loadreggrid(dxdbgrid2,true,caption+'2');
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.bsSkinButton9Click(Sender: TObject);
|
|
|
begin
|
|
|
sys_print('ҵ<><D2B5><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>',2,nil,nil,nil,nil,memtblDetail1,P_SUM1,nil,nil,nil,nil,nil);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.N10Click(Sender: TObject);
|
|
|
begin
|
|
|
update_grid_view_no(dxdbgrid2);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.N14Click(Sender: TObject);
|
|
|
begin
|
|
|
|
|
|
update_grid_view_all(dxdbgrid2);
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.N16Click(Sender: TObject);
|
|
|
begin
|
|
|
grid_save_xls(dxdbgrid2);
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.bsSkinButton10Click(Sender: TObject);
|
|
|
var
|
|
|
aquery:TADOQuery;
|
|
|
str:String;
|
|
|
begin
|
|
|
|
|
|
memtblrpt_total.EmptyTable;
|
|
|
memtblDetail.EmptyTable;
|
|
|
P_SUM.EmptyTable;
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;SQL.Clear;
|
|
|
str:=' where <20><><EFBFBD><EFBFBD>=''<27><>'' ';
|
|
|
if wwDBDateTimePicker1.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+wwDBDateTimePicker1.text+'''';
|
|
|
if wwDBDateTimePicker2.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+wwDBDateTimePicker2.text+'''';
|
|
|
if wwDBDateTimePicker3.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>>='+''''+wwDBDateTimePicker3.text+'''';
|
|
|
if wwDBDateTimePicker4.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><='+''''+wwDBDateTimePicker4.text+'''';
|
|
|
|
|
|
if wwDBDateTimePicker5.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+wwDBDateTimePicker5.text+'''';
|
|
|
if wwDBDateTimePicker6.Text<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+wwDBDateTimePicker6.text+'''';
|
|
|
|
|
|
if RxDBLookupCombo3.DisplayValue<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
|
|
|
if RxDBLookupCombo2.DisplayValue<>'' then
|
|
|
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
|
|
|
if RxDBLookupCombo10.DisplayValue<>'' then
|
|
|
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
|
|
|
|
|
|
if wwDBComboBox44.Text='<27><><EFBFBD>ڿͻ<DABF>' then
|
|
|
str:=str+' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (''Լ<><D4BC>ʱ<EFBFBD><CAB1>'',''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'')) '
|
|
|
else
|
|
|
str:=str+' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (''Լ<><D4BC>ʱ<EFBFBD><CAB1>'',''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'')) ';
|
|
|
|
|
|
|
|
|
Str:='select <20><><EFBFBD><EFBFBD>,ҵ<><D2B5>״̬,<2C><><EFBFBD><EFBFBD>״̬,<2C>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,ί<>б<EFBFBD><D0B1><EFBFBD>,װ<>˷<EFBFBD>ʽ,ί<>е<EFBFBD>λ,'+
|
|
|
'<27><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,װ<><D7B0><EFBFBD><EFBFBD>,ж<><D0B6><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><>װ<EFBFBD><D7B0>,¼<><C2BC><EFBFBD><EFBFBD>, ¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'+
|
|
|
'<27><><EFBFBD><EFBFBD>Ա,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ͷ<EFBFBD>Ա,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>˾,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> as <20>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>㷽ʽ,<2C><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>,<2C><><EFBFBD><EFBFBD>,'+
|
|
|
' SUM(case ԭʼ<D4AD>ұ<EFBFBD> when ''USD'' then ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> else 0 end) as <20><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>,SUM(case ԭʼ<D4AD>ұ<EFBFBD> when ''USD'' then 0 else ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> end) as <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> '+
|
|
|
'from v_fee_do_bscard_detail '+str+
|
|
|
'Group by <20><><EFBFBD><EFBFBD>,ҵ<><D2B5>״̬,<2C><><EFBFBD><EFBFBD>״̬,<2C>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,ί<>б<EFBFBD><D0B1><EFBFBD>,װ<>˷<EFBFBD>ʽ,ί<>е<EFBFBD>λ,'+
|
|
|
'<27><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,װ<><D7B0><EFBFBD><EFBFBD>,ж<><D0B6><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>,<2C><>װ<EFBFBD><D7B0>,¼<><C2BC><EFBFBD><EFBFBD>, ¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '+
|
|
|
'<27><><EFBFBD><EFBFBD>Ա,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>ͷ<EFBFBD>Ա,<2C><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>˾,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>㷽ʽ,<2C><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>,<2C><><EFBFBD><EFBFBD> '+
|
|
|
'order by <20><><EFBFBD><EFBFBD> desc';
|
|
|
SQL.Add(str);
|
|
|
Open;
|
|
|
memtblrpt_total.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
|
|
|
Getlx;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aquery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_lx.Getlx;
|
|
|
var
|
|
|
aQuery,aQuery3:TADOQuery;
|
|
|
aStlDate:TDate;
|
|
|
|
|
|
function getstlDate(aetd:TDateTime;Cust,SaleID:String):TDate;
|
|
|
var
|
|
|
aQuery2:TADOQuery;
|
|
|
aYear,aMonth,aDay,bDay:word;
|
|
|
aStlDate:TDateTime;
|
|
|
|
|
|
begin
|
|
|
aQuery2:=CreateAdoQuery;
|
|
|
aStlDate:=aetd;
|
|
|
result:=aStlDate;
|
|
|
try
|
|
|
|
|
|
with aQuery2 do begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select * from t_crm_client_sales where <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+'''');
|
|
|
Open;
|
|
|
if IsEmpty then begin
|
|
|
Result:=aetd;
|
|
|
Exit;
|
|
|
end;
|
|
|
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then begin
|
|
|
Result:=aetd;
|
|
|
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then begin
|
|
|
result:=aStlDate+fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC>ʱ<EFBFBD><CAB1>' then begin
|
|
|
if FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString='<27>̶<EFBFBD>' then begin
|
|
|
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
|
|
|
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
|
|
|
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
|
|
|
result:=EncodeDate(aYear,aMonth,bDay)
|
|
|
else
|
|
|
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
|
|
|
end else
|
|
|
result:=IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0));
|
|
|
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽθ<D7B6><CEB8><EFBFBD>' then begin
|
|
|
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
|
|
|
if aDay>fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger then begin
|
|
|
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
|
|
|
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger>bDay then
|
|
|
result:=EncodeDate(aYear,aMonth,bDay)
|
|
|
else
|
|
|
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger);
|
|
|
end else begin
|
|
|
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
|
|
|
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
|
|
|
result:=EncodeDate(aYear,aMonth,bDay)
|
|
|
else
|
|
|
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
|
|
|
|
|
|
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
|
|
|
end;
|
|
|
|
|
|
end else begin
|
|
|
Result:=aetd;
|
|
|
end;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery2);
|
|
|
end;
|
|
|
end;
|
|
|
begin
|
|
|
|
|
|
if NOT memtblDetail.Active then
|
|
|
memtblDetail.Open;
|
|
|
if NOT p_sum.Active then
|
|
|
p_sum.Open;
|
|
|
|
|
|
if memtblrpt_total.RecordCount=0 then exit;
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
aQuery3:=CreateAdoQuery;
|
|
|
|
|
|
try
|
|
|
if not ASSIGNED(frm_sys_progress) then
|
|
|
frm_sys_progress:=tfrm_sys_progress.Create(application);
|
|
|
frm_sys_progress.Show;
|
|
|
frm_sys_progress.bsSkinGauge1.MaxValue:=memtblrpt_total.RecordCount;
|
|
|
frm_sys_progress.bsSkinGauge1.MinValue:=0;
|
|
|
frm_sys_progress.bsSkinGauge1.Value:=0;
|
|
|
frm_sys_progress.Update;
|
|
|
|
|
|
memtblrpt_total.First;
|
|
|
while not memtblrpt_total.eof do begin
|
|
|
|
|
|
aStlDate:=getstlDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString,memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
if memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>aStlDate then begin
|
|
|
memtblDetail.Insert;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>˾').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>˾').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ж<><D0B6><EFBFBD><EFBFBD>').AsString;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
memtblDetail.FieldByName('<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>').Value;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>').Value;
|
|
|
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
|
|
|
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger:=DaysBetween(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asDatetime,aStlDate);
|
|
|
memtblDetail.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').Value:=(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>').asfloat+memtblrpt_total.FieldByName('<27><>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD>').Value*(GetUsdExrate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring)))*strtofloat(Edit1.text)/100*memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger;
|
|
|
if p_sum.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,[]) then begin
|
|
|
P_sum.Edit;
|
|
|
P_sum.fieldbyname('<27><><EFBFBD><EFBFBD>Ϣ').AsFloat:=P_sum.fieldbyname('<27><><EFBFBD><EFBFBD>Ϣ').AsFloat+memtblDetail.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').Value;
|
|
|
P_sum.post;
|
|
|
end else begin
|
|
|
P_sum.insert;
|
|
|
p_sum.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
P_sum.fieldbyname('<27><><EFBFBD><EFBFBD>Ϣ').AsFloat:=P_sum.fieldbyname('<27><><EFBFBD><EFBFBD>Ϣ').AsFloat+memtblDetail.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').Value;
|
|
|
P_sum.post;
|
|
|
end;
|
|
|
memtblDetail.post;
|
|
|
end;
|
|
|
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
|
|
|
memtblrpt_total.Next;
|
|
|
end;
|
|
|
finally
|
|
|
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
|
|
|
frm_sys_progress.free;
|
|
|
frm_sys_progress:=nil;
|
|
|
FreeAndNil(aQuery);
|
|
|
FreeAndNil(aQuery3);
|
|
|
end;
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_rp_sales_profit_lx.GetBetwMonth(aBe, aEe: TDate): Integer;
|
|
|
var
|
|
|
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
|
|
|
begin
|
|
|
DecodeDate(aBe,bYear,bMonth,bDate);
|
|
|
DecodeDate(aEe,eYear,eMonth,eDate);
|
|
|
if bYear=eYear then
|
|
|
Result:=Abs(bMonth-eMonth)
|
|
|
else begin
|
|
|
if bYear>eYear then begin
|
|
|
Result:=bMonth+(12-eMonth);
|
|
|
end else begin
|
|
|
Result:=eMonth+(12-bMonth);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_rp_sales_profit_lx.issameMonth(aBe, aEe: TDate): Boolean;
|
|
|
var
|
|
|
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
|
|
|
begin
|
|
|
DecodeDate(aBe,bYear,bMonth,bDate);
|
|
|
DecodeDate(aEe,eYear,eMonth,eDate);
|
|
|
if (eMonth=bMonth) or (aBe>aEe) then
|
|
|
Result:=True
|
|
|
else result:=false;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end.
|