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.

668 lines
21 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_profit_gl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DB, ADODB,DateUtils,
dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner,
kbmMemTable, kbmMemBinaryStreamFormat, Menus, StdCtrls,
wwdbdatetimepicker, Grids, DBGridEh, Mask, wwdbedit, Wwdotdot, Wwdbcomb,
RxLookup, DBGrids, bsSkinBoxCtrls, DBCtrlsEh;
type
Tfrm_rp_sales_profit_gl = class(TForm)
Panel1: TPanel;
bsSkinPanel2: TbsSkinPanel;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
kbmThreadDataSet1: TkbmThreadDataSet;
bsSkinPageControl1: TbsSkinPageControl;
DateTimePicker1: TDateTimePicker;
Label1: TLabel;
bsSkinTabSheet2: TbsSkinTabSheet;
dxDBGrid2: TdxDBGrid;
dxDBGrid2Column1: TdxDBGridColumn;
memtblItems: TkbmMemTable;
memtblItemsField: TStringField;
memtblItemsField2: TStringField;
memtblItemsField3: TStringField;
memtblItems1: TDataSource;
dxDBGrid2Column2: TdxDBGridColumn;
dxDBGrid2Column3: TdxDBGridColumn;
memtblItemsField5: TStringField;
memtblItemsField4: TFloatField;
memtblItemsField6: TIntegerField;
dxDBGrid2Column4: TdxDBGridColumn;
dxDBGrid2Column7: TdxDBGridColumn;
memtblItemsField8: TStringField;
dxDBGrid2Column8: TdxDBGridColumn;
memtblItemsField10: TStringField;
dxDBGrid2Column9: TdxDBGridColumn;
memtblItemsField12: TFloatField;
memtblItemsField13: TFloatField;
dxDBGrid2Column11: TdxDBGridColumn;
dxDBGrid2Column12: TdxDBGridColumn;
Label2: TLabel;
DBComboBoxEh1: TDBComboBoxEh;
memtblItemsField14: TFloatField;
dxDBGrid2Column15: TdxDBGridColumn;
bsSkinPanel1: TbsSkinPanel;
bsSkinButton10: TbsSkinButton;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
memtblItemsField16: TStringField;
dxDBGrid2Column17: TdxDBGridColumn;
memtblItemsOrdno: TIntegerField;
dxDBGrid2Column18: TdxDBGridColumn;
memtblItemsField17: TStringField;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
memtblItemsField7: TFloatField;
memtblItemsField9: TFloatField;
memtblItemsField11: TFloatField;
memtblItemsField15: TFloatField;
dxDBGrid2Column13: TdxDBGridColumn;
dxDBGrid2Column14: TdxDBGridColumn;
dxDBGrid2Column16: TdxDBGridColumn;
dxDBGrid2Column19: TdxDBGridColumn;
dxDBGrid2Column20: TdxDBGridColumn;
memtblItemsField18: TStringField;
memtblItemsField19: TStringField;
dxDBGrid2Column21: TdxDBGridColumn;
dxDBGrid2Column22: TdxDBGridColumn;
memtblItemsField20: TFloatField;
dxDBGrid2Column23: TdxDBGridColumn;
procedure bsSkinButton5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure bsSkinButton10Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure DBComboBoxEh1DropDown(Sender: TObject);
procedure bsSkinPanel1Resize(Sender: TObject);
procedure dxDBGrid2CustomDraw(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
AFocused: Boolean; var ADone: Boolean);
procedure dxDBGrid2DblClick(Sender: TObject);
private
NextDateBegin,NextDateEnd
,CurDateBegin,CurDateEnd
,LastDateOneBegin,LastDateOneEnd
,LastDateTwoBegin,LastDateTwoEnd:TDateTime;
procedure Creatememtbl;
function getleftstr(substr:String;leng:integer;left:boolean=true):String;
function CalcProftAmt(days:Integer;ProftAmt:Double;Employee:string;var planbegin,planend:Double):Double;
procedure GetFeeItems;
function GetProftAmt(Employee:string;AEtd:TDateTime):Double;
{ Private declarations }
public
{ Public declarations }
function GetProftRate(days:integer):Double;
end;
var
frm_rp_sales_profit_gl: Tfrm_rp_sales_profit_gl;
FmDate,ToDate:String;
sqlstr:WideString;
implementation
uses u_main, my_sys_function,u_sys_progress ;
{$R *.dfm}
function Tfrm_rp_sales_profit_gl.GetProftRate(days:integer):Double;
begin
Result:=0;
if (days>=0) and (days<=30) then
Result:=100/100
else
if (days>30) and (days<=60) then
Result:=80/100
else
if (days>60) and (days<=90) then
Result:=60/100
else
if (days>90) and (days<=120) then
Result:=40/100
else
if (days>120) and (days<=150) then
Result:=20/100
else
if Result>150 then
Result:=0;
end;
function Tfrm_rp_sales_profit_gl.GetProftAmt(Employee:string;AEtd:TDateTime):Double;
var aDate:String;
aDateTime,aCurDateBegin,aCurDateEnd:TDateTime;
y,m,d,hh,mm,ss,Endhh,Endmm,Endss,mmmm:Word;
aAdoQuery:TAdoQuery;
begin
Result:=0;
aDate:=FormatDateTime('YYYY-MM-DD',AEtd);
aDateTime:=StrToDateTime(aDate);
if DateTimePicker1.Date=null then
begin
MessageDlg('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>Ϊ<EFBFBD><CEAA>!',mtWarning,[mbOk],0);
exit;
end;
y:=0;
m:=0;
d:=0;
hh:=0;
mm:=0;
ss:=0;
Endhh:=23;
Endmm:=59;
Endss:=00;
mmmm:=0;
decodedate(incMonth(aDateTime,-1),y,m,d);
aCurDateBegin:=encodedatetime(y,m,26,hh,mm,ss,mmmm);
decodedate(aDateTime,y,m,d);
aCurDateEnd:=encodedatetime(y,m,25,Endhh,Endmm,Endss,mmmm);
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do //һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
try
Close;SQL.Clear;
SQL.Add('Select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(<28><><EFBFBD>񲻺<EFBFBD>˰ë<CBB0><C3AB><EFBFBD><EFBFBD>) ë<><C3AB><EFBFBD><EFBFBD> From v_op_bscard');
SQL.Add('Where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> between :BeginDate and :EndDate');
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=Employee;
Parameters.ParamByName('BeginDate').Value:=CurDateBegin;
Parameters.ParamByName('EndDate').Value:=CurDateEnd;
SQL.Add('Group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('Order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Open;First;
Result:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
finally
Free;
end;
end;
procedure Tfrm_rp_sales_profit_gl.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_rp_sales_profit_gl.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
savereggrid(dxdbgrid2,caption+'2');
frm_rp_sales_profit_gl.Hide;
frm_rp_sales_profit_gl.ManualFloat(frm_rp_sales_profit_gl.BoundsRect );
frm_main.freeTabs('frm_rp_sales_profit_gl');
action:=cafree;
frm_rp_sales_profit_gl:=nil;
end;
procedure Tfrm_rp_sales_profit_gl.bsSkinButton10Click(Sender: TObject);
var aDate,s:String;
aDateTime:TDateTime;
y,m,d,hh,mm,ss,Endhh,Endmm,Endss,mmmm:Word;
begin
aDate:=FormatDateTime('YYYY-MM-DD',DateTimePicker1.Date);
aDateTime:=StrToDateTime(aDate);
if DateTimePicker1.Date=null then
begin
MessageDlg('ͳ<><CDB3><EFBFBD>²<EFBFBD><C2B2><EFBFBD>Ϊ<EFBFBD><CEAA>!',mtWarning,[mbOk],0);
exit;
end;
y:=0;
m:=0;
d:=0;
hh:=0;
mm:=0;
ss:=0;
Endhh:=23;
Endmm:=59;
Endss:=00;
mmmm:=0;
if bsSkinCheckRadioBox1.Checked then
begin
decodedate(incMonth(aDateTime,1),y,m,d);
NextDateBegin:=encodedatetime(y,m,1,hh,mm,ss,mmmm);
NextDateEnd:=encodedatetime(y,m,DaysInAMonth(y,m),hh,mm,ss,mmmm);
decodedate(aDateTime,y,m,d);
CurDateBegin:=encodedatetime(y,m,1,hh,mm,ss,mmmm);
CurDateEnd:=encodedatetime(y,m,DaysInAMonth(y,m),Endhh,Endmm,Endss,mmmm);
decodedate(incMonth(aDateTime,-1),y,m,d);
LastDateOneBegin:=encodedatetime(y,m,1,hh,mm,ss,mmmm);
LastDateOneEnd:=encodedatetime(y,m,DaysInAMonth(y,m),Endhh,Endmm,Endss,mmmm);
decodedate(incMonth(aDateTime,-2),y,m,d);
LastDateTwoBegin:=encodedatetime(y,m,1,hh,mm,ss,mmmm);
LastDateTwoEnd:=encodedatetime(y,m,DaysInAMonth(y,m),Endhh,Endmm,Endss,mmmm);
end
else
begin
decodedate(aDateTime,y,m,d);
NextDateBegin:=EncodeDate(y,m,26);
decodedate(incMonth(aDateTime,1),y,m,d);
NextDateEnd:=EncodeDate(y,m,25);
decodedate(incMonth(aDateTime,-1),y,m,d);
CurDateBegin:=encodedatetime(y,m,26,hh,mm,ss,mmmm);
decodedate(aDateTime,y,m,d);
CurDateEnd:=encodedatetime(y,m,25,Endhh,Endmm,Endss,mmmm);
decodedate(incMonth(aDateTime,-2),y,m,d);
LastDateOneBegin:=encodedatetime(y,m,26,hh,mm,ss,mmmm);
decodedate(incMonth(aDateTime,-1),y,m,d);
LastDateOneEnd:=encodedatetime(y,m,25,Endhh,Endmm,Endss,mmmm);
decodedate(incMonth(aDateTime,-3),y,m,d);
LastDateTwoBegin:=EncodeDate(y,m,26);
decodedate(incMonth(aDateTime,-2),y,m,d);
LastDateTwoEnd:=EncodeDate(y,m,25);
end;
s:=datetostr(NextDateBegin)+#13#10+datetostr(NextDateEnd)+#13#10+datetostr(CurDateBegin)+datetostr(CurDateEnd)+#13#10;
s:=s+datetostr(LastDateOneBegin)+#13#10+datetostr(LastDateOneEnd)+#13#10+datetostr(LastDateTwoBegin)+#13#10+datetostr(LastDateTwoEnd);
//ShowMessage(s);
GetFeeItems;
end;
function Tfrm_rp_sales_profit_gl.CalcProftAmt(days:Integer;ProftAmt:Double;Employee:string;var planbegin,planend:Double):Double;
var aAdoQueryProfitPlan,aAdoQueryProfitPlanItem:TAdoQuery;
PlanName:string;
rate1,rate2:Double;
begin
rate1:=100;
result:=0;
PlanName:='';
aAdoQueryProfitPlan:=CreateAdoQuery;
aAdoQueryProfitPlanItem:=CreateAdoQuery;
with aAdoQueryProfitPlan do
begin
Close;SQL.Clear;
SQL.Add('select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee');
SQL.Add('Where <20><><EFBFBD><EFBFBD>=:Employee');
Parameters.ParamByName('Employee').Value:=Employee;
Open;
PlanName:=FieldByName('<27><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>').AsString;
end;
if PlanName='' then Exit;
with aAdoQueryProfitPlanItem do
try
Close;SQL.Clear;
SQL.Add(' select * from t_crm_salesproftSet');
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:PlanName');
Parameters.ParamByName('PlanName').Value:=trim(PlanName);
Open;First;
while not eof do
begin
if ProftAmt<>0 then
begin
if (ProftAmt>FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) and (ProftAmt<=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat) then
begin
result:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100*rate1/100;
planbegin:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
planend:=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat;
end
else
// result:=0;
end;
Next;
end;
finally
Free;
aAdoQueryProfitPlan.Free;
end;
end;
{
function Tfrm_rp_sales_profit_gl.CalcProftAmt(days:Integer;ProftAmt:Double;Employee:string;var planbegin,planend:Double):Double;
var aAdoQueryProfitPlan,aAdoQueryProfitPlanItem:TAdoQuery;
PlanName:string;
rate1,rate2:Double;
begin
if (days>0) and (days<=30) then
rate1:=100
else
if (days>30) and (days<=60) then
rate1:=80
else
if (days>60) and (days<=90) then
rate1:=60
else
if (days>90) and (days<=120) then
rate1:=40
else
if (days>120) and (days<=150) then
rate1:=20
else
if days>150 then
rate1:=0;
result:=0;
PlanName:='';
aAdoQueryProfitPlan:=CreateAdoQuery;
aAdoQueryProfitPlanItem:=CreateAdoQuery;
with aAdoQueryProfitPlan do
begin
Close;SQL.Clear;
SQL.Add('select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee');
SQL.Add('Where <20><><EFBFBD><EFBFBD>=:Employee');
Parameters.ParamByName('Employee').Value:=Employee;
Open;
PlanName:=FieldByName('<27><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>').AsString;
end;
if PlanName='' then Exit;
with aAdoQueryProfitPlanItem do
try
Close;SQL.Clear;
SQL.Add(' select * from t_crm_salesproftSet');
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:PlanName');
Parameters.ParamByName('PlanName').Value:=trim(PlanName);
Open;First;
while not eof do
begin
if ProftAmt<>0 then
begin
if (ProftAmt>FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) and (ProftAmt<=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat) then
begin
result:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100*rate1/100;
planbegin:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
planend:=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat;
end
else
// result:=0;
end;
Next;
end;
finally
Free;
aAdoQueryProfitPlan.Free;
end;
end;
}
procedure Tfrm_rp_sales_profit_gl.GetFeeItems;
var
aAdoQuery,aAdoQueryEmpl :TAdoQuery;
Amt,AmtTC:Double;
salses:string;
ordno:Integer;
lastplanbegin,lastplanend,planbegin,planend,lastprofit,lasttcxs,lasttc,precent:Double;
begin
memtblItems.Close;
memtblItems.Open;
memtblItems.EmptyTable;
memtblItems.IndexDefs.Clear;
memtblItems.AddIndex('Indexordno', 'ordno', []);
memtblItems.IndexName := 'Indexordno';
ordno:=1;
precent:=0;
aAdoQueryEmpl:=CreateAdoQuery;
aAdoQuery:=CreateAdoQuery;
with aAdoQuery do // 1 1
begin
Close;SQL.Clear;
SQL.Add('select v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>˰ë<CBB0><C3AB><EFBFBD><EFBFBD> ë<><C3AB><EFBFBD><EFBFBD>,');
SQL.Add('v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>,v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>,(v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>) <20>ϼ<EFBFBD>δ<EFBFBD><CEB4>,');
SQL.Add('DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) AS ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
SQL.Add('jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
SQL.Add('sum((fee.<2E><><EFBFBD><EFBFBD>-fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)*<2A><><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add('from v_op_bscard ');
SQL.Add('left join v_fee_do_max jie on v_op_bscard.<2E><><EFBFBD><EFBFBD>=jie.<2E><><EFBFBD><EFBFBD>');
SQL.Add('left join t_ch_fee fee on v_op_bscard.<2E><><EFBFBD><EFBFBD>=fee.<2E><><EFBFBD><EFBFBD> and fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>''');
SQL.Add('where v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(CurDateBegin)+'''');//
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(CurDateEnd)+'''');//
SQL.Add('group by v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
SQL.Add(',v_op_bscard.<2E><><EFBFBD><EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>˰ë<CBB0><C3AB><EFBFBD><EFBFBD>,');
SQL.Add('v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>,v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>,');
SQL.Add('DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),');
SQL.Add('jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
SQL.add('order by v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
with aAdoQueryEmpl do // 1 1
try
Close;SQL.Clear;
SQL.Add('select <20><><EFBFBD><EFBFBD> from t_sys_employee');
SQL.Add('where 1=1');
if Trim(DBComboBoxEh1.text)<>'' then
begin
SQL.Add('and <20><><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD>');
Parameters.ParamByName('<27><><EFBFBD><EFBFBD>').Value:=Trim(DBComboBoxEh1.text);
end;
if bsSkinCheckRadioBox2.Checked then
begin
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><><EFBFBD>۲<EFBFBD>''');
precent:=1;
end
else
begin
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>''<27><><EFBFBD>۲<EFBFBD>''');
precent:=0.15;
end;
SQL.Add(' and '+open_data('0021','<27><><EFBFBD><EFBFBD>','no','no','no','no','no','no'));
Open;First;
while not Eof do
begin
aAdoQuery.Close;
aAdoQuery.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD>').Value;
aAdoQuery.Open;aAdoQuery.First;
Amt:=0;
planbegin:=0;
planend:=0;
lastplanbegin:=0;
lastplanend:=0;
lasttcxs:=0;
lasttc:=0;
AmtTC:=0;
while not aAdoQuery.Eof do
begin
memtblItems.Append;
memtblItems.FieldByName('ordno').AsInteger:=ordno;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
memtblItems.FieldByName('ί<>е<EFBFBD>λ').asstring:=aAdoQuery.FieldByName('ί<>е<EFBFBD>λ').asstring;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>״̬').asstring:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD>״̬').asstring;
memtblItems.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=aAdoQuery.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
memtblItems.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=aAdoQuery.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblItems.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat:=aAdoQuery.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat;
memtblItems.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=aAdoQuery.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtblItems.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat:=aAdoQuery.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4>').AsFloat:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
if aAdoQuery.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=0 then
memtblItems.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=0
else
memtblItems.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=aAdoQuery.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
memtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
if not aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
begin
if aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat>0 then
memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat:=strtofloat(formatFloat('0.00;-0.00;0',aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*GetProftRate(memtblItems.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger)))
else memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat:=aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end
else
begin
if aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat>0 then
memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat:=0
else memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat:=aAdoQuery.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
Amt:=Amt+memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat:=Amt;
memtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=StrToFloat(formatFloat('0.00;-0.00;0',CalcProftAmt(0,memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat,memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,planbegin,planend)));
if memtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value<>0 then
begin
if planbegin>(memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').Value) then
begin
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value
:=formatFloat('0.00;-0.00;0',memtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*(memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin)*precent);
lastprofit:=memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat-memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').AsFloat; //<2F>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lasttcxs:=CalcProftAmt(0,lastprofit,memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,lastplanbegin,lastplanend);
if lasttcxs>0 then
begin
if (memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').Value-(memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin))>0 then
lasttc:=lasttcxs*(memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').Value-(memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin))*precent;
end;
if (lasttcxs>0) and (lasttc>0) then
begin
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value+strToFloat(formatFloat('0.00;-0.00;0',lasttc)));
memtblItems.FieldByName('<27><>ע').Value:='ϵ<><CFB5>:'+FloatToStr(lasttcxs)+' <20><><EFBFBD><EFBFBD>:'+formatFloat('0.00;-0.00;0',lasttc);
end;
end
else
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',memtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*memtblItems.FieldByName('<27><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>').Value*precent);
end
else
begin
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=0;
end;
AmtTC:=AmtTC+memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblItems.Post;
ordno:=ordno+1;
aAdoQuery.Next;
end;
next;
end;
{
ordno:=ordno+1;
memtblItems.Append;
memtblItems.FieldByName('ordno').AsInteger:=ordno;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:='';
memtblItems.FieldByName('ί<>е<EFBFBD>λ').Value:='<27>ϼ<EFBFBD>';
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aAdoQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').Value:='';
memtblItems.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:='';
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat:=Amt;
memtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=AmtTC;
memtblItems.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat:=0;
memtblItems.Post;
}
finally
free;
end;
end;
procedure Tfrm_rp_sales_profit_gl.Creatememtbl;
begin
end;
function Tfrm_rp_sales_profit_gl.getleftstr(substr: String; leng: integer;
left: boolean=true): String;
begin
end;
procedure Tfrm_rp_sales_profit_gl.FormShow(Sender: TObject);
begin
DateTimePicker1.Date:=Date;
loadreggrid(dxdbgrid2,false,caption+'2');
end;
procedure Tfrm_rp_sales_profit_gl.bsSkinButton1Click(Sender: TObject);
begin
grid_save_xls(dxdbgrid2);
end;
procedure Tfrm_rp_sales_profit_gl.DBComboBoxEh1DropDown(Sender: TObject);
var AdoQuery1:TAdoQuery;
begin
DBComboBoxEh1.items.clear;
AdoQuery1:=CreateAdoQuery;
with AdoQuery1 do
try
Close;sql.Clear;
SQL.Add('select * from t_sys_employee where <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><>''''');
SQL.Add('Order by <20><><EFBFBD><EFBFBD>');
Open;first;
while not Eof do
begin
DBComboBoxEh1.Items.Add(AdoQuery1.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString);
Next;
end;
finally
Free;
end;
end;
procedure Tfrm_rp_sales_profit_gl.bsSkinPanel1Resize(Sender: TObject);
var
i:integer;
begin
i:=round(bsSkinPanel1.Width/4);
bsSkinButton1.Width:=i;
bsSkinButton2.Width:=i;
bsSkinButton10.Width:=i;
// bsSkinButton3.Width:=i;
// bsSkinButton13.Left:=Panel2.Width-bsSkinButton13.Width-20;
// bsSkinButton15.left:=bsSkinButton13.Left-75;
end;
procedure Tfrm_rp_sales_profit_gl.dxDBGrid2CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
if StrToFloat( ANode.Strings[dxDBGrid2Column19.Index])<>0 then
begin
AFont.Color:=clBlack;
AColor:=$0080FF00;
exit;
end;
end;
procedure Tfrm_rp_sales_profit_gl.dxDBGrid2DblClick(Sender: TObject);
begin
fee_view(memtblItems.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring);
end;
end.