unit UnitPjgl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, cxStyles, cxCustomData, cxGraphics,
cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel,
cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, ExtCtrls, Buttons, ADODB,
cxGridBandedTableView, cxGridDBBandedTableView, cxTextEdit, cxCalc;
type
TFramePjgl = class(TFrame)
tbcpjgl: TTabControl;
grp1: TGroupBox;
grpOperator: TGroupBox;
lblNewPjDate: TLabel;
pnlList: TPanel;
rbzdSearch: TRadioButton;
rbxlSearch: TRadioButton;
edtSearchIf: TEdit;
btnSearch: TBitBtn;
cbbOperatorType: TComboBox;
cbbJsfs: TComboBox;
edtContext: TEdit;
btnSwitch: TBitBtn;
btnSave: TBitBtn;
qryPjList: TADOQuery;
dsPjList: TDataSource;
cxgrd1: TcxGrid;
bandtvfilms: TcxGridDBBandedTableView;
lvfilms: TcxGridLevel;
bandtvfilmszddm: TcxGridDBBandedColumn;
bandtvfilmszm: TcxGridDBBandedColumn;
bandtvfilmszs: TcxGridDBBandedColumn;
bandtvfilmsa: TcxGridDBBandedColumn;
bandtvfilmsb: TcxGridDBBandedColumn;
bandtvfilmsc: TcxGridDBBandedColumn;
bandtvfilmsd: TcxGridDBBandedColumn;
bandtvfilmse: TcxGridDBBandedColumn;
bandtvfilmsf: TcxGridDBBandedColumn;
bandtvfilmsg: TcxGridDBBandedColumn;
bandtvfilmsh: TcxGridDBBandedColumn;
bandtvfilmsi: TcxGridDBBandedColumn;
bandtvfilmsj: TcxGridDBBandedColumn;
bandtvfilmsk: TcxGridDBBandedColumn;
bandtvfilmsl: TcxGridDBBandedColumn;
bandtvfilmsm: TcxGridDBBandedColumn;
bandtvfilmsn: TcxGridDBBandedColumn;
bandtvfilmso: TcxGridDBBandedColumn;
bandtvfilmsp: TcxGridDBBandedColumn;
bandtvfilmsq: TcxGridDBBandedColumn;
bandtvfilmsr: TcxGridDBBandedColumn;
bandtvfilmss: TcxGridDBBandedColumn;
bandtvfilmst: TcxGridDBBandedColumn;
bandtvfilmsu: TcxGridDBBandedColumn;
bandtvfilmsv: TcxGridDBBandedColumn;
bandtvfilmsw: TcxGridDBBandedColumn;
bandtvfilmsx: TcxGridDBBandedColumn;
bandtvfilmsy: TcxGridDBBandedColumn;
bandtvfilmsz: TcxGridDBBandedColumn;
bandtvfilmsFlag: TcxGridDBBandedColumn;
cxstylrpstry1: TcxStyleRepository;
cxgrdtblvwstylshtGridTableViewStyleSheetDevExpress: TcxGridTableViewStyleSheet;
cxstyl1: TcxStyle;
cxstyl2: TcxStyle;
cxstyl3: TcxStyle;
cxstyl4: TcxStyle;
cxstyl5: TcxStyle;
cxstyl6: TcxStyle;
cxstyl7: TcxStyle;
cxstyl8: TcxStyle;
cxstyl9: TcxStyle;
cxstyl10: TcxStyle;
cxstyl11: TcxStyle;
cxstyl12: TcxStyle;
cxstyl13: TcxStyle;
cxstyl14: TcxStyle;
cxStyle1: TcxStyle;
con1: TADOConnection;
btnTbxpj: TBitBtn;
btnUpdatePj: TBitBtn;
procedure tbcpjglChange(Sender: TObject);
private
procedure InitTableTitle;
{ Private declarations }
public
procedure GetConnectionDB(flag:Integer);
{ Public declarations }
end;
implementation
uses UnitMain, PublicFile;
{$R *.dfm}
procedure TFramePjgl.GetConnectionDB(flag:Integer);
begin
if Flag=1 then
begin
try
con1.Connected:=True;
except
HintInfo('连接数据库失败!',2);
end;
end;
end;
procedure TFramePjgl.InitTableTitle;
var
SqlStr:string;
QryTmp:TADOQuery;
i:Integer;
begin
QryTmp:=TADOQuery.Create(Self);
QryTmp.Connection:=con1;
try
SqlStr:='select ''到站''as zddm,''到站''as zddm,''注释''as zs,zsa,zsb,zsc,zsd,zse,zsf,zsg,zsh,zsi,zsj,zsk,zsl,';
SqlStr:=SqlStr+'zsm,zsn,zso,zsp,zsq,zsr,zss,zst,zsu,zsv,zsw,zsx,zsy,zsz,''1'' as bz from pjzsb';
DataFind(SqlStr,QryTmp);
i:=3;
while QryTmp.FieldCount> i do
begin
bandtvfilms.Bands.Items[i-1].Caption:=Trim(QryTmp.Fields[i].AsString);
i:=i+1;
end;
finally
QryTmp.Free;
end;
end;
procedure TFramePjgl.tbcpjglChange(Sender: TObject);
var
Sqlstr:string;
begin
qryPjList.Connection:=con1;
if tbcpjgl.TabIndex=1 then
begin
//cxgrd1.Levels[0].GridView:=tvfilms;
//cxgrd1.Levels[0].GridView:=bandtvfilms; 指定View
InitTableTitle; //动态生成注释表头
Sqlstr:='select * from (select zddm,zm,''里程'' as zs,la as a,lb as b,lc as c,ld as d,le as e,lf as f,lg as g,lh as h,li as i, ';
Sqlstr:=Sqlstr+' lj as j,lk as k,ll as l,lm as m,ln as n,lo as o,lp as p,lq as q,lr as r,ls as s,lt as t,lu as u, ';
Sqlstr:=Sqlstr+' lv as v,lw as w,lx as x,ly as y,lz as z,''1''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''客票票价'' as pj,xa,xb,xc,xd,xe,xf,xg,xh,xi,xj,xk,xl,xm,xn,xo,xp,xq,xr,xs,xt,xu,xv,xw,xx,xy,xz,''2''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''燃油附加'' as ry,rxa,rxb,rxc,rxd,rxe,rxf,rxg,rxh,rxi,rxj,rxk,rxl,rxm,rxn,rxo,rxp,rxq,rxr, ';
Sqlstr:=Sqlstr+' rxs,rxt,rxu,rxv,rxw,rxx,rxy,rxz,''3''as Flag from zmpjb) aa order by zddm ,flag ';
DataFind(Sqlstr,qryPjList);
end
else if tbcpjgl.TabIndex=0 then
begin
Sqlstr:='select * from (select zddm,zm,''里程'' as zs,la as a,lb as b,lc as c,ld as d,le as e,lf as f,lg as g,lh as h,li as i, ';
Sqlstr:=Sqlstr+' lj as j,lk as k,ll as l,lm as m,ln as n,lo as o,lp as p,lq as q,lr as r,ls as s,lt as t,lu as u, ';
Sqlstr:=Sqlstr+' lv as v,lw as w,lx as x,ly as y,lz as z,''1''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''客票票价'' as pj,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,''2''as Flag from zmpjb ';
Sqlstr:=Sqlstr+' union all select zddm,zm,''燃油附加'' as ry,ra,rb,rc,rd,re,rf,rg,rh,ri,rj,rk,rl,rm,rn,ro,rp,rq,rr, ';
Sqlstr:=Sqlstr+' rs,rt,ru,rv,rw,rx,ry,rz,''3''as Flag from zmpjb) aa order by zddm ,flag ';
DataFind(Sqlstr,qryPjList);
end;
end;
end.