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.

1339 lines
50 KiB
Plaintext

11 months ago
unit u_rp_sales_profit;
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;
type
Tfrm_rp_sales_profit = class(TForm)
Panel1: TPanel;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet4: TbsSkinTabSheet;
bsSkinTabSheet6: TbsSkinTabSheet;
bsSkinPageControl2: TbsSkinPageControl;
bsSkinTabSheet11: TbsSkinTabSheet;
bsSkinTabSheet13: TbsSkinTabSheet;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column5: TdxDBGridMaskColumn;
dxDBGrid1Column3: TdxDBGridMaskColumn;
dxDBGrid1Column4: TdxDBGridMaskColumn;
dxDBGrid1Column6: TdxDBGridDateColumn;
dxDBGrid1Column7: TdxDBGridMaskColumn;
dxDBGrid1Column8: TdxDBGridMaskColumn;
dxDBGrid1Column9: TdxDBGridMaskColumn;
dxDBGrid1Column10: TdxDBGridMaskColumn;
dxDBGrid1Column11: TdxDBGridMaskColumn;
dxDBGrid1Column24: TdxDBGridMaskColumn;
dxDBGrid1Column25: TdxDBGridMaskColumn;
dxDBGrid1Column26: TdxDBGridDateColumn;
dxDBGrid1Column31: TdxDBGridMaskColumn;
dxDBGrid1Column54: TdxDBGridMaskColumn;
dxDBGrid1Column55: TdxDBGridMaskColumn;
dxDBGrid1Column56: TdxDBGridColumn;
dxDBGrid1Column57: TdxDBGridColumn;
dxDBGrid11: TdxDBGridMaskColumn;
dxDBGrid12: TdxDBGridMaskColumn;
dxDBGrid13: TdxDBGridMaskColumn;
dxDBGrid14: TdxDBGridMaskColumn;
dxDBGrid15: TdxDBGridMaskColumn;
dxDBGrid16: TdxDBGridMaskColumn;
dxDBGrid17: TdxDBGridMaskColumn;
dxDBGrid18: TdxDBGridMaskColumn;
dxDBGrid19: TdxDBGridMaskColumn;
dxDBGrid110: TdxDBGridMaskColumn;
dxDBGrid1Column80: TdxDBGridMaskColumn;
dxDBGrid1TEU: TdxDBGridMaskColumn;
dxDBGrid1Column82: TdxDBGridMaskColumn;
dxDBGrid1Column83: TdxDBGridMaskColumn;
dxDBGrid1Column84: TdxDBGridDateColumn;
dxDBGrid1Column89: TdxDBGridMaskColumn;
dxDBGrid1Column90: TdxDBGridMaskColumn;
dxDBGrid1Column92: TdxDBGridMaskColumn;
dxDBGrid1Column85: TdxDBGridMaskColumn;
dxDBGrid1Column87: TdxDBGridMaskColumn;
dxDBGrid1Column86: TdxDBGridMaskColumn;
dxDBGrid1USD: TdxDBGridColumn;
dxDBGrid1RMB: TdxDBGridColumn;
dxDBGrid1Column102: TdxDBGridColumn;
dxDBGrid1Column105: TdxDBGridColumn;
dxDBGrid1Column108: TdxDBGridColumn;
dxDBGrid1Column111: TdxDBGridColumn;
dxDBGrid1Column114: TdxDBGridColumn;
dxDBGrid1Column115: TdxDBGridColumn;
dxDBGrid1Column116: TdxDBGridColumn;
dxDBGrid1Column117: TdxDBGridMaskColumn;
dxDBGrid7: TdxDBGrid;
dxDBGridMaskColumn93: TdxDBGridMaskColumn;
dxDBGrid1Column68: TdxDBGridColumn;
dxDBGrid1Column69: TdxDBGridColumn;
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;
dxDBGridMaskColumn40: TdxDBGridMaskColumn;
dxDBGridMaskColumn41: TdxDBGridMaskColumn;
dxDBGridDateColumn6: TdxDBGridDateColumn;
dxDBGridMaskColumn42: TdxDBGridMaskColumn;
dxDBGridMaskColumn43: TdxDBGridMaskColumn;
dxDBGridMaskColumn44: TdxDBGridMaskColumn;
dxDBGridMaskColumn45: TdxDBGridMaskColumn;
dxDBGridMaskColumn46: TdxDBGridMaskColumn;
dxDBGridMaskColumn47: TdxDBGridMaskColumn;
dxDBGridMaskColumn48: TdxDBGridMaskColumn;
dxDBGridDateColumn7: TdxDBGridDateColumn;
dxDBGridDateColumn8: TdxDBGridDateColumn;
dxDBGridDateColumn9: TdxDBGridDateColumn;
dxDBGridMaskColumn49: TdxDBGridMaskColumn;
dxDBGridMaskColumn50: TdxDBGridMaskColumn;
dxDBGridMaskColumn51: TdxDBGridMaskColumn;
dxDBGridMaskColumn52: TdxDBGridMaskColumn;
dxDBGridMaskColumn53: TdxDBGridMaskColumn;
dxDBGridMaskColumn54: TdxDBGridMaskColumn;
dxDBGridColumn14: TdxDBGridColumn;
dxDBGridColumn15: TdxDBGridColumn;
dxDBGridMaskColumn55: TdxDBGridMaskColumn;
dxDBGridMaskColumn56: TdxDBGridMaskColumn;
dxDBGridMaskColumn57: TdxDBGridMaskColumn;
dxDBGridMaskColumn58: TdxDBGridMaskColumn;
dxDBGridMaskColumn59: TdxDBGridMaskColumn;
dxDBGridMaskColumn60: TdxDBGridMaskColumn;
dxDBGridMaskColumn61: TdxDBGridMaskColumn;
dxDBGridMaskColumn62: TdxDBGridMaskColumn;
dxDBGridMaskColumn63: TdxDBGridMaskColumn;
dxDBGridMaskColumn64: TdxDBGridMaskColumn;
dxDBGridMaskColumn65: TdxDBGridMaskColumn;
dxDBGridMaskColumn66: TdxDBGridMaskColumn;
dxDBGridMaskColumn67: TdxDBGridMaskColumn;
dxDBGridMaskColumn68: TdxDBGridMaskColumn;
dxDBGridDateColumn10: TdxDBGridDateColumn;
dxDBGridMaskColumn69: TdxDBGridMaskColumn;
dxDBGridMaskColumn70: TdxDBGridMaskColumn;
dxDBGridMaskColumn71: TdxDBGridMaskColumn;
dxDBGridMaskColumn72: TdxDBGridMaskColumn;
dxDBGridMaskColumn73: TdxDBGridMaskColumn;
dxDBGridMaskColumn74: TdxDBGridMaskColumn;
dxDBGridMaskColumn75: TdxDBGridMaskColumn;
dxDBGridColumn16: TdxDBGridColumn;
dxDBGridColumn17: TdxDBGridColumn;
dxDBGridColumn18: TdxDBGridColumn;
dxDBGridColumn19: TdxDBGridColumn;
dxDBGridColumn20: TdxDBGridColumn;
dxDBGridColumn21: TdxDBGridColumn;
dxDBGridColumn22: TdxDBGridColumn;
dxDBGridColumn23: TdxDBGridColumn;
dxDBGridColumn24: TdxDBGridColumn;
dxDBGridMaskColumn76: TdxDBGridMaskColumn;
dxDBGridColumn25: TdxDBGridColumn;
dxDBGridColumn26: TdxDBGridColumn;
t_salepriftset: TADOQuery;
ds1: TDataSource;
kbmThreadDataSet1: TkbmThreadDataSet;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
memtblrpt_total: TkbmMemTable;
Label2: TLabel;
wwDBComboBox20: TwwDBComboBox;
Label3: TLabel;
wwDBComboBox1: TwwDBComboBox;
RxDBLookupCombo3: TRxDBLookupCombo;
Label14: TLabel;
kbmMemTable1: TkbmMemTable;
kbmMemTable2: TkbmMemTable;
P_SUM: TkbmMemTable;
DataSource1: TDataSource;
DataSource2: TDataSource;
DataSource3: TDataSource;
DataSource4: TDataSource;
dxDBGrid1Column51: TdxDBGridColumn;
dxDBGrid1Column52: TdxDBGridColumn;
dxDBGrid1Column53: TdxDBGridColumn;
dxDBGrid1Column58: TdxDBGridColumn;
dxDBGrid1Column59: TdxDBGridColumn;
dxDBGrid1Column60: TdxDBGridColumn;
dxDBGrid1Column61: TdxDBGridColumn;
dxDBGrid3Column57: TdxDBGridColumn;
dxDBGrid7Column12: TdxDBGridColumn;
dxDBGrid7Column13: TdxDBGridColumn;
dxDBGrid7Column14: TdxDBGridColumn;
dxDBGrid7Column15: TdxDBGridColumn;
dxDBGrid7Column16: TdxDBGridColumn;
dxDBGrid7Column17: TdxDBGridColumn;
dxDBGrid7Column18: TdxDBGridColumn;
dxDBGrid7Column19: TdxDBGridColumn;
dxDBGrid7Column20: TdxDBGridColumn;
dxDBGrid1Column62: 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;
dxDBGrid3Column58: TdxDBGridColumn;
bskntbsht1: TbsSkinTabSheet;
dxDBGrid4: TdxDBGrid;
dxDBGridMaskColumn78: TdxDBGridMaskColumn;
dxDBGridMaskColumn79: TdxDBGridMaskColumn;
dxDBGridMaskColumn80: TdxDBGridMaskColumn;
dxDBGridDateColumn11: TdxDBGridDateColumn;
dxDBGridMaskColumn81: TdxDBGridMaskColumn;
dxDBGridMaskColumn82: TdxDBGridMaskColumn;
dxDBGridMaskColumn83: TdxDBGridMaskColumn;
dxDBGridMaskColumn84: TdxDBGridMaskColumn;
dxDBGridMaskColumn85: TdxDBGridMaskColumn;
dxDBGridMaskColumn86: TdxDBGridMaskColumn;
dxDBGridMaskColumn87: TdxDBGridMaskColumn;
dxDBGridDateColumn12: TdxDBGridDateColumn;
dxDBGridDateColumn13: TdxDBGridDateColumn;
dxDBGridDateColumn14: TdxDBGridDateColumn;
dxDBGridMaskColumn88: TdxDBGridMaskColumn;
dxDBGridMaskColumn89: TdxDBGridMaskColumn;
dxDBGridMaskColumn90: TdxDBGridMaskColumn;
dxDBGridMaskColumn91: TdxDBGridMaskColumn;
dxDBGridMaskColumn92: TdxDBGridMaskColumn;
dxDBGridMaskColumn94: TdxDBGridMaskColumn;
dxDBGridColumn57: TdxDBGridColumn;
dxDBGridColumn58: TdxDBGridColumn;
dxDBGridMaskColumn95: TdxDBGridMaskColumn;
dxDBGridMaskColumn96: TdxDBGridMaskColumn;
dxDBGridMaskColumn97: TdxDBGridMaskColumn;
dxDBGridMaskColumn98: TdxDBGridMaskColumn;
dxDBGridMaskColumn99: TdxDBGridMaskColumn;
dxDBGridMaskColumn100: TdxDBGridMaskColumn;
dxDBGridMaskColumn101: TdxDBGridMaskColumn;
dxDBGridMaskColumn102: TdxDBGridMaskColumn;
dxDBGridMaskColumn103: TdxDBGridMaskColumn;
dxDBGridMaskColumn104: TdxDBGridMaskColumn;
dxDBGridMaskColumn105: TdxDBGridMaskColumn;
dxDBGridMaskColumn106: TdxDBGridMaskColumn;
dxDBGridMaskColumn107: TdxDBGridMaskColumn;
dxDBGridMaskColumn108: TdxDBGridMaskColumn;
dxDBGridDateColumn15: TdxDBGridDateColumn;
dxDBGridMaskColumn109: TdxDBGridMaskColumn;
dxDBGridMaskColumn110: TdxDBGridMaskColumn;
dxDBGridMaskColumn111: TdxDBGridMaskColumn;
dxDBGridMaskColumn112: TdxDBGridMaskColumn;
dxDBGridMaskColumn113: TdxDBGridMaskColumn;
dxDBGridMaskColumn114: TdxDBGridMaskColumn;
dxDBGridMaskColumn115: TdxDBGridMaskColumn;
dxDBGridColumn59: TdxDBGridColumn;
dxDBGridColumn60: TdxDBGridColumn;
dxDBGridColumn61: TdxDBGridColumn;
dxDBGridColumn62: TdxDBGridColumn;
dxDBGridColumn63: TdxDBGridColumn;
dxDBGridColumn64: TdxDBGridColumn;
dxDBGridColumn65: TdxDBGridColumn;
dxDBGridColumn66: TdxDBGridColumn;
dxDBGridColumn67: TdxDBGridColumn;
dxDBGridMaskColumn116: TdxDBGridMaskColumn;
dxDBGridColumn68: TdxDBGridColumn;
dxDBGridColumn69: TdxDBGridColumn;
dxDBGridColumn70: TdxDBGridColumn;
dxDBGridColumn71: TdxDBGridColumn;
kbmMemTable4: TkbmMemTable;
DataSource5: TDataSource;
dxDBGrid7Column22: 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;
bskntbsht3: TbsSkinTabSheet;
dxDBGrid2: TdxDBGrid;
dxDBGridMaskColumn32: TdxDBGridMaskColumn;
dxDBGridMaskColumn33: TdxDBGridMaskColumn;
dxDBGridMaskColumn34: TdxDBGridMaskColumn;
dxDBGridMaskColumn35: TdxDBGridMaskColumn;
dxDBGridMaskColumn36: TdxDBGridMaskColumn;
dxDBGridMaskColumn37: TdxDBGridMaskColumn;
dxDBGridColumn10: TdxDBGridColumn;
dxDBGridColumn11: TdxDBGridColumn;
dxDBGridColumn47: 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;
memtblLX: TkbmMemTable;
StringField2: TStringField;
StringField3: TStringField;
DateTimeField1: TDateTimeField;
DateTimeField2: TDateTimeField;
StringField6: TStringField;
FloatField10: TFloatField;
FloatField11: TFloatField;
FloatField19: TFloatField;
memtblLXField: TIntegerField;
memtblLXField2: TFloatField;
memtblDetailField8: TStringField;
memtblDetailField9: TStringField;
memtblLXField3: TStringField;
memtblLXField4: TStringField;
DataSource6: TDataSource;
DataSource7: TDataSource;
dxDBGrid2Column11: TdxDBGridColumn;
dxDBGrid2Column12: TdxDBGridColumn;
dxDBGrid2Column13: TdxDBGridColumn;
dxDBGrid2Column14: TdxDBGridColumn;
dxDBGrid2Column15: TdxDBGridColumn;
dxDBGrid2Column16: TdxDBGridColumn;
dxDBGrid2Column17: TdxDBGridColumn;
dxDBGrid5: TdxDBGrid;
dxDBGridMaskColumn1: TdxDBGridMaskColumn;
dxDBGridMaskColumn2: TdxDBGridMaskColumn;
dxDBGridMaskColumn3: TdxDBGridMaskColumn;
dxDBGridColumn1: TdxDBGridColumn;
dxDBGridColumn2: TdxDBGridColumn;
dxDBGridColumn3: TdxDBGridColumn;
dxDBGridColumn4: TdxDBGridColumn;
dxDBGridColumn5: TdxDBGridColumn;
dxDBGridColumn6: TdxDBGridColumn;
dxDBGridColumn8: TdxDBGridColumn;
memtblDetailField10: TStringField;
memtblDetailField11: TStringField;
memtblDetailField12: TDateTimeField;
memtblDetailField13: TDateTimeField;
memtblLXField5: TFloatField;
P_SUMField17: TFloatField;
dxDBGrid2Column18: TdxDBGridColumn;
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 N12Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
private
procedure GetProfit;
procedure Getlx;
procedure GetProfitSum;
function GetSALEprofit(SALE:string;aMonth:Integer;profit:Double;tuo:boolean):Double;
function GetBetwMonth(aBe,aEe:TDate):Integer;
function issameMonth(aBe,aEe:TDate):Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
frm_rp_sales_profit: Tfrm_rp_sales_profit;
rp_rp_total_open:boolean;
implementation
uses u_main, my_sys_function, u_rp_query, u_sys_progress,
u_data_share;
{$R *.dfm}
procedure Tfrm_rp_sales_profit.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
function Tfrm_rp_sales_profit.GetSALEprofit(SALE:string;aMonth:Integer;profit:Double;tuo:boolean):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_salesproftSet where <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>='+inttostr(aMonth)+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=(select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+SALE+''') 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
if tuo then begin
BL:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat;
end else begin
if aMonth<>0 then
BL:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat
else
BL:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat;
end;
end;
Next;
end;
Result:=BL;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_sales_profit.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
savereggrid(dxdbgrid1,caption+'1');
savereggrid(dxdbgrid2,caption+'2');
savereggrid(dxdbgrid3,caption+'3');
savereggrid(dxdbgrid7,caption+'7');
savereggrid(dxdbgrid9,caption+'9');
frm_rp_sales_profit.Hide;
frm_rp_sales_profit.ManualFloat(frm_rp_sales_profit.BoundsRect );
frm_main.freeTabs('frm_rp_sales_profit');
action:=cafree;
frm_rp_sales_profit:=nil;
end;
procedure Tfrm_rp_sales_profit.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(dxdbgrid1,true,caption+'1');
loadreggrid(dxdbgrid2,true,caption+'2');
loadreggrid(dxdbgrid3,false,caption+'3');
loadreggrid(dxdbgrid4,false,caption+'4');
loadreggrid(dxdbgrid7,false,caption+'7');
loadreggrid(dxdbgrid9,false,caption+'9');
end;
procedure Tfrm_rp_sales_profit.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_profit.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;
if bskntbsht3.Showing then
begin
update_grid_view_no(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
update_grid_view_no(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid_view_no(dxdbgrid4);
exit;
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_profit.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;
if bskntbsht3.Showing then
begin
update_grid_view_all(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
update_grid_view_all(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid_view_all(dxdbgrid4);
exit;
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_profit.N12Click(Sender: TObject);
begin
{
if bsSkinTabSheet1.Showing then
begin
if bsSkinTabSheet11.Showing then
begin
update_grid(dxdbgrid1,108);
exit;
end;
if bsSkinTabSheet12.Showing then
begin
update_grid(dxdbgrid2,109);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid(dxdbgrid3,110);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid(dxdbgrid4,111);
exit;
end;
end;
if bsSkinTabSheet4.Showing then
begin
update_grid(dxdbgrid7,112);
exit;
end;
if bsSkinTabSheet6.Showing then
begin
update_grid(dxdbgrid9,95);
exit;
end;
}
end;
procedure Tfrm_rp_sales_profit.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;
if bskntbsht3.Showing then
begin
grid_save_xls(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
grid_save_xls(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
grid_save_xls(dxdbgrid4);
exit;
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;
{
if bsSkinTabSheet1.Showing then
begin
if bsSkinTabSheet11.Showing then
begin
grid_save_xls(dxdbgrid1);
exit;
end;
if bsSkinTabSheet12.Showing then
begin
grid_save_xls(dxdbgrid2);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
grid_save_xls(dxdbgrid3);
exit;
end;
if bskntbsht1.Showing then
begin
grid_save_xls(dxdbgrid4);
exit;
end;
end;
if bsSkinTabSheet4.Showing then
begin
grid_save_xls(dxdbgrid7);
exit;
end;
if bsSkinTabSheet6.Showing then
begin
grid_save_xls(dxdbgrid9);
exit;
end;
}
end;
procedure Tfrm_rp_sales_profit.bsSkinButton10Click(Sender: TObject);
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 * from v_op_bscard_MAX where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>=<3D>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> 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 ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
memtblrpt_total.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
Close;SQL.Clear;
str:='select *,<2C>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-<2D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> as <20>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD> from v_op_bscard where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><><3E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'+''''+DateToStr(incmonth(betd,-6))+'''';
str:=Str+'and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>'+''''+DateToStr(incmonth(betd,-7))+'''';
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 ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
kbmMemTable2.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
Close;SQL.Clear;
str:='select *,ë<><C3AB><EFBFBD><EFBFBD>*0.05 as <20><><EFBFBD><EFBFBD> from v_op_bscard where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><><3E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> 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 ί<>е<EFBFBD>λ in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
kbmMemTable4.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
end;
GetProfit;
Getlx;
GetProfitSum;
finally
FreeAndNil(aquery);
end;
end;
procedure Tfrm_rp_sales_profit.GetProfit;
var
aQuery:TADOQuery;
aStlDate:TDate;
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
btMonth:Integer;
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><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
Open;
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
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;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
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));
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
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;
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end;
end;
finally
FreeAndNil(aQuery2);
end;
end;
begin
if memtblrpt_total.RecordCount=0 then exit;
aQuery:=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+kbmMemTable4.RecordCount;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
if memtblDetail.Active then
memtblDetail.Close;
if P_SUM.Active then
P_SUM.Close;
{
memtblDetail.Open;
if not memtblDetail.IsEmpty then begin
memtblDetail.First;
while not memtblDetail.Eof do begin
memtblDetail.Delete;
end;
end;
P_SUM.Open;
if not P_SUM.IsEmpty then begin
P_SUM.First;
while not P_SUM.Eof do begin
P_SUM.Delete;
end;
end;
}
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;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=0;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0;
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;
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('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
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);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
if aStlDate>=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then begin
if memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then begin
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end else begin
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(aStlDate,eYear,eMonth,eDate);
if bMonth=eMonth then begin
if memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then begin
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end else begin
if memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then begin
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end;
memtblDetail.Post;
P_SUM.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblrpt_total.Next;
end;
if not kbmMemTable4.IsEmpty then begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do begin
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:='';
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
aStlDate:=getstlDate(kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString,kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.Post;
kbmMemTable4.Next;
end;
end;
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_sales_profit.GetProfitSum;
var
aK,YB,SB:Double;
begin
if not memtblrpt_total.Active then
exit;
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:=memtblLX.RecordCount+kbmMemTable2.RecordCount+kbmMemTable4.RecordCount+memtblDetail.RecordCount*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
P_SUM.Open;
if not memtblLX.IsEmpty then begin
memtblLX.First;
while not memtblLX.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
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['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0;
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>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']+memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblLX.Next;
end;
end;
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['<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;
if not kbmMemTable4.IsEmpty then begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
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['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']+kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable4.Next;
end;
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 P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat>P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat then begin
aK:=P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat-P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
if aK>memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat then begin
P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat+memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=aK;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat-aK;
P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat+aK;
end;
end else begin
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,False);
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,issameMonth(memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime));
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=YB;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*YB/100;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat*SB/100;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat-memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><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;
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
end;
end;
procedure Tfrm_rp_sales_profit.Getlx;
var
aQuery:TADOQuery;
Str:String;
betd,eetd:TDate;
LXBL:Double;
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)]);
t_salepriftset.Open;
if memtblLX.Active then
memtblLX.Close;
memtblLX.Open;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
str:='select *,(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-<2D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>)*0.01 as <20>۳<EFBFBD><DBB3><EFBFBD>Ϣ from v_op_bscard where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><><3E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> and ';
str:=Str+'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'+''''+DateToStr(eetd)+'''';
str:=Str+'and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(incmonth(betd,-6))+'''';
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 ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=RecordCount;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
if IsEmpty then exit;
first;
while not eof do begin
memtblLX.insert;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ί<>е<EFBFBD>λ').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
memtblLX.FieldByName('δ<><CEB4>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
memtblLX.FieldByName('δ<><CEB4>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').value:=IncMonth(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value,5);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=GetBetwMonth(eetd,memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').value);
if t_salepriftset.Locate('<27><><EFBFBD><EFBFBD>',Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring),[]) then
LXBL:=t_salepriftset.FieldByName('<27><>Ϣ').AsFloat
else
LXBL:=0;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=LXBL;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=(FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*LXBL/100;
memtblLX.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
Next;
end;
end;
memtblLX.SortOn('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
end;
end;
function Tfrm_rp_sales_profit.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.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.