|
|
|
|
unit u_rp_sales_profit_two;
|
|
|
|
|
|
|
|
|
|
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,inifiles, CheckLst;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
TSalesTc = Record
|
|
|
|
|
bsNo //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
,shippers //ί<>е<EFBFBD>λ
|
|
|
|
|
,sales //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
,mblno //<2F><><EFBFBD>ᵥ<EFBFBD><E1B5A5>
|
|
|
|
|
,bstype //ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
,FeeStaus //<2F><><EFBFBD><EFBFBD>״̬
|
|
|
|
|
,EtdYearMonth //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
,CorpStlType //<2F>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
:string;
|
|
|
|
|
Etd //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
,StlDate:TDateTime; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
AmtRmb //RMB<4D>ϼ<EFBFBD>
|
|
|
|
|
,AmtUsd // USD<53>ϼ<EFBFBD>
|
|
|
|
|
,ProfitAmt
|
|
|
|
|
,TtlProfitAmt
|
|
|
|
|
:Double; //ë<><C3AB><EFBFBD><EFBFBD>
|
|
|
|
|
ACTCQDays, //ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CQDays, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
xyDays //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
:integer;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tfrm_rp_sales_profit_two = class(TForm)
|
|
|
|
|
kbmThreadDataSet1: TkbmThreadDataSet;
|
|
|
|
|
Panel2: TPanel;
|
|
|
|
|
Label2: TLabel;
|
|
|
|
|
Label3: TLabel;
|
|
|
|
|
Label1: TLabel;
|
|
|
|
|
Label4: TLabel;
|
|
|
|
|
Label5: TLabel;
|
|
|
|
|
Label6: TLabel;
|
|
|
|
|
bsSkinEdit1: TbsSkinEdit;
|
|
|
|
|
wwDBComboBox1: TwwDBComboBox;
|
|
|
|
|
wwDBComboBox20: TwwDBComboBox;
|
|
|
|
|
wwDBComboBox2: TwwDBComboBox;
|
|
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
|
|
CheckListBox1: TCheckListBox;
|
|
|
|
|
bsSkinButton9: TbsSkinButton;
|
|
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
|
|
dxDBGrid8: TdxDBGrid;
|
|
|
|
|
dxDBGrid8Column7: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn4: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid8Column6: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid8Column4: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid8Column5: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn7: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn9: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid8Column8: TdxDBGridColumn;
|
|
|
|
|
bsSkinPanel2: TbsSkinPanel;
|
|
|
|
|
Label7: TLabel;
|
|
|
|
|
Label8: TLabel;
|
|
|
|
|
Label9: TLabel;
|
|
|
|
|
Label10: TLabel;
|
|
|
|
|
wwDBDateTimePicker1: TwwDBDateTimePicker;
|
|
|
|
|
wwDBDateTimePicker2: TwwDBDateTimePicker;
|
|
|
|
|
bsSkinButton3: TbsSkinButton;
|
|
|
|
|
Edit1: TEdit;
|
|
|
|
|
tex: TbsSkinButton;
|
|
|
|
|
Edit2: TEdit;
|
|
|
|
|
dxDBGrid6: TdxDBGrid;
|
|
|
|
|
dxDBGrid6Column19: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column1: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column2: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column3: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column4: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column5: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column6: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column7: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column10: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column8: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column11: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column12: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column17: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid6Column18: TdxDBGridColumn;
|
|
|
|
|
kbmqc: TkbmMemTable;
|
|
|
|
|
kbmqcField4: TStringField;
|
|
|
|
|
kbmqcField: TStringField;
|
|
|
|
|
kbmqcField2: TStringField;
|
|
|
|
|
kbmqcField3: TStringField;
|
|
|
|
|
kbmqcField5: TDateField;
|
|
|
|
|
kbmqcField6: TDateField;
|
|
|
|
|
kbmqcField7: TFloatField;
|
|
|
|
|
kbmqcField8: TFloatField;
|
|
|
|
|
kbmqcField9: TStringField;
|
|
|
|
|
kbmqcField11: TIntegerField;
|
|
|
|
|
kbmqcField10: TIntegerField;
|
|
|
|
|
kbmqcField12: TFloatField;
|
|
|
|
|
kbmqcField13: TStringField;
|
|
|
|
|
kbmqcUSD: TFloatField;
|
|
|
|
|
kbmqcRMB: TFloatField;
|
|
|
|
|
kbmqcField14: TDateField;
|
|
|
|
|
kbmqcRMB2: TFloatField;
|
|
|
|
|
kbmqcUSD2: TFloatField;
|
|
|
|
|
kbmqcField15: TFloatField;
|
|
|
|
|
kbmqcField16: TStringField;
|
|
|
|
|
kbmqc1: TDataSource;
|
|
|
|
|
kbmtc: TkbmMemTable;
|
|
|
|
|
kbmtcField: TStringField;
|
|
|
|
|
kbmtcField2: TFloatField;
|
|
|
|
|
kbmtcField3: TFloatField;
|
|
|
|
|
kbmtcUSD: TFloatField;
|
|
|
|
|
kbmtcRMB: TFloatField;
|
|
|
|
|
kbmtcField4: TFloatField;
|
|
|
|
|
kbmtcField5: TStringField;
|
|
|
|
|
kbmtcField6: TFloatField;
|
|
|
|
|
kbmtc1: TDataSource;
|
|
|
|
|
RxDBLookupCombo3: TRxDBLookupCombo;
|
|
|
|
|
kbmtcField7: TFloatField;
|
|
|
|
|
dxDBGrid8Column9: TdxDBGridColumn;
|
|
|
|
|
kbmqcField17: TStringField;
|
|
|
|
|
ComboBox1: TComboBox;
|
|
|
|
|
Label11: TLabel;
|
|
|
|
|
PopupMenu1: TPopupMenu;
|
|
|
|
|
MenuItem7: TMenuItem;
|
|
|
|
|
kbmtcOrdno: TIntegerField;
|
|
|
|
|
PopupMenu2: TPopupMenu;
|
|
|
|
|
N1: TMenuItem;
|
|
|
|
|
N2: TMenuItem;
|
|
|
|
|
N3: TMenuItem;
|
|
|
|
|
kbmtcField8: TStringField;
|
|
|
|
|
dxDBGrid8Column10: TdxDBGridColumn;
|
|
|
|
|
kbmtcField9: TFloatField;
|
|
|
|
|
dxDBGrid8Column11: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid8Column12: TdxDBGridColumn;
|
|
|
|
|
kbmtcField10: TFloatField;
|
|
|
|
|
Label12: TLabel;
|
|
|
|
|
ComboBox2: TComboBox;
|
|
|
|
|
Label13: TLabel;
|
|
|
|
|
ComboBox3: TComboBox;
|
|
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton10Click(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton3Click(Sender: TObject);
|
|
|
|
|
procedure texClick(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton9Click(Sender: TObject);
|
|
|
|
|
procedure MenuItem7Click(Sender: TObject);
|
|
|
|
|
procedure N1Click(Sender: TObject);
|
|
|
|
|
procedure N3Click(Sender: TObject);
|
|
|
|
|
procedure dxDBGrid6CustomDraw(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 dxDBGrid8CustomDraw(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 kbmtcBeforePost(DataSet: TDataSet);
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ Private declarations }
|
|
|
|
|
public
|
|
|
|
|
{ Public declarations }
|
|
|
|
|
ordno:Integer;
|
|
|
|
|
procedure GetProfittcLx(depts:string;beginEtd,EndEtd:TDateTime);
|
|
|
|
|
function CalcProftAmttc(ProftAmt:Double;Employee:string):Double;
|
|
|
|
|
function getzq(cust: string;aDate:TDateTime):TDateTime;
|
|
|
|
|
function getzqtype(cust: string;aDate:TDateTime):string;
|
|
|
|
|
function CalcProftAmtqx(ProftAmt:Double;Employee:string):Double;
|
|
|
|
|
procedure UpdateBsProfit(bstype,bsno:String;fee:integer);
|
|
|
|
|
procedure UpdateBsProfitLc(bstype,bsno,LcYYMM:String);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
frm_rp_sales_profit_two: Tfrm_rp_sales_profit_two;
|
|
|
|
|
FmDate,ToDate:String;
|
|
|
|
|
sqlstr:WideString;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses u_main, my_sys_function,u_sys_progress;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.bsSkinButton5Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
close;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.FormClose(Sender: TObject;
|
|
|
|
|
var Action: TCloseAction);
|
|
|
|
|
var inifile1:Tinifile;
|
|
|
|
|
begin
|
|
|
|
|
savereggrid(dxdbgrid6,caption+'6');
|
|
|
|
|
savereggrid(dxdbgrid8,caption+'8');
|
|
|
|
|
frm_rp_sales_profit_two.Hide;
|
|
|
|
|
frm_rp_sales_profit_two.ManualFloat(frm_rp_sales_profit_two.BoundsRect );
|
|
|
|
|
frm_main.freeTabs('frm_rp_sales_profit_two');
|
|
|
|
|
action:=cafree;
|
|
|
|
|
frm_rp_sales_profit_two:=nil;
|
|
|
|
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
|
|
inifile1.WriteString('TC','DAYS',bsSkinEdit1.text);
|
|
|
|
|
inifile1.free;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.FormShow(Sender: TObject);
|
|
|
|
|
var
|
|
|
|
|
bYear,bMonth,bDate:Word;
|
|
|
|
|
inifile1:Tinifile;
|
|
|
|
|
aAdoQuery:TAdoQuery;
|
|
|
|
|
begin
|
|
|
|
|
loadreggrid(dxdbgrid6,false,caption+'6');
|
|
|
|
|
loadreggrid(dxdbgrid8,false,caption+'8');
|
|
|
|
|
DecodeDate(incmonth(Now),bYear,bMonth,bDate);
|
|
|
|
|
wwDBComboBox20.Text:=IntToStr(bYear);
|
|
|
|
|
wwDBComboBox20.Text:=IntToStr(YearOf(date));
|
|
|
|
|
wwDBComboBox1.Text:=IntToStr(bMonth);
|
|
|
|
|
wwDBComboBox2.Text:=IntToStr(bMonth);
|
|
|
|
|
|
|
|
|
|
aAdoQuery:=CreateAdoQuery;
|
|
|
|
|
with aAdoQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_sys_department ');
|
|
|
|
|
SQL.Add('order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
Open;first;
|
|
|
|
|
CheckListBox1.Clear;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
CheckListBox1.Items.Add(trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
|
|
|
|
|
next;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
aAdoQuery.Free;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
|
|
bsSkinEdit1.text:=inifile1.Readstring('TC','DAYS','0');
|
|
|
|
|
inifile1.free;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_two.CalcProftAmttc(ProftAmt:Double;Employee:string):Double;
|
|
|
|
|
var aAdoQueryProfitPlan,aAdoQueryProfitPlanItem:TAdoQuery;
|
|
|
|
|
PlanName:string;
|
|
|
|
|
begin
|
|
|
|
|
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 distinct <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ֹ,<2C><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD> from t_crm_salesproftSet');
|
|
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:PlanName');
|
|
|
|
|
SQL.Add('Order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
Parameters.ParamByName('PlanName').Value:=trim(PlanName);
|
|
|
|
|
Open;First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
if ProftAmt>=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat then
|
|
|
|
|
begin
|
|
|
|
|
result:=result+(FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if (ProftAmt>FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) and (ProftAmt<=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat) then
|
|
|
|
|
begin
|
|
|
|
|
result:=result+(ProftAmt-FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat)*FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
|
|
|
|
|
end
|
|
|
|
|
end;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
Free;
|
|
|
|
|
aAdoQueryProfitPlan.Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.GetProfittcLx(depts:string;beginEtd,EndEtd:TDateTime);
|
|
|
|
|
var
|
|
|
|
|
betd,eetd:TDate;
|
|
|
|
|
aquery,bquery:TADOQuery;
|
|
|
|
|
str,bdatestr:String;
|
|
|
|
|
begin
|
|
|
|
|
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
betd:=beginEtd;
|
|
|
|
|
eetd:=EndEtd;
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
bQuery:=CreateAdoQuery;
|
|
|
|
|
|
|
|
|
|
with bQuery do
|
|
|
|
|
begin
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('select distinct Fee2 from v_op_bscard');
|
|
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> between :beginEtd and :EndEtd');
|
|
|
|
|
SQL.Add(' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
str:='select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>- <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>) δ<>պϼ<D5BA>,sum(ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,sum(<28><><EFBFBD><EFBFBD>RMB) as <20><><EFBFBD><EFBFBD>RMB,sum(<28><><EFBFBD><EFBFBD>USD) as <20><><EFBFBD><EFBFBD>USD from v_op_bscard where 1=1 and ';
|
|
|
|
|
str:=Str+' '+bdatestr+'>='+''''+DateToStr(betd)+'''';
|
|
|
|
|
str:=Str+' and '+bdatestr+'<='+''''+DateToStr(eetd)+'''';
|
|
|
|
|
|
|
|
|
|
if RxDBLookupCombo3.DisplayValue<>'' then
|
|
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
|
|
|
|
|
|
|
|
|
|
if if_open('405') then
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+employee+'''';
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if depts<>'' then
|
|
|
|
|
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD> in ('+depts+')';
|
|
|
|
|
|
|
|
|
|
SQL.Add(str);
|
|
|
|
|
SQL.Add(' group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
{
|
|
|
|
|
case ComboBox3.itemindex of
|
|
|
|
|
0:;
|
|
|
|
|
1:begin
|
|
|
|
|
SQL.Add(' having (sum(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>- <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>)=0) or (sum(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>- <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>) is null)');
|
|
|
|
|
end;
|
|
|
|
|
2:begin
|
|
|
|
|
SQL.Add(' having sum(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>- <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>)<>0');
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SQL.Add(' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
|
|
|
|
|
Open;First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
case ComboBox3.itemindex of
|
|
|
|
|
0:
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.insert;
|
|
|
|
|
kbmtc.FieldByName('OrdNo').AsInteger:=OrdNo;
|
|
|
|
|
bQuery.Close;
|
|
|
|
|
bQuery.Parameters.ParamByName('beginEtd').Value:=betd;
|
|
|
|
|
bQuery.Parameters.ParamByName('EndEtd').Value:=eetd;
|
|
|
|
|
bQuery.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
bQuery.Open;bQuery.first;
|
|
|
|
|
if bQuery.RecordCount>1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else
|
|
|
|
|
if bQuery.RecordCount=1 then
|
|
|
|
|
begin
|
|
|
|
|
if bQuery.FieldByName('Fee2').AsInteger=1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
end
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('δ<>պϼ<D5BA>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=getUsdExRate(DateToStr(betd),'USD');
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYMM',betd);
|
|
|
|
|
kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsString:=FormatFloat('0;-0;0',CalcProftAmttc(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
|
|
|
|
|
kbmtc.FieldByName('˰<><CBB0>').AsString:=FormatFloat('0;-0;0',kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsFloat*0.08);
|
|
|
|
|
case ComboBox2.itemindex of
|
|
|
|
|
0:
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
end;
|
|
|
|
|
1:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
2:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
1:begin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if FieldByName('δ<>պϼ<D5BA>').AsFloat=0 then
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.insert;
|
|
|
|
|
kbmtc.FieldByName('OrdNo').AsInteger:=OrdNo;
|
|
|
|
|
bQuery.Close;
|
|
|
|
|
bQuery.Parameters.ParamByName('beginEtd').Value:=betd;
|
|
|
|
|
bQuery.Parameters.ParamByName('EndEtd').Value:=eetd;
|
|
|
|
|
bQuery.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
bQuery.Open;bQuery.first;
|
|
|
|
|
if bQuery.RecordCount>1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else
|
|
|
|
|
if bQuery.RecordCount=1 then
|
|
|
|
|
begin
|
|
|
|
|
if bQuery.FieldByName('Fee2').AsInteger=1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
end
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('δ<>պϼ<D5BA>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=getUsdExRate(DateToStr(betd),'USD');
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYMM',betd);
|
|
|
|
|
kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsString:=FormatFloat('0;-0;0',CalcProftAmttc(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
|
|
|
|
|
kbmtc.FieldByName('˰<><CBB0>').AsString:=FormatFloat('0;-0;0',kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsFloat*0.08);
|
|
|
|
|
case ComboBox2.itemindex of
|
|
|
|
|
0:
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
end;
|
|
|
|
|
1:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
2:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2:begin
|
|
|
|
|
if FieldByName('δ<>պϼ<D5BA>').AsFloat<>0 then
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.insert;
|
|
|
|
|
kbmtc.FieldByName('OrdNo').AsInteger:=OrdNo;
|
|
|
|
|
bQuery.Close;
|
|
|
|
|
bQuery.Parameters.ParamByName('beginEtd').Value:=betd;
|
|
|
|
|
bQuery.Parameters.ParamByName('EndEtd').Value:=eetd;
|
|
|
|
|
bQuery.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
bQuery.Open;bQuery.first;
|
|
|
|
|
if bQuery.RecordCount>1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else
|
|
|
|
|
if bQuery.RecordCount=1 then
|
|
|
|
|
begin
|
|
|
|
|
if bQuery.FieldByName('Fee2').AsInteger=1 then
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>'
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
end
|
|
|
|
|
else kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('δ<>պϼ<D5BA>').AsFloat;
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat:=getUsdExRate(DateToStr(betd),'USD');
|
|
|
|
|
kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYMM',betd);
|
|
|
|
|
kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsString:=FormatFloat('0;-0;0',CalcProftAmttc(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
|
|
|
|
|
kbmtc.FieldByName('˰<><CBB0>').AsString:=FormatFloat('0;-0;0',kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsFloat*0.08);
|
|
|
|
|
case ComboBox2.itemindex of
|
|
|
|
|
0:
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
end;
|
|
|
|
|
1:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
2:
|
|
|
|
|
begin
|
|
|
|
|
if kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString='<27><>' then
|
|
|
|
|
kbmtc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmtc.Delete;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrdNo:=OrdNo+1;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aquery);
|
|
|
|
|
FreeAndNil(bquery);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.bsSkinButton10Click(Sender: TObject);
|
|
|
|
|
var i,j :integer;
|
|
|
|
|
depts:string;
|
|
|
|
|
betd,eetd:TDate;
|
|
|
|
|
begin
|
|
|
|
|
ordno:=1;
|
|
|
|
|
for i:=0 to CheckListBox1.Items.Count-1 do
|
|
|
|
|
begin
|
|
|
|
|
if CheckListBox1.Checked[i] then
|
|
|
|
|
if depts='' then
|
|
|
|
|
depts:=''''+CheckListBox1.Items[i]+''''
|
|
|
|
|
else depts:=depts+','+''''+CheckListBox1.Items[i]+'''';
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
kbmtc.EmptyTable;
|
|
|
|
|
kbmtc.Open;
|
|
|
|
|
for j:=StrToInt(wwDBComboBox1.Text) to StrToInt(wwDBComboBox2.Text) do
|
|
|
|
|
begin
|
|
|
|
|
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), j, 1);
|
|
|
|
|
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), j, MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),j]);
|
|
|
|
|
GetProfittcLx(depts,betd,eetd);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_two.getzq(cust: string;aDate:TDateTime):TDateTime;
|
|
|
|
|
var
|
|
|
|
|
aQuery:TAdoQuery;
|
|
|
|
|
begin
|
|
|
|
|
result:=0;
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
try
|
|
|
|
|
with aQuery do
|
|
|
|
|
begin
|
|
|
|
|
close;sql.Clear;
|
|
|
|
|
sql.Add('select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ģʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>');
|
|
|
|
|
sql.Add('from t_crm_client_sales');
|
|
|
|
|
sql.Add('where <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+cust+'''');
|
|
|
|
|
sql.Add('and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><=:Date1 and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:date2');
|
|
|
|
|
Parameters.ParamByName('Date1').Value:=aDate;
|
|
|
|
|
Parameters.ParamByName('Date2').Value:=aDate;
|
|
|
|
|
open;First;
|
|
|
|
|
if IsEmpty then
|
|
|
|
|
begin
|
|
|
|
|
result:=aDate;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if Trim(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asString)='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then
|
|
|
|
|
result:=aDate
|
|
|
|
|
else
|
|
|
|
|
if Trim(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asString)='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then
|
|
|
|
|
result:=aDate+fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat
|
|
|
|
|
else
|
|
|
|
|
if Trim(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asString)='Լ<><D4BC>ʱ<EFBFBD><CAB1>' then
|
|
|
|
|
begin
|
|
|
|
|
if DaysInMonth(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger))>fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger then
|
|
|
|
|
begin
|
|
|
|
|
result:=EncodeDate(Yearof(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger)),Monthof(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger)),fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Asinteger);
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
result:=EncodeDate(Yearof(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger)),Monthof(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger)),DaysInMonth(IncMonth(aDate,fieldbyname('<27><><EFBFBD><EFBFBD>ģʽ').Asinteger)));
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aQuery);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_two.getzqtype(cust: string;aDate:TDateTime):string;
|
|
|
|
|
var
|
|
|
|
|
aQuery:TAdoQuery;
|
|
|
|
|
begin
|
|
|
|
|
result:='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
try
|
|
|
|
|
with aQuery do
|
|
|
|
|
begin
|
|
|
|
|
close;sql.Clear;
|
|
|
|
|
sql.Add('select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ģʽ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ѽ<EFBFBD><D1BD><EFBFBD>');
|
|
|
|
|
sql.Add('from t_crm_client_sales');
|
|
|
|
|
sql.Add('where <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+cust+'''');
|
|
|
|
|
sql.Add('and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><=:Date1 and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=:date2');
|
|
|
|
|
Parameters.ParamByName('Date1').Value:=aDate;
|
|
|
|
|
Parameters.ParamByName('Date2').Value:=aDate;
|
|
|
|
|
open;First;
|
|
|
|
|
if IsEmpty then
|
|
|
|
|
begin
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
result:=Trim(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asString);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aQuery);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_two.CalcProftAmtqx(ProftAmt:Double;Employee:string):Double;
|
|
|
|
|
var aAdoQueryProfitPlan,aAdoQueryProfitPlanItem:TAdoQuery;
|
|
|
|
|
PlanName:string;
|
|
|
|
|
begin
|
|
|
|
|
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 distinct <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>Ϣ<EFBFBD>ٷֱ<D9B7> from t_crm_saleslxSet');
|
|
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:PlanName');
|
|
|
|
|
SQL.Add('Order by <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> ');
|
|
|
|
|
Parameters.ParamByName('PlanName').Value:=trim(PlanName);
|
|
|
|
|
Open;First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
if ProftAmt>0 then
|
|
|
|
|
if (ProftAmt>FieldByName('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').AsFloat) and (ProftAmt<=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) then
|
|
|
|
|
begin
|
|
|
|
|
result:=FieldByName('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').AsFloat;
|
|
|
|
|
end;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
Free;
|
|
|
|
|
aAdoQueryProfitPlan.Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.UpdateBsProfit(bstype,bsno:String;fee:integer);
|
|
|
|
|
var
|
|
|
|
|
aQuery:TADOQuery;
|
|
|
|
|
tblname:string;
|
|
|
|
|
begin
|
|
|
|
|
tblname:='';
|
|
|
|
|
if bstype='<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>' then tblname:='t_op_seae'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>' then tblname:='t_op_seai'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>' then tblname:='t_op_aire'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>' then tblname:='t_op_airi';
|
|
|
|
|
if tblname='' then exit;
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('update '+tblname +' set Fee2=:fee');
|
|
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD>=:bsno');
|
|
|
|
|
Parameters.ParamByName('bsno').Value:=bsno;
|
|
|
|
|
Parameters.ParamByName('fee').Value:=fee;
|
|
|
|
|
Execsql;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aQuery);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.UpdateBsProfitLc(bstype,bsno,LcYYMM:String);
|
|
|
|
|
var
|
|
|
|
|
aQuery:TADOQuery;
|
|
|
|
|
tblname:string;
|
|
|
|
|
begin
|
|
|
|
|
tblname:='';
|
|
|
|
|
if bstype='<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>' then tblname:='t_op_seae'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>' then tblname:='t_op_seai'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>' then tblname:='t_op_aire'
|
|
|
|
|
else if bstype='<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>' then tblname:='t_op_airi';
|
|
|
|
|
if tblname='' then exit;
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('update '+tblname +' set <20><>Ʊ<EFBFBD><C6B1>=:<3A><>Ʊ<EFBFBD><C6B1>');
|
|
|
|
|
SQL.Add('where <20><><EFBFBD><EFBFBD>=:bsno');
|
|
|
|
|
Parameters.ParamByName('bsno').Value:=bsno;
|
|
|
|
|
Parameters.ParamByName('<27><>Ʊ<EFBFBD><C6B1>').Value:=LcYYMM;
|
|
|
|
|
Execsql;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aQuery);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.bsSkinButton3Click(Sender: TObject);
|
|
|
|
|
var
|
|
|
|
|
betd,eetd:TDate;
|
|
|
|
|
aquery,bquery:TADOQuery;
|
|
|
|
|
str,bdatestr:String;
|
|
|
|
|
begin
|
|
|
|
|
if Trim(Edit1.Text)<>'' then
|
|
|
|
|
begin
|
|
|
|
|
ComboBox1.ItemIndex:=2;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if not kbmtc.IsEmpty then
|
|
|
|
|
with kbmtc do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not Eof do
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.Edit;
|
|
|
|
|
kbmtc.FieldByName('<27><>Ϣ').AsFloat:=0;
|
|
|
|
|
kbmtc.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=0;
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
bQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
str:='select <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,<2C><>Ʊ<EFBFBD><C6B1>,ί<>б<EFBFBD><D0B1><EFBFBD>,ί<>е<EFBFBD>λ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,(Ӧ<><D3A6>RMB-<2D><><EFBFBD><EFBFBD>RMB) δ<><CEB4>RMB,(Ӧ<><D3A6>USD- <20><><EFBFBD><EFBFBD>USD) δ<><CEB4>USD,(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>- <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>) δ<>պϼ<D5BA>,Ӧ<><D3A6>RMB,Ӧ<><D3A6>USD,<2C>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> Ӧ<>պϼ<D5BA> from v_op_bscard where 1=1 and ';
|
|
|
|
|
if (wwDBDateTimePicker1.text<>'') and (wwDBDateTimePicker2.text<>'') then
|
|
|
|
|
begin
|
|
|
|
|
str:=Str+' '+bdatestr+'>='+''''+DateToStr(wwDBDateTimePicker1.Date)+'''';
|
|
|
|
|
str:=Str+' and '+bdatestr+'<='+''''+DateToStr(wwDBDateTimePicker2.Date)+'''';
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
str:=Str+' 1=1';
|
|
|
|
|
end;
|
|
|
|
|
{
|
|
|
|
|
if Edit1.text<>'' then
|
|
|
|
|
str:=Str+' and <20><>Ʊ<EFBFBD><C6B1>='+''''+Edit1.text+'''';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if if_open('405') then
|
|
|
|
|
begin
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+employee+'''';
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
SQL.Add(str);
|
|
|
|
|
SQL.Add(' and ί<>е<EFBFBD>λ in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>''<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>'')');
|
|
|
|
|
case ComboBox1.ItemIndex of
|
|
|
|
|
0:begin //ȫ<><C8AB>
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
1:begin //δ<><CEB4><EFBFBD><EFBFBD>
|
|
|
|
|
SQL.Add(' and (<28><>Ʊ<EFBFBD><C6B1> is Null or <20><>Ʊ<EFBFBD><C6B1>='''')');
|
|
|
|
|
end;
|
|
|
|
|
2:begin //<2F>ѽ<EFBFBD><D1BD><EFBFBD>
|
|
|
|
|
if trim(Edit1.text)<>'' then
|
|
|
|
|
SQL.Add(' and <20><>Ʊ<EFBFBD><C6B1>='+''''+Edit1.text+'''')
|
|
|
|
|
else
|
|
|
|
|
SQL.Add(' and (not <20><>Ʊ<EFBFBD><C6B1> is Null and <20><>Ʊ<EFBFBD><C6B1><>'''')');
|
|
|
|
|
end;
|
|
|
|
|
3:begin //δ<>տ<EFBFBD>
|
|
|
|
|
SQL.Add(' and (<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-<2D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>)<>0');
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
SQL.Add(' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
Open;First;
|
|
|
|
|
//ShowMessage(SQL.Text);
|
|
|
|
|
|
|
|
|
|
kbmqc.EmptyTable;
|
|
|
|
|
kbmqc.Open;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
kbmqc.insert;
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmqc.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2>').AsString:=FieldByName('<27><>Ʊ<EFBFBD><C6B1>').AsString;
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
|
|
kbmqc.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
|
|
|
|
|
kbmqc.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('ί<>е<EFBFBD>λ').AsString;
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime;
|
|
|
|
|
kbmqc.FieldByName('δ<><CEB4>RMB').AsFloat:=FieldByName('δ<><CEB4>RMB').AsFloat;
|
|
|
|
|
kbmqc.FieldByName('δ<><CEB4>USD').AsFloat:=FieldByName('δ<><CEB4>USD').AsFloat;
|
|
|
|
|
kbmqc.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('δ<>պϼ<D5BA>').AsFloat;
|
|
|
|
|
|
|
|
|
|
kbmqc.FieldByName('Ӧ<><D3A6>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat;
|
|
|
|
|
kbmqc.FieldByName('Ӧ<><D3A6>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat;
|
|
|
|
|
kbmqc.FieldByName('Ӧ<>պϼ<D5BA>').AsFloat:=FieldByName('Ӧ<>պϼ<D5BA>').AsFloat;
|
|
|
|
|
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ').AsFloat:=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=getzq(kbmqc.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString,kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bQuery.Close;
|
|
|
|
|
bQuery.SQL.Clear;
|
|
|
|
|
bQuery.SQL.Add('select top 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from v_fee_do_jie where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+kbmqc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+''' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DESC ');
|
|
|
|
|
bQuery.Open;
|
|
|
|
|
if not bQuery.IsEmpty then
|
|
|
|
|
begin
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').VALUE:=bQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime;
|
|
|
|
|
end;
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=getzqtype(kbmqc.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString,kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
|
|
|
|
|
kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=StrToInt(bsSkinEdit1.text);
|
|
|
|
|
|
|
|
|
|
if (DaysBetween(Date,kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)-kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger)>0 then
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
|
|
if not kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
|
|
|
|
|
begin
|
|
|
|
|
if kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=DaysBetween(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)-kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger
|
|
|
|
|
else kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=0;
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').AsFloat:=CalcProftAmtqx(kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat,kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
if trim(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)<>'<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ').AsString:=FormatFloat('0.00;-0.00;0',kbmqc.FieldByName('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').AsFloat/100*kbmqc.FieldByName('Ӧ<>պϼ<D5BA>').AsFloat*kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger);
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if Date>kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=DaysBetween(Date,kbmqc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)-kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger
|
|
|
|
|
else kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=0;
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').AsFloat:=CalcProftAmtqx(kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat,kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
if trim(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)<>'<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ').AsString:=FormatFloat('0.00;-0.00;0',kbmqc.FieldByName('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').AsFloat/100*kbmqc.FieldByName('Ӧ<>պϼ<D5BA>').AsFloat*kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger);
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
if (Trim(kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2>').AsString)<>'') and (kbmqc.FieldByName('<27><>Ϣ').AsFloat>0) then
|
|
|
|
|
if not kbmtc.IsEmpty then
|
|
|
|
|
if kbmtc.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD>',vararrayof([Trim(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString),Trim(kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2>').AsString)]),[]) then
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.Edit;
|
|
|
|
|
kbmtc.FieldByName('<27><>Ϣ').AsFloat:=kbmtc.FieldByName('<27><>Ϣ').AsFloat+StrToFloat(FormatFloat('0;-0;0',kbmqc.FieldByName('<27><>Ϣ').AsFloat));
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if kbmqc.FieldByName('<27><>Ϣ').AsFloat>0 then
|
|
|
|
|
kbmqc.Post
|
|
|
|
|
else
|
|
|
|
|
kbmqc.Delete;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
FreeAndNil(aquery);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.texClick(Sender: TObject);
|
|
|
|
|
var i:integer;
|
|
|
|
|
begin
|
|
|
|
|
if Edit2.text='' then
|
|
|
|
|
begin
|
|
|
|
|
if not if_open('406') then
|
|
|
|
|
begin
|
|
|
|
|
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա,Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---><3E><><EFBFBD>۹<EFBFBD><DBB9><EFBFBD>--->ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
if MessageDlg('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>(YYMM)Ϊ<><CEAA>Ҫȡ<D2AA><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
|
|
Exit;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if not if_open('405') then
|
|
|
|
|
begin
|
|
|
|
|
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա,Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---><3E><><EFBFBD>۹<EFBFBD><DBB9><EFBFBD>---><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if MessageDlg('ȷʵҪ<CAB5><D2AA><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵽'+Edit2.text+'<27><>? <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
|
|
Exit;
|
|
|
|
|
end;
|
|
|
|
|
if dxDBGrid6.SelectedCount<1 then
|
|
|
|
|
begin
|
|
|
|
|
showmessage('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>');
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
try
|
|
|
|
|
kbmqc.DisableControls;
|
|
|
|
|
for i:=0 to dxDBGrid6.SelectedCount-1 do
|
|
|
|
|
begin
|
|
|
|
|
kbmqc.GotoBookmark(pointer(dxDBGrid6.selectedrows[i]));
|
|
|
|
|
kbmqc.Edit;
|
|
|
|
|
kbmqc.FieldByName('<27><>Ϣ<EFBFBD><CFA2>').AsString:=Edit2.text;
|
|
|
|
|
kbmqc.Post;
|
|
|
|
|
UpdateBsProfitLc(kbmqc.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,kbmqc.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,Edit2.text);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
kbmqc.EnableControls;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.bsSkinButton9Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
sys_print('ҵ<><D2B5><EFBFBD>ۺ<EFBFBD>ͳ<EFBFBD><CDB3>',2,nil,nil,nil,nil,nil,nil,nil,kbmtc1,kbmqc1,nil,nil);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.MenuItem7Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
grid_save_xls(dxdbgrid6);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.N1Click(Sender: TObject);
|
|
|
|
|
var aquery:TADOQuery;
|
|
|
|
|
begin
|
|
|
|
|
if not if_open('405') then
|
|
|
|
|
begin
|
|
|
|
|
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա,Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---><3E><><EFBFBD>۹<EFBFBD><DBB9><EFBFBD>---><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if MessageDlg('ȷʵҪ<CAB5><D2AA><EFBFBD><EFBFBD> '+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+' '+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+'<27><>? <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
close;SQL.Clear;
|
|
|
|
|
SQL.Add('select * from v_op_bscard');
|
|
|
|
|
SQL.Add('where substring(CONVERT(varchar(100), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 112),3,4)='''+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+'''');
|
|
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+'''');
|
|
|
|
|
open;First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
UpdateBsProfit(fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,1);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
kbmtc.Edit;
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
finally
|
|
|
|
|
Free;
|
|
|
|
|
end;
|
|
|
|
|
//
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.N3Click(Sender: TObject);
|
|
|
|
|
var aquery:TADOQuery;
|
|
|
|
|
begin
|
|
|
|
|
if not if_open('406') then
|
|
|
|
|
begin
|
|
|
|
|
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD>,<2C><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա,Ȩ<><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>---><3E><><EFBFBD>۹<EFBFBD><DBB9><EFBFBD>--->ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if MessageDlg('ȷʵҪȡ<D2AA><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+' '+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+'<27><>? <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',mtWarning,[mbyes,mbno],0)<>mryes then
|
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
|
|
with aQuery do
|
|
|
|
|
try
|
|
|
|
|
close;SQL.Clear;
|
|
|
|
|
SQL.Add('select * from v_op_bscard');
|
|
|
|
|
SQL.Add('where substring(CONVERT(varchar(100), <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 112),3,4)='''+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+'''');
|
|
|
|
|
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+kbmtc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+'''');
|
|
|
|
|
open;First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
UpdateBsProfit(fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,0);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
kbmtc.Edit;
|
|
|
|
|
kbmtc.FieldByName('<27>Ƿ<C7B7>').AsString:='<27><>';
|
|
|
|
|
kbmtc.Post;
|
|
|
|
|
finally
|
|
|
|
|
Free;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.dxDBGrid6CustomDraw(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 uppercase(ANode.Strings[dxDBGrid6Column19.Index])<>'' then
|
|
|
|
|
begin
|
|
|
|
|
// AFont.Style:=AFont.Style+[fsStrikeOut];
|
|
|
|
|
AColor:=$00E3C784;
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.dxDBGrid8CustomDraw(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 uppercase(ANode.Strings[dxDBGrid8Column10.Index])='<27><>' then
|
|
|
|
|
begin
|
|
|
|
|
// AFont.Style:=AFont.Style+[fsStrikeOut];
|
|
|
|
|
AColor:=$00E3C784;
|
|
|
|
|
exit;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_two.kbmtcBeforePost(DataSet: TDataSet);
|
|
|
|
|
begin
|
|
|
|
|
kbmtc.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=StrToFloat(FormatFloat('0;-0;0',kbmtc.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD>').AsFloat-kbmtc.FieldByName('˰<><CBB0>').AsFloat-kbmtc.FieldByName('<27><>Ϣ').AsFloat));
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|