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.

776 lines
24 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

unit u_rp_sales_dayprofit;
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,
Grids, DBGrids;
type
Tfrm_rp_sales_dayprofit = class(TForm)
Panel1: TPanel;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet4: TbsSkinTabSheet;
bsSkinTabSheet6: TbsSkinTabSheet;
bsSkinPageControl2: TbsSkinPageControl;
bsSkinTabSheet13: TbsSkinTabSheet;
dxDBGrid7: TdxDBGrid;
dxDBGridMaskColumn93: TdxDBGridMaskColumn;
PopupMenu2: TPopupMenu;
N10: TMenuItem;
N11: TMenuItem;
N14: TMenuItem;
N13: TMenuItem;
N12: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
XPMenu2: TXPMenu;
bsSkinPanel1: TbsSkinPanel;
bsSkinPanel3: TbsSkinPanel;
dxDBGrid3: TdxDBGrid;
dxDBGridMaskColumn39: TdxDBGridMaskColumn;
dxDBGridMaskColumn42: TdxDBGridMaskColumn;
dxDBGridMaskColumn47: TdxDBGridMaskColumn;
dxDBGridDateColumn7: TdxDBGridDateColumn;
dxDBGridMaskColumn75: TdxDBGridMaskColumn;
t_salepriftset: TADOQuery;
t_salepriftset1: TDataSource;
kbmThreadDataSet1: TkbmThreadDataSet;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
memtblrpt_total: TkbmMemTable;
RxDBLookupCombo3: TRxDBLookupCombo;
Label14: TLabel;
kbmMemTable2: TkbmMemTable;
P_SUM: TkbmMemTable;
DataSource1: TDataSource;
DataSource3: TDataSource;
DataSource4: TDataSource;
dxDBGrid3Column57: TdxDBGridColumn;
dxDBGrid7Column20: TdxDBGridColumn;
dxDBGrid9: TdxDBGrid;
dxDBGridMaskColumn77: TdxDBGridMaskColumn;
dxDBGridColumn27: TdxDBGridColumn;
dxDBGridColumn28: TdxDBGridColumn;
dxDBGridColumn29: TdxDBGridColumn;
dxDBGridColumn30: TdxDBGridColumn;
dxDBGridColumn31: TdxDBGridColumn;
dxDBGridColumn32: TdxDBGridColumn;
dxDBGridColumn33: TdxDBGridColumn;
dxDBGridColumn34: TdxDBGridColumn;
dxDBGridColumn35: TdxDBGridColumn;
dxDBGridColumn36: TdxDBGridColumn;
dxDBGridColumn37: TdxDBGridColumn;
dxDBGridColumn38: TdxDBGridColumn;
dxDBGridColumn39: TdxDBGridColumn;
dxDBGridColumn40: TdxDBGridColumn;
dxDBGridColumn41: TdxDBGridColumn;
dxDBGridColumn42: TdxDBGridColumn;
dxDBGridColumn43: TdxDBGridColumn;
dxDBGridColumn44: TdxDBGridColumn;
dxDBGridColumn45: TdxDBGridColumn;
dxDBGridColumn56: TdxDBGridColumn;
dxDBGrid7Column23: TdxDBGridColumn;
P_SUMField: TStringField;
P_SUMField2: TFloatField;
P_SUMField3: TFloatField;
P_SUMField4: TFloatField;
P_SUMField5: TFloatField;
P_SUMField6: TFloatField;
P_SUMField7: TFloatField;
P_SUMField8: TFloatField;
P_SUMField9: TFloatField;
P_SUMField10: TFloatField;
P_SUMField11: TFloatField;
P_SUMField12: TFloatField;
P_SUMField13: TFloatField;
P_SUMField14: TFloatField;
P_SUMField15: TFloatField;
P_SUMField16: TFloatField;
pnl1: TPanel;
bsSkinButton10: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
RxDBLookupCombo2: TRxDBLookupCombo;
Label9: TLabel;
Label22: TLabel;
RxDBLookupCombo10: TRxDBLookupCombo;
bskntbsht2: TbsSkinTabSheet;
bsSkinPageControl3: TbsSkinPageControl;
bskntbshtpg1: TbsSkinTabSheet;
dxDBGrid2: TdxDBGrid;
dxDBGridMaskColumn32: TdxDBGridMaskColumn;
dxDBGridMaskColumn33: TdxDBGridMaskColumn;
dxDBGridMaskColumn36: TdxDBGridMaskColumn;
dxDBGridColumn10: TdxDBGridColumn;
memtblDetail: TkbmMemTable;
StringField1: TStringField;
FloatField1: TFloatField;
FloatField2: TFloatField;
FloatField3: TFloatField;
FloatField4: TFloatField;
FloatField5: TFloatField;
FloatField7: TFloatField;
FloatField8: TFloatField;
FloatField15: TFloatField;
memtblDetailField: TStringField;
memtblDetailField2: TDateTimeField;
memtblDetailField3: TStringField;
memtblDetailField4: TStringField;
memtblDetailField5: TDateTimeField;
memtblDetailField6: TStringField;
memtblDetailField7: TFloatField;
memtblDetailField8: TStringField;
memtblDetailField9: TStringField;
DataSource6: TDataSource;
DataSource7: TDataSource;
dxDBGrid2Column11: TdxDBGridColumn;
dxDBGrid2Column12: TdxDBGridColumn;
dxDBGrid2Column14: TdxDBGridColumn;
dxDBGrid2Column15: TdxDBGridColumn;
memtblDetailField10: TStringField;
memtblDetailField11: TStringField;
memtblDetailField12: TDateTimeField;
memtblDetailField13: TDateTimeField;
P_SUMField17: TFloatField;
dxDBGrid2Column18: TdxDBGridColumn;
P_SUMField18: TFloatField;
dxDBGrid7Column21: TdxDBGridColumn;
dxDBGrid3Column7: TdxDBGridColumn;
dxDBGrid3Column8: TdxDBGridColumn;
dxDBGrid3Column9: TdxDBGridColumn;
dxDBGrid3Column10: TdxDBGridColumn;
dxDBGrid3Column11: TdxDBGridColumn;
dxDBGrid3Column12: TdxDBGridColumn;
dxDBGrid3Column13: TdxDBGridColumn;
dxDBGrid3Column14: TdxDBGridColumn;
dxDBGrid3Column15: TdxDBGridColumn;
kbmMemTable2Field: TStringField;
kbmMemTable2Field2: TStringField;
kbmMemTable2Field3: TStringField;
kbmMemTable2Field4: TDateField;
kbmMemTable2Field5: TStringField;
kbmMemTable2USD: TFloatField;
kbmMemTable2RMB: TFloatField;
kbmMemTable2Field6: TFloatField;
kbmMemTable2USD2: TFloatField;
kbmMemTable2RMB2: TFloatField;
kbmMemTable2Field7: TFloatField;
kbmMemTable2USD3: TFloatField;
kbmMemTable2RMB3: TFloatField;
kbmMemTable2Field8: TFloatField;
kbmMemTable2Field9: TFloatField;
kbmMemTable2Field10: TStringField;
kbmMemTable2USD4: TFloatField;
kbmMemTable2RMB4: TFloatField;
kbmMemTable2Field11: TFloatField;
dxDBGrid3Column16: TdxDBGridColumn;
dxDBGrid3Column17: TdxDBGridColumn;
dxDBGrid3Column18: TdxDBGridColumn;
Label2: TLabel;
wwDBComboBox20: TwwDBComboBox;
Label3: TLabel;
wwDBComboBox1: TwwDBComboBox;
RxDBLookupCombo1: TRxDBLookupCombo;
Label1: TLabel;
bsSkinButton12: TbsSkinButton;
dxDBGrid7Column5: TdxDBGridColumn;
memtblDetailField14: TStringField;
memtblDetailField15: TFloatField;
memtblDetailField16: TFloatField;
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);
procedure kbmMemTable4AfterOpen(DataSet: TDataSet);
procedure kbmMemTable2AfterOpen(DataSet: TDataSet);
procedure P_SUMAfterOpen(DataSet: TDataSet);
procedure memtblrpt_totalAfterOpen(DataSet: TDataSet);
procedure kbmMemTable1AfterOpen(DataSet: TDataSet);
procedure memtblDetailAfterOpen(DataSet: TDataSet);
procedure memtblLXAfterOpen(DataSet: TDataSet);
procedure bsSkinButton12Click(Sender: TObject);
private
procedure GetProfit;
procedure Getcq;
procedure GetProfitSum;
function GetSALEprofit(SALE:string;aMonth:Integer;profit:Double):Double;
function GetBetwMonth(aBe,aEe:TDate):Integer;
function gettotalprofit(sale:string):double;
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rp_sales_dayprofit: Tfrm_rp_sales_dayprofit;
rp_rp_total_open:boolean;
implementation
uses u_main, my_sys_function, u_rp_query, u_sys_progress,
u_data_share, u_sys_sale_dayprofitset;
{$R *.dfm}
procedure Tfrm_rp_sales_dayprofit.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
function Tfrm_rp_sales_dayprofit.GetSALEprofit(SALE:string;aMonth:Integer;profit:Double):Double;
var
aQuery:TADOQuery;
BL:Double;
begin
BL:=0.00;
if profit=0 then begin
result:=0.0;
exit;
end;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select * from t_crm_salesdayproftSet where <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='+inttostr(aMonth)+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+inttostr(amonth)+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+RxDBLookupCombo1.DisplayValues[0]+''' Order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ASC');
Open;
first;
while not eof do begin
if (Profit>FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) and (Profit<=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat) then begin
Result:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat;
exit;
end;
Next;
end;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_sales_dayprofit.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
savereggrid(dxdbgrid2,caption+'2');
savereggrid(dxdbgrid3,caption+'3');
savereggrid(dxdbgrid9,caption+'9');
frm_rp_sales_dayprofit.Hide;
frm_rp_sales_dayprofit.ManualFloat(frm_rp_sales_dayprofit.BoundsRect );
frm_main.freeTabs('frm_rp_sales_dayprofit');
action:=cafree;
frm_rp_sales_dayprofit:=nil;
end;
procedure Tfrm_rp_sales_dayprofit.FormShow(Sender: TObject);
var
bYear,bMonth,bDate:Word;
begin
DecodeDate(incmonth(Now,-5),bYear,bMonth,bDate);
wwDBComboBox20.Text:=IntToStr(bYear);
wwDBComboBox1.Text:=IntToStr(bMonth);
loadreggrid(dxdbgrid2,true,caption+'2');
loadreggrid(dxdbgrid3,false,caption+'3');
loadreggrid(dxdbgrid9,false,caption+'9');
t_salepriftset.Open;
end;
procedure Tfrm_rp_sales_dayprofit.bsSkinButton9Click(Sender: TObject);
begin
sys_print('ҵ<><D2B5><EFBFBD>ۺ<EFBFBD>ͳ<EFBFBD><CDB3>',2,nil,nil,nil,DataSource4,DataSource6,DataSource7,DataSource3,nil,nil,nil,nil);
end;
procedure Tfrm_rp_sales_dayprofit.N10Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
update_grid_view_no(dxdbgrid2);
exit;
end;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid_view_no(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
update_grid_view_no(dxdbgrid7);
exit;
end;
end;
end;
procedure Tfrm_rp_sales_dayprofit.N14Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
update_grid_view_all(dxdbgrid2);
exit;
end;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid_view_all(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
update_grid_view_all(dxdbgrid7);
exit;
end;
end;
end;
procedure Tfrm_rp_sales_dayprofit.N16Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
grid_save_xls(dxdbgrid2);
exit;
end;
end;
if bsSkinTabSheet13.Showing then
begin
grid_save_xls(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
grid_save_xls(dxdbgrid7);
exit;
end;
end;
end;
procedure Tfrm_rp_sales_dayprofit.bsSkinButton10Click(Sender: TObject);
var
betd,eetd:TDate;
aquery:TADOQuery;
str:String;
begin
if RxDBLookupCombo1.DisplayValue='' then begin
showmessage('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>壡');
exit;
end;
memtblrpt_total.EmptyTable;
kbmMemTable2.EmptyTable;
memtblDetail.EmptyTable;
P_SUM.EmptyTable;
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
str:='select * from v_op_bscard where װ<>˷<EFBFBD>ʽ=''<27><><EFBFBD><EFBFBD>'' and <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=<3D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd)+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+DateToStr(eetd)+'''';
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+'''';
str:=str+' and '+open_data('0039','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no');
{
str:=str+' union select * from v_op_bscard where (װ<>˷<EFBFBD>ʽ=''ƴ<>䵥Ʊ'' or װ<>˷<EFBFBD>ʽ=''ƴ<><C6B4><EFBFBD><EFBFBD>Ʊ'') and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd)+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+DateToStr(eetd)+'''';
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+'''';
str:=str+' and '+open_data('0039','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no');
}
SQL.Add(str);
Open;
memtblrpt_total.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
Close;SQL.Clear;
str:='select * from v_op_bscard where <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6><><3E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=''2009-12-31'' ';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd-180)+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+DateToStr(eetd-180)+'''';
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+'''';
str:=str+' and '+open_data('0039','<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no');
SQL.Add(str);
Open;
kbmMemTable2.LoadFromDataSet(aQuery,[]);
end;
if (memtblrpt_total.RecordCount=0) and (kbmMemTable2.RecordCount=0) then exit;
GetProfit;
Getcq;
GetProfitSum;
finally
FreeAndNil(aquery);
end;
end;
procedure Tfrm_rp_sales_dayprofit.GetProfit;
var
aQuery,aQuery3:TADOQuery;
aStlDate:TDate;
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
btMonth,l,d:Integer;
LXBL:Double;
ED:Boolean;
begin
if memtblrpt_total.RecordCount=0 then exit;
if not P_SUM.Active then
P_SUM.Open;
if not t_salepriftset.Active then
t_salepriftset.Open;
if NOT memtblDetail.Active then
memtblDetail.Open;
l:=memtblrpt_total.RecordCount;
if l=0 then l:=100;
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:=l;
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
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0.00;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
end
else
begin
P_SUM.edit;
end;
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;
aQuery.Close;
aQuery.SQL.Clear;
aQuery.SQL.Add('select top 1 * from v_fee_do where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+''' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DESC ');
aQuery.Open;
if not aQuery.IsEmpty then begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=aQuery.fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=aQuery.fieldByName('<27>ұ<EFBFBD>').AsString+Floattostr(aQuery.fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
end;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ί<>е<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('ë<><C3AB><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.Post;
P_SUM.post;
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;
procedure Tfrm_rp_sales_dayprofit.GetProfitSum;
var
aK,YB,SB:Double;
aSBDATE:TDate;
aQuery3:TAdoQuery;
d:integer;
ED:Boolean;
begin
if (memtblrpt_total.RecordCount=0) and (kbmMemTable2.RecordCount=0) then exit;
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:=memtblDetail.RecordCount*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
P_SUM.Open;
if kbmMemTable2.Active then
if not kbmMemTable2.IsEmpty then begin
kbmMemTable2.First;
while not kbmMemTable2.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable2.Next;
end;
end;
P_SUM.First;
while not P_SUM.Eof do begin
P_SUM.Edit;
P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=gettotalprofit(P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
P_SUM.post;
P_sum.Next;
end;
if not memtblDetail.IsEmpty then begin
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
memtblDetail.Last;
while not memtblDetail.Bof do begin
if P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,[]) then begin
memtblDetail.Edit;
P_SUM.Edit;
if (memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime<memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime) then begin
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
end else begin
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString, DaysBetween(strtodate(formatdatetime('YYYY-MM-DD',memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)),strtodate(formatdatetime('YYYY-MM-DD',memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime))),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
end;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM.Post;
memtblDetail.Post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblDetail.Prior;
end;
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
end;
p_sum.First;
while not p_sum.eof do begin
P_SUM.edit;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']-P_SUM['<27><><EFBFBD><EFBFBD>Ϣ'];
P_SUM.post;
P_SUM.Next;
end;
finally
FreeAndNil(aQuery3);
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
end;
end;
function Tfrm_rp_sales_dayprofit.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;
procedure Tfrm_rp_sales_dayprofit.Getcq;
begin
end;
procedure Tfrm_rp_sales_dayprofit.kbmMemTable4AfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.kbmMemTable2AfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.P_SUMAfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.memtblrpt_totalAfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.kbmMemTable1AfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.memtblDetailAfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
procedure Tfrm_rp_sales_dayprofit.memtblLXAfterOpen(DataSet: TDataSet);
begin
AdoFormatdxDBGrid(DataSet);
end;
function Tfrm_rp_sales_dayprofit.gettotalprofit(sale: string): double;
var
betd,eetd:TDate;
aquery:TADOQuery;
str:String;
begin
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
str:='select sum(ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD> from v_op_bscard where 1=1 and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd)+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+DateToStr(eetd)+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+sale+'''';
SQL.Add(str);
Open;
if IsEmpty then begin
result:=0.00;
end else
result:=fieldbyname('ë<><C3AB><EFBFBD><EFBFBD>').asfloat;
end;
finally
FreeAndNil(aquery);
end;
end;
procedure Tfrm_rp_sales_dayprofit.bsSkinButton12Click(Sender: TObject);
begin
if not if_open('252') then
begin
showmessage('<27>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD>');
exit;
end;
try
frm_sys_sale_dayprofitset:=tfrm_sys_sale_dayprofitset.Create (self);
frm_sys_sale_dayprofitset.ShowModal;
finally
FreeAndNil(frm_sys_sale_dayprofitset);
end;
end;
end.