unit u_rp_zou_linehistry; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DB, ADODB,DateUtils, dxExEdtr, dxDBTLCl, dxGrClms, dxDBGrid, dxTL, dxDBCtrl, dxCntner, kbmMemTable, kbmMemBinaryStreamFormat, Menus, StdCtrls, wwdbdatetimepicker, Grids, DBGridEh, Mask, wwdbedit, Wwdotdot, Wwdbcomb,teeprevi, RxLookup, TeEngine, Series, TeeProcs, Chart, DbChart, DBGrids, TeeFunci, wwdblook; type Tfrm_rp_zou_linehistry = class(TForm) Panel1: TPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton10: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton5: TbsSkinButton; SaveDialog: TSaveDialog; kbmBinaryStreamFormat1: TkbmBinaryStreamFormat; kbmThreadDataSet1: TkbmThreadDataSet; PopupMenu1: TPopupMenu; N1101: TMenuItem; memtblDetail: TkbmMemTable; p_total1: TDataSource; bsSkinPanel1: TbsSkinPanel; Label3: TLabel; cbYear: TwwDBComboBox; Label13: TLabel; RxDBLookupCombo5: TRxDBLookupCombo; Label14: TLabel; wwDBComboBox14: TwwDBComboBox; RxDBLookupCombo3: TRxDBLookupCombo; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; dxDBGrid1: TdxDBGrid; dxDBGrid1Column5: TdxDBGridColumn; dxDBGridMaskColumn95: TdxDBGridMaskColumn; memtotal1: TDataSource; memtotal: TkbmMemTable; memtotalField: TStringField; memtotalField2: TFloatField; memtblDetailField: TStringField; memtblDetailField01: TFloatField; memtblDetailField02: TFloatField; memtblDetailField03: TFloatField; memtblDetailField04: TFloatField; memtblDetailField05: TFloatField; memtblDetailField06: TFloatField; memtblDetailField07: TFloatField; memtblDetailField08: TFloatField; memtblDetailField09: TFloatField; memtblDetailField10: TFloatField; memtblDetailField11: TFloatField; memtblDetailField12: TFloatField; memtblDetailField2: TFloatField; Chart1: TChart; bsSkinRadioGroup1: TbsSkinRadioGroup; RxDBLookupCombo10: TRxDBLookupCombo; Label22: TLabel; t_code_trade_two: TADOQuery; t_code_trade_two1: TDataSource; t_code_trade_one: TADOQuery; t_code_trade_oneDSDesigner: TStringField; t_code_trade_one1: TDataSource; t_code_trade1: TDataSource; t_code_trade: TADOQuery; Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Label4: TLabel; bsSkinCheckGroup1: TbsSkinCheckGroup; RxDBLookupCombo20: TRxDBLookupCombo; Label21: TLabel; Label2: TLabel; RxDBLookupCombo1: TRxDBLookupCombo; bsSkinRadioGroup2: TbsSkinRadioGroup; bsSkinRadioGroup3: TbsSkinRadioGroup; wwDBLookupCombo52: TwwDBLookupCombo; Label124: TLabel; Label5: TLabel; cbeYear: TwwDBComboBox; Label12: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; bsSkinTabSheet3: TbsSkinTabSheet; ado_bs_items: TADOQuery; ado_bs_items1: TDataSource; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridColumn; dxDBGrid2Column2: TdxDBGridColumn; dxDBGrid2Column3: TdxDBGridColumn; dxDBGrid2Column4: TdxDBGridColumn; dxDBGrid2Column5: TdxDBGridColumn; dxDBGrid2Column6: TdxDBGridColumn; Label53: TLabel; wwDBComboBox58: TwwDBComboBox; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; bsSkinGroupBox1: TbsSkinGroupBox; Memo1: TMemo; Series1: TBarSeries; procedure bsSkinButton5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure Panel1Resize(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinCheckRadioBox3Click(Sender: TObject); procedure bsSkinCheckRadioBox2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure N1101Click(Sender: TObject); procedure bsSkinRadioGroup1Click(Sender: TObject); procedure RxDBLookupCombo1Change(Sender: TObject); procedure bsSkinRadioGroup2Click(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Chart1DblClick(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure dxDBGrid2DblClick(Sender: TObject); private FmDate,ToDate:String; sqlstr,cntrstr,linestr:WideString; procedure do_1(str_bill:widestring); procedure GetNoFee; procedure Getcntr; procedure Getlirun; procedure Getctnitems(years,weeks:Integer); procedure Creatememtbl; function GetZhangQi(SaleID,Cust:String):String; function isChaoQi(SaleID,Cust:String):Boolean; function GetZhangQiNum(SaleID,Cust:String;aetd:TDateTime):Double; function GetZhangQiStr(SaleID,Cust:String):String; function getleftstr(substr:String;leng:integer;left:boolean=true):String; function GetEtdStr(aYear,aWeek:Integer):String; { Private declarations } public { Public declarations } end; var frm_rp_zou_linehistry: Tfrm_rp_zou_linehistry; frmshow:boolean; implementation uses u_main, u_rp_no_seae_query,my_sys_function, u_rp_total_query, u_rp_no_total, u_sys_progress, u_rp_no_selfno, u_data_share; {$R *.dfm} function Tfrm_rp_zou_linehistry.GetEtdStr(aYear,aWeek:Integer):String; var FirstweekDay,endWeekday,aPerWeek: TDate; i:integer; S,datetype:String; begin Result:=''; datetype:='开船日期'; if (bsSkinCheckRadioBox1.Checked) then datetype:='预抵日期'; S:=''; aperweek:=EncodeDate(aYear, 1, 1); i:=DayOfWeek(aperweek); if i=1 then FirstweekDay:=aPerWeek-6 else FirstweekDay:=aPerWeek-(i-2); firstweekday:=firstweekday+7*(aWeek-1); endWeekday:=FirstweekDay+6; if S='' then begin if (bsSkinCheckRadioBox1.Checked) then S:=' t_op_seae.'+datetype+'>='''+FormatDateTime('YYYY-MM-DD',FirstweekDay)+''' and t_op_seae.'+datetype+'<'''+FormatDateTime('YYYY-MM-DD',FirstweekDay+7)+'''' else begin S:=' t_op_seae.'+datetype+'>='''+FormatDateTime('YYYY-MM-DD',FirstweekDay)+''' and t_op_seae.'+datetype+'<='''+FormatDateTime('YYYY-MM-DD',FirstweekDay+6)+''''; end; end; Result:=S; end; function Tfrm_rp_zou_linehistry.GetZhangQi(SaleID,Cust:String):String; var aQuery:TADOQuery; S:String; begin if (FmDate='') then begin FmDate:='2006-01-01'; end; aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; // SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 开始日期<='''+FmDate+''' and 结束日期>='''+ToDate+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); SQL.Add('Select * from t_crm_client_sales where 状态=''审核'' and 结束日期>'''+FmDate+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); Open; if not IsEmpty then begin first; S:=''; while not eof do begin S:=S+'开始日期:'+FormatDateTime('YYYY-MM-DD',FieldByName('开始日期').AsDateTime)+',结束日期'+FormatDateTime('YYYY-MM-DD',FieldByName('结束日期').AsDateTime); if FieldByName('结费类型').AsString='现结买单' then begin S:=S+'当月结算;'; end else if FieldByName('结费类型').AsString='约定天数' then begin S:=S+'约定天数,'+fieldByName('结费期限').AsString+'天;'; end else if FieldByName('结费类型').AsString='约定时间' then begin S:=S+'约定时间,'+FieldByName('类型模式').AsString+'月;'+FieldByName('结费日期').AsString+'日结算'; end else if FieldByName('结费类型').AsString='分阶段付费' then begin S:=S+'分阶段付费;'; end; Next; end; result:=S; end else begin Result:='无账期'; end; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_rp_zou_linehistry.do_1(str_bill:widestring); begin end; procedure Tfrm_rp_zou_linehistry.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_rp_zou_linehistry.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_rp_zou_linehistry.Hide; frm_rp_zou_linehistry.ManualFloat(frm_rp_zou_linehistry.BoundsRect ); frm_main.freeTabs('frm_rp_zou_linehistry'); action:=cafree; frm_rp_zou_linehistry:=nil; end; procedure Tfrm_rp_zou_linehistry.Panel1Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.Width/7); bsSkinButton10.Width:=i; bsSkinButton9.Width:=i; bsSkinButton1.Width:=i; end; procedure Tfrm_rp_zou_linehistry.bsSkinButton10Click(Sender: TObject); var FirstweekDay,endWeekday,aPerWeek: TDate; barse:TBarSeries; f,t,i,weekday:integer; sdate:string; aQuery:TAdoQuery; begin if cbyear.Text='' then begin MessageDlg('统计年不能为空!',mtWarning,[mbOk],0); exit; end; f:=strtoint(edit1.Text); t:=strtoint(edit2.text); cntrstr:=''; for i:=0 to bsSkinCheckGroup1.Items.Count-1 do begin if bsSkinCheckGroup1.Checked[i] then begin if cntrstr='' then cntrstr:=''''+StringReplace(bsSkinCheckGroup1.Items[i],'''','''''',[])+'''' else cntrstr:=cntrstr+','+''''+StringReplace(bsSkinCheckGroup1.Items[i],'''','''''',[])+''''; end; end; if cntrstr<>'' then cntrstr:='('+cntrstr+')'; linestr:=''; if bsSkinRadioGroup2.ItemIndex<>0 then begin linestr:=bsSkinRadioGroup2.Items.Strings[bsSkinRadioGroup2.ItemIndex]; linestr:='('+''''+linestr+''''+')'; end else if (RxDBLookupCombo20.DisplayValue<>'') or (RxDBLookupCombo1.DisplayValue<>'') then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; sql.Add('select 航线 from t_code_trade where 1=1 '); if RxDBLookupCombo20.DisplayValue<>'' then sql.Add(' and 一级航线='''+RxDBLookupCombo20.DisplayValue+''''); if RxDBLookupCombo1.DisplayValue<>'' then sql.Add(' and 二级航线='''+RxDBLookupCombo1.DisplayValue+''''); Open; first; while not eof do begin if linestr='' then linestr:=''''+FieldByName('航线').AsString+'''' else linestr:=linestr+','+''''+FieldByName('航线').AsString+''''; Next; end; if linestr<>'' then linestr:='('+linestr+')'; end; finally FreeAndNil(aQuery); end; end; Creatememtbl; memtblDetail.DisableControls; if bsSkinRadioGroup1.ItemIndex=0 then begin Getcntr; end; if bsSkinRadioGroup1.ItemIndex=1 then begin Getlirun; end; Memo1.Lines.Clear; Chart1.SeriesList.Clear; memtblDetail.First; while not memtblDetail.Eof do begin barse:=TBarSeries.Create(self); barse.Title:=memtblDetail.fieldbyname('年度').asstring+'数据'; for i:=f to t do begin sDate:=getleftstr(inttostr(i),2); aperweek:=EncodeDate(StrToInt64(memtblDetail.fieldbyname('年度').asstring), 1, 1); weekday:=DayOfWeek(aperweek); if weekday=1 then FirstweekDay:=aPerWeek-6 else FirstweekDay:=aPerWeek-(weekday-2); firstweekday:=firstweekday+7*(i-1); endWeekday:=FirstweekDay+6; barse.Add(memtblDetail.fieldbyname(sDate+'数量').AsFloat); barse.Marks.Style:= smsValue; Memo1.Lines.Add('年份:'+memtblDetail.fieldbyname('年度').asstring+'第'+sDate+'周('+FormatDateTime('YYYY-MM-DD',FirstweekDay)+'至'+FormatDateTime('YYYY-MM-DD',endWeekday)+')') end; Chart1.AddSeries(barse); memtblDetail.Next; end; Chart1.Repaint; memtblDetail.EnableControls; end; procedure Tfrm_rp_zou_linehistry.bsSkinButton1Click(Sender: TObject); begin with SaveDialog do begin DefaultExt :='xls'; Filter := '(*.xls)|*.xls'; if Execute then begin dxDBGrid1.SaveToXLS(FileName,true) end; end; end; procedure Tfrm_rp_zou_linehistry.bsSkinButton9Click(Sender: TObject); begin sys_print('业务综合欠费',2,nil,nil,nil,nil,p_total1,nil,nil,nil,nil,nil,nil); end; procedure Tfrm_rp_zou_linehistry.GetNoFee; begin end; procedure Tfrm_rp_zou_linehistry.Creatememtbl; var aDate,aToDate:TDate; sDate,aYear,aMonth,acaption:String; aColumn:TdxDBTreeListColumn; aBand:TdxTreeListBand; i,f,t:integer; begin f:=strtoint(edit1.Text); t:=strtoint(edit2.text); dxDBGrid1.Bands.Clear; // dxDBGrid1.DestroyColumns; while dxDBGrid1.columncount>0 do begin dxDBGrid1.Columns[0].Destroy; end; memtblDetail.Close; memtblDetail.EmptyTable; if bsSkinRadioGroup1.ItemIndex=0 then begin acaption:='标箱'; end else if bsSkinRadioGroup1.ItemIndex=1 then begin acaption:='利润'; end; memtblDetail.Fields.Clear; memtblDetail.FieldDefs.Clear; memtblDetail.FieldDefs.Add('年度', ftString, 20, false); aBand:=dxDBGrid1.Bands.Add; aBand.Caption:='基本信息'; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='年度'; aColumn.BandIndex:=0; aColumn.FieldName:='年度'; aBand:=dxDBGrid1.Bands.Add; aBand.Caption:=acaption; for i:=f to t do begin aMonth:=getleftstr(inttostr(i),2); aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:=aMonth+'周'+acaption; aColumn.FieldName:=aMonth+'数量'; aColumn.SummaryFooterType:=cstAvg; aColumn.BandIndex:=1; memtblDetail.FieldDefs.Add(aMonth+'数量',ftFloat, 0, false); end; aColumn:=dxDBGrid1.CreateColumn(TdxDBGridColumn); aColumn.Caption:='平均'+acaption; aColumn.FieldName:='平均数量'; aColumn.SummaryFooterType:=cstAvg; aColumn.BandIndex:=1; memtblDetail.FieldDefs.Add('平均数量',ftFloat, 0, false); memtblDetail.CreateTable; memtblDetail.Open; memtblDetail.IndexName:='年度'; end; function Tfrm_rp_zou_linehistry.GetZhangQiNum(SaleID, Cust: String; aetd: TDateTime): Double; var aQuery:TAdoQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 结费金额 from t_crm_client_sales where 状态=''审核'' and 开始日期<='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and 结束日期>='''+FormatDateTime('YYYY-MM-DD',aetd)+''' and 客户简称='''+Cust+''' and 揽货人='''+SaleID+''''); Open; if not IsEmpty then begin if FieldByName('结费金额').IsNull or (FieldByName('结费金额').AsFloat<=0) then begin Result:=0; end else begin Result:=FieldByName('结费金额').AsFloat; end; end else begin Result:=-1; end; end; finally FreeAndNil(aQuery); end; end; function Tfrm_rp_zou_linehistry.isChaoQi(SaleID, Cust: String): Boolean; begin end; procedure Tfrm_rp_zou_linehistry.bsSkinCheckRadioBox3Click(Sender: TObject); begin GetNoFee; end; procedure Tfrm_rp_zou_linehistry.bsSkinCheckRadioBox2Click(Sender: TObject); begin GetNoFee; end; function Tfrm_rp_zou_linehistry.GetZhangQiStr(SaleID, Cust: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; Result:=''; try with aQuery do begin Close;SQL.Clear; sql.Add(' select distinct SUBSTRING(CONVERT(char(15), dbo.v_op_bscard.开船日期, 111), 1, 7) from v_op_bscard left join t_ch_fee on t_ch_fee.编号=v_op_bscard.编号 '); sql.Add(sqlstr); sql.Add(' and t_ch_fee.客户名称='''+Cust+''' and v_op_bscard.揽货人='''+SaleID+''''); Open; if not IsEmpty then begin first; while not eof do begin if Result='' then result:=Fields[0].value else Result:=Result+','+Fields[0].value; Next; end; Result:=Result+'的欠费' end else result:=''; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_rp_zou_linehistry.FormShow(Sender: TObject); begin frmshow:=true; cbyear.Items.IndexOf(FormatDateTime('YYYY',Now)); cbyear.text:=FormatDateTime('YYYY',Now); cbeYear.Items.IndexOf(FormatDateTime('YYYY',Now)); cbeYear.text:=FormatDateTime('YYYY',Now); edit1.Text:='1'; edit2.Text:=inttostr(WeekofYear(now)); t_code_trade_one.Open; t_code_trade_two.Open; t_code_trade.Open; bsSkinCheckGroup1.Items.Clear; frm_data_share.t_code_ctn.First; while not frm_data_share.t_code_ctn.eof do begin bsSkinCheckGroup1.Items.add(frm_data_share.t_code_ctn.fieldbyname('表现形式').AsString); frm_data_share.t_code_ctn.Next; end; RxDBLookupCombo1.OnChange(nil); frmshow:=false; end; procedure Tfrm_rp_zou_linehistry.N1101Click(Sender: TObject); begin chartpreview(frm_rp_zou_linehistry,chart1); end; function Tfrm_rp_zou_linehistry.getleftstr(substr: String; leng: integer; left: boolean=true): String; var str:String; begin str:=substr; if length(str)>=leng then begin result:=str; exit; end; while length(str)t) do begin ydate:=inttostr(y); sDate:=getleftstr(inttostr(f),2); frm_sys_progress.bsSkinGauge1.ProgressText:='年:'+IntToStr(y)+' 周 '+IntToStr(f); CLOSE; SQL.Clear; { SQL.Add('Select '); SQL.Add('sum(isnull(t_op_ctn.TEU,0)) as 数量 '); SQL.Add('from t_op_seae '); SQL.Add('left join t_op_ctn on t_op_seae.编号=t_op_ctn.编号 where '+GetEtdStr(y,f)); } SQL.Add('Select '); SQL.Add('sum(isnull(t_op_ctn.TEU,0)) as 数量 '); SQL.Add('from t_op_ctn,t_op_seae '); SQL.Add('where t_op_seae.编号=t_op_ctn.编号 and '+GetEtdStr(y,f)); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_op_seae.委托单位='''+RxDBLookupCombo5.DisplayValues[1]+''''); if RxDBLookupCombo3.DisplayValue<>'' then begin if wwDBComboBox14.Text='不等于' then SQL.Add(' and t_op_seae.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') else SQL.Add(' and t_op_seae.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; if RxDBLookupCombo2.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.船公司='''+RxDBLookupCombo2.DisplayValues[1]+''''); end; if cntrstr<>'' then begin SQL.Add(' and t_op_ctn.表现形式 in '+cntrstr); end; if (wwDBComboBox58.Value<>'') then begin SQL.Add(' and t_op_seae.是否占舱='''+wwDBComboBox58.Value+''''); end; if linestr<>'' then begin if bsSkinRadioGroup3.ItemIndex=1 then SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI代码=t_op_seae.卸货代码 and t_code_disport.航线 in '+linestr+')') else SQL.Add(' and t_op_seae.航线 in '+linestr) end; if wwDBLookupCombo52.Text<>'' then begin SQL.Add(' and t_op_seae.卸货港 like ''%'+wwDBLookupCombo52.Text+'%''') end; SQL.Add(' and '+open_data('9009','t_op_seae.操作员','t_op_seae.揽货人','no','no','no','no')); Open; // showmessage(sql.Text); if not IsEmpty then begin first; while not eof do begin if memtblDetail.Locate('年度',Ydate,[]) then begin memtblDetail.Edit; memtblDetail.FieldByName(sDate+'数量').AsFloat:=memtblDetail.FieldByName(sDate+'数量').AsFloat+FieldbyName('数量').AsFloat; memtblDetail.Post; end else begin memtblDetail.Insert; for i:=0 to memtbldetail.FieldCount-1 do begin if memtbldetail.Fields[i].FieldName='年度' then memtbldetail.Fields[i].AsString:=Ydate else memtbldetail.Fields[i].AsFloat:=0; end; memtblDetail.FieldByName(sDate+'数量').AsFloat:=memtblDetail.FieldByName(sDate+'数量').AsFloat+FieldbyName('数量').AsFloat; memtblDetail.Post; end; frm_sys_progress.bsSkinGauge1.ProgressText:='年:'+IntToStr(y)+' 周: '+IntToStr(f); Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; f:=f+1; end; end; end; finally FreeAndNil(aQuery); freeAndNil(frm_sys_progress); end; end; procedure Tfrm_rp_zou_linehistry.Getlirun; var aQuery:TAdoQuery; aDate,aToDate:TDate; strdate,strbdate,sDate,yDate:String; i,f,t,n,fyear,eyear,y:integer; // S:TChartSeries; begin // DBChart3.AddSeries(); fyear:=strtoint(cbYear.text); eyear:=strtoint(cbeYear.text); aQuery:=CreateAdoQuery; try with aQuery do begin if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.Show; n:=eyear-fyear; if n=0 then n:=1; frm_sys_progress.bsSkinGauge1.MaxValue:=n; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; frm_sys_progress.Update; for y:=fyear to eyear do begin f:=strtoint(edit1.Text); t:=strtoint(edit2.text); while not (f>t) do begin ydate:=inttostr(y); sDate:=getleftstr(inttostr(f),2); CLOSE; SQL.Clear; SQL.Add('Select '); SQL.Add('sum(t_op_gain_main.毛利润) as 数量 '); SQL.Add('from t_op_seae inner JOIN t_op_gain_main ON t_op_seae.编号 =t_op_gain_main.编号 '); SQL.Add(' where '+GetEtdStr(y,f)); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_op_seae.委托单位='''+RxDBLookupCombo5.DisplayValues[1]+''''); if RxDBLookupCombo3.DisplayValue<>'' then begin if wwDBComboBox14.Text='不等于' then SQL.Add(' and t_op_seae.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') else SQL.Add(' and t_op_seae.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; if RxDBLookupCombo2.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.船公司='''+RxDBLookupCombo2.DisplayValues[1]+''''); end; if (wwDBComboBox58.Value<>'') then begin SQL.Add(' and t_op_seae.是否占舱='''+wwDBComboBox58.Value+''''); end; if cntrstr<>'' then begin SQL.Add(' and EXISTS (select * from t_op_ctn where t_op_ctn.编号=t_op_seae.编号 and t_op_ctn.表现形式 in '+cntrstr+')'); end; if linestr<>'' then begin if bsSkinRadioGroup3.ItemIndex=1 then SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI代码=t_op_seae.卸货代码 and t_code_disport.航线 in '+linestr+')') else SQL.Add(' and t_op_seae.航线 in '+linestr) end; if wwDBLookupCombo52.Text<>'' then begin SQL.Add(' and t_op_seae.卸货港 like ''%'+wwDBLookupCombo52.Text+'%''') end; SQL.Add(' and '+open_data('9009','t_op_seae.操作员','t_op_seae.揽货人','no','no','no','no')); Open; if not IsEmpty then begin first; while not eof do begin if memtblDetail.Locate('年度',Ydate,[]) then begin memtblDetail.Edit; memtblDetail.FieldByName(sDate+'数量').AsFloat:=memtblDetail.FieldByName(sDate+'数量').AsFloat+FieldbyName('数量').AsFloat; memtblDetail.Post; end else begin memtblDetail.Insert; for i:=0 to memtbldetail.FieldCount-1 do begin if memtbldetail.Fields[i].FieldName='年度' then memtbldetail.Fields[i].AsString:=Ydate else memtbldetail.Fields[i].AsFloat:=0; end; memtblDetail.FieldByName(sDate+'数量').AsFloat:=memtblDetail.FieldByName(sDate+'数量').AsFloat+FieldbyName('数量').AsFloat; memtblDetail.Post; end; Next; end; end; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; f:=f+1; end; end; end; finally FreeAndNil(aQuery); freeAndNil(frm_sys_progress); end; end; procedure Tfrm_rp_zou_linehistry.Getctnitems(years,weeks:Integer); begin with ado_bs_items do begin CLOSE; SQL.Clear; SQL.Add('Select t_op_seae.编号,t_op_seae.船公司,t_op_seae.委托单位,t_op_seae.集装箱,t_op_seae.卸货港,t_op_seae.主提单号,t_op_seae.委托单位'); SQL.Add(',sum(isnull(t_op_ctn.TEU,0)) as 数量 '); SQL.Add('from t_op_ctn,t_op_seae '); SQL.Add('where t_op_seae.编号=t_op_ctn.编号 and '+GetEtdStr(years,weeks)); if RxDBLookupCombo5.DisplayValues[1]<>'' then SQL.Add(' and t_op_seae.委托单位='''+RxDBLookupCombo5.DisplayValues[1]+''''); if RxDBLookupCombo3.DisplayValue<>'' then begin if wwDBComboBox14.Text='不等于' then SQL.Add(' and t_op_seae.揽货人<>'''+RxDBLookupCombo3.DisplayValues[0]+'''') else SQL.Add(' and t_op_seae.揽货人='''+RxDBLookupCombo3.DisplayValues[0]+''''); end; if RxDBLookupCombo10.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.销售部门='''+RxDBLookupCombo10.DisplayValues[0]+''''); end; if RxDBLookupCombo2.DisplayValue<>'' then begin SQL.Add(' and t_op_seae.船公司='''+RxDBLookupCombo2.DisplayValues[1]+''''); end; if cntrstr<>'' then begin SQL.Add(' and t_op_ctn.表现形式 in '+cntrstr); end; if linestr<>'' then begin if bsSkinRadioGroup3.ItemIndex=1 then SQL.Add(' and EXISTS (select * from t_code_disport where t_code_disport.EDI代码=t_op_seae.卸货代码 and t_code_disport.航线 in '+linestr+')') else SQL.Add(' and t_op_seae.航线 in '+linestr) end; if wwDBLookupCombo52.Text<>'' then begin SQL.Add(' and t_op_seae.卸货港 like ''%'+wwDBLookupCombo52.Text+'%''') end; SQL.Add(' and '+open_data('9009','t_op_seae.操作员','t_op_seae.揽货人','no','no','no','no')); SQL.Add('Group by t_op_seae.编号,t_op_seae.船公司,t_op_seae.委托单位,t_op_seae.集装箱,t_op_seae.卸货港,t_op_seae.主提单号,t_op_seae.委托单位'); Open; end; end; procedure Tfrm_rp_zou_linehistry.bsSkinRadioGroup1Click(Sender: TObject); begin bsSkinButton10.OnClick(sender); end; procedure Tfrm_rp_zou_linehistry.RxDBLookupCombo1Change(Sender: TObject); var aQuery:TADOQuery; begin bsSkinRadioGroup2.Items.Clear; bsSkinRadioGroup2.Items.Add('全部'); if RxDBLookupCombo1.DisplayValue<>'' then begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; sql.Add('select 航线 from t_code_trade where 1=1 '); if RxDBLookupCombo20.DisplayValue<>'' then sql.Add(' and 一级航线='''+RxDBLookupCombo20.DisplayValue+''''); if RxDBLookupCombo1.DisplayValue<>'' then sql.Add(' and 二级航线='''+RxDBLookupCombo1.DisplayValue+''''); Open; first; while not eof do begin bsSkinRadioGroup2.Items.Add(FieldByName('航线').AsString); Next; end; end; finally FreeAndNil(aQuery); end; end else begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; sql.Add('select 航线 from t_code_trade where 1=1 '); Open; first; while not eof do begin bsSkinRadioGroup2.Items.Add(FieldByName('航线').AsString); Next; end; end; finally FreeAndNil(aQuery); end; end; bsSkinRadioGroup2.ItemIndex:=0; end; procedure Tfrm_rp_zou_linehistry.bsSkinRadioGroup2Click(Sender: TObject); begin if frmshow then exit; bsSkinButton10.OnClick(sender); end; procedure Tfrm_rp_zou_linehistry.Button1Click(Sender: TObject); begin showmessage(GetEtdStr(strtoint(cbYear.text),strtoint(edit1.text))); end; procedure Tfrm_rp_zou_linehistry.Chart1DblClick(Sender: TObject); begin //showmessage(Chart1.Title.); //Chart1.SeriesList.g end; procedure Tfrm_rp_zou_linehistry.dxDBGrid1DblClick(Sender: TObject); var years,weeks:integer; begin years:=strtoint(memtblDetail.FieldByName('年度').AsString); weeks:=strtoint(Copy(dxDBGrid1.FocusedField.FieldName,1,2)); if bsSkinRadioGroup1.ItemIndex=0 then begin Getctnitems(years,weeks); bsSkinPageControl1.ActivePageIndex:=2; end; end; procedure Tfrm_rp_zou_linehistry.dxDBGrid2DblClick(Sender: TObject); begin fee_view(ado_bs_items.fieldbyname('编号').asstring); end; end.