329 lines
8.8 KiB
ObjectPascal
329 lines
8.8 KiB
ObjectPascal
![]() |
unit U_BaoGuanXSList;
|
|||
|
|
|||
|
interface
|
|||
|
|
|||
|
uses
|
|||
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|||
|
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|||
|
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
|
|||
|
cxGridTableView, cxGridBandedTableView, cxGridDBBandedTableView,
|
|||
|
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridDBTableView,
|
|||
|
cxGrid, StdCtrls, ComCtrls, ExtCtrls, ToolWin, cxGridCustomPopupMenu,
|
|||
|
cxGridPopupMenu, ADODB, DBClient, cxDropDownEdit, cxCheckBox, RM_Common,
|
|||
|
RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, Menus,
|
|||
|
cxCalendar, cxPC;
|
|||
|
|
|||
|
type
|
|||
|
TfrmBaoGuanXSList = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
Panel1: TPanel;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
Label1: TLabel;
|
|||
|
Label2: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDBMain: TRMDBDataSet;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
RMDBHZ: TRMDBDataSet;
|
|||
|
CDS_HZ: TClientDataSet;
|
|||
|
CDS_PRT: TClientDataSet;
|
|||
|
TBRKCX: TToolButton;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
Panel2: TPanel;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v1Column9: TcxGridDBColumn;
|
|||
|
v1Column11: TcxGridDBColumn;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
v1Column13: TcxGridDBColumn;
|
|||
|
v1Column14: TcxGridDBColumn;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
Label6: TLabel;
|
|||
|
Label8: TLabel;
|
|||
|
Label3: TLabel;
|
|||
|
A4FPNO: TEdit;
|
|||
|
A5ConNO: TEdit;
|
|||
|
A1ChuKouShang: TEdit;
|
|||
|
cxTabControl3: TcxTabControl;
|
|||
|
v1Column15: TcxGridDBColumn;
|
|||
|
v1Column16: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormCreate(Sender: TObject);
|
|||
|
procedure TBRafreshClick(Sender: TObject);
|
|||
|
procedure ConNoMChange(Sender: TObject);
|
|||
|
procedure TBCloseClick(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure TBExportClick(Sender: TObject);
|
|||
|
procedure TBFindClick(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure v2Column1CompareRowValuesForCellMerging(
|
|||
|
Sender: TcxGridColumn; ARow1: TcxGridDataRow;
|
|||
|
AProperties1: TcxCustomEditProperties; const AValue1: Variant;
|
|||
|
ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties;
|
|||
|
const AValue2: Variant; var AAreEqual: Boolean);
|
|||
|
procedure TBRKCXClick(Sender: TObject);
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
private
|
|||
|
procedure InitGrid();
|
|||
|
procedure GetColor(color:TColor);
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmBaoGuanXSList: TfrmBaoGuanXSList;
|
|||
|
|
|||
|
implementation
|
|||
|
uses
|
|||
|
U_DataLink,U_RTFun;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmBaoGuanXSList:=nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.FormClose(Sender: TObject;
|
|||
|
var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action:=caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
//cxGrid1.Align:=alClient;
|
|||
|
EndDate.DateTime:=SGetServerDate10(ADOQueryTemp);
|
|||
|
BegDate.DateTime:=SGetServerDateMBeg(ADOQueryTemp);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.InitGrid();
|
|||
|
var
|
|||
|
fsj:string;
|
|||
|
begin
|
|||
|
Panel2.Visible:=True;
|
|||
|
Panel2.Refresh;
|
|||
|
fsj:=' and A7FPDate>='''+Trim(FormatDateTime('yyyy-MM-dd',BegDate.Date))+''''
|
|||
|
+' and A7FPDate<'''+Trim(FormatDateTime('yyyy-MM-dd',EndDate.Date+1))+'''';
|
|||
|
if cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption<>'ȫ<><C8AB>' then
|
|||
|
begin
|
|||
|
fsj:=fsj+' and A1ChuKouShang like '''+'%'+Trim(cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption)+'%'+''''
|
|||
|
end;
|
|||
|
if cxTabControl3.TabIndex=0 then
|
|||
|
begin
|
|||
|
fsj:=fsj+'and isnull(SChker,'''')=''''';
|
|||
|
end else
|
|||
|
if cxTabControl3.TabIndex=1 then
|
|||
|
begin
|
|||
|
fsj:=fsj+' and isnull(OKPerson,'''')='''' and isnull(SChker,'''')<>'''' ';
|
|||
|
end else
|
|||
|
if cxTabControl3.TabIndex=2 then
|
|||
|
begin
|
|||
|
fsj:=fsj+' and isnull(Chker,'''')='''' and isnull(OKPerson,'''')<>'''' ';
|
|||
|
end else
|
|||
|
if cxTabControl3.TabIndex=3 then
|
|||
|
begin
|
|||
|
fsj:=fsj+' and isnull(Chker,'''')<>'''' ';
|
|||
|
end;
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered:=False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_View_BaoGuanData_XS :WSql');
|
|||
|
Parameters.ParamByName('WSql').Value:=fsj;
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
Panel2.Visible:=False;
|
|||
|
end;
|
|||
|
Panel2.Visible:=False;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
BegDate.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid('<27><><EFBFBD><EFBFBD><F1B1A8B9><EFBFBD><EFBFBD>۱<EFBFBD><DBB1><EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
ReadCxGrid('<27><><EFBFBD><EFBFBD><F1B1A8B9><EFBFBD><EFBFBD>۱<EFBFBD><DBB1><EFBFBD>',Tv1,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from KH_Zdy where Type=''A1ChuKouShang'' ');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not Eof do
|
|||
|
begin
|
|||
|
cxTabControl1.Tabs.Add(ADOQueryTemp.fieldbyname('ZdyName').asstring);
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
cxTabControl1.Tabs.Add('ȫ<><C8AB>');
|
|||
|
//InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD><EFBFBD><F1B1A8B9><EFBFBD><EFBFBD>۱<EFBFBD><DBB1><EFBFBD>',cxGrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.TBFindClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2));
|
|||
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.v2Column1CompareRowValuesForCellMerging(
|
|||
|
Sender: TcxGridColumn; ARow1: TcxGridDataRow;
|
|||
|
AProperties1: TcxCustomEditProperties; const AValue1: Variant;
|
|||
|
ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties;
|
|||
|
const AValue2: Variant; var AAreEqual: Boolean);
|
|||
|
|
|||
|
var
|
|||
|
colIdx0:integer;
|
|||
|
begin
|
|||
|
colIdx0:= tv1.GetColumnByFieldName('A4FPNO').Index;
|
|||
|
if ARow1.Values[colIdx0] = ARow2.Values[colIdx0] then
|
|||
|
AAreEqual := True
|
|||
|
else
|
|||
|
AAreEqual := False;
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.TBRKCXClick(Sender: TObject);
|
|||
|
var
|
|||
|
fPrintFile,fsj:string;
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then Exit;
|
|||
|
//if cxTabControl3.TabIndex<>3 then Exit;
|
|||
|
fPrintFile:= ExtractFilePath(Application.ExeName) + 'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf';
|
|||
|
fsj:=' and SubString(convert(varchar(10),A7FPDate,120),1,7)='''+Copy(Trim(CDS_Main.fieldbyname('A7FPDate').AsString),1,7)+'''';
|
|||
|
if cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption<>'ȫ<><C8AB>' then
|
|||
|
begin
|
|||
|
fsj:=fsj+' and A1ChuKouShang like '''+'%'+Trim(cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption)+'%'+'''';
|
|||
|
//+' and isnull(Chker,'''')<>'''' ';
|
|||
|
end else
|
|||
|
begin
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('exec P_View_BaoGuanData_XS :WSql');
|
|||
|
Parameters.ParamByName('WSql').Value:=fsj;
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryTemp,CDS_PRT);
|
|||
|
SInitCDSData20(ADOQueryTemp,CDS_PRT);
|
|||
|
RMXLSExport1:= TRMXLSExport.Create(RMXLSExport1);
|
|||
|
if FileExists(fPrintFile) then
|
|||
|
begin
|
|||
|
//RMVariables['enddate']:=enddate.DateTime;
|
|||
|
RMVariables['TaiTou']:=cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption;
|
|||
|
RM1.LoadFromFile(fPrintFile);
|
|||
|
RM1.ShowReport;
|
|||
|
end else
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('û<><C3BB><EFBFBD><EFBFBD>'+ExtractFilePath(Application.ExeName)+'Report\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.rmf'),'<27><>ʾ',0);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
GetColor(clRed);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmBaoGuanXSList.GetColor(color:TColor);
|
|||
|
var
|
|||
|
R,G,B:Integer;
|
|||
|
color10:TColor;
|
|||
|
begin
|
|||
|
R:=0;
|
|||
|
G:=0;
|
|||
|
B:=0;
|
|||
|
for R:=0 to 255 do
|
|||
|
begin
|
|||
|
for G:=0 to 255 do
|
|||
|
begin
|
|||
|
for B:=0 to 255 do
|
|||
|
begin
|
|||
|
//HZ:=i+j+k;
|
|||
|
color10:=(R shr 3)shl 11+(G shr 2)shl 5+B shr 3;
|
|||
|
if color10=color then
|
|||
|
begin
|
|||
|
Application.MessageBox(PChar('R='+IntToStr(R)+',G='+IntToStr(G)+',B='+IntToStr(B)),'<27><>ʾ',0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|