|
|
|
|
unit u_rp_sales_profit_tc;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
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_tc = 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;
|
|
|
|
|
memtblItemsField7: TIntegerField;
|
|
|
|
|
dxDBGrid2Column4: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column5: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column6: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column7: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField8: TStringField;
|
|
|
|
|
bsSkinLabel1: TbsSkinLabel;
|
|
|
|
|
bsSkinEdit1: TbsSkinEdit;
|
|
|
|
|
bsSkinLabel2: TbsSkinLabel;
|
|
|
|
|
bsSkinEdit2: TbsSkinEdit;
|
|
|
|
|
memtblItemsField9: TIntegerField;
|
|
|
|
|
dxDBGrid2Column8: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField10: TStringField;
|
|
|
|
|
dxDBGrid2Column9: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column10: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField11: TStringField;
|
|
|
|
|
memtblItemsField12: TFloatField;
|
|
|
|
|
memtblItemsField13: TFloatField;
|
|
|
|
|
dxDBGrid2Column11: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column12: TdxDBGridColumn;
|
|
|
|
|
memtblItemsRMB: TFloatField;
|
|
|
|
|
memtblItemsUSD: TFloatField;
|
|
|
|
|
dxDBGrid2Column13: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column14: TdxDBGridColumn;
|
|
|
|
|
Label2: TLabel;
|
|
|
|
|
DBComboBoxEh1: TDBComboBoxEh;
|
|
|
|
|
memtblItemsField14: TFloatField;
|
|
|
|
|
dxDBGrid2Column15: TdxDBGridColumn;
|
|
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
|
|
bsSkinButton1: TbsSkinButton;
|
|
|
|
|
bsSkinButton2: TbsSkinButton;
|
|
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
|
|
memtblItemsField15: TStringField;
|
|
|
|
|
dxDBGrid2Column16: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField16: TStringField;
|
|
|
|
|
dxDBGrid2Column17: TdxDBGridColumn;
|
|
|
|
|
memtblItemsOrdno: TIntegerField;
|
|
|
|
|
dxDBGrid2Column18: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField17: TStringField;
|
|
|
|
|
dxDBGrid2Column19: TdxDBGridColumn;
|
|
|
|
|
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
|
|
|
|
|
bsSkinTabSheet3: TbsSkinTabSheet;
|
|
|
|
|
bsSkinTabSheet4: TbsSkinTabSheet;
|
|
|
|
|
bsSkinTabSheet5: TbsSkinTabSheet;
|
|
|
|
|
memtblItems31: TDataSource;
|
|
|
|
|
memtblItems3: TkbmMemTable;
|
|
|
|
|
StringField1: TStringField;
|
|
|
|
|
StringField2: TStringField;
|
|
|
|
|
StringField3: TStringField;
|
|
|
|
|
StringField4: TStringField;
|
|
|
|
|
FloatField1: TFloatField;
|
|
|
|
|
IntegerField1: TIntegerField;
|
|
|
|
|
IntegerField2: TIntegerField;
|
|
|
|
|
StringField5: TStringField;
|
|
|
|
|
IntegerField3: TIntegerField;
|
|
|
|
|
StringField6: TStringField;
|
|
|
|
|
StringField7: TStringField;
|
|
|
|
|
FloatField2: TFloatField;
|
|
|
|
|
FloatField3: TFloatField;
|
|
|
|
|
FloatField4: TFloatField;
|
|
|
|
|
FloatField5: TFloatField;
|
|
|
|
|
FloatField6: TFloatField;
|
|
|
|
|
StringField8: TStringField;
|
|
|
|
|
StringField9: TStringField;
|
|
|
|
|
IntegerField4: TIntegerField;
|
|
|
|
|
StringField10: TStringField;
|
|
|
|
|
memtblItems2: TkbmMemTable;
|
|
|
|
|
StringField11: TStringField;
|
|
|
|
|
StringField12: TStringField;
|
|
|
|
|
StringField13: TStringField;
|
|
|
|
|
StringField14: TStringField;
|
|
|
|
|
FloatField7: TFloatField;
|
|
|
|
|
IntegerField5: TIntegerField;
|
|
|
|
|
IntegerField6: TIntegerField;
|
|
|
|
|
StringField15: TStringField;
|
|
|
|
|
IntegerField7: TIntegerField;
|
|
|
|
|
StringField16: TStringField;
|
|
|
|
|
StringField17: TStringField;
|
|
|
|
|
FloatField8: TFloatField;
|
|
|
|
|
FloatField9: TFloatField;
|
|
|
|
|
FloatField10: TFloatField;
|
|
|
|
|
FloatField11: TFloatField;
|
|
|
|
|
FloatField12: TFloatField;
|
|
|
|
|
StringField18: TStringField;
|
|
|
|
|
StringField19: TStringField;
|
|
|
|
|
IntegerField8: TIntegerField;
|
|
|
|
|
StringField20: TStringField;
|
|
|
|
|
memtblItems21: TDataSource;
|
|
|
|
|
memtblItems111: TDataSource;
|
|
|
|
|
memtblItems11: TkbmMemTable;
|
|
|
|
|
StringField21: TStringField;
|
|
|
|
|
StringField22: TStringField;
|
|
|
|
|
StringField23: TStringField;
|
|
|
|
|
StringField24: TStringField;
|
|
|
|
|
FloatField13: TFloatField;
|
|
|
|
|
IntegerField9: TIntegerField;
|
|
|
|
|
IntegerField10: TIntegerField;
|
|
|
|
|
StringField25: TStringField;
|
|
|
|
|
IntegerField11: TIntegerField;
|
|
|
|
|
StringField26: TStringField;
|
|
|
|
|
StringField27: TStringField;
|
|
|
|
|
FloatField14: TFloatField;
|
|
|
|
|
FloatField15: TFloatField;
|
|
|
|
|
FloatField16: TFloatField;
|
|
|
|
|
FloatField17: TFloatField;
|
|
|
|
|
FloatField18: TFloatField;
|
|
|
|
|
StringField28: TStringField;
|
|
|
|
|
StringField29: TStringField;
|
|
|
|
|
IntegerField12: TIntegerField;
|
|
|
|
|
StringField30: TStringField;
|
|
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn1: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn2: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn3: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn4: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn5: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn6: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn7: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn8: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn9: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn10: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn11: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn12: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn13: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn14: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn15: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn16: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn17: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn18: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn19: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid3: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn20: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn21: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn22: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn23: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn24: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn25: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn26: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn27: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn28: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn29: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn30: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn31: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn32: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn33: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn34: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn35: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn36: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn37: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn38: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid4: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn39: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn40: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn41: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn42: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn43: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn44: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn45: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn46: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn47: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn48: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn49: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn50: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn51: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn52: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn53: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn54: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn55: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn56: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn57: TdxDBGridColumn;
|
|
|
|
|
memtblItemsField18: TStringField;
|
|
|
|
|
memtblItems2Field: TStringField;
|
|
|
|
|
memtblItems3Field: TStringField;
|
|
|
|
|
dxDBGrid2Column20: TdxDBGridColumn;
|
|
|
|
|
PopupMenu2: TPopupMenu;
|
|
|
|
|
N14: TMenuItem;
|
|
|
|
|
memtblItems11Field: TStringField;
|
|
|
|
|
bsSkinTabSheet6: TbsSkinTabSheet;
|
|
|
|
|
dxDBGrid5: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn58: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn59: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn60: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn61: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn62: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn63: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn64: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn65: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn66: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn67: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn68: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn69: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn70: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn71: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn72: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn73: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn74: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn75: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn76: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn77: TdxDBGridColumn;
|
|
|
|
|
memtblDetailTC: TkbmMemTable;
|
|
|
|
|
StringField31: TStringField;
|
|
|
|
|
StringField32: TStringField;
|
|
|
|
|
StringField33: TStringField;
|
|
|
|
|
StringField34: TStringField;
|
|
|
|
|
FloatField19: TFloatField;
|
|
|
|
|
IntegerField13: TIntegerField;
|
|
|
|
|
IntegerField14: TIntegerField;
|
|
|
|
|
StringField35: TStringField;
|
|
|
|
|
IntegerField15: TIntegerField;
|
|
|
|
|
StringField36: TStringField;
|
|
|
|
|
StringField37: TStringField;
|
|
|
|
|
FloatField20: TFloatField;
|
|
|
|
|
FloatField21: TFloatField;
|
|
|
|
|
FloatField22: TFloatField;
|
|
|
|
|
FloatField23: TFloatField;
|
|
|
|
|
FloatField24: TFloatField;
|
|
|
|
|
StringField38: TStringField;
|
|
|
|
|
StringField39: TStringField;
|
|
|
|
|
IntegerField16: TIntegerField;
|
|
|
|
|
StringField40: TStringField;
|
|
|
|
|
StringField41: TStringField;
|
|
|
|
|
memtblDetailTC1: TDataSource;
|
|
|
|
|
memtblDetailTCFloatField: TFloatField;
|
|
|
|
|
dxDBGrid5Column21: TdxDBGridColumn;
|
|
|
|
|
bsSkinTabSheet7: TbsSkinTabSheet;
|
|
|
|
|
dxDBGrid6: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn78: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn94: TdxDBGridColumn;
|
|
|
|
|
kbmMemTableCLF: TkbmMemTable;
|
|
|
|
|
kbmMemTableCLF1: TDataSource;
|
|
|
|
|
bsSkinButton4: TbsSkinButton;
|
|
|
|
|
kbmMemTableCLFField: TStringField;
|
|
|
|
|
kbmMemTableCLFField2: TFloatField;
|
|
|
|
|
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 N14Click(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton4Click(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(cqMonth:string;ProftAmt:Double;Employee:string;var planbegin,planend:Double):Double;
|
|
|
|
|
procedure GetBsDate(curDate:TDate);
|
|
|
|
|
procedure GetFeeItems(aMemtblItems:TKbmmemTable);
|
|
|
|
|
function GetProftAmt(Employee:string;AEtd:TDateTime):Double;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ Private declarations }
|
|
|
|
|
public
|
|
|
|
|
{ Public declarations }
|
|
|
|
|
ordno_tc:Integer;
|
|
|
|
|
procedure IsertFeeItems(aMemtblItems:TKbmmemTable;SalesTc:TSalesTc);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
frm_rp_sales_profit_tc: Tfrm_rp_sales_profit_tc;
|
|
|
|
|
FmDate,ToDate:String;
|
|
|
|
|
sqlstr:WideString;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses u_main, my_sys_function,u_sys_progress;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_tc.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(ë<><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_tc.bsSkinButton5Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
close;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.FormClose(Sender: TObject;
|
|
|
|
|
var Action: TCloseAction);
|
|
|
|
|
begin
|
|
|
|
|
savereggrid(dxdbgrid2,caption+'2');
|
|
|
|
|
frm_rp_sales_profit_tc.Hide;
|
|
|
|
|
frm_rp_sales_profit_tc.ManualFloat(frm_rp_sales_profit_tc.BoundsRect );
|
|
|
|
|
frm_main.freeTabs('frm_rp_sales_profit_tc');
|
|
|
|
|
action:=cafree;
|
|
|
|
|
frm_rp_sales_profit_tc:=nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.GetBsDate(curDate:TDate);
|
|
|
|
|
var aDate,s:String;
|
|
|
|
|
aDateTime:TDateTime;
|
|
|
|
|
y,m,d,hh,mm,ss,Endhh,Endmm,Endss,mmmm:Word;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
aDate:=FormatDateTime('YYYY-MM-DD',curDate);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.IsertFeeItems(aMemtblItems:TKbmmemTable;SalesTc:TSalesTc);
|
|
|
|
|
var
|
|
|
|
|
aAdoQuery :TAdoQuery;
|
|
|
|
|
Amt:Double;
|
|
|
|
|
salses:string;
|
|
|
|
|
ordno:Integer;
|
|
|
|
|
lastplanbegin,lastplanend,lasttcxs,lasttc,lastprofit,planbegin,planend:Double;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
try
|
|
|
|
|
aMemtblItems.DisableControls;
|
|
|
|
|
Amt:=0;
|
|
|
|
|
// ordno:=1;
|
|
|
|
|
planbegin:=0;
|
|
|
|
|
planend:=0;
|
|
|
|
|
lastplanbegin:=0;
|
|
|
|
|
lastplanend:=0;
|
|
|
|
|
lasttcxs:=0;
|
|
|
|
|
lasttc:=0;
|
|
|
|
|
aMemtblItems.IndexDefs.Clear;
|
|
|
|
|
aMemtblItems.AddIndex('Index1', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', []);
|
|
|
|
|
aMemtblItems.IndexName := 'Index1';
|
|
|
|
|
ordno_tc:=ordno_tc+1;
|
|
|
|
|
aMemtblItems.Append;
|
|
|
|
|
aMemtblItems.FieldByName('ordno').AsInteger:=ordno_tc;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=SalesTc.bsNo;
|
|
|
|
|
aMemtblItems.FieldByName('ί<>е<EFBFBD>λ').Value:=SalesTc.shippers;
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=SalesTc.sales;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value:=SalesTc.mblno;
|
|
|
|
|
aMemtblItems.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=SalesTc.bstype;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>״̬').Value:=SalesTc.FeeStaus;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=SalesTc.Etd;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FormatDateTime('YYYY-MM-DD hh:mm:sss',SalesTc.StlDate);
|
|
|
|
|
aMemtblItems.FieldByName('RMB<4D>ϼ<EFBFBD>').Value:=SalesTc.AmtRmb;
|
|
|
|
|
aMemtblItems.FieldByName('USD<53>ϼ<EFBFBD>').Value:=SalesTc.AmtUsd;
|
|
|
|
|
aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=SalesTc.ProfitAmt;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYYY-MM',SalesTc.Etd);
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value:=SalesTc.TtlProfitAmt;
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=0;
|
|
|
|
|
|
|
|
|
|
if SalesTc.CQDays<=0 then
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=0
|
|
|
|
|
else
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=SalesTc.CQDays;
|
|
|
|
|
|
|
|
|
|
if (SalesTc.CorpStlType='') or (SalesTc.CorpStlType='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>') then
|
|
|
|
|
begin
|
|
|
|
|
if SalesTc.CQDays>=StrToInt(bsSkinEdit1.Text) then
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=SalesTc.CQDays-StrToInt(bsSkinEdit1.Text)
|
|
|
|
|
else aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if SalesTc.CQDays>=StrToInt(bsSkinEdit2.Text) then
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=SalesTc.CQDays-StrToInt(bsSkinEdit2.Text)
|
|
|
|
|
else aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>=0) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=30) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=0;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=100;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>30) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=60) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=1;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=80;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>60) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=90) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=2;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=60;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:='<27><><EFBFBD><EFBFBD>3';
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=0;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=SalesTc.xyDays;
|
|
|
|
|
lasttcxs:=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value:=CalcProftAmt(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat,SalesTc.sales,planbegin,planend);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value<>0 then
|
|
|
|
|
begin
|
|
|
|
|
if planbegin>(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin));
|
|
|
|
|
|
|
|
|
|
lastprofit:=aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat-aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
|
|
|
|
|
lasttcxs:=CalcProftAmt(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,lastprofit,SalesTc.sales,lastplanbegin,lastplanend);
|
|
|
|
|
if lasttcxs>0 then
|
|
|
|
|
begin
|
|
|
|
|
if (aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value-(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin))>0 then
|
|
|
|
|
lasttc:=lasttcxs*(aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value-(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin));
|
|
|
|
|
end;
|
|
|
|
|
if (lasttcxs>0) and (lasttc>0) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value+strToFloat(formatFloat('0.00;-0.00;0',lasttc));
|
|
|
|
|
aMemtblItems.FieldByName('<27><>ע').Value:='ϵ<><CFB5>:'+FloatToStr(lasttcxs)+' <20><><EFBFBD><EFBFBD>:'+formatFloat('0.00;-0.00;0',lasttc);
|
|
|
|
|
end;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*memtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value);
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=0;
|
|
|
|
|
end;
|
|
|
|
|
aMemtblItems.Post;
|
|
|
|
|
finally
|
|
|
|
|
aMemtblItems.EnableControls;
|
|
|
|
|
aMemtblItems.Refresh;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.bsSkinButton10Click(Sender: TObject);
|
|
|
|
|
var y,m,d:Word;
|
|
|
|
|
ListEmpl,ListEtdYearMonth:TStringlist;
|
|
|
|
|
i,j:Integer;
|
|
|
|
|
Amt:Double;
|
|
|
|
|
SalesTc:TSalesTc;
|
|
|
|
|
begin
|
|
|
|
|
ordno_tc:=0;
|
|
|
|
|
GetBsDate(DateTimePicker1.Date);
|
|
|
|
|
GetFeeItems(memtblItems);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decodedate(incMonth(DateTimePicker1.Date,-1),y,m,d);
|
|
|
|
|
GetBsDate(encodedatetime(y,m,1,0,0,0,0));
|
|
|
|
|
GetFeeItems(memtblItems11);
|
|
|
|
|
|
|
|
|
|
decodedate(incMonth(DateTimePicker1.Date,-2),y,m,d);
|
|
|
|
|
GetBsDate(encodedatetime(y,m,1,0,0,0,0));
|
|
|
|
|
GetFeeItems(memtblItems2);
|
|
|
|
|
|
|
|
|
|
decodedate(incMonth(DateTimePicker1.Date,-3),y,m,d);
|
|
|
|
|
GetBsDate(encodedatetime(y,m,1,0,0,0,0));
|
|
|
|
|
GetFeeItems(memtblItems3);
|
|
|
|
|
|
|
|
|
|
//exit;
|
|
|
|
|
ListEmpl:=TStringlist.Create;
|
|
|
|
|
ListEtdYearMonth:=TStringlist.Create;
|
|
|
|
|
ListEmpl.Clear;
|
|
|
|
|
ListEtdYearMonth.Clear;
|
|
|
|
|
try
|
|
|
|
|
with memtblItems do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
if ListEmpl.IndexOf(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)<0 then
|
|
|
|
|
ListEmpl.Add(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
memtblDetailTC.Close;
|
|
|
|
|
memtblDetailTC.EmptyTable;
|
|
|
|
|
memtblDetailTC.Open;
|
|
|
|
|
for i:=0 to ListEmpl.count-1 do
|
|
|
|
|
begin
|
|
|
|
|
memtblItems.Filtered:=False;
|
|
|
|
|
memtblItems.Filter:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEmpl[i]+'''';
|
|
|
|
|
memtblItems.Filtered:=True;
|
|
|
|
|
ListEtdYearMonth.Clear;
|
|
|
|
|
with memtblItems do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
if ListEtdYearMonth.IndexOf(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)<0 then
|
|
|
|
|
ListEtdYearMonth.Add(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
// ShowMessage(ListEtdYearMonth[j]);
|
|
|
|
|
for j:=0 to ListEtdYearMonth.count-1 do
|
|
|
|
|
begin
|
|
|
|
|
Amt:=0;
|
|
|
|
|
memtblItems11.Filtered:=False;
|
|
|
|
|
memtblItems11.Filter:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEmpl[i]+'''';
|
|
|
|
|
memtblItems11.Filter:=memtblItems11.Filter+' And <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEtdYearMonth[j]+'''';
|
|
|
|
|
memtblItems11.Filtered:=True;
|
|
|
|
|
with memtblItems11 do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
Amt:=Amt+s_w(2,FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
memtblItems2.Filtered:=False;
|
|
|
|
|
memtblItems2.Filter:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEmpl[i]+'''';
|
|
|
|
|
memtblItems2.Filter:=memtblItems2.Filter+' And <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEtdYearMonth[j]+'''';
|
|
|
|
|
memtblItems2.Filtered:=True;
|
|
|
|
|
with memtblItems2 do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
Amt:=Amt+s_w(2,FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
memtblItems3.Filtered:=False;
|
|
|
|
|
memtblItems3.Filter:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEmpl[i]+'''';
|
|
|
|
|
memtblItems3.Filter:=memtblItems2.Filter+' And <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEtdYearMonth[j]+'''';
|
|
|
|
|
memtblItems3.Filtered:=True;
|
|
|
|
|
with memtblItems3 do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
Amt:=Amt+s_w(2,FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
memtblItems.Filtered:=False;
|
|
|
|
|
memtblItems.Filter:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEmpl[i]+'''';
|
|
|
|
|
memtblItems.Filter:=memtblItems.Filter+' And <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+ListEtdYearMonth[j]+'''';
|
|
|
|
|
memtblItems.Filtered:=True;
|
|
|
|
|
memtblItems.IndexDefs.Clear;
|
|
|
|
|
memtblItems.AddIndex('Index1', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', []);
|
|
|
|
|
memtblItems.IndexName := 'Index1';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decodedate(incMonth(DateTimePicker1.Date,-1),y,m,d);
|
|
|
|
|
if not kbmMemTableCLF.IsEmpty then
|
|
|
|
|
if FormatDateTime('YYYY-MM',encodedatetime(y,m,1,0,0,0,0))=ListEtdYearMonth[j] then
|
|
|
|
|
begin
|
|
|
|
|
if kbmMemTableCLF.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',ListEmpl[i],[]) then
|
|
|
|
|
begin
|
|
|
|
|
Amt:=Amt-kbmMemTableCLF.FieldByName('<27><><EFBFBD>÷<EFBFBD>').AsFloat;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
with memtblItems do
|
|
|
|
|
begin
|
|
|
|
|
First;
|
|
|
|
|
while not eof do
|
|
|
|
|
begin
|
|
|
|
|
Amt:=Amt+s_w(2,FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat);
|
|
|
|
|
|
|
|
|
|
SalesTc.bsNo:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
SalesTc.shippers:=FieldByName('ί<>е<EFBFBD>λ').AsString;
|
|
|
|
|
|
|
|
|
|
SalesTc.sales:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
SalesTc.mblno:=FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').AsString;
|
|
|
|
|
SalesTc.bstype:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
SalesTc.FeeStaus:=FieldByName('<27><><EFBFBD><EFBFBD>״̬').AsString;
|
|
|
|
|
SalesTc.Etd:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime;
|
|
|
|
|
SalesTc.StlDate:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime;
|
|
|
|
|
SalesTc.AmtRmb:=FieldByName('RMB<4D>ϼ<EFBFBD>').AsFloat;
|
|
|
|
|
SalesTc.AmtUsd:=FieldByName('USD<53>ϼ<EFBFBD>').AsFloat;
|
|
|
|
|
SalesTc.ProfitAmt:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
SalesTc.EtdYearMonth:=FormatDateTime('YYYY-MM',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
|
|
|
|
|
SalesTc.CQDays:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
SalesTc.xyDays:=FieldByName('Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
SalesTc.TtlProfitAmt:=Amt;
|
|
|
|
|
IsertFeeItems(memtblDetailTC,SalesTc);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
finally
|
|
|
|
|
ListEmpl.Free;
|
|
|
|
|
ListEtdYearMonth.Free;
|
|
|
|
|
|
|
|
|
|
memtblItems11.Filtered:=False;
|
|
|
|
|
memtblItems11.Filter:='';
|
|
|
|
|
memtblItems3.Filtered:=False;
|
|
|
|
|
memtblItems3.Filter:='';
|
|
|
|
|
memtblItems2.Filtered:=False;
|
|
|
|
|
memtblItems2.Filter:='';
|
|
|
|
|
memtblItems.Filtered:=False;
|
|
|
|
|
memtblItems.Filter:='';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_tc.CalcProftAmt(cqMonth:string;ProftAmt:Double;Employee:string;var planbegin,planend:Double):Double;
|
|
|
|
|
var aAdoQueryProfitPlan,aAdoQueryProfitPlanItem:TAdoQuery;
|
|
|
|
|
PlanName:string;
|
|
|
|
|
rate1,rate2:Double;
|
|
|
|
|
begin
|
|
|
|
|
if Trim(cqMonth)='0' then
|
|
|
|
|
rate1:=100
|
|
|
|
|
else
|
|
|
|
|
if Trim(cqMonth)='1' then
|
|
|
|
|
rate1:=80
|
|
|
|
|
else
|
|
|
|
|
if Trim(cqMonth)='2' then
|
|
|
|
|
rate1:=60
|
|
|
|
|
else 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;
|
|
|
|
|
// ShowMessage(PlanName);
|
|
|
|
|
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_tc.GetFeeItems(aMemtblItems:TKbmmemTable);
|
|
|
|
|
var
|
|
|
|
|
aAdoQuery :TAdoQuery;
|
|
|
|
|
Amt:Double;
|
|
|
|
|
salses,field_lirun:string;
|
|
|
|
|
ordno:Integer;
|
|
|
|
|
lastplanbegin,lastplanend,lasttcxs,lasttc,lastprofit,planbegin,planend:Double;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
field_lirun:='<27><><EFBFBD><EFBFBD>˰ë<CBB0><C3AB><EFBFBD><EFBFBD> ë<><C3AB><EFBFBD><EFBFBD>';
|
|
|
|
|
aMemtblItems.Close;
|
|
|
|
|
aMemtblItems.EmptyTable;
|
|
|
|
|
// memtblItems.CreateTable;
|
|
|
|
|
aMemtblItems.Open;
|
|
|
|
|
|
|
|
|
|
if Trim(DBComboBoxEh1.Text)='' then
|
|
|
|
|
begin
|
|
|
|
|
// showmessage('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
// exit;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
aAdoQuery:=CreateAdoQuery;
|
|
|
|
|
|
|
|
|
|
with aAdoQuery do // 1 1
|
|
|
|
|
try
|
|
|
|
|
Close;SQL.Clear;
|
|
|
|
|
SQL.Add('select v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,convert(varchar(7),v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,120) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.'+field_lirun+'');
|
|
|
|
|
SQL.Add(',v_op_bscard.Ӧ<><D3A6>USD,v_op_bscard.Ӧ<><D3A6>RMB,');
|
|
|
|
|
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>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('isnull(DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)-(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)');
|
|
|
|
|
SQL.Add(' else (case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then');
|
|
|
|
|
SQL.Add(' ( DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(month, CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int), DATEADD(day,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(Day,-Day(v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+1,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>))))) else 0 end) end)');
|
|
|
|
|
SQL.Add(',DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int)*30+isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' else 0 ');
|
|
|
|
|
SQL.Add(' end) as Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('from v_op_bscard ');
|
|
|
|
|
SQL.Add(' left join t_crm_client_sales on v_op_bscard.ί<>е<EFBFBD>λ=t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('left join v_fee_do_max jie on v_op_bscard.<2E><><EFBFBD><EFBFBD>=jie.<2E><><EFBFBD><EFBFBD>');
|
|
|
|
|
SQL.Add('where v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6><>0');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(CurDateBegin)+'''');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(CurDateEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <'+''''+datetimetostr(CurDateBegin)+'''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >''2012-12-26''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
Parameters.ParamByName('StlBeginDate').Value:=CurDateBegin;
|
|
|
|
|
Parameters.ParamByName('StlEndDate').Value:=CurDateEnd;
|
|
|
|
|
}
|
|
|
|
|
SQL.Add(' union ');
|
|
|
|
|
SQL.Add('select v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,convert(varchar(7),v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,120) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.'+field_lirun+'');
|
|
|
|
|
SQL.Add(',v_op_bscard.Ӧ<><D3A6>USD,v_op_bscard.Ӧ<><D3A6>RMB,');
|
|
|
|
|
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>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('isnull(DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)-(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)');
|
|
|
|
|
SQL.Add(' else (case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then');
|
|
|
|
|
SQL.Add(' ( DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(month, CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int), DATEADD(day,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(Day,-Day(v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+1,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>))))) else 0 end) end)');
|
|
|
|
|
SQL.Add(',DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int)*30+isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' else 0 ');
|
|
|
|
|
SQL.Add(' end) as Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('from v_op_bscard ');
|
|
|
|
|
SQL.Add(' left join t_crm_client_sales on v_op_bscard.ί<>е<EFBFBD>λ=t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('left join v_fee_do_max_cr jie on v_op_bscard.<2E><><EFBFBD><EFBFBD>=jie.<2E><><EFBFBD><EFBFBD>');
|
|
|
|
|
SQL.Add('where v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v_op_bscard.<2E>ϼ<EFBFBD><CFBC>Ѹ<EFBFBD> and v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0'); //ȡֻ<C8A1>и<EFBFBD>û<EFBFBD><C3BB><EFBFBD>յ<EFBFBD>
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(CurDateBegin)+'''');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(CurDateEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <'+''''+datetimetostr(CurDateBegin)+'''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >''2012-12-26''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ȡ<><C8A1><EFBFBD>½<EFBFBD><C2BD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>з<EFBFBD><D0B7>ʵ<EFBFBD>ҵ<EFBFBD><D2B5>
|
|
|
|
|
SQL.Add(' union ');
|
|
|
|
|
SQL.Add('select v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,convert(varchar(7),v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,120) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.'+field_lirun+'');
|
|
|
|
|
SQL.Add(',v_op_bscard.Ӧ<><D3A6>USD,v_op_bscard.Ӧ<><D3A6>RMB,');
|
|
|
|
|
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>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('isnull(DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)-(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)');
|
|
|
|
|
SQL.Add(' else (case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then');
|
|
|
|
|
SQL.Add(' ( DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(month, CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int), DATEADD(day,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(Day,-Day(v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+1,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>))))) else 0 end) end)');
|
|
|
|
|
SQL.Add(',DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int)*30+isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' else 0 ');
|
|
|
|
|
SQL.Add(' end) as Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('from v_op_bscard ');
|
|
|
|
|
SQL.Add(' left join t_crm_client_sales on v_op_bscard.ί<>е<EFBFBD>λ=t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('left join v_fee_do_max jie on v_op_bscard.<2E><><EFBFBD><EFBFBD>=jie.<2E><><EFBFBD><EFBFBD>');
|
|
|
|
|
SQL.Add('where v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6><>0');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(LastDateOneBegin)+'''');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(LastDateOneEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(LastDateOneBegin)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(LastDateOneEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >''2012-12-26''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
|
|
|
|
|
SQL.Add(' union ');
|
|
|
|
|
SQL.Add('select v_op_bscard.<2E><><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,convert(varchar(7),v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,120) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.<2E><><EFBFBD><EFBFBD>״̬,v_op_bscard.<2E><><EFBFBD>ᵥ<EFBFBD><E1B5A5>,v_op_bscard.ί<>е<EFBFBD>λ,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,v_op_bscard.'+field_lirun+'');
|
|
|
|
|
SQL.Add(',v_op_bscard.Ӧ<><D3A6>USD,v_op_bscard.Ӧ<><D3A6>RMB,');
|
|
|
|
|
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>,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('isnull(DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)-(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)');
|
|
|
|
|
SQL.Add(' else (case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then');
|
|
|
|
|
SQL.Add(' ( DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(month, CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int), DATEADD(day,t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,DATEADD(Day,-Day(v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+1,v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>))))) else 0 end) end)');
|
|
|
|
|
SQL.Add(',DATEDIFF([day],v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,');
|
|
|
|
|
SQL.Add('(case t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' then isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' when ''Լ<><D4BC>ʱ<EFBFBD><CAB1>'' then CAST(t_crm_client_sales.<2E><><EFBFBD><EFBFBD>ģʽ AS int)*30+isnull(t_crm_client_sales.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0) ');
|
|
|
|
|
SQL.Add(' else 0 ');
|
|
|
|
|
SQL.Add(' end) as Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('from v_op_bscard ');
|
|
|
|
|
SQL.Add(' left join t_crm_client_sales on v_op_bscard.ί<>е<EFBFBD>λ=t_crm_client_sales.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> ');
|
|
|
|
|
SQL.Add('left join v_fee_do_max_cr jie on v_op_bscard.<2E><><EFBFBD><EFBFBD>=jie.<2E><><EFBFBD><EFBFBD>');
|
|
|
|
|
SQL.Add('where v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v_op_bscard.<2E>ϼ<EFBFBD><CFBC>Ѹ<EFBFBD> and v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0'); //ȡֻ<C8A1>и<EFBFBD>û<EFBFBD><C3BB><EFBFBD>յ<EFBFBD>
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(LastDateOneBegin)+'''');
|
|
|
|
|
SQL.add(' and jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(LastDateOneEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+datetimetostr(LastDateOneBegin)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+datetimetostr(LastDateOneEnd)+'''');
|
|
|
|
|
SQL.add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >''2012-12-26''');// <20><>ȡ<EFBFBD><C8A1><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
|
|
|
|
SQL.add('order by v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,convert(varchar(7),v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,120),jie.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
Open;First;
|
|
|
|
|
salses:='';
|
|
|
|
|
aMemtblItems.EmptyTable;
|
|
|
|
|
aMemtblItems.DisableControls;
|
|
|
|
|
Amt:=0;
|
|
|
|
|
ordno:=1;
|
|
|
|
|
planbegin:=0;
|
|
|
|
|
planend:=0;
|
|
|
|
|
lastplanbegin:=0;
|
|
|
|
|
lastplanend:=0;
|
|
|
|
|
lasttcxs:=0;
|
|
|
|
|
lasttc:=0;
|
|
|
|
|
aMemtblItems.IndexDefs.Clear;
|
|
|
|
|
aMemtblItems.AddIndex('Index1', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', []);
|
|
|
|
|
aMemtblItems.IndexName := 'Index1';
|
|
|
|
|
|
|
|
|
|
{ aMemtblItems.AddIndex('Indexordno', 'ordno', []);
|
|
|
|
|
aMemtblItems.IndexName := 'Indexordno';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
salses:=Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
while not Eof do
|
|
|
|
|
begin
|
|
|
|
|
ordno:=ordno+1;
|
|
|
|
|
aMemtblItems.Append;
|
|
|
|
|
aMemtblItems.FieldByName('ordno').AsInteger:=ordno;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD>').Value;
|
|
|
|
|
aMemtblItems.FieldByName('ί<>е<EFBFBD>λ').Value:=FieldByName('ί<>е<EFBFBD>λ').Value;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value:=FieldByName('<27><><EFBFBD>ᵥ<EFBFBD><E1B5A5>').Value;
|
|
|
|
|
aMemtblItems.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>״̬').Value:=FieldByName('<27><><EFBFBD><EFBFBD>״̬').Value;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FormatDateTime('YYYY-MM-DD hh:mm:sss',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime);
|
|
|
|
|
aMemtblItems.FieldByName('RMB<4D>ϼ<EFBFBD>').Value:=FieldByName('Ӧ<><D3A6>RMB').Value;
|
|
|
|
|
aMemtblItems.FieldByName('USD<53>ϼ<EFBFBD>').Value:=FieldByName('Ӧ<><D3A6>USD').Value;
|
|
|
|
|
aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FormatDateTime('YYYY-MM',FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ShowMessage(salses+' '+Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
|
|
|
|
|
if salses=Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString) then
|
|
|
|
|
Amt:=Amt+FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat
|
|
|
|
|
else Amt:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value:=Amt;
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=0;
|
|
|
|
|
|
|
|
|
|
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=0 then
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=0
|
|
|
|
|
else
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='') or (FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>') then
|
|
|
|
|
begin
|
|
|
|
|
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>=StrToInt(bsSkinEdit1.Text) then
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger-StrToInt(bsSkinEdit1.Text)
|
|
|
|
|
else aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>=StrToInt(bsSkinEdit2.Text) then
|
|
|
|
|
aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger-StrToInt(bsSkinEdit2.Text)
|
|
|
|
|
else aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>=0) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=30) then
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=0
|
|
|
|
|
else
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>30) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=60) then
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=1
|
|
|
|
|
else
|
|
|
|
|
if (aMemtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>60) and (memtblItems.FieldByName('ʵ<>ʳ<EFBFBD><CAB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger<=90) then
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=2
|
|
|
|
|
else aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:='<27><><EFBFBD><EFBFBD>3';
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger:=FieldByName('Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
|
|
|
|
|
lasttcxs:=0;
|
|
|
|
|
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value:=CalcProftAmt(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,planbegin,planend);
|
|
|
|
|
|
|
|
|
|
if aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value<>0 then
|
|
|
|
|
begin
|
|
|
|
|
if planbegin>(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin));
|
|
|
|
|
|
|
|
|
|
lastprofit:=aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').AsFloat-aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
|
|
|
|
|
|
|
|
|
|
lasttcxs:=CalcProftAmt(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,lastprofit,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,lastplanbegin,lastplanend);
|
|
|
|
|
if lasttcxs>0 then
|
|
|
|
|
begin
|
|
|
|
|
if (aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value-(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin))>0 then
|
|
|
|
|
lasttc:=lasttcxs*(aMemtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value-(aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD>').Value-planbegin));
|
|
|
|
|
end;
|
|
|
|
|
if (lasttcxs>0) and (lasttc>0) then
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value+strToFloat(formatFloat('0.00;-0.00;0',lasttc));
|
|
|
|
|
aMemtblItems.FieldByName('<27><>ע').Value:='ϵ<><CFB5>:'+FloatToStr(lasttcxs)+' <20><><EFBFBD><EFBFBD>:'+formatFloat('0.00;-0.00;0',lasttc);
|
|
|
|
|
end;
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=formatFloat('0.00;-0.00;0',aMemtblItems.FieldByName('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').Value*memtblItems.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value);
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
aMemtblItems.FieldByName('<27><><EFBFBD><EFBFBD>').Value:=0;
|
|
|
|
|
end;
|
|
|
|
|
aMemtblItems.Post;
|
|
|
|
|
salses:=Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
aMemtblItems.EnableControls;
|
|
|
|
|
aMemtblItems.Refresh;
|
|
|
|
|
Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.Creatememtbl;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_rp_sales_profit_tc.getleftstr(substr: String; leng: integer;
|
|
|
|
|
left: boolean=true): String;
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.FormShow(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
DateTimePicker1.Date:=Date;
|
|
|
|
|
loadreggrid(dxdbgrid2,false,caption+'2');
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.bsSkinButton1Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
grid_save_xls(dxdbgrid5);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.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_tc.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_tc.N14Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
update_grid_view_all(dxdbgrid2);
|
|
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_sales_profit_tc.bsSkinButton4Click(Sender: TObject);
|
|
|
|
|
var AdoQuery1:TAdoQuery;
|
|
|
|
|
begin
|
|
|
|
|
kbmMemTableCLF.Close;
|
|
|
|
|
kbmMemTableCLF.EmptyTable;
|
|
|
|
|
kbmMemTableCLF.Open;
|
|
|
|
|
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
|
|
|
|
|
kbmMemTableCLF.Append;
|
|
|
|
|
kbmMemTableCLF.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
|
|
|
|
|
kbmMemTableCLF.FieldByName('<27><><EFBFBD>÷<EFBFBD>').AsFloat:=0;
|
|
|
|
|
kbmMemTableCLF.Post;
|
|
|
|
|
Next;
|
|
|
|
|
end;
|
|
|
|
|
finally
|
|
|
|
|
Free;
|
|
|
|
|
end;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|