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.

942 lines
35 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_profitLcx;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RxLookup, bsSkinCtrls, StdCtrls, wwdbdatetimepicker, XPMenu,
dxExEdtr, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, dxTL, dxCntner, DB,
ADODB, Menus, kbmMemTable,DateUtils, ExtCtrls,inifiles, bsSkinBoxCtrls;
type
Tfrm_rp_sales_profitLcx = class(TForm)
bsSkinPanel1: TbsSkinPanel;
Label5: TLabel;
Label8: TLabel;
Label11: TLabel;
Label16: TLabel;
Label1: TLabel;
Label2: TLabel;
wwDBDateTimePicker3: TwwDBDateTimePicker;
bsSkinButton10: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
wwDBDateTimePicker1: TwwDBDateTimePicker;
wwDBDateTimePicker2: TwwDBDateTimePicker;
wwDBDateTimePicker4: TwwDBDateTimePicker;
RxDBLookupCombo6: TRxDBLookupCombo;
RxDBLookupCombo1: TRxDBLookupCombo;
RxDBLookupCombo2: TRxDBLookupCombo;
bsSkinButton6: TbsSkinButton;
XPMenu1: TXPMenu;
dxDBGrid1: TdxDBGrid;
Label3: TLabel;
cmbbYwlb: TComboBox;
tv_bscard_all: TADOQuery;
tv_bscard_all1: TDataSource;
dxDBGrid1Column1: TdxDBGridMaskColumn;
dxDBGrid1Column3: TdxDBGridMaskColumn;
dxDBGrid1Column4: TdxDBGridMaskColumn;
dxDBGrid1Column5: TdxDBGridMaskColumn;
dxDBGrid1Column6: TdxDBGridDateColumn;
dxDBGrid1Column7: TdxDBGridMaskColumn;
dxDBGrid1Column8: TdxDBGridMaskColumn;
dxDBGrid1Column9: TdxDBGridMaskColumn;
dxDBGrid1Column10: TdxDBGridMaskColumn;
dxDBGrid1Column11: TdxDBGridMaskColumn;
dxDBGrid1Column12: TdxDBGridMaskColumn;
dxDBGrid1Column13: TdxDBGridMaskColumn;
dxDBGrid1Column14: TdxDBGridDateColumn;
dxDBGrid1Column15: TdxDBGridMaskColumn;
dxDBGrid1Column16: TdxDBGridMaskColumn;
dxDBGrid1Column17: TdxDBGridMaskColumn;
dxDBGrid1Column18: TdxDBGridMaskColumn;
dxDBGrid1Column20: TdxDBGridMaskColumn;
dxDBGrid1Column21: TdxDBGridDateColumn;
dxDBGrid1Column22: TdxDBGridMaskColumn;
dxDBGrid1Column23: TdxDBGridMaskColumn;
dxDBGrid1Column24: TdxDBGridMaskColumn;
dxDBGrid1Column25: TdxDBGridMaskColumn;
dxDBGrid1Column31: TdxDBGridMaskColumn;
dxDBGrid1Column32: TdxDBGridMaskColumn;
dxDBGrid1Column40: TdxDBGridMaskColumn;
dxDBGrid1Column41: TdxDBGridMaskColumn;
dxDBGrid1Column68: TdxDBGridMaskColumn;
dxDBGrid1Column83: TdxDBGridMaskColumn;
PopupMenu2: TPopupMenu;
N10: TMenuItem;
MenuItem1: TMenuItem;
N14: TMenuItem;
N13: TMenuItem;
N12: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
dxDBGrid1Column94: TdxDBGridColumn;
dxDBGrid1Column19: TdxDBGridColumn;
dxDBGrid1USD: TdxDBGridColumn;
dxDBGrid1Column71: TdxDBGridColumn;
dxDBGrid1Column72: TdxDBGridColumn;
dxDBGrid1Column73: TdxDBGridColumn;
dxDBGrid1Column74: TdxDBGridColumn;
dxDBGrid1RMB: TdxDBGridColumn;
dxDBGrid1Column76: TdxDBGridColumn;
dxDBGrid1Column77: TdxDBGridColumn;
dxDBGrid1Column78: TdxDBGridColumn;
dxDBGrid1Column79: TdxDBGridColumn;
dxDBGrid1Column80: TdxDBGridColumn;
dxDBGrid1Column81: TdxDBGridColumn;
dxDBGrid1Column82: TdxDBGridColumn;
dxDBGrid1Column84: TdxDBGridColumn;
dxDBGrid1Column85: TdxDBGridColumn;
memTblCustDetail: TkbmMemTable;
dsrTblCustDetal: TDataSource;
memTblCustDetailField2: TStringField;
memTblCustDetailField3: TStringField;
memTblCustDetailField4: TStringField;
memTblCustDetailField5: TStringField;
memTblCustDetailField6: TStringField;
memTblCustDetailField9: TStringField;
memTblCustDetailField8: TIntegerField;
memTblCustDetailField10: TStringField;
memTblCustDetailField11: TStringField;
memTblCustDetailField12: TStringField;
memTblCustDetailField13: TStringField;
memTblCustDetailField14: TStringField;
memTblCustDetailField16: TStringField;
memTblCustDetailField17: TStringField;
memTblCustDetailField18: TIntegerField;
memTblCustDetailField19: TStringField;
memTblCustDetailField20: TFloatField;
memTblCustDetailField21: TStringField;
memTblCustDetailField23: TStringField;
memTblCustDetailField24: TStringField;
memTblCustDetailField25: TStringField;
memTblCustDetailField26: TStringField;
memTblCustDetailField27: TStringField;
memTblCustDetailField28: TStringField;
memTblCustDetailField29: TStringField;
memTblCustDetailField30: TStringField;
memTblCustDetailField31: TStringField;
memTblCustDetailUSD: TFloatField;
memTblCustDetailUSD2: TFloatField;
memTblCustDetailUSD3: TFloatField;
memTblCustDetailUSD4: TFloatField;
memTblCustDetailUSD5: TFloatField;
memTblCustDetailRMB: TFloatField;
memTblCustDetailRMB2: TFloatField;
memTblCustDetailRMB3: TFloatField;
memTblCustDetailRMB4: TFloatField;
memTblCustDetailRMB5: TFloatField;
memTblCustDetailField32: TFloatField;
memTblCustDetailField33: TFloatField;
memTblCustDetailField34: TFloatField;
memTblCustDetailField35: TFloatField;
memTblCustDetailField36: TFloatField;
memTblCustDetailField37: TStringField;
memTblCustDetailField38: TFloatField;
memTblCustDetailField: TDateTimeField;
memTblCustDetailField7: TDateTimeField;
memTblCustDetailField15: TDateTimeField;
dxDBGrid1Column47: TdxDBGridColumn;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
memTblCustDetailField22: TStringField;
dxDBGrid1Column48: TdxDBGridColumn;
bsSkinCheckRadioBox3: TbsSkinCheckRadioBox;
memTblCustDetailField39: TDateTimeField;
dxDBGrid1Column49: TdxDBGridColumn;
bsSkinButton2: TbsSkinButton;
bsSkinButton3: TbsSkinButton;
dxDBGrid1Column50: TdxDBGridCheckColumn;
memTblCustDetailFEE2: TIntegerField;
memTblCustDetailField40: TStringField;
dxDBGrid1Column51: TdxDBGridColumn;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
wdbdtmpckr1: TwwDBDateTimePicker;
qry_SearchRecord: TADOQuery;
qry_QF: TADOQuery;
ds_QF: TDataSource;
qry_TC: TADOQuery;
ds_TC: TDataSource;
pnl1: TPanel;
dxDBGrid2: TdxDBGrid;
dxdbgrdclmnDBGrid2Column1: TdxDBGridColumn;
dxdbgrdclmnDBGrid2Column2: TdxDBGridColumn;
dxDBGrid3: TdxDBGrid;
dxdbgrdclmn1: TdxDBGridColumn;
dxdbgrdclmn2: TdxDBGridColumn;
dxdbgrdclmn3: TdxDBGridColumn;
dxdbgrdclmn4: TdxDBGridColumn;
bsSkinButton1: TbsSkinButton;
qry_InsertRecord: TADOQuery;
qry_UPDRecord: TADOQuery;
bsSkinPanel2: TbsSkinPanel;
bsSkinButton4: TbsSkinButton;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
dxdbgrdclmnDBGrid2Column3: TdxDBGridColumn;
dxdbgrdclmnDBGrid2Column4: TdxDBGridColumn;
edt1: TEdit;
lbl4: TLabel;
lbl5: TLabel;
lbl6: TLabel;
dxdbgrdclmnDBGrid3Column5: TdxDBGridColumn;
dxdbgrdclmnDBGrid3Column6: TdxDBGridColumn;
qry_UPDQF: TADOQuery;
lbl7: TLabel;
lbl8: TLabel;
wdbdtmpckr2: TwwDBDateTimePicker;
edt2: TEdit;
bsknchckgrp1: TbsSkinCheckGroup;
qry_Ctn: TADOQuery;
qry_ResetQF: TADOQuery;
qry_ResetRecord: TADOQuery;
memTblCustDetailField41: TStringField;
memTblCustDetailField42: TStringField;
qry_InsertDo: TADOQuery;
dxdbgrdclmnDBGrid1Column52: TdxDBGridColumn;
dxdbgrdclmnDBGrid1Column53: TdxDBGridColumn;
bsSkinCheckRadioBox4: TbsSkinCheckRadioBox;
memTblCustDetailField43: TDateTimeField;
dxDBGrid1Column54: TdxDBGridColumn;
Label4: TLabel;
wwDBDateTimePicker5: TwwDBDateTimePicker;
Label6: TLabel;
wwDBDateTimePicker6: TwwDBDateTimePicker;
Label7: TLabel;
procedure bsSkinButton5Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure bsSkinButton6Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure N10Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure dxDBGrid1DblClick(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure dxDBGrid1CustomDraw(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 wdbdtmpckr1Change(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinCheckRadioBox1Click(Sender: TObject);
procedure edt1KeyPress(Sender: TObject; var Key: Char);
procedure bsSkinButton4Click(Sender: TObject);
private
function getlx(etd:TDate;bsno,saleid:string):double;
{ Private declarations }
public
{ Public declarations }
procedure UpdateBsProfit(bstype,bsno:String;fee:integer);
end;
var
frm_rp_sales_profitLcx: Tfrm_rp_sales_profitLcx;
implementation
{$R *.dfm}
uses u_main, my_sys_function;
procedure Tfrm_rp_sales_profitLcx.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;
function Tfrm_rp_sales_profitLcx.getlx(etd:TDate;bsno,saleid:string):double;
var
aQuery,aQuery2:TAdoQuery;
d:integer;
lx:real;
begin
aQuery:=CreateAdoQuery;
aQuery2:=CreateAdoQuery;
result:=0;
try
with aQuery do begin
close;sql.clear;
sql.Add('select * from t_crm_saleslxSet where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=(select <20><><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD> from t_sys_employee where <20><><EFBFBD><EFBFBD>='''+saleid+''') order by <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>');
open;
if IsEmpty then begin
result:=0;
exit;
end else begin
aQuery2.close;aQuery2.sql.clear;
aQuery2.sql.Add('select sum(ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>*<2A><><EFBFBD><EFBFBD>) as <20><><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from v_fee_do_detail where <20><><EFBFBD><EFBFBD>=''<27><>'' and <20><><EFBFBD><EFBFBD>='''+bsno+'''');
aQuery2.sql.Add('group by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
aQuery2.Open;
aQuery2.First;
while not aQuery2.Eof do begin
if aQuery2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime>etd then begin
d:=abs(daysbetween(etd,aQuery2.FieldByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime));
first;
lx:=0.00;
while not eof do begin
if (d>=fieldbyname('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').asinteger) and (d<=fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asinteger) then begin
lx:=fieldbyname('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').asfloat;
result:=result+(aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat*lx/100*(d-fieldbyname('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').asinteger));
end else begin
if d>fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asinteger then begin
lx:=fieldbyname('<27><>Ϣ<EFBFBD>ٷֱ<D9B7>').asfloat;
result:=result+(aQuery2.fieldbyname('<27><><EFBFBD><EFBFBD>').asfloat*lx/100*(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asinteger-fieldbyname('<27><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>').asinteger));
end;
end;
next;
end;
end;
aQuery2.Next;
end;
end;
end;
finally
FreeAndNil(aQuery);
FreeAndNil(aQuery2);
end;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton5Click(Sender: TObject);
begin
close ;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton10Click(Sender: TObject);
var _time1,_time2,_year,lilv,_time0,_ctnList,_ctn :string;
i:integer;
begin
if bsSkinCheckRadioBox2.Checked then begin
if (wwDBDateTimePicker1.text='')or (wwDBDateTimePicker2.text='')or (wdbdtmpckr1.text='') then begin
MessageDlg('<27><>ʼ<EFBFBD>ͽ<EFBFBD>ֹ<EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>',mtWarning,[mbok],0);
exit;
end;
end;
_time0 :=wdbdtmpckr2.text;//<2F><>ʼ<EFBFBD><CABC>
_time1 :=wwDBDateTimePicker1.text;
_time2 :=wwDBDateTimePicker2.text+' 23:59:00';
_year:= Copy(wdbdtmpckr1.text,0,4);
lilv:= edt2.text;
_ctnList:='';
for i:=0 to bsknchckgrp1.Items.Count-1 do
begin
if bsknchckgrp1.itemindex=1 then begin
_ctn:=StringReplace (bsknchckgrp1.Items.Strings[i], '''', '''''', [rfReplaceAll]);
if (_ctnList='') then
_ctnList:=''''+_ctn+''''
else
_ctnList:=_ctnList+','''+_ctn+'''';
end;
end;
with tv_bscard_all,sql do
begin
close ; clear ;
add(' SELECT V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD>Դ],V_op_bscard.[ҵ<><D2B5>״̬],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>״̬] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><E1B5A5>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><E1B5A5>],V_op_bscard.[ί<>е<EFBFBD>λ],V_op_bscard.[<5B><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ί<>б<EFBFBD><D0B1><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>˾] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[װ<><D7B0><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>],V_op_bscard.[<5B><>Ӫ<EFBFBD><D3AA>λ],V_op_bscard.[<5B>Ƿ<EFBFBD><C7B7><EFBFBD>˰],V_op_bscard.[<5B><><EFBFBD><EFBFBD>Ա] ');
add(' ,V_op_bscard.[<5B>ͷ<EFBFBD>Ա],V_op_bscard.[¼<><C2BC><EFBFBD><EFBFBD>],V_op_bscard.[¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[װ<>˷<EFBFBD>ʽ],V_op_bscard.[ж<><D0B6><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>ѷ<EFBFBD>ʽ],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>1],V_op_bscard.[<5B><><EFBFBD><EFBFBD>2],V_op_bscard.[<5B><><EFBFBD><EFBFBD>3],V_op_bscard.[<5B><><EFBFBD><EFBFBD>4],V_op_bscard.[<5B><><EFBFBD><EFBFBD>5],V_op_bscard.[<5B><><EFBFBD><EFBFBD>6],V_op_bscard.[<5B><><EFBFBD><EFBFBD>7],V_op_bscard.[<5B><><EFBFBD><EFBFBD>8] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD>9],V_op_bscard.[<5B><><EFBFBD><EFBFBD>10],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><>TEU],V_op_bscard.[<5B><><EFBFBD><EFBFBD>USD],V_op_bscard.[Ӧ<><D3A6>USD],V_op_bscard.[Ӧ<><D3A6>USD],V_op_bscard.[<5B><><EFBFBD><EFBFBD>USD] ');
add(' ,V_op_bscard.[<5B>Ѹ<EFBFBD>USD],V_op_bscard.[<5B><><EFBFBD><EFBFBD>RMB],V_op_bscard.[Ӧ<><D3A6>RMB],V_op_bscard.[Ӧ<><D3A6>RMB],V_op_bscard.[<5B><><EFBFBD><EFBFBD>RMB],V_op_bscard.[<5B>Ѹ<EFBFBD>RMB],V_op_bscard.[<5B>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>],V_op_bscard.[<5B>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>] ');
add(' ,V_op_bscard.[ë<><C3AB><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B>ϼ<EFBFBD><CFBC>Ѹ<EFBFBD>] ');
add(' ,case when isnull(V_op_bscard.[fee2] ,0)=0 then ''0'' else ''1'' end [fee2], v_fee_do_max.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0 <20><><EFBFBD><EFBFBD>,0 <20>ʽ<EFBFBD><CABD><EFBFBD>Ϣ,isnull(d.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'''') <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,d.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> ');
add(' FROM V_op_bscard left join v_fee_do_max on v_fee_do_max.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> ');
add(' left join t_2016TC_FeeDo d on v_op_bscard.<2E><><EFBFBD><EFBFBD>=d.<2E><><EFBFBD><EFBFBD> ');
add(' and d.id=(select max(id) from t_2016TC_FeeDo where <20><><EFBFBD><EFBFBD>=v_op_bscard.<2E><><EFBFBD><EFBFBD>) ');
add(' where 1=1 and V_op_bscard.<2E><><EFBFBD><EFBFBD> in( select distinct ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_ch_fee_do where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> in( ');
add(' select <20>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> from t_ch_balance where V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>] >='''+_time0+''' and v_fee_do_max.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='''+_time1+''' and v_fee_do_max.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='''+_time2+''')) ');
add(' and (not EXISTS (select 1 from t_ch_fee where <20><><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>=''<27><>'' and <20><><EFBFBD><EFBFBD>״̬<>''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>''))');
if not bsSkinCheckRadioBox4.Checked then begin
add(' and isnull(V_op_bscard.[fee2] ,0)=0 ');
end;
//add(' and EXISTS (select 1 from t_op_ctn where <20><><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ in('+_ctnList+')) ');
{
if bsSkinCheckRadioBox1.Checked then begin
add(' and (v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=v_op_bscard.<2E>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>) and (v_op_bscard.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6><>0)');
end;
}
case cmbbYwlb.ItemIndex of
1:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>'''+')');
2:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>'''+')');
3:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>'''+')');
4:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>'''+')');
end ;
if wwDBDateTimePicker6.text<>''then
add(' and V_op_bscard.Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+wwDBDateTimePicker6.text+'''');
if wwDBDateTimePicker5.text<>''then
add(' and V_op_bscard.Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+wwDBDateTimePicker5.text+' 23:59:59''');
if wwDBDateTimePicker3.text<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='+''''+wwDBDateTimePicker3.text+'''');
if wwDBDateTimePicker4.text<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='+''''+wwDBDateTimePicker4.text+'''');
if RxDBLookupCombo6.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD>Ա='+''''+RxDBLookupCombo6.DisplayValue+'''');
if RxDBLookupCombo1.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo1.DisplayValue+'''');
if RxDBLookupCombo2.DisplayValue<>''then
add(' and V_op_bscard.¼<><C2BC><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo2.DisplayValue+'''');
{
if RxDBLookupCombo12.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo12.DisplayValue+'''');
if RxDBLookupCombo15.DisplayValue<>''then
add(' and V_op_bscard.<2E>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo15.DisplayValue+'''');
if RxDBLookupCombo20.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo20.DisplayValues[1]+'''');
}
//add(' and '+open_data('0021','v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no'));
if bsSkinCheckRadioBox2.Checked then begin
add(' union SELECT V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD>Դ],V_op_bscard.[ҵ<><D2B5>״̬],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>״̬] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><E1B5A5>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><E1B5A5>],V_op_bscard.[ί<>е<EFBFBD>λ],V_op_bscard.[<5B><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ί<>б<EFBFBD><D0B1><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>˾] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[װ<><D7B0><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>],V_op_bscard.[<5B><>Ӫ<EFBFBD><D3AA>λ],V_op_bscard.[<5B>Ƿ<EFBFBD><C7B7><EFBFBD>˰],V_op_bscard.[<5B><><EFBFBD><EFBFBD>Ա] ');
add(' ,V_op_bscard.[<5B>ͷ<EFBFBD>Ա],V_op_bscard.[¼<><C2BC><EFBFBD><EFBFBD>],V_op_bscard.[¼<><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[װ<>˷<EFBFBD>ʽ],V_op_bscard.[ж<><D0B6><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD>ѷ<EFBFBD>ʽ],V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD>1],V_op_bscard.[<5B><><EFBFBD><EFBFBD>2],V_op_bscard.[<5B><><EFBFBD><EFBFBD>3],V_op_bscard.[<5B><><EFBFBD><EFBFBD>4],V_op_bscard.[<5B><><EFBFBD><EFBFBD>5],V_op_bscard.[<5B><><EFBFBD><EFBFBD>6],V_op_bscard.[<5B><><EFBFBD><EFBFBD>7],V_op_bscard.[<5B><><EFBFBD><EFBFBD>8] ');
add(' ,V_op_bscard.[<5B><><EFBFBD><EFBFBD>9],V_op_bscard.[<5B><><EFBFBD><EFBFBD>10],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B><>TEU],V_op_bscard.[<5B><><EFBFBD><EFBFBD>USD],V_op_bscard.[Ӧ<><D3A6>USD],V_op_bscard.[Ӧ<><D3A6>USD],V_op_bscard.[<5B><><EFBFBD><EFBFBD>USD] ');
add(' ,V_op_bscard.[<5B>Ѹ<EFBFBD>USD],V_op_bscard.[<5B><><EFBFBD><EFBFBD>RMB],V_op_bscard.[Ӧ<><D3A6>RMB],V_op_bscard.[Ӧ<><D3A6>RMB],V_op_bscard.[<5B><><EFBFBD><EFBFBD>RMB],V_op_bscard.[<5B>Ѹ<EFBFBD>RMB],V_op_bscard.[<5B>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>],V_op_bscard.[<5B>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>] ');
add(' ,V_op_bscard.[ë<><C3AB><EFBFBD><EFBFBD>],V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B>ϼ<EFBFBD><CFBC><EFBFBD><EFBFBD><EFBFBD>],V_op_bscard.[<5B>ϼ<EFBFBD><CFBC>Ѹ<EFBFBD>] ');
add(' ,case when isnull(V_op_bscard.[fee2] ,0)=0 then ''0'' else ''1'' end [fee2], v_fee_do_max.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0,0,isnull(d.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'''') <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,d.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1> ');
add(' FROM V_op_bscard left join v_fee_do_max on v_fee_do_max.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> ');
add(' left join t_2016TC_FeeDo d on v_op_bscard.<2E><><EFBFBD><EFBFBD>=d.<2E><><EFBFBD><EFBFBD> and d.id=(select max(id) from t_2016TC_FeeDo where <20><><EFBFBD><EFBFBD>=v_op_bscard.<2E><><EFBFBD><EFBFBD>) ');
add(' where 1=1 and V_op_bscard.[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]>='''+_time0+''' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+_time1+''' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='''+_time2+''' ');
add(' and isnull((select sum(<28><><EFBFBD><EFBFBD>) from t_ch_fee where <20><><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>=''<27><>'' ),0)=0 ');
//add(' and EXISTS (select 1 from t_op_ctn where <20><><EFBFBD><EFBFBD>=V_op_bscard.<2E><><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ in('+_ctnList+')) ');
{
if wwDBDateTimePicker5.text<>''then
begin
add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >='+''''+wwDBDateTimePicker5.text+'''');
end;
if wwDBDateTimePicker6.text<>''then
begin
add(' and v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <='+''''+wwDBDateTimePicker6.text+'''');
end; }
// add(')');
if RxDBLookupCombo6.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD>Ա='+''''+RxDBLookupCombo6.DisplayValue+'''');
if RxDBLookupCombo1.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo1.DisplayValue+'''');
if RxDBLookupCombo2.DisplayValue<>''then
add(' and V_op_bscard.¼<><C2BC><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo2.DisplayValue+'''');
if not bsSkinCheckRadioBox4.Checked then begin
add(' and isnull(V_op_bscard.[fee2] ,0)=''0'' ');
end;
{
if RxDBLookupCombo20.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo20.DisplayValues[1]+'''');
}
case cmbbYwlb.ItemIndex of
1:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>'''+')');
2:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>'''+')');
3:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˳<EFBFBD><CBB3><EFBFBD>'''+')');
4:add('and (V_op_bscard.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ='+'''<27><><EFBFBD>˽<EFBFBD><CBBD><EFBFBD>'''+')');
end ;
{
if RxDBLookupCombo12.DisplayValue<>''then
add(' and V_op_bscard.<2E><><EFBFBD>۲<EFBFBD><DBB2><EFBFBD>='+''''+RxDBLookupCombo12.DisplayValue+'''');
if RxDBLookupCombo15.DisplayValue<>''then
add(' and V_op_bscard.<2E>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>='+''''+RxDBLookupCombo15.DisplayValue+'''');
}
//add(' and '+open_data('0021','v_op_bscard.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','no','no','no','no'));
qry_TC.Close;
qry_TC.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_TC.Open;
end;
//showmessage(tv_bscard_all.SQL.CommaText);
open ;
memTblCustDetail.LoadFromDataSet(tv_bscard_all,[]);
{
if bsSkinCheckRadioBox3.Checked then begin
with memTblCustDetail do begin
First;
while not eof do begin
if Fieldbyname('<27>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>').Asfloat<>0 then begin
edit;
fieldbyname('<27><><EFBFBD><EFBFBD>Ϣ').AsFloat:=getlx(fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsDateTime,fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring);
post;
end;
Next;
end;
end;
end; }
end ;
//<2F><><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>
qry_QF.SQL.Text:='';
//qry_QF.SQL.Add(' select sum(<28><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) Ƿ<><C7B7>,v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> from t_ch_fee f left join V_op_bscard v on V.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD> ');
//qry_QF.SQL.Add(' left join t_2016TC_saler_limit sl on sl.<2E><><EFBFBD><EFBFBD>=v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>='''++''' ');
//qry_QF.SQL.Add(' where f.<2E><><EFBFBD><EFBFBD>=''<27><>'' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='''+_time2+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>=''2016-6-1'' group by v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ');
qry_QF.SQL.Add(' select isnull(sum(<28><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),0) Ƿ<><C7B7>,v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,isnull(sl.<2E>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>,0) <20>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD> ');
qry_QF.SQL.Add(' ,case when (isnull(sum(<28><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),0)-isnull(sl.<2E>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>,0))*'+lilv+'>0 then (isnull(sum(<28><><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>),0)-isnull(sl.<2E>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>,0))*'+lilv+' else 0 end <20><>Ϣ ');
qry_QF.SQL.Add(' from t_ch_fee f left join V_op_bscard v on V.<2E><><EFBFBD><EFBFBD>=f.<2E><><EFBFBD><EFBFBD> ');
qry_QF.SQL.Add(' left join t_2016TC_saler_limit sl on sl.<2E><><EFBFBD><EFBFBD>=v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and <20><><EFBFBD><EFBFBD>='''+_year+''' ');
qry_QF.SQL.Add(' where f.<2E><><EFBFBD><EFBFBD>=''<27><>'' and v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>>='''+_time0+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><='''+_time2+''' group by v.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,sl.<2E>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD> '); //
qry_QF.Open;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD>¼
qry_TC.Close;
qry_TC.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_TC.Open;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton6Click(Sender: TObject);
begin
wwDBDateTimePicker1.Clear;
wwDBDateTimePicker2.Clear;
wwDBDateTimePicker3.Clear;
wwDBDateTimePicker4.Clear;
RxDBLookupCombo6.ClearValue;
RxDBLookupCombo1.ClearValue;
RxDBLookupCombo2.ClearValue;
cmbbYwlb.ItemIndex:=-1 ;
end;
procedure Tfrm_rp_sales_profitLcx.FormClose(Sender: TObject;
var Action: TCloseAction);
var inifile1:TIniFile;
begin
savereggrid(dxdbgrid1,caption);
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteString('2016TC','STARTDATE',wdbdtmpckr2.text);
inifile1.WriteString('2016TC','TCBL',edt1.text);
inifile1.WriteString('2016TC','ZJLL',edt2.text);
inifile1.free;
frm_rp_sales_profitLcx.Hide;
frm_rp_sales_profitLcx.ManualFloat(frm_rp_sales_profitLcx.BoundsRect );
frm_main.freeTabs('frm_rp_sales_profitLcx');
action:=cafree;
frm_rp_sales_profitLcx:=nil;
end;
procedure Tfrm_rp_sales_profitLcx.N10Click(Sender: TObject);
begin
update_grid_view_no(dxdbgrid1);
end;
procedure Tfrm_rp_sales_profitLcx.N14Click(Sender: TObject);
begin
update_grid_view_all(dxdbgrid1);
end;
procedure Tfrm_rp_sales_profitLcx.N12Click(Sender: TObject);
begin
update_grid(dxdbgrid1,111);
end;
procedure Tfrm_rp_sales_profitLcx.N16Click(Sender: TObject);
begin
grid_save_xls(dxdbgrid1);
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton9Click(Sender: TObject);
begin
sys_print('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>',2,nil,nil,nil,nil,dsrTblCustDetal,nil,nil,nil,nil,nil,nil);
end;
procedure Tfrm_rp_sales_profitLcx.FormShow(Sender: TObject);
var ctnlist:TStringList;
i:integer;
inifile1:Tinifile;
begin
loadreggrid(dxdbgrid1,true,caption);
qry_ctn.Close;
qry_ctn.open;
ctnlist := TStringList.Create;
qry_ctn.First;
while not qry_ctn.Eof do begin
//ctnlist.Add(StringReplace (qry_ctn.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ').asstring, '''', '''''', [rfReplaceAll]));
ctnlist.Add(qry_ctn.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ').asstring);
qry_ctn.Next;
end;
with bsknchckgrp1 do begin
items:= ctnlist;
end;
for i:=0 to bsknchckgrp1.Items.Count-1 do
begin
if (pos('RF',bsknchckgrp1.Items.Strings[i])>0) or(pos('RH',bsknchckgrp1.Items.Strings[i])>0)
or(pos('TK',bsknchckgrp1.Items.Strings[i])>0)
then begin
end else begin
// bsknchckgrp1.itemindex:=tru;
end;
end;
//////
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
wdbdtmpckr2.date:=strtodate(inifile1.ReadString('2016TC','STARTDATE','2016-06-01'));
edt1.text:=inifile1.ReadString('2016TC','TCBL','0.3');
edt2.text:=inifile1.ReadString('2016TC','ZJLL','0.01');
inifile1.free;
end;
procedure Tfrm_rp_sales_profitLcx.dxDBGrid1DblClick(Sender: TObject);
begin
fee_view(memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring);
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton2Click(Sender: TObject);
var i:integer;
amount:double;
begin
if not if_open('254') then
begin
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD> <20><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>');
exit;
end;
if dxDBGrid1.SelectedCount>=1 then
begin
for i:=0 to dxDBGrid1.SelectedCount-1 do
begin
memTblCustDetail.GotoBookmark(pointer(dxDBGrid1.selectedrows[i]));
UpdateBsProfit(memTblCustDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,1);
amount:=memTblCustDetail.fieldbyname('ë<><C3AB><EFBFBD><EFBFBD>').asFloat;
amount:=amount*0.3;
memTblCustDetail.Edit;
memTblCustDetail.fieldbyname('FEE2').AsString:='1';
//memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='1';
//memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString:='1';
memTblCustDetail.Post;
qry_InsertDo.SQL.Text:='';
with qry_InsertDo.SQL do begin
Add(' insert into t_2016TC_FeeDo (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>,<2C><><EFBFBD><EFBFBD>) values('''
+employee+''',getdate(),'''+memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+''')');
end;
qry_InsertDo.ExecSQL;
{
qry_TCRecord.SQL.Text:='';
with qry_TCRecord.SQL do begin
Add(' insert into t_2016TC_Record (ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>,<2C><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>) values('''
+memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+''','''+trim(wdbdtmpckr1.Text)+''','+floattostr(amount)+')');
end;
qry_TCRecord.ExecSQL; }
end;
end;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton3Click(Sender: TObject);
var i:integer;
begin
if not if_open('254') then
begin
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD> <20><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>');
exit;
end;
if dxDBGrid1.SelectedCount>=1 then
begin
for i:=0 to dxDBGrid1.SelectedCount-1 do
begin
memTblCustDetail.GotoBookmark(pointer(dxDBGrid1.selectedrows[i]));
UpdateBsProfit(memTblCustDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,0);
memTblCustDetail.Edit;
memTblCustDetail.fieldbyname('FEE2').AsString:='0';
memTblCustDetail.Post;
with qry_InsertDo.SQL do begin
Add(' insert into t_2016TC_FeeDo (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>,<2C><><EFBFBD><EFBFBD>) values('''
+employee+''',getdate(),'''+memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+''')');
end;
qry_InsertDo.ExecSQL;
{
qry_TCRecord.SQL.Text:='';
with qry_TCRecord.SQL do begin
Add(' delete from t_2016TC_Record where ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''
+memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring+''' and <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>='''+trim(wdbdtmpckr1.Text)+'''');
end;
qry_TCRecord.ExecSQL; }
end;
end;
end;
procedure Tfrm_rp_sales_profitLcx.dxDBGrid1CustomDraw(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[dxDBGrid1Column50.Index])='1' then begin
AColor:=$FACE87;
exit;
end;
end;
procedure Tfrm_rp_sales_profitLcx.wdbdtmpckr1Change(Sender: TObject);
var myYear, myMonth, myDay,myYear2, myMonth2, myDay2 : Word;
_S:string;
begin
DecodeDate(wdbdtmpckr1.DateTime, myYear, myMonth, myDay);
if (myYear<>1899) then
begin
//DecodeDate(wwDBDateTimePicker1.Time, myYear2, myMonth2, myDay2);
if (wwDBDateTimePicker1.Time=0) then begin
//_S:=IntToStr(myYear) +'-'+ IntToStr(myMonth)+'-'+ StartOfTheMonth(wdbdtmpckr1.Time);
wwDBDateTimePicker1.DateTime:=StartOfTheMonth(wdbdtmpckr1.DateTime);
wwDBDateTimePicker2.DateTime:=EndOfTheMonth(wdbdtmpckr1.DateTime);
end;
end else begin
//DecodeDate(wwDBDateTimePicker1.Time, myYear, myMonth, myDay);
//ShowMessage('2 '+IntToStr(myMonth));
end;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton1Click(Sender: TObject);
var SALER,namelist:string;
amount,TCRate,lilv:Extended;
begin
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0
{
qry_ResetRecord.Close;
qry_ResetRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_ResetRecord.ExecSQL;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
namelist:='';
memTblCustDetail.first;
TCRate:= StrToFloat(edt1.text);
lilv:= StrToFloat(edt2.text);
while not memTblCustDetail.Eof do begin
//memTblCustDetail.GotoBookmark(pointer(dxDBGrid1.selectedrows[i]));
if (memTblCustDetail.fieldbyname('FEE2').AsString<>'1') then
begin
end
else begin
SALER :=memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>·ݵķ<DDB5><C4B7>ż<EFBFBD>¼<EFBFBD><C2BC>
//trim(wdbdtmpckr1.Text)
qry_SearchRecord.Close;
qry_SearchRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:=SALER ;
qry_SearchRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_SearchRecord.Open;
if (qry_SearchRecord.RecordCount=0) then begin
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
qry_InsertRecord.Close;
qry_InsertRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_InsertRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_InsertRecord.ExecSQL;
end;
//if not qry_TC.Locate('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',SALER,[]) then begin
if (pos(SALER+',',namelist)>0) then begin
end else begin
namelist:=namelist+SALER+',';
qry_ResetRecord.Close;
{ qry_ResetRecord.SQL.Text:='update t_2016TC_record set <20><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>=0 ,Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=0,<2C><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>=0 where <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>='''
+trim(wdbdtmpckr1.Text)+''' and <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>='''+SALER+''' ; }
qry_ResetRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_ResetRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_ResetRecord.ExecSQL;
end;
//update<74><65><EFBFBD>˸<EFBFBD><CBB8><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>¼<EFBFBD><C2BC>
amount:=memTblCustDetail.fieldbyname('ë<><C3AB><EFBFBD><EFBFBD>').asFloat;
amount:=amount*TCRate;
qry_UPDRecord.Close;
qry_UPDRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_UPDRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_UPDRecord.Parameters.ParamByName('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>').value:= FloatToStr(amount);
qry_UPDRecord.Parameters.ParamByName('<27><><EFBFBD>ɽ<EFBFBD><C9BD><EFBFBD>2').value:= FloatToStr(amount);
qry_UPDRecord.ExecSQL;
end;
memTblCustDetail.Next;
//memTblCustDetail.Edit;
//memTblCustDetail.fieldbyname('FEE2').AsString:='1';
//memTblCustDetail.Post;
end;
//<2F><><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>
qry_QF.first;
namelist:='';
while not qry_QF.Eof do begin
if (qry_QF.fieldbyname('<27><>Ϣ').AsFloat=0) then begin
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
end else begin
SALER :=qry_QF.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>и<EFBFBD><D0B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>·ݵķ<DDB5><C4B7>ż<EFBFBD>¼<EFBFBD><C2BC>
//trim(wdbdtmpckr1.Text)
qry_SearchRecord.Close;
qry_SearchRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_SearchRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_SearchRecord.Open;
if (qry_SearchRecord.RecordCount=0) then begin
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>
qry_InsertRecord.Close;
qry_InsertRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_InsertRecord.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_InsertRecord.ExecSQL;
end;
if (pos(SALER+',',namelist)>0) then begin
end else begin
namelist:=namelist+SALER+',';
qry_ResetQF.Close;
qry_ResetQF.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_ResetQF.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_ResetQF.ExecSQL;
end;
//,<2C><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>=0 ,Ӧ<><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=0
//update<74><65><EFBFBD>˸<EFBFBD><CBB8><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>¼<EFBFBD><C2BC>
amount:=qry_QF.fieldbyname('<27><>Ϣ').asFloat;
qry_UPDQF.Close;
qry_UPDQF.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').value:= SALER;
qry_UPDQF.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_UPDQF.Parameters.ParamByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>').value:= FloatToStr(amount);
qry_UPDQF.Parameters.ParamByName('<27><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>2').value:= FloatToStr(amount);
qry_UPDQF.ExecSQL;
end;
qry_QF.Next;
//memTblCustDetail.Edit;
//memTblCustDetail.fieldbyname('FEE2').AsString:='1';
//memTblCustDetail.Post;
end;
qry_TC.Close;
qry_TC.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>').value:= trim(wdbdtmpckr1.Text);
qry_TC.Open;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinCheckRadioBox1Click(
Sender: TObject);
var i:Integer;
begin
if not if_open('254') then
begin
showmessage('<27><>û<EFBFBD>д<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ȩ<EFBFBD>ޣ<EFBFBD> <20><><EFBFBD><EFBFBD>ϵϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>');
exit;
end;
if bsSkinCheckRadioBox1.Checked then begin
//ȫ<><C8AB><EFBFBD><EFBFBD>
memTblCustDetail.First;
while not memTblCustDetail.Eof do begin
//memTblCustDetail.GotoBookmark(pointer(dxDBGrid1.selectedrows[i]));
if (memTblCustDetail.fieldbyname('FEE2').AsString<>'1') then
begin
UpdateBsProfit(memTblCustDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,1);
memTblCustDetail.Edit;
memTblCustDetail.fieldbyname('FEE2').AsString:='1';
memTblCustDetail.Post;
end
else begin
end;
memTblCustDetail.Next;
end;
end else begin
//ȫȡ<C8AB><C8A1>
memTblCustDetail.First;
while not memTblCustDetail.Eof do begin
//memTblCustDetail.GotoBookmark(pointer(dxDBGrid1.selectedrows[i]));
if (memTblCustDetail.fieldbyname('FEE2').AsString='1') then
begin
UpdateBsProfit(memTblCustDetail.fieldbyname('ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring,memTblCustDetail.fieldbyname('<27><><EFBFBD><EFBFBD>').asstring,0);
memTblCustDetail.Edit;
memTblCustDetail.fieldbyname('FEE2').AsString:='0';
memTblCustDetail.Post;
end
else begin
end;
memTblCustDetail.Next;
end;
end;
//bsSkinButton10Click(Sender);
end;
procedure Tfrm_rp_sales_profitLcx.edt1KeyPress(Sender: TObject;
var Key: Char);
begin
if not (key in ['0'..'9',#13,#8 ,#46]) then
key := #0;
end;
procedure Tfrm_rp_sales_profitLcx.bsSkinButton4Click(Sender: TObject);
begin
table_post(qry_TC);
end;
end.