You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3325 lines
133 KiB
Plaintext

This file contains ambiguous Unicode characters!

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

unit u_rp_sales_profit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, dxExEdtr, RxMemDS, DB, ADODB, Menus, XPMenu, bsSkinCtrls,
dxDBGrid, dxDBTLCl, dxGrClms, dxTL, dxDBCtrl, dxCntner, ComCtrls,DateUtils,
bsSkinTabs, ExtCtrls, StdCtrls, Mask, wwdbedit, Wwdotdot, Wwdbcomb,
kbmMemTable, kbmMemBinaryStreamFormat, wwdbdatetimepicker, RxLookup,
bsSkinBoxCtrls,inifiles;
type
Tfrm_rp_sales_profit = class(TForm)
Panel1: TPanel;
bsSkinPageControl1: TbsSkinPageControl;
bsSkinTabSheet1: TbsSkinTabSheet;
bsSkinTabSheet4: TbsSkinTabSheet;
bsSkinTabSheet6: TbsSkinTabSheet;
bsSkinPageControl2: TbsSkinPageControl;
bsSkinTabSheet11: TbsSkinTabSheet;
bsSkinTabSheet13: TbsSkinTabSheet;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column5: TdxDBGridMaskColumn;
dxDBGrid1Column3: TdxDBGridMaskColumn;
dxDBGrid1Column4: TdxDBGridMaskColumn;
dxDBGrid1Column6: TdxDBGridDateColumn;
dxDBGrid1Column7: TdxDBGridMaskColumn;
dxDBGrid1Column8: TdxDBGridMaskColumn;
dxDBGrid1Column9: TdxDBGridMaskColumn;
dxDBGrid1Column10: TdxDBGridMaskColumn;
dxDBGrid1Column11: TdxDBGridMaskColumn;
dxDBGrid1Column24: TdxDBGridMaskColumn;
dxDBGrid1Column25: TdxDBGridMaskColumn;
dxDBGrid1Column26: TdxDBGridDateColumn;
dxDBGrid1Column31: TdxDBGridMaskColumn;
dxDBGrid1Column54: TdxDBGridMaskColumn;
dxDBGrid1Column55: TdxDBGridMaskColumn;
dxDBGrid1Column56: TdxDBGridColumn;
dxDBGrid1Column57: TdxDBGridColumn;
dxDBGrid11: TdxDBGridMaskColumn;
dxDBGrid12: TdxDBGridMaskColumn;
dxDBGrid13: TdxDBGridMaskColumn;
dxDBGrid14: TdxDBGridMaskColumn;
dxDBGrid15: TdxDBGridMaskColumn;
dxDBGrid16: TdxDBGridMaskColumn;
dxDBGrid17: TdxDBGridMaskColumn;
dxDBGrid18: TdxDBGridMaskColumn;
dxDBGrid19: TdxDBGridMaskColumn;
dxDBGrid110: TdxDBGridMaskColumn;
dxDBGrid1Column80: TdxDBGridMaskColumn;
dxDBGrid1TEU: TdxDBGridMaskColumn;
dxDBGrid1Column82: TdxDBGridMaskColumn;
dxDBGrid1Column83: TdxDBGridMaskColumn;
dxDBGrid1Column84: TdxDBGridDateColumn;
dxDBGrid1Column89: TdxDBGridMaskColumn;
dxDBGrid1Column90: TdxDBGridMaskColumn;
dxDBGrid1Column92: TdxDBGridMaskColumn;
dxDBGrid1Column85: TdxDBGridMaskColumn;
dxDBGrid1Column87: TdxDBGridMaskColumn;
dxDBGrid1Column86: TdxDBGridMaskColumn;
dxDBGrid1USD: TdxDBGridColumn;
dxDBGrid1RMB: TdxDBGridColumn;
dxDBGrid1Column102: TdxDBGridColumn;
dxDBGrid1Column105: TdxDBGridColumn;
dxDBGrid1Column108: TdxDBGridColumn;
dxDBGrid1Column111: TdxDBGridColumn;
dxDBGrid1Column114: TdxDBGridColumn;
dxDBGrid1Column115: TdxDBGridColumn;
dxDBGrid1Column116: TdxDBGridColumn;
dxDBGrid1Column117: TdxDBGridMaskColumn;
dxDBGrid7: TdxDBGrid;
dxDBGridMaskColumn93: TdxDBGridMaskColumn;
dxDBGrid1Column68: TdxDBGridColumn;
dxDBGrid1Column69: TdxDBGridColumn;
PopupMenu2: TPopupMenu;
N10: TMenuItem;
N11: TMenuItem;
N14: TMenuItem;
N13: TMenuItem;
N12: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
XPMenu2: TXPMenu;
bsSkinPanel1: TbsSkinPanel;
dxDBGrid3: TdxDBGrid;
dxDBGridMaskColumn39: TdxDBGridMaskColumn;
dxDBGridMaskColumn42: TdxDBGridMaskColumn;
dxDBGridMaskColumn47: TdxDBGridMaskColumn;
dxDBGridDateColumn7: TdxDBGridDateColumn;
dxDBGridMaskColumn75: TdxDBGridMaskColumn;
t_salepriftset: TADOQuery;
ds1: TDataSource;
kbmThreadDataSet1: TkbmThreadDataSet;
kbmBinaryStreamFormat1: TkbmBinaryStreamFormat;
memtblrpt_total: TkbmMemTable;
kbmMemTable1: TkbmMemTable;
kbmMemTable2: TkbmMemTable;
P_SUM: TkbmMemTable;
DataSource1: TDataSource;
DataSource2: TDataSource;
DataSource3: TDataSource;
DataSource4: TDataSource;
dxDBGrid1Column51: TdxDBGridColumn;
dxDBGrid1Column52: TdxDBGridColumn;
dxDBGrid1Column53: TdxDBGridColumn;
dxDBGrid1Column58: TdxDBGridColumn;
dxDBGrid1Column59: TdxDBGridColumn;
dxDBGrid1Column60: TdxDBGridColumn;
dxDBGrid1Column61: TdxDBGridColumn;
dxDBGrid3Column57: TdxDBGridColumn;
dxDBGrid7Column12: TdxDBGridColumn;
dxDBGrid7Column13: TdxDBGridColumn;
dxDBGrid7Column14: TdxDBGridColumn;
dxDBGrid7Column15: TdxDBGridColumn;
dxDBGrid7Column16: TdxDBGridColumn;
dxDBGrid7Column17: TdxDBGridColumn;
dxDBGrid7Column18: TdxDBGridColumn;
dxDBGrid7Column19: TdxDBGridColumn;
dxDBGrid7Column20: TdxDBGridColumn;
dxDBGrid1Column62: TdxDBGridColumn;
dxDBGrid9: TdxDBGrid;
dxDBGridMaskColumn77: TdxDBGridMaskColumn;
dxDBGridColumn27: TdxDBGridColumn;
dxDBGridColumn28: TdxDBGridColumn;
dxDBGridColumn29: TdxDBGridColumn;
dxDBGridColumn30: TdxDBGridColumn;
dxDBGridColumn31: TdxDBGridColumn;
dxDBGridColumn32: TdxDBGridColumn;
dxDBGridColumn33: TdxDBGridColumn;
dxDBGridColumn34: TdxDBGridColumn;
dxDBGridColumn35: TdxDBGridColumn;
dxDBGridColumn36: TdxDBGridColumn;
dxDBGridColumn37: TdxDBGridColumn;
dxDBGridColumn38: TdxDBGridColumn;
dxDBGridColumn39: TdxDBGridColumn;
dxDBGridColumn40: TdxDBGridColumn;
dxDBGridColumn41: TdxDBGridColumn;
dxDBGridColumn42: TdxDBGridColumn;
dxDBGridColumn43: TdxDBGridColumn;
dxDBGridColumn44: TdxDBGridColumn;
dxDBGridColumn45: TdxDBGridColumn;
dxDBGridColumn56: TdxDBGridColumn;
bskntbsht1: TbsSkinTabSheet;
dxDBGrid4: TdxDBGrid;
dxDBGridMaskColumn78: TdxDBGridMaskColumn;
dxDBGridMaskColumn79: TdxDBGridMaskColumn;
dxDBGridMaskColumn80: TdxDBGridMaskColumn;
dxDBGridDateColumn11: TdxDBGridDateColumn;
dxDBGridMaskColumn81: TdxDBGridMaskColumn;
dxDBGridMaskColumn82: TdxDBGridMaskColumn;
dxDBGridMaskColumn83: TdxDBGridMaskColumn;
dxDBGridMaskColumn84: TdxDBGridMaskColumn;
dxDBGridMaskColumn85: TdxDBGridMaskColumn;
dxDBGridMaskColumn86: TdxDBGridMaskColumn;
dxDBGridMaskColumn87: TdxDBGridMaskColumn;
dxDBGridDateColumn12: TdxDBGridDateColumn;
dxDBGridDateColumn13: TdxDBGridDateColumn;
dxDBGridDateColumn14: TdxDBGridDateColumn;
dxDBGridMaskColumn88: TdxDBGridMaskColumn;
dxDBGridMaskColumn89: TdxDBGridMaskColumn;
dxDBGridMaskColumn90: TdxDBGridMaskColumn;
dxDBGridMaskColumn91: TdxDBGridMaskColumn;
dxDBGridMaskColumn92: TdxDBGridMaskColumn;
dxDBGridMaskColumn94: TdxDBGridMaskColumn;
dxDBGridColumn57: TdxDBGridColumn;
dxDBGridColumn58: TdxDBGridColumn;
dxDBGridMaskColumn95: TdxDBGridMaskColumn;
dxDBGridMaskColumn96: TdxDBGridMaskColumn;
dxDBGridMaskColumn97: TdxDBGridMaskColumn;
dxDBGridMaskColumn98: TdxDBGridMaskColumn;
dxDBGridMaskColumn99: TdxDBGridMaskColumn;
dxDBGridMaskColumn100: TdxDBGridMaskColumn;
dxDBGridMaskColumn101: TdxDBGridMaskColumn;
dxDBGridMaskColumn102: TdxDBGridMaskColumn;
dxDBGridMaskColumn103: TdxDBGridMaskColumn;
dxDBGridMaskColumn104: TdxDBGridMaskColumn;
dxDBGridMaskColumn105: TdxDBGridMaskColumn;
dxDBGridMaskColumn106: TdxDBGridMaskColumn;
dxDBGridMaskColumn107: TdxDBGridMaskColumn;
dxDBGridMaskColumn108: TdxDBGridMaskColumn;
dxDBGridDateColumn15: TdxDBGridDateColumn;
dxDBGridMaskColumn109: TdxDBGridMaskColumn;
dxDBGridMaskColumn110: TdxDBGridMaskColumn;
dxDBGridMaskColumn111: TdxDBGridMaskColumn;
dxDBGridMaskColumn112: TdxDBGridMaskColumn;
dxDBGridMaskColumn113: TdxDBGridMaskColumn;
dxDBGridMaskColumn114: TdxDBGridMaskColumn;
dxDBGridMaskColumn115: TdxDBGridMaskColumn;
dxDBGridColumn59: TdxDBGridColumn;
dxDBGridColumn60: TdxDBGridColumn;
dxDBGridColumn61: TdxDBGridColumn;
dxDBGridColumn62: TdxDBGridColumn;
dxDBGridColumn63: TdxDBGridColumn;
dxDBGridColumn64: TdxDBGridColumn;
dxDBGridColumn65: TdxDBGridColumn;
dxDBGridColumn66: TdxDBGridColumn;
dxDBGridColumn67: TdxDBGridColumn;
dxDBGridMaskColumn116: TdxDBGridMaskColumn;
dxDBGridColumn68: TdxDBGridColumn;
dxDBGridColumn69: TdxDBGridColumn;
dxDBGridColumn70: TdxDBGridColumn;
dxDBGridColumn71: TdxDBGridColumn;
kbmMemTable4: TkbmMemTable;
DataSource5: TDataSource;
dxDBGrid7Column22: TdxDBGridColumn;
P_SUMField: TStringField;
P_SUMField2: TFloatField;
P_SUMField3: TFloatField;
P_SUMField4: TFloatField;
P_SUMField5: TFloatField;
P_SUMField6: TFloatField;
P_SUMField7: TFloatField;
P_SUMField8: TFloatField;
P_SUMField9: TFloatField;
P_SUMField10: TFloatField;
P_SUMField11: TFloatField;
P_SUMField12: TFloatField;
P_SUMField13: TFloatField;
P_SUMField14: TFloatField;
P_SUMField15: TFloatField;
P_SUMField16: TFloatField;
bskntbsht2: TbsSkinTabSheet;
bsSkinPageControl3: TbsSkinPageControl;
bskntbshtpg1: TbsSkinTabSheet;
bskntbsht3: TbsSkinTabSheet;
dxDBGrid2: TdxDBGrid;
dxDBGridMaskColumn32: TdxDBGridMaskColumn;
dxDBGridMaskColumn33: TdxDBGridMaskColumn;
dxDBGridMaskColumn34: TdxDBGridMaskColumn;
dxDBGridMaskColumn35: TdxDBGridMaskColumn;
dxDBGridMaskColumn36: TdxDBGridMaskColumn;
dxDBGridMaskColumn37: TdxDBGridMaskColumn;
dxDBGridColumn10: TdxDBGridColumn;
dxDBGridColumn11: TdxDBGridColumn;
dxDBGridColumn47: TdxDBGridColumn;
memtblDetail: TkbmMemTable;
StringField1: TStringField;
FloatField1: TFloatField;
FloatField2: TFloatField;
FloatField3: TFloatField;
FloatField4: TFloatField;
FloatField5: TFloatField;
FloatField7: TFloatField;
FloatField8: TFloatField;
FloatField15: TFloatField;
memtblDetailField: TStringField;
memtblDetailField2: TDateTimeField;
memtblDetailField3: TStringField;
memtblDetailField4: TStringField;
memtblDetailField5: TDateTimeField;
memtblDetailField6: TStringField;
memtblDetailField7: TFloatField;
memtblLX: TkbmMemTable;
StringField2: TStringField;
StringField3: TStringField;
DateTimeField1: TDateTimeField;
DateTimeField2: TDateTimeField;
StringField6: TStringField;
FloatField10: TFloatField;
FloatField11: TFloatField;
FloatField19: TFloatField;
memtblLXField: TIntegerField;
memtblLXField2: TFloatField;
memtblDetailField8: TStringField;
memtblDetailField9: TStringField;
memtblLXField3: TStringField;
memtblLXField4: TStringField;
DataSource6: TDataSource;
DataSource7: TDataSource;
dxDBGrid2Column11: TdxDBGridColumn;
dxDBGrid2Column12: TdxDBGridColumn;
dxDBGrid2Column13: TdxDBGridColumn;
dxDBGrid2Column14: TdxDBGridColumn;
dxDBGrid2Column15: TdxDBGridColumn;
dxDBGrid2Column16: TdxDBGridColumn;
dxDBGrid2Column17: TdxDBGridColumn;
dxDBGrid5: TdxDBGrid;
dxDBGridMaskColumn1: TdxDBGridMaskColumn;
dxDBGridMaskColumn2: TdxDBGridMaskColumn;
dxDBGridMaskColumn3: TdxDBGridMaskColumn;
dxDBGridColumn1: TdxDBGridColumn;
dxDBGridColumn2: TdxDBGridColumn;
dxDBGridColumn3: TdxDBGridColumn;
dxDBGridColumn5: TdxDBGridColumn;
dxDBGridColumn6: TdxDBGridColumn;
dxDBGridColumn8: TdxDBGridColumn;
memtblDetailField10: TStringField;
memtblDetailField11: TStringField;
memtblDetailField12: TDateTimeField;
memtblDetailField13: TDateTimeField;
memtblLXField5: TFloatField;
P_SUMField17: TFloatField;
dxDBGrid2Column18: TdxDBGridColumn;
dxDBGrid2Column19: TdxDBGridColumn;
P_SUMField18: TFloatField;
dxDBGrid7Column21: TdxDBGridColumn;
dxDBGrid3Column7: TdxDBGridColumn;
dxDBGrid3Column8: TdxDBGridColumn;
dxDBGrid3Column9: TdxDBGridColumn;
dxDBGrid3Column10: TdxDBGridColumn;
dxDBGrid3Column11: TdxDBGridColumn;
dxDBGrid3Column12: TdxDBGridColumn;
dxDBGrid3Column13: TdxDBGridColumn;
dxDBGrid3Column14: TdxDBGridColumn;
dxDBGrid3Column15: TdxDBGridColumn;
kbmMemTable2Field: TStringField;
kbmMemTable2Field2: TStringField;
kbmMemTable2Field3: TStringField;
kbmMemTable2Field4: TDateField;
kbmMemTable2Field5: TStringField;
kbmMemTable2USD: TFloatField;
kbmMemTable2RMB: TFloatField;
kbmMemTable2Field6: TFloatField;
kbmMemTable2USD2: TFloatField;
kbmMemTable2RMB2: TFloatField;
kbmMemTable2Field7: TFloatField;
kbmMemTable2USD3: TFloatField;
kbmMemTable2RMB3: TFloatField;
kbmMemTable2Field8: TFloatField;
kbmMemTable2Field9: TFloatField;
kbmMemTable2Field10: TStringField;
kbmMemTable2USD4: TFloatField;
kbmMemTable2RMB4: TFloatField;
kbmMemTable2Field11: TFloatField;
dxDBGrid3Column16: TdxDBGridColumn;
dxDBGrid3Column17: TdxDBGridColumn;
dxDBGrid3Column18: TdxDBGridColumn;
memtblDetailField14: TFloatField;
memtblDetailField15: TFloatField;
memtblDetailField16: TFloatField;
memtblDetailField17: TFloatField;
Saleprofitsum: TADOQuery;
dxDBGrid2Column20: TdxDBGridColumn;
dxDBGrid2Column21: TdxDBGridColumn;
dxDBGrid2Column22: TdxDBGridColumn;
dxDBGrid2Column23: TdxDBGridColumn;
bsSkinRadioGroup1: TbsSkinRadioGroup;
memtblDetailField18: TDateField;
dxDBGrid2Column24: TdxDBGridColumn;
dxDBGrid2Column25: TdxDBGridColumn;
memtblDetailField19: TStringField;
memtblDetailField20: TStringField;
dxDBGrid2Column26: TdxDBGridColumn;
memtblDetailField21: TIntegerField;
dxDBGrid2Column27: TdxDBGridColumn;
dxDBGrid2Column28: TdxDBGridColumn;
dxDBGrid2Column29: TdxDBGridColumn;
memtblDetailRMB: TFloatField;
memtblDetailUSD: TFloatField;
memtblDetailField22: TFloatField;
dxDBGrid2Column30: TdxDBGridColumn;
kbmMemTable3: TkbmMemTable;
kbmMemTable3Field: TStringField;
kbmMemTable3Field2: TFloatField;
memtblDetailField23: TStringField;
dxDBGrid2Column31: TdxDBGridColumn;
memtblDetailField24: TStringField;
dxDBGrid2Column32: TdxDBGridColumn;
dxDBGrid2Column33: TdxDBGridCheckColumn;
memtblDetailField25: TIntegerField;
memtblDetailField26: TStringField;
dxDBGrid2Column34: TdxDBGridColumn;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton10: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinLabel1: TbsSkinLabel;
bsSkinEdit1: TbsSkinEdit;
Label4: TLabel;
bsSkinComboBox2: TbsSkinComboBox;
Label14: TLabel;
Label22: TLabel;
RxDBLookupCombo3: TRxDBLookupCombo;
RxDBLookupCombo10: TRxDBLookupCombo;
Label3: TLabel;
wwDBComboBox1: TwwDBComboBox;
bsSkinComboBox1: TbsSkinComboBox;
Label1: TLabel;
Label2: TLabel;
wwDBComboBox20: TwwDBComboBox;
RxDBLookupCombo2: TRxDBLookupCombo;
Label9: TLabel;
memtblDetailField27: TStringField;
dxDBGrid2Column35: TdxDBGridColumn;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
bsSkinTabSheet5: TbsSkinTabSheet;
dxDBGrid6: TdxDBGrid;
kbmtc: TkbmMemTable;
kbmtc1: TDataSource;
kbmqc: TkbmMemTable;
kbmqc1: TDataSource;
kbmtcField: TStringField;
kbmtcField2: TFloatField;
kbmtcField3: TFloatField;
kbmqcField: TStringField;
kbmqcField2: TStringField;
kbmqcField3: TStringField;
kbmqcField4: TStringField;
kbmqcField5: TDateField;
kbmqcField6: TDateField;
kbmqcField7: TFloatField;
kbmqcField8: TFloatField;
dxDBGrid8: TdxDBGrid;
dxDBGridColumn4: TdxDBGridColumn;
dxDBGridColumn7: TdxDBGridColumn;
dxDBGridColumn9: TdxDBGridColumn;
dxDBGrid6Column1: TdxDBGridColumn;
dxDBGrid6Column2: TdxDBGridColumn;
dxDBGrid6Column3: TdxDBGridColumn;
dxDBGrid6Column4: TdxDBGridColumn;
kbmqcField9: TStringField;
dxDBGrid6Column5: TdxDBGridColumn;
dxDBGrid6Column6: TdxDBGridColumn;
dxDBGrid6Column7: TdxDBGridColumn;
dxDBGrid6Column8: TdxDBGridColumn;
kbmqcField10: TIntegerField;
dxDBGrid6Column9: TdxDBGridColumn;
kbmqcField11: TIntegerField;
dxDBGrid6Column10: TdxDBGridColumn;
kbmqcField12: TFloatField;
dxDBGrid6Column11: TdxDBGridColumn;
kbmtcUSD: TFloatField;
kbmtcRMB: TFloatField;
kbmtcField4: TFloatField;
kbmtcField5: TStringField;
dxDBGrid8Column4: TdxDBGridColumn;
dxDBGrid8Column5: TdxDBGridColumn;
dxDBGrid8Column6: TdxDBGridColumn;
dxDBGrid8Column7: TdxDBGridColumn;
kbmtcField6: TFloatField;
dxDBGrid8Column8: TdxDBGridColumn;
kbmqcField13: TStringField;
dxDBGrid6Column12: TdxDBGridColumn;
kbmqcUSD: TFloatField;
kbmqcRMB: TFloatField;
PopupMenu1: TPopupMenu;
MenuItem7: TMenuItem;
bsSkinPanel2: TbsSkinPanel;
wwDBDateTimePicker1: TwwDBDateTimePicker;
wwDBDateTimePicker2: TwwDBDateTimePicker;
Label5: TLabel;
Label6: TLabel;
kbmqcField14: TDateField;
kbmqcRMB2: TFloatField;
kbmqcUSD2: TFloatField;
kbmqcField15: TFloatField;
dxDBGrid6Column15: TdxDBGridColumn;
dxDBGrid6Column16: TdxDBGridColumn;
dxDBGrid6Column17: TdxDBGridColumn;
dxDBGrid6Column18: TdxDBGridColumn;
bsSkinButton3: TbsSkinButton;
kbmqcField16: TStringField;
dxDBGrid6Column19: TdxDBGridColumn;
N1: TMenuItem;
Label7: TLabel;
Edit1: TEdit;
Label8: TLabel;
tex: TbsSkinButton;
Edit2: TEdit;
procedure bsSkinButton5Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure dxDBGrid2DblClick(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure dxDBGrid2CustomDraw(Sender: TObject; ACanvas: TCanvas;
ARect: TRect; ANode: TdxTreeListNode; AColumn: TdxDBTreeListColumn;
const AText: String; AFont: TFont; var AColor: TColor; ASelected,
AFocused: Boolean; var ADone: Boolean);
procedure MenuItem7Click(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure texClick(Sender: TObject);
private
function GetSALEprofit(SALE:string;aMonth:Integer;profit:Double;tuo:boolean):Double;
procedure GetProfit;
procedure GetProfitall;
procedure Getlx;
procedure Getcq;
procedure GetProfitSum;
procedure GetProfitSumall;
procedure GetProfittcLx;
function GetBetwMonth(aBe,aEe:TDate):Integer;
function issameMonth(aBe,aEe:TDate):Boolean;
{ Private declarations }
public
bdatestr:String;
{ Public declarations }
procedure UpdateBsProfit(bstype,bsno:String;fee:integer);
function CalcProftAmttc(ProftAmt:Double;Employee:string):Double;
function getzq(cust: string;aDate:TDateTime):TDateTime;
function CalcProftAmtqx(ProftAmt:Double;Employee:string):Double;
function getzqtype(cust: string;aDate:TDateTime):string;
end;
var
frm_rp_sales_profit: Tfrm_rp_sales_profit;
rp_rp_total_open:boolean;
implementation
uses u_main, my_sys_function, u_rp_query, u_sys_progress,
u_data_share;
{$R *.dfm}
function Tfrm_rp_sales_profit.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.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.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;
function Tfrm_rp_sales_profit.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.GetProfittcLx;
var
betd,eetd:TDate;
aquery,bquery:TADOQuery;
str:String;
begin
if bsSkinRadioGroup1.ItemIndex=1 then
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'
else
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
kbmtc.EmptyTable;
kbmtc.Open;
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
aQuery:=CreateAdoQuery;
bQuery:=CreateAdoQuery;
with aQuery do
try
Close;SQL.Clear;
if bsSkinCheckRadioBox1.Checked then //<2F><><EFBFBD><EFBFBD>RMB,<2C><><EFBFBD><EFBFBD>USD
str:='select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,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 <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=<3D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and '
else
str:='select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,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 RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
case bsSkinComboBox1.itemindex of
1: str:=Str+' and (fee2=0 or fee2 is null) ';
2: str:=Str+' and (fee2=1) ';
end;
case bsSkinComboBox2.itemindex of
1: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''¼<><C2BC>״̬''';
2: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''';
end;
SQL.Add(str);
SQL.Add(' group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Open;First;
while not eof do
begin
kbmtc.insert;
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('<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.00;-0.00;',CalcProftAmttc(FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString));
kbmtc.Post;
Next;
end;
///
{
Close;SQL.Clear;
str:='select <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><E1B5A5><>б<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 ';
str:=Str+' '+bdatestr+'>='+''''+DateToStr(wwDBDateTimePicker1.Date)+'''';
str:=Str+' and '+bdatestr+'<='+''''+DateToStr(wwDBDateTimePicker2.Date)+'''';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
case bsSkinComboBox1.itemindex of
1: str:=Str+' and (fee2=0 or fee2 is null) ';
2: str:=Str+' and (fee2=1) ';
end;
case bsSkinComboBox2.itemindex of
1: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''¼<><C2BC>״̬''';
2: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''';
end;
SQL.Add(str);
SQL.Add(' and ί<>е<EFBFBD>λ in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales)');
SQL.Add(' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Open;First;
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('<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('Ӧ<><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;
if kbmtc.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Trim(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString),[]) then
begin
kbmtc.Edit;
kbmtc.FieldByName('<27><>Ϣ').AsFloat:=kbmtc.FieldByName('<27><>Ϣ').AsFloat+kbmqc.FieldByName('<27><>Ϣ').AsFloat;
kbmtc.Post;
end;
try
kbmqc.Post;
except
on e:Exception do
begin
ShowMessage(e.Message);
end;
end;
end;
Next;
end;
}
finally
FreeAndNil(aquery);
end;
end;
procedure Tfrm_rp_sales_profit.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.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
function Tfrm_rp_sales_profit.GetSALEprofit(SALE:string;aMonth:Integer;profit:Double;tuo:boolean):Double;
var
aQuery:TADOQuery;
BL:Double;
begin
BL:=0.00;
if profit=0 then begin
result:=0.0;
exit;
end;
aQuery:=CreateAdoQuery;
try
with aQuery do begin
Close;SQL.Clear;
SQL.Add('Select * from t_crm_salesproftSet where <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>='+inttostr(aMonth)+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=(select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+SALE+''') Order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ASC');
Open;
first;
while not eof do
begin
if (Profit>FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat) and (Profit<=FieldByName('<27><><EFBFBD><EFBFBD>ֹ').AsFloat) then
begin
if tuo then
begin
BL:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat;
end
else
begin
if aMonth<>0 then
BL:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat
else
BL:=FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat;
end;
end;
Next;
end;
Result:=BL;
end;
finally
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_sales_profit.FormClose(Sender: TObject;
var Action: TCloseAction);
var inifile1:Tinifile;
begin
savereggrid(dxdbgrid1,caption+'1');
savereggrid(dxdbgrid2,caption+'2');
savereggrid(dxdbgrid3,caption+'3');
savereggrid(dxdbgrid9,caption+'9');
savereggrid(dxdbgrid6,caption+'6');
frm_rp_sales_profit.Hide;
frm_rp_sales_profit.ManualFloat(frm_rp_sales_profit.BoundsRect );
frm_main.freeTabs('frm_rp_sales_profit');
action:=cafree;
frm_rp_sales_profit:=nil;
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('TC','DAYS',bsSkinEdit1.text);
inifile1.free;
end;
procedure Tfrm_rp_sales_profit.FormShow(Sender: TObject);
var
bYear,bMonth,bDate:Word;
inifile1:Tinifile;
begin
DecodeDate(incmonth(Now,-5),bYear,bMonth,bDate);
wwDBComboBox20.Text:=IntToStr(bYear);
wwDBComboBox20.Text:=IntToStr(YearOf(date));
wwDBComboBox1.Text:=IntToStr(bMonth);
loadreggrid(dxdbgrid1,true,caption+'1');
loadreggrid(dxdbgrid2,true,caption+'2');
loadreggrid(dxdbgrid3,false,caption+'3');
loadreggrid(dxdbgrid4,false,caption+'4');
loadreggrid(dxdbgrid9,false,caption+'9');
loadreggrid(dxdbgrid6,false,caption+'6');
wwDBDateTimePicker1.Date:=Date;
wwDBDateTimePicker2.Date:=Date;
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
bsSkinEdit1.text:=inifile1.Readstring('TC','DAYS','0');
inifile1.free;
end;
procedure Tfrm_rp_sales_profit.bsSkinButton9Click(Sender: TObject);
begin
sys_print('ҵ<><D2B5><EFBFBD>ۺ<EFBFBD>ͳ<EFBFBD><CDB3>',2,nil,nil,nil,DataSource4,DataSource6,DataSource7,DataSource3,kbmtc1,kbmqc1,nil,nil);
end;
procedure Tfrm_rp_sales_profit.N10Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
update_grid_view_no(dxdbgrid2);
exit;
end;
if bskntbsht3.Showing then
begin
update_grid_view_no(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
update_grid_view_no(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid_view_no(dxdbgrid4);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid_view_no(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
update_grid_view_no(dxdbgrid7);
exit;
end;
end;
end;
procedure Tfrm_rp_sales_profit.N14Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
update_grid_view_all(dxdbgrid2);
exit;
end;
if bskntbsht3.Showing then
begin
update_grid_view_all(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
update_grid_view_all(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid_view_all(dxdbgrid4);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid_view_all(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
update_grid_view_all(dxdbgrid7);
exit;
end;
end;
end;
procedure Tfrm_rp_sales_profit.N12Click(Sender: TObject);
begin
{
if bsSkinTabSheet1.Showing then
begin
if bsSkinTabSheet11.Showing then
begin
update_grid(dxdbgrid1,108);
exit;
end;
if bsSkinTabSheet12.Showing then
begin
update_grid(dxdbgrid2,109);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
update_grid(dxdbgrid3,110);
exit;
end;
if bskntbsht1.Showing then
begin
update_grid(dxdbgrid4,111);
exit;
end;
end;
if bsSkinTabSheet4.Showing then
begin
update_grid(dxdbgrid7,112);
exit;
end;
if bsSkinTabSheet6.Showing then
begin
update_grid(dxdbgrid9,95);
exit;
end;
}
end;
procedure Tfrm_rp_sales_profit.N16Click(Sender: TObject);
begin
if bsSkinTabSheet1.Showing then begin
if bskntbsht2.Showing then
begin
if bskntbshtpg1.Showing then
begin
grid_save_xls(dxdbgrid2);
exit;
end;
if bskntbsht3.Showing then
begin
grid_save_xls(dxdbgrid5);
exit;
end;
end;
if bsSkinTabSheet11.Showing then
begin
grid_save_xls(dxdbgrid1);
exit;
end;
if bskntbsht1.Showing then
begin
grid_save_xls(dxdbgrid4);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
grid_save_xls(dxdbgrid3);
exit;
end;
end else begin
if bsSkinTabSheet4.Showing then
begin
grid_save_xls(dxdbgrid7);
exit;
end;
end;
{
if bsSkinTabSheet1.Showing then
begin
if bsSkinTabSheet11.Showing then
begin
grid_save_xls(dxdbgrid1);
exit;
end;
if bsSkinTabSheet12.Showing then
begin
grid_save_xls(dxdbgrid2);
exit;
end;
if bsSkinTabSheet13.Showing then
begin
grid_save_xls(dxdbgrid3);
exit;
end;
if bskntbsht1.Showing then
begin
grid_save_xls(dxdbgrid4);
exit;
end;
end;
if bsSkinTabSheet4.Showing then
begin
grid_save_xls(dxdbgrid7);
exit;
end;
if bsSkinTabSheet6.Showing then
begin
grid_save_xls(dxdbgrid9);
exit;
end;
}
end;
procedure Tfrm_rp_sales_profit.bsSkinButton10Click(Sender: TObject);
var
betd,eetd:TDate;
aquery:TADOQuery;
str:String;
begin
if bsSkinCheckRadioBox2.Checked then
begin
GetProfittcLx;
end
else
begin
if bsSkinRadioGroup1.ItemIndex=1 then
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'
else
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
//showmessage('1');
memtblrpt_total.EmptyTable;
kbmMemTable2.EmptyTable;
kbmMemTable1.EmptyTable;
kbmMemTable4.EmptyTable;
memtblDetail.EmptyTable;
memtblLX.EmptyTable;
P_SUM.EmptyTable;
//showmessage('2');
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
aQuery:=CreateAdoQuery;
try
Saleprofitsum.Close;
Saleprofitsum.sql.clear;
Saleprofitsum.SQL.Add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD> from v_op_bscard where '+bdatestr+'>='''+DateToStr(betd)+''' and '+bdatestr+'<='''+DateToStr(eetd)+''' group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
// showmessage(Saleprofitsum.SQL.text);
Saleprofitsum.Open;
// showmessage('30');
with aQuery do begin
Close;SQL.Clear;
if bsSkinCheckRadioBox1.Checked then
str:='select * from v_op_bscard_MAX where <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=<3D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and '
else
str:='select * 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 RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
case bsSkinComboBox1.itemindex of
1: str:=Str+' and (fee2=0 or fee2 is null) ';
2: str:=Str+' and (fee2=1) ';
end;
case bsSkinComboBox2.itemindex of
1: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''¼<><C2BC>״̬''';
2: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''';
end;
str:=Str+' and ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
try
// showmessage('31');
Open;
// showmessage('32');
memtblrpt_total.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
except
on e:exception do
begin
SHOWMESSAGE(E.Message);
end;
end;
//showmessage('3');
Close;SQL.Clear;
str:='select *,ë<><C3AB><EFBFBD><EFBFBD>*0.05 as <20><><EFBFBD><EFBFBD> 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 RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' and ί<>е<EFBFBD>λ in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
try
Open;
kbmMemTable4.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
except
on e:exception do
begin
SHOWMESSAGE(E.Message);
end;
end;
//showmessage('4');
Close;SQL.Clear;
str:='select v.<2E><><EFBFBD><EFBFBD><E1B5A5>,sum(fee.<2E><><EFBFBD><EFBFBD>) <20><><EFBFBD><EFBFBD> from v_op_bscard_MAX v';
str:=Str+' Left join t_ch_fee fee on v.<2E><><EFBFBD><EFBFBD>=fee.<2E><><EFBFBD><EFBFBD> and fee.<2E><><EFBFBD><EFBFBD>=''<27><>'' ';
str:=Str+' where fee.<2E>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> in (''<27><><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>'',''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ'',''<27><><EFBFBD>DZ<EFBFBD><C7B1><EFBFBD>0000'',''<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>'') ';
str:=Str+' and v.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and ';
// str:=Str+' and v.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and v.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=''<27><>ͨ<EFBFBD><CDA8>'' and ';
str:=Str+' '+bdatestr+'>='+''''+DateToStr(betd)+'''';
str:=Str+' and '+bdatestr+'<='+''''+DateToStr(eetd)+'''';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and v.ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and v.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' Group by v.<2E><><EFBFBD><EFBFBD><E1B5A5>';
SQL.Add(str);
try
Open;
kbmMemTable3.EmptyTable;
kbmMemTable3.LoadFromDataSet(aQuery,[mtcpostructure,mtcpoProperties,mtcpoFieldIndex]);
except
on e:exception do
begin
SHOWMESSAGE(E.Message);
end;
end;
end;
//showmessage('5');
if bsSkinCheckRadioBox1.Checked then begin
GetProfit;
try
Getlx;
Getcq;
GetProfitSum;
except
on e:exception do
begin
SHOWMESSAGE(E.Message);
end;
end;
end else begin
GetProfitall;
Getlx;
try
Getcq;
except
on e:exception do
begin
SHOWMESSAGE(E.Message);
end;
end;
GetProfitSumall;
end;
finally
FreeAndNil(aquery);
end;
end;
end;
procedure Tfrm_rp_sales_profit.GetProfit;
var
aQuery,aQuery3:TADOQuery;
aStlDate:TDate;
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
btMonth,l,d:Integer;
LXBL:Double;
function getstlDate(aetd:TDateTime;Cust,SaleID:String):TDate;
var
aQuery2:TADOQuery;
aYear,aMonth,aDay,bDay:word;
aStlDate:TDateTime;
bMonth:Integer;
begin
aQuery2:=CreateAdoQuery;
aStlDate:=aetd;
result:=aStlDate;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+'''');
// SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
Open;
if IsEmpty then begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
Exit;
end;
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then begin
result:=aStlDate+fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
bMonth:=GetBetwMonth(aetd,result);
if bMonth=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC>ʱ<EFBFBD><CAB1>' then begin
if FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString='<27>̶<EFBFBD>' then begin
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
end else
result:=IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0));
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ׶θ<D7B6><CEB8><EFBFBD>' then begin
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
if aDay>fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger then begin
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger);
end else begin
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
end;
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end;
end;
finally
FreeAndNil(aQuery2);
end;
end;
begin
if not P_SUM.Active then
P_SUM.Open;
if not t_salepriftset.Active then
t_salepriftset.Open;
if not memtblLX.Active then
memtblLX.Open;
if NOT memtblDetail.Active then
memtblDetail.Open;
if memtblrpt_total.RecordCount=0 then exit;
l:=memtblrpt_total.RecordCount+kbmMemTable4.RecordCount;
if l=0 then l:=100;
aQuery:=CreateAdoQuery;
aQuery3:=CreateAdoQuery;
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=l;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
{
memtblDetail.Open;
if not memtblDetail.IsEmpty then begin
memtblDetail.First;
while not memtblDetail.Eof do begin
memtblDetail.Delete;
end;
end;
P_SUM.Open;
if not P_SUM.IsEmpty then begin
P_SUM.First;
while not P_SUM.Eof do begin
P_SUM.Delete;
end;
end;
}
memtblrpt_total.First;
while not memtblrpt_total.eof do
begin
{
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
if btMonth>3 then begin
if not memtblLX.Active then
memtblLX.Open;
memtblLX.insert;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring:=memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
memtblLX.FieldByName('δ<><CEB4>USD').AsFloat:=memtblrpt_total.FieldByName('Ӧ<><D3A6>USD').AsFloat;
memtblLX.FieldByName('δ<><CEB4>RMB').AsFloat:=memtblrpt_total.FieldByName('Ӧ<><D3A6>RMB').AsFloat;
memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat:=memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').value:=IncMonth(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value,4);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=btMonth;
if t_salepriftset.Locate('<27><><EFBFBD><EFBFBD>',Trim(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring),[]) then
LXBL:=t_salepriftset.FieldByName('<27><>Ϣ').AsFloat
else
LXBL:=0;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=LXBL;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=(memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*LXBL/100;
memtblLX.post;
end;
}
aQuery3.Close;aQuery3.SQL.Clear;
aQuery3.SQL.Add('select * from t_crm_salesproftt where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')');
aQuery3.open;
if aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
d:=0
else
d:=aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0.00;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
end
else
begin
P_SUM.edit;
end;
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('FEE2').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>״̬').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>״̬').AsString;
aQuery.Close;
aQuery.SQL.Clear;
aQuery.SQL.Add('select top 1 * from v_fee_do_jie where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+''' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DESC ');
aQuery.Open;
if not aQuery.IsEmpty then begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=aQuery.fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:=aQuery.fieldByName('<27>ұ<EFBFBD>').AsString+Floattostr(aQuery.fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat);
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
end;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>RMB').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>RMB').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>USD').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>USD').Value;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
bdatestr:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'; // bdatestr
aStlDate:=getstlDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString,memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
begin
aStlDate:=getstlDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString,memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
end
else
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime<memtblrpt_total.FieldByName(bdatestr).AsDateTime+d+1 then
begin
aStlDate:=getstlDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString,memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end
else
begin
if aStlDate>=memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then begin
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName(bdatestr).AsDateTime then begin
DecodeDate(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
else
begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
end;
end;
end
else
begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end
else
begin
DecodeDate(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(aStlDate,eYear,eMonth,eDate);
if bMonth=eMonth then begin
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName(bdatestr).AsDateTime then begin
DecodeDate(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
end;
end;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end else begin
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblrpt_total.FieldByName(bdatestr).AsDateTime then begin
DecodeDate(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,bYear,bMonth,bDate);
DecodeDate(memtblrpt_total.FieldByName(bdatestr).AsDateTime,eYear,eMonth,eDate);
if bYear=eYear then
btMonth:=bMonth-eMonth
else begin
btMonth:=bMonth+(12-eMonth);
end;
case btMonth of
0: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
1: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
2: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
3: begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
end;
end;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
end;
end;
end;
end;
with aQuery do
try
Close;
SQL.Clear;
SQL.Add('select * from t_op_fee');
SQL.Add('where ACCYEAR=:ACCYEAR and ACCMONTH=:ACCMONTH');
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա=:Empl');
Parameters.ParamByName('ACCYEAR').Value:=wwDBComboBox20.Text;
Parameters.ParamByName('ACCMONTH').Value:=wwDBComboBox1.Text;
Parameters.ParamByName('Empl').Value:=RxDBLookupCombo3.DisplayValue;
Open;First;
while not eof do
begin
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=RxDBLookupCombo3.DisplayValue;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>ؿͻ<D8BF>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=-FieldByName('<27><><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.Post;
Next;
end;
finally
end;
if (trim(memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)='<27><>ͨ<EFBFBD><CDA8>')
and (kbmMemTable3.Locate('<27><><EFBFBD><EFBFBD><E1B5A5>',Trim(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring),[])) then
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>').Value:=kbmMemTable3.FieldByName('<27><><EFBFBD><EFBFBD>').value;
if (memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value<=0)
or (memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>')
or (memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27><><EFBFBD>ĵ<EFBFBD>')then
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=0
else memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value
:=daysbetween(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)-strtoInt(bsSkinEdit1.Text);
memtblDetail.Post;
P_SUM.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblrpt_total.Next;
end;
if not kbmMemTable4.IsEmpty then begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do begin
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
aStlDate:=getstlDate(kbmMemTable4.FieldByName(bdatestr).AsDateTime,kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString,kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.Post;
kbmMemTable4.Next;
end;
end;
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
FreeAndNil(aQuery3);
end;
end;
procedure Tfrm_rp_sales_profit.GetProfitall;
var
aQuery,aQuery3:TADOQuery;
aStlDate,aSBDATE:TDate;
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
btMonth,l,d:Integer;
LXBL,YB,SB:Double;
function getstlDate(aetd:TDateTime;Cust,SaleID:String):TDate;
var
aQuery2:TADOQuery;
aYear,aMonth,aDay,bDay:word;
aStlDate:TDateTime;
bMonth:Integer;
begin
aQuery2:=CreateAdoQuery;
aStlDate:=aetd;
result:=aStlDate;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+'''');
// SQL.Add('Select * from t_crm_client_sales where ״̬=''<27><><EFBFBD><EFBFBD>'' and <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>='''+Cust+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SaleID+'''');
Open;
if IsEmpty then begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
Exit;
end;
if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>' then begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' then begin
result:=aStlDate+fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
bMonth:=GetBetwMonth(aetd,result);
if bMonth=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if bMonth=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='Լ<><D4BC>ʱ<EFBFBD><CAB1>' then begin
if FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString='<27>̶<EFBFBD>' then begin
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
end else
result:=IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0));
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else if FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27>ֽ׶θ<D7B6><CEB8><EFBFBD>' then begin
DecodeDate(IncMonth(aStlDate,StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)),aYear,aMonth,aDay);
if aDay>fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger then begin
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2').AsInteger);
end else begin
bDay:=DaysInMonth(EncodeDate(aYear,aMonth,1));
if fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger>bDay then
result:=EncodeDate(aYear,aMonth,bDay)
else
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
result:=EncodeDate(aYear,aMonth,fieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger);
end;
if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=0 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=1 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=2 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>'
else if StrToIntDef(FieldByName('<27><><EFBFBD><EFBFBD>ģʽ').AsString,0)=3 then
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end else begin
Result:=aetd;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>';
end;
end;
finally
FreeAndNil(aQuery2);
end;
end;
begin
if not P_SUM.Active then
P_SUM.Open;
if not t_salepriftset.Active then
t_salepriftset.Open;
if not memtblLX.Active then
memtblLX.Open;
if NOT memtblDetail.Active then
memtblDetail.Open;
if memtblrpt_total.RecordCount=0 then exit;
l:=memtblrpt_total.RecordCount+kbmMemTable4.RecordCount;
if l=0 then l:=100;
aQuery:=CreateAdoQuery;
aQuery3:=CreateAdoQuery;
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=l;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
{
memtblDetail.Open;
if not memtblDetail.IsEmpty then begin
memtblDetail.First;
while not memtblDetail.Eof do begin
memtblDetail.Delete;
end;
end;
P_SUM.Open;
if not P_SUM.IsEmpty then begin
P_SUM.First;
while not P_SUM.Eof do begin
P_SUM.Delete;
end;
end;
}
memtblrpt_total.First;
while not memtblrpt_total.eof do
begin
aQuery3.Close;aQuery3.SQL.Clear;
aQuery3.SQL.Add('select * from t_crm_salesproftt where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')');
aQuery3.open;
if aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
d:=0
else
d:=aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0.00;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
end
else
begin
P_SUM.edit;
end;
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ί<>б<EFBFBD><D0B1><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>Ա').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('FEE2').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>״̬').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>״̬').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
aStlDate:=getstlDate(memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString,memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=memtblrpt_total.FieldByName('ί<>е<EFBFBD>λ').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>RMB').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>RMB').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>USD').Value:=memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD>USD').Value;
if (trim(memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)='<27><>ͨ<EFBFBD><CDA8>')
and (kbmMemTable3.Locate('<27><><EFBFBD><EFBFBD><E1B5A5>',Trim(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring),[])) then
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD>').Value:=kbmMemTable3.FieldByName('<27><><EFBFBD><EFBFBD>').value;
if (memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value<=0)
or (memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>')
or (memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString='<27><><EFBFBD>ĵ<EFBFBD>')then
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=0
else memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value
:=daysbetween(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime)-strtoInt(bsSkinEdit1.Text);
Saleprofitsum.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,[]);
//<2F><><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
aQuery.Close;
aQuery.SQL.Clear;
aQuery.SQL.Add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sum(ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*<2A><><EFBFBD><EFBFBD>) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from v_fee_do where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString+''' and <20>ո<EFBFBD><D5B8><EFBFBD><EFBFBD><EFBFBD>=''<27><>'' and <20><><EFBFBD><EFBFBD>=''3'' group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
aQuery.Open;
if not aQuery.IsEmpty then
begin
aQuery.first;
while not aQuery.Eof do
begin
if (memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat=0) or (memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat=0) then
begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
end
else
begin
aQuery3.Close;aQuery3.SQL.Clear;
aQuery3.SQL.Add('select * from t_crm_salesproftt where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+''')');
aQuery3.open;
if aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
d:=0
else
d:=aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
if (d<>0) and (aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime<memtblDetail.FieldByName(bdatestr).AsDateTime+d+1) then
begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
memtblDetail.FieldByName('һ<>½<EFBFBD><C2BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('һ<>½<EFBFBD><C2BD><EFBFBD>').AsFloat+aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*(aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*SB/100)
end
else
begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName(bdatestr).AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime),Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,False);
if aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
aSBDATE:=aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime
else
aSBDATE:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime;
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,aSBDATE),Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,issameMonth(memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,aQuery.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime));
end;
// ShowMessage(IntToStr(GetBetwMonth(memtblDetail.FieldByName(bdatestr).AsDateTime,aSBDATE))+floattostr(SB));
case GetBetwMonth(memtblDetail.FieldByName(bdatestr).AsDateTime,aSBDATE) of
0:begin
memtblDetail.FieldByName('һ<>½<EFBFBD><C2BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('һ<>½<EFBFBD><C2BD><EFBFBD>').AsFloat+aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*(aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*SB/100)
end;
1:begin
memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat+aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*(aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*SB/100)
end;
2:begin
memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat+aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*(aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*SB/100)
end;
3:
begin
memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>').AsFloat+aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*(aQuery.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat/memtblrpt_total.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat)*SB/100)
end;
end;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
end;
aQuery.Next;
end;
end
else
begin
//showmessage(memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+' '+memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsString);
if trim(memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString)='<27><><EFBFBD>ĵ<EFBFBD>' then
begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,Saleprofitsum.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
//YB:=1;
//SB:=1;
// showmessage(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsString);
memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtbldetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat+(memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*SB/100);
// showmessage(memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsString);
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
end
else
begin
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
end;
end;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']+memtblrpt_total.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
P_SUM.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblrpt_total.Next;
end;
with aQuery do
try
Close;
SQL.Clear;
SQL.Add('select * from t_op_fee');
SQL.Add('where ACCYEAR=:ACCYEAR and ACCMONTH=:ACCMONTH');
SQL.Add('and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա=:Empl');
Parameters.ParamByName('ACCYEAR').Value:=wwDBComboBox20.Text;
Parameters.ParamByName('ACCMONTH').Value:=wwDBComboBox1.Text;
Parameters.ParamByName('Empl').Value:=RxDBLookupCombo3.DisplayValue;
Open;First;
while not eof do
begin
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=FieldByName('<27><><EFBFBD>غ<EFBFBD><D8BA><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=RxDBLookupCombo3.DisplayValue;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=FieldByName('<27><><EFBFBD>ؿͻ<D8BF>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=-FieldByName('<27><><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=0;
memtblDetail.Post;
Next;
end;
finally
end;
if not kbmMemTable4.IsEmpty then
begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do
begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblrpt_total.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0.00;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
end
else
begin
P_SUM.edit;
end;
memtblDetail.Insert;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27>տ<EFBFBD><D5BF><EFBFBD><EFBFBD><EFBFBD>').AsString:='';
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=null;
memtblDetail.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').AsString:=kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>').Value;
memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=0;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').Value;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=0;
aStlDate:=getstlDate(kbmMemTable4.FieldByName(bdatestr).AsDateTime,kbmMemTable4.FieldByName('ί<>е<EFBFBD>λ').AsString,kbmMemTable4.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString);
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime:=aStlDate;
memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>';
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=5;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']:=P_SUM['ë<><C3AB><EFBFBD><EFBFBD>']+kbmMemTable4.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.Post;
P_SUM.post;
kbmMemTable4.Next;
end;
end;
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
FreeAndNil(aQuery3);
end;
end;
procedure Tfrm_rp_sales_profit.GetProfitSum;
var
aK,YB,SB:Double;
aSBDATE:TDate;
aQuery3:TAdoQuery;
d:integer;
begin
if not memtblrpt_total.Active then
exit;
aQuery3:=CreateAdoQuery;
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=memtblLX.RecordCount+kbmMemTable4.RecordCount+memtblDetail.RecordCount*2;
// frm_sys_progress.bsSkinGauge1.MaxValue:=kbmMemTable2.RecordCount+kbmMemTable4.RecordCount+memtblDetail.RecordCount*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
P_SUM.Open;
if not memtblLX.IsEmpty then begin
memtblLX.First;
while not memtblLX.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=-memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']+memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblLX.Next;
end;
end;
if kbmMemTable2.Active then
if not kbmMemTable2.IsEmpty then begin
kbmMemTable2.First;
while not kbmMemTable2.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable2.Next;
end;
end;
if not kbmMemTable4.IsEmpty then begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']+kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable4.Next;
end;
end;
if not memtblDetail.IsEmpty then begin
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
memtblDetail.Last;
while not memtblDetail.Bof do begin
if P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,[]) then begin
memtblDetail.Edit;
P_SUM.Edit;
{
if (P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat>P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat) AND (P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat<>0) then begin
aK:=P_SUM.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsFloat-P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
if aK>memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat then begin
P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat+memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=0;
end else begin
memtblDetail.FieldByName('<27><><EFBFBD>ʿۿ<CABF>').AsFloat:=aK;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat-aK;
P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=P_SUM.FieldByName('<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>').AsFloat+aK;
end;
end else begin
}
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
// end;
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString<>'<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>' then begin
aQuery3.Close;aQuery3.SQL.Clear;
aQuery3.SQL.Add('select * from t_crm_salesproftt where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+''')');
aQuery3.open;
if aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
d:=0
else
d:=aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
if (d<>0) and (memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime<memtblDetail.FieldByName(bdatestr).AsDateTime+d+1) then begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
aSBDATE:=memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime
else
aSBDATE:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime;
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=YB;
end else begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName(bdatestr).AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,False);
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
aSBDATE:=memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime
else
aSBDATE:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime;
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName(bdatestr).AsDateTime,aSBDATE),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,issameMonth(memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime));
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=YB;
end;
end;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat*memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat-memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM.Post;
memtblDetail.Post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblDetail.Prior;
end;
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
end;
p_sum.First;
while not p_sum.eof do begin
P_SUM.edit;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']-P_SUM['<27><><EFBFBD><EFBFBD>Ϣ'];
P_SUM.post;
P_SUM.Next;
end;
finally
FreeAndNil(aQuery3);
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
end;
end;
procedure Tfrm_rp_sales_profit.GetProfitSumall;
var
aK,YB,SB:Double;
aSBDATE:TDate;
aQuery3:TAdoQuery;
d:integer;
begin
if not memtblrpt_total.Active then
exit;
aQuery3:=CreateAdoQuery;
try
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=memtblLX.RecordCount+kbmMemTable4.RecordCount+memtblDetail.RecordCount*2;
// frm_sys_progress.bsSkinGauge1.MaxValue:=kbmMemTable2.RecordCount+kbmMemTable4.RecordCount+memtblDetail.RecordCount*2;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
P_SUM.Open;
if not memtblLX.IsEmpty then begin
memtblLX.First;
while not memtblLX.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=0;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=-memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=memtblLX.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']+memtblLX.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblLX.Next;
end;
end;
if kbmMemTable2.Active then
if not kbmMemTable2.IsEmpty then begin
kbmMemTable2.First;
while not kbmMemTable2.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']+kbmMemTable2.fieldbyname('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable2.Next;
end;
end;
if not kbmMemTable4.IsEmpty then begin
kbmMemTable4.First;
while not kbmMemTable4.Eof do begin
if not P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,[])then
begin
P_SUM.insert;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM['<27>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD>']:=0;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD>Ϣ']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>']:=0.00;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=0.00;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=0.00;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end
else
begin
P_SUM.Edit;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']:=P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']+kbmMemTable4.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat;
P_SUM.post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
kbmMemTable4.Next;
end;
end;
{
if not memtblDetail.IsEmpty then begin
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
memtblDetail.Last;
while not memtblDetail.Bof do begin
if P_SUM.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,[]) then begin
memtblDetail.Edit;
P_SUM.Edit;
memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString<>'<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>' then begin
aQuery3.Close;aQuery3.SQL.Clear;
aQuery3.SQL.Add('select * from t_crm_salesproftt where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString+''')');
aQuery3.open;
if aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').IsNull then
d:=0
else
d:=aQuery3.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger;
if (d<>0) and (memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime<memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime+d+1) then begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
aSBDATE:=memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime
else
aSBDATE:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime;
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,0,P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,true);
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=YB;
end else begin
YB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,False);
if memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime then
aSBDATE:=memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime
else
aSBDATE:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDatetime;
SB:=GetSALEprofit(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString,GetBetwMonth(memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,aSBDATE),P_SUM.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat,issameMonth(memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,memtblDetail.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime));
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=SB;
memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat:=YB;
end;
end;
memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat*memtblDetail.FieldByName('ԭ<><D4AD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat:=memtblDetail.FieldByName('ʣ<><CAA3>ë<EFBFBD><C3AB>').AsFloat*memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD>').AsFloat/100;
memtblDetail.FieldByName('<27><><EFBFBD>ɲ<EFBFBD><C9B2><EFBFBD>').AsFloat:=memtblDetail.FieldByName('Ӧ<><D3A6><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat-memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+memtblDetail.FieldByName('ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsFloat;
P_SUM.Post;
memtblDetail.Post;
end;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
memtblDetail.Prior;
end;
memtblDetail.SortOn('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
end;
}
p_sum.First;
while not p_sum.eof do begin
P_SUM.edit;
P_SUM['<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>']:=P_SUM['Ӧ<><D3A6><EFBFBD><EFBFBD>']+P_SUM['<27><><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>']-P_SUM['<27><><EFBFBD><EFBFBD>Ϣ'];
P_SUM.post;
P_SUM.Next;
end;
finally
FreeAndNil(aQuery3);
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
end;
end;
procedure Tfrm_rp_sales_profit.Getlx;
var
aQuery:TADOQuery;
aQuery2:TADOQuery;
Str:String;
betd,eetd:TDate;
LXBL:Double;
function GetHistryno(nodate:Tdate;bsno:String):double;
var
aQuery2:TADOQuery;
begin
aQuery2:=CreateAdoQuery;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('select sum(CASE <20><><EFBFBD><EFBFBD> when ''<27><>'' then ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*<2A><><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA> ');
SQL.Add(' from v_fee_do_detail where <20><><EFBFBD><EFBFBD>='''+bsno+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'''+DateToStr(nodate)+'''');
SQL.Add(' Group by <20><><EFBFBD><EFBFBD>');
OPEN;
if IsEmpty then
result:=0.00
else
Result:=fieldbyName('δ<>պϼ<D5BA>').AsFloat;
end;
finally
FreeAndNil(aQuery2);
end;
end;
begin
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
if not t_salepriftset.Active then
t_salepriftset.Open;
if not memtblLX.Active then
memtblLX.Open;
aQuery:=CreateAdoQuery;
aQuery2:=CreateAdoQuery;
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
try
aQuery2.close;aQuery2.SQL.Clear;
aQuery2.SQL.Add('select * from t_crm_salesproftt where (<28><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><> 0) AND (<28><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><> 0) and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select distinct <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_sys_employee where 1=1 ');
if RxDBLookupCombo3.DisplayValue<>'' then
aQuery2.SQL.Add(' and <20><><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValue+'''');
aQuery2.SQL.Add(')');
aQuery2.Open;
aQuery2.First;
while not aQuery2.Eof do begin
with aQuery do begin
Close;SQL.Clear;
str:='select *,(<28>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-<2D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>)*0.01 as <20>۳<EFBFBD><DBB3><EFBFBD>Ϣ from v_op_bscard where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><><3E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> and ';
str:=Str+' '+bdatestr+'<'+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>').AsInteger-1)))+'''';
str:=Str+' and '+bdatestr+'>='+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger-1)))+'''';
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD><EFBFBD> from t_sys_employee where <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>='''+aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' and ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
if not IsEmpty then begin
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=RecordCount;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
first;
while not eof do begin
memtblLX.insert;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ί<>е<EFBFBD>λ').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
memtblLX.FieldByName('δ<><CEB4>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
memtblLX.FieldByName('δ<><CEB4>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-GetHistryno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').value:=IncMonth(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value,3);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=1;
if t_salepriftset.Locate('<27><><EFBFBD><EFBFBD>',Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring),[]) then
LXBL:=t_salepriftset.FieldByName('<27><>Ϣ').AsFloat
else
LXBL:=0;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=LXBL;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=(memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat)*LXBL/100;
memtblLX.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
Next;
end;
end;
Close;SQL.Clear;
str:='select * from v_op_bscard_MAX where <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=<3D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and ';
str:=Str+' '+bdatestr+'<'+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>').AsInteger-1)))+'''';
str:=Str+' and '+bdatestr+'>='+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsInteger-1)))+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd)+'''';
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD><EFBFBD> from t_sys_employee where <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>='''+aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')';
if not bsSkinCheckRadioBox1.Checked then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+'''2008-01-01''';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' and ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
if not IsEmpty then begin
first;
while not eof do begin
memtblLX.insert;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
memtblLX.FieldByName('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ί<>е<EFBFBD>λ').asstring;
memtblLX.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
memtblLX.FieldByName('δ<><CEB4>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
memtblLX.FieldByName('δ<><CEB4>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat-FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-GetHistryno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').value:=IncMonth(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value,3);
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsInteger:=1;
if t_salepriftset.Locate('<27><><EFBFBD><EFBFBD>',Trim(FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring),[]) then
LXBL:=t_salepriftset.FieldByName('<27><>Ϣ').AsFloat
else
LXBL:=0;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=LXBL;
memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat:=(memtblLX.FieldByName('δ<>պϼ<D5BA>').AsFloat)*LXBL/100;
memtblLX.post;
Next;
end;
end;
end;
aQuery2.Next;
end;
memtblLX.first;
while not memtblLX.Eof do begin
if memtblLX.FieldByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').AsFloat=0 then
memtblLX.Delete
else
memtblLX.Next;
end;
memtblLX.SortOn('<27>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
FreeAndNil(aQuery2);
end;
end;
function Tfrm_rp_sales_profit.GetBetwMonth(aBe, aEe: TDate): Integer;
var
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
begin
DecodeDate(aBe,bYear,bMonth,bDate);
DecodeDate(aEe,eYear,eMonth,eDate);
if bYear=eYear then
Result:=Abs(bMonth-eMonth)
else begin
if bYear>eYear then begin
Result:=bMonth+(12-eMonth);
end else begin
Result:=eMonth+(12-bMonth);
end;
end;
end;
function Tfrm_rp_sales_profit.issameMonth(aBe, aEe: TDate): Boolean;
var
bYear,bMonth,bDate,eYear,eMonth,eDate:Word;
begin
DecodeDate(aBe,bYear,bMonth,bDate);
DecodeDate(aEe,eYear,eMonth,eDate);
if (eMonth=bMonth) or (aBe>aEe) then
Result:=True
else result:=false;
end;
procedure Tfrm_rp_sales_profit.Getcq;
var
aQuery:TADOQuery;
aQuery2:TADOQuery;
Str:String;
betd,eetd:TDate;
LXBL:Double;
function GetHistryno(nodate:Tdate;bsno:String):double;
var
aQuery2:TADOQuery;
begin
aQuery2:=CreateAdoQuery;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('select sum(CASE <20><><EFBFBD><EFBFBD> when ''<27><>'' then ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*<2A><><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA> ');
SQL.Add(' from v_fee_do_detail where <20><><EFBFBD><EFBFBD>='''+bsno+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'''+DateToStr(nodate)+'''');
SQL.Add(' Group by <20><><EFBFBD><EFBFBD>');
OPEN;
if IsEmpty then
result:=0.00
else
Result:=fieldbyName('δ<>պϼ<D5BA>').AsFloat;
end;
finally
FreeAndNil(aQuery2);
end;
end;
function GetHistryUSDno(nodate:Tdate;bsno:String):double;
var
aQuery2:TADOQuery;
begin
aQuery2:=CreateAdoQuery;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('select sum(CASE <20><><EFBFBD><EFBFBD> when ''<27><>'' then ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA> ');
SQL.Add(' from v_fee_do_detail where ԭʼ<D4AD>ұ<EFBFBD>=''USD'' and <20><><EFBFBD><EFBFBD>='''+bsno+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'''+DateToStr(nodate)+'''');
SQL.Add(' Group by <20><><EFBFBD><EFBFBD>');
OPEN;
if IsEmpty then
result:=0.00
else
Result:=fieldbyName('δ<>պϼ<D5BA>').AsFloat;
end;
finally
FreeAndNil(aQuery2);
end;
end;
function GetHistryRMBno(nodate:Tdate;bsno:String):double;
var
aQuery2:TADOQuery;
begin
aQuery2:=CreateAdoQuery;
try
with aQuery2 do begin
Close;SQL.Clear;
SQL.Add('select sum(CASE <20><><EFBFBD><EFBFBD> when ''<27><>'' then ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*<2A><><EFBFBD><EFBFBD> else 0 end) as δ<>պϼ<D5BA> ');
SQL.Add(' from v_fee_do_detail where ԭʼ<D4AD>ұ<EFBFBD><>''USD'' and <20><><EFBFBD><EFBFBD>='''+bsno+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><'''+DateToStr(nodate)+'''');
SQL.Add(' Group by <20><><EFBFBD><EFBFBD>');
OPEN;
if IsEmpty then
result:=0.00
else
Result:=fieldbyName('δ<>պϼ<D5BA>').AsFloat;
end;
finally
FreeAndNil(aQuery2);
end;
end;
begin
betd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), 1);
eetd:=EncodeDate(StrToInt(wwDBComboBox20.Text), StrToInt(wwDBComboBox1.Text), MonthDays[isLeapYear(StrToInt(wwDBComboBox20.Text)),StrToInt(wwDBComboBox1.Text)]);
if not kbmMemTable2.Active then
kbmMemTable2.Open;
aQuery:=CreateAdoQuery;
aQuery2:=CreateAdoQuery;
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
try
aQuery2.close;aQuery2.SQL.Clear;
aQuery2.SQL.Add('select * from t_crm_salesproftt where (<28><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD><> 0) and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select distinct <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_sys_employee where 1=1 ');
if RxDBLookupCombo3.DisplayValue<>'' then
aQuery2.SQL.Add(' and <20><><EFBFBD><EFBFBD>='''+RxDBLookupCombo3.DisplayValue+'''');
aQuery2.SQL.Add(')');
aQuery2.Open;
aQuery2.First;
while not aQuery2.Eof do begin
with aQuery do begin
Close;SQL.Clear;
str:='select *,<2C>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>-<2D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> as <20>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD> from v_op_bscard where <20>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD><><3E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> and ';
str:=Str+' '+bdatestr+'<'+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD>').AsInteger-1)))+'''';
str:=Str+' and '+bdatestr+'>='+''''+DateToStr(incmonth(betd,-aQuery2.fieldbyname('<27><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD>').AsInteger))+'''';
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD><EFBFBD> from t_sys_employee where <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>='''+aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' and ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
Open;
if not IsEmpty then begin
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.MaxValue:=RecordCount;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.bsSkinGauge1.Value:=0;
frm_sys_progress.Update;
first;
while not eof do begin
kbmMemTable2.insert;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('ί<>е<EFBFBD>λ').asstring:=FieldByName('ί<>е<EFBFBD>λ').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
kbmMemTable2.FieldByName('Ӧ<><D3A6>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat;
kbmMemTable2.FieldByName('Ӧ<><D3A6>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat;
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=GetHistryusdno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=GetHistryRMBno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=GetHistryno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('δ<><CEB4>USD').AsFloat:=kbmMemTable2.FieldByName('Ӧ<><D3A6>USD').AsFloat-kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
kbmMemTable2.FieldByName('δ<><CEB4>RMB').AsFloat:=kbmMemTable2.FieldByName('Ӧ<><D3A6>RMB').AsFloat-kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-kbmMemTable2.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
kbmMemTable2.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
kbmMemTable2.FieldByName('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat;
kbmMemTable2.post;
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1;
Next;
end;
end;
Close;SQL.Clear;
str:='select * from v_op_bscard_MAX where <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=<3D>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD> and ';
str:=Str+' '+bdatestr+'<'+''''+DateToStr(incmonth(betd,-(aQuery2.fieldbyname('<27><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD>').AsInteger-1)))+'''';
str:=Str+' and '+bdatestr+'>='+''''+DateToStr(incmonth(betd,-aQuery2.fieldbyname('<27><><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD>').AsInteger))+'''';
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+DateToStr(betd)+'''';
str:=str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in (select <20><><EFBFBD><EFBFBD> from t_sys_employee where <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>='''+aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring+''')';
if not bsSkinCheckRadioBox1.Checked then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+'''2008-01-01''';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
str:=Str+' and ί<>е<EFBFBD>λ not in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales where <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>=1) ';
SQL.Add(str);
// SHOWMESSAGE(str);
Open;
if not IsEmpty then begin
first;
while not eof do begin
kbmMemTable2.insert;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><E1B5A5>').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
kbmMemTable2.FieldByName('ί<>е<EFBFBD>λ').asstring:=FieldByName('ί<>е<EFBFBD>λ').asstring;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value;
kbmMemTable2.FieldByName('Ӧ<><D3A6>USD').AsFloat:=FieldByName('Ӧ<><D3A6>USD').AsFloat;
kbmMemTable2.FieldByName('Ӧ<><D3A6>RMB').AsFloat:=FieldByName('Ӧ<><D3A6>RMB').AsFloat;
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat:=FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=GetHistryusdno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=GetHistryRMBno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=GetHistryno(eetd+1,FieldByName('<27><><EFBFBD><EFBFBD>').asstring);
kbmMemTable2.FieldByName('δ<><CEB4>USD').AsFloat:=kbmMemTable2.FieldByName('Ӧ<><D3A6>USD').AsFloat-kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
kbmMemTable2.FieldByName('δ<><CEB4>RMB').AsFloat:=kbmMemTable2.FieldByName('Ӧ<><D3A6>RMB').AsFloat-kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat:=kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').AsFloat-kbmMemTable2.FieldByName('<27>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>USD').AsFloat;
kbmMemTable2.FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat:=FieldByName('<27><><EFBFBD><EFBFBD>RMB').AsFloat;
kbmMemTable2.FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat:=FieldByName('ë<><C3AB><EFBFBD><EFBFBD>').AsFloat;
kbmMemTable2.FieldByName('<27>۳<EFBFBD><DBB3><EFBFBD><EFBFBD><EFBFBD>').AsFloat:=kbmMemTable2.FieldByName('<27>ϼ<EFBFBD>δ<EFBFBD><CEB4>').AsFloat;
kbmMemTable2.post;
Next;
end;
end;
end;
aQuery2.next;
end;
kbmMemTable2.SortOn('ί<>е<EFBFBD>λ;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',[]);
finally
frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.MaxValue;
frm_sys_progress.free;
frm_sys_progress:=nil;
FreeAndNil(aQuery);
end;
end;
procedure Tfrm_rp_sales_profit.dxDBGrid2DblClick(Sender: TObject);
begin
fee_view(memtblDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring);
end;
procedure Tfrm_rp_sales_profit.bsSkinButton1Click(Sender: TObject);
var i:integer;
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;
try
memtblDetail.DisableControls;
for i:=0 to dxDBGrid2.SelectedCount-1 do
begin
memtblDetail.GotoBookmark(pointer(dxDBGrid2.selectedrows[i]));
UpdateBsProfit(memtblDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memtblDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,1);
memtblDetail.Edit;
memtblDetail.fieldbyname('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsString:='1';
memtblDetail.Post;
end;
finally
memtblDetail.EnableControls;
end;
end;
procedure Tfrm_rp_sales_profit.bsSkinButton2Click(Sender: TObject);
var i:integer;
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;
try
memtblDetail.DisableControls;
for i:=0 to dxDBGrid2.SelectedCount-1 do
begin
memtblDetail.GotoBookmark(pointer(dxDBGrid2.selectedrows[i]));
UpdateBsProfit(memtblDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memtblDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,0);
memtblDetail.Edit;
memtblDetail.fieldbyname('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').AsString:='0';
memtblDetail.Post;
end;
finally
memtblDetail.EnableControls;
end;
end;
procedure Tfrm_rp_sales_profit.dxDBGrid2CustomDraw(Sender: TObject;
ACanvas: TCanvas; ARect: TRect; ANode: TdxTreeListNode;
AColumn: TdxDBTreeListColumn; const AText: String; AFont: TFont;
var AColor: TColor; ASelected, AFocused: Boolean; var ADone: Boolean);
begin
if uppercase(ANode.Strings[dxDBGrid2Column33.Index])='1' then begin
// AFont.Style:=AFont.Style+[fsStrikeOut];
AColor:=clRed;
exit;
end;
end;
procedure Tfrm_rp_sales_profit.MenuItem7Click(Sender: TObject);
begin
grid_save_xls(dxdbgrid6);
end;
procedure Tfrm_rp_sales_profit.bsSkinButton3Click(Sender: TObject);
var
betd,eetd:TDate;
aquery,bquery:TADOQuery;
str:String;
begin
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 ';
str:=Str+' '+bdatestr+'>='+''''+DateToStr(wwDBDateTimePicker1.Date)+'''';
str:=Str+' and '+bdatestr+'<='+''''+DateToStr(wwDBDateTimePicker2.Date)+'''';
if RxDBLookupCombo3.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo3.DisplayValue+'''';
if Edit1.text<>'' then
str:=Str+' and <20><>Ʊ<EFBFBD><C6B1>='+''''+Edit1.text+'''';
if RxDBLookupCombo2.DisplayValue<>'' then
str:=Str+' and ί<>е<EFBFBD>λ='+''''+RxDBLookupCombo2.DisplayValues[1]+'''';
if RxDBLookupCombo10.DisplayValue<>'' then
str:=Str+' and <20><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo10.DisplayValue+'''';
case bsSkinComboBox1.itemindex of
1: str:=Str+' and (fee2=0 or fee2 is null) ';
2: str:=Str+' and (fee2=1) ';
end;
case bsSkinComboBox2.itemindex of
1: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''¼<><C2BC>״̬''';
2: str:=Str+' and <20><><EFBFBD><EFBFBD>״̬=''<27><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>''';
end;
SQL.Add(str);
SQL.Add(' and ί<>е<EFBFBD>λ in (select <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD> from t_crm_client_sales)');
SQL.Add(' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Open;First;
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('<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('Ӧ<><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;
{
if kbmtc.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',Trim(kbmqc.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString),[]) then
begin
kbmtc.Edit;
kbmtc.FieldByName('<27><>Ϣ').AsFloat:=kbmtc.FieldByName('<27><>Ϣ').AsFloat+kbmqc.FieldByName('<27><>Ϣ').AsFloat;
kbmtc.Post;
end;
}
try
kbmqc.Post;
except
on e:Exception do
begin
ShowMessage(e.Message);
end;
end;
end;
Next;
end;
finally
FreeAndNil(aquery);
end;
end;
procedure Tfrm_rp_sales_profit.texClick(Sender: TObject);
var i:integer;
begin
if Edit2.text='' then
begin
ShowMessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>');
Exit;
end;
if dxDBGrid6.SelectedCount<1 then
begin
showmessage('<27><>ѡ<EFBFBD><D1A1>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD><D3A1>ҵ<EFBFBD><D2B5><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD>');
exit;
end;
try
kbmqc.DisableControls;
for i:=0 to dxDBGrid6.SelectedCount-1 do
begin
kbmqc.GotoBookmark(pointer(dxDBGrid6.selectedrows[i]));
end;
finally
kbmqc.EnableControls;
end;
end;
end.