425 lines
12 KiB
ObjectPascal
425 lines
12 KiB
ObjectPascal
![]() |
unit U_DJGCLList;
|
|||
|
|
|||
|
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, cxButtonEdit, cxTextEdit, BtnEdit,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, cxPC;
|
|||
|
|
|||
|
type
|
|||
|
TfrmDJGCLLIST = class(TForm)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBRafresh: TToolButton;
|
|||
|
TBFind: TToolButton;
|
|||
|
TBExport: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
DataSource1: TDataSource;
|
|||
|
cxGridPopupMenu1: TcxGridPopupMenu;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
RM1: TRMGridReport;
|
|||
|
RMDBMain: TRMDBDataSet;
|
|||
|
RMXLSExport1: TRMXLSExport;
|
|||
|
RMDBHZ: TRMDBDataSet;
|
|||
|
CDS_HZ: TClientDataSet;
|
|||
|
CDS_PRT: TClientDataSet;
|
|||
|
PopupMenu1: TPopupMenu;
|
|||
|
N1: TMenuItem;
|
|||
|
N2: TMenuItem;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column26: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column15: TcxGridDBColumn;
|
|||
|
v1Column17: TcxGridDBColumn;
|
|||
|
v1Column18: TcxGridDBColumn;
|
|||
|
cxGrid2Level1: TcxGridLevel;
|
|||
|
Panel1: TPanel;
|
|||
|
Label2: TLabel;
|
|||
|
Label5: TLabel;
|
|||
|
BegDate: TDateTimePicker;
|
|||
|
EndDate: TDateTimePicker;
|
|||
|
FILLER: TEdit;
|
|||
|
chkdate: TCheckBox;
|
|||
|
Panel12: TPanel;
|
|||
|
cxTabControl1: TcxTabControl;
|
|||
|
ADOQueryPrint: TADOQuery;
|
|||
|
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 N1Click(Sender: TObject);
|
|||
|
procedure N2Click(Sender: TObject);
|
|||
|
procedure FILLERKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure FILLERChange(Sender: TObject);
|
|||
|
procedure SPSpecChange(Sender: TObject);
|
|||
|
procedure FactoryNameChange(Sender: TObject);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
procedure CheckBox1Click(Sender: TObject);
|
|||
|
|
|||
|
procedure ToolButton1Click(Sender: TObject);
|
|||
|
procedure cxTabControl1Change(Sender: TObject);
|
|||
|
procedure ToolButton2Click(Sender: TObject);
|
|||
|
procedure ToolButton3Click(Sender: TObject);
|
|||
|
private
|
|||
|
procedure SetStatus();
|
|||
|
procedure InitGrid();
|
|||
|
{ Private declarations }
|
|||
|
public
|
|||
|
canshu1: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmDJGCLLIST: TfrmDJGCLLIST;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.SetStatus();
|
|||
|
begin
|
|||
|
// ToolButton2.Visible := False;
|
|||
|
// ToolButton3.Visible := False;
|
|||
|
// if cxTabControl1.TabIndex = 0 then
|
|||
|
// begin
|
|||
|
// ToolButton2.Visible := true;
|
|||
|
// end
|
|||
|
// else if cxTabControl1.TabIndex = 1 then
|
|||
|
// begin
|
|||
|
// ToolButton3.Visible := true;
|
|||
|
// end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FormCreate(Sender: TObject);
|
|||
|
begin
|
|||
|
EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
|
|||
|
BegDate.DateTime := EndDate.DateTime;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.InitGrid();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
if cxTabControl1.TabIndex = 0 then
|
|||
|
begin
|
|||
|
SQL.Add(' SELECT count(mjid)PS,sum(MJLen)CD,sum(MJMaoZ)ZL,filler,CONVERT(varchar(7),FillTime,120)FillTime FROM WFB_MJJY WHERE');
|
|||
|
SQL.Add(' filler in (SELECT UserName FROM SY_User B WHERE B.Udept=''<27><><EFBFBD>ʼ<EFBFBD>'')');
|
|||
|
SQL.Add(' and ZDMJID is null ');
|
|||
|
if chkdate.Checked = True then
|
|||
|
begin
|
|||
|
sql.Add(' and filltime>=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', Begdate.DateTime))));
|
|||
|
sql.Add(' and filltime<' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1))));
|
|||
|
end;
|
|||
|
|
|||
|
SQL.Add(' group by filler,CONVERT(varchar(7),FillTime,120) order by CONVERT(varchar(7),FillTime,120)');
|
|||
|
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
SQL.Add(' SELECT count(mjid)PS,sum(MJLen)CD,sum(MJMaoZ)ZL,filler,CONVERT(varchar(10),FillTime,120)FillTime FROM WFB_MJJY WHERE');
|
|||
|
SQL.Add(' filler in (SELECT UserName FROM SY_User B WHERE B.Udept=''<27><><EFBFBD>ʼ<EFBFBD>'')');
|
|||
|
SQL.Add(' and ZDMJID is null ');
|
|||
|
if chkdate.Checked = True then
|
|||
|
begin
|
|||
|
sql.Add(' and filltime>=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', Begdate.DateTime))));
|
|||
|
sql.Add(' and filltime<' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1))));
|
|||
|
end;
|
|||
|
SQL.Add(' group by filler,CONVERT(varchar(10),FillTime,120) order by CONVERT(varchar(10),FillTime,120)');
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain, CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain, CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.TBRafreshClick(Sender: TObject);
|
|||
|
begin
|
|||
|
BegDate.SetFocus;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.ConNoMChange(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.Active then
|
|||
|
begin
|
|||
|
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
// WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|||
|
WriteCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>');
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
SetStatus();
|
|||
|
|
|||
|
ReadCxGrid(trim(self.Caption), Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>');
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.TBExportClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if ADOQueryMain.IsEmpty then
|
|||
|
exit;
|
|||
|
TcxGridToExcel('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>', cxGrid2);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.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 TfrmDJGCLLIST.N1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, True);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.N2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
SelOKNo(CDS_Main, False);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FILLERKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
{if Length(Trim(SPID.Text))<4 then Exit;
|
|||
|
try
|
|||
|
ADOQueryMain.DisableControls;
|
|||
|
with ADOQueryMain do
|
|||
|
begin
|
|||
|
Filtered:=False;
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ');
|
|||
|
sql.Add(',ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId)');
|
|||
|
//sql.Add(' ,ConNo=(select ConNo from Contract_Main CM where CM.MainId=A.CGMainId )');
|
|||
|
sql.Add(' from CK_SXPB_CR A');
|
|||
|
sql.add(' where SPID like :SXID');
|
|||
|
Parameters.ParamByName('SXID').Value:='%'+Trim(SXID.Text)+'%';
|
|||
|
Open;
|
|||
|
//ShowMessage(SQL.Text);
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryMain,CDS_Main);
|
|||
|
SInitCDSData20(ADOQueryMain,CDS_Main);
|
|||
|
finally
|
|||
|
ADOQueryMain.EnableControls;
|
|||
|
end; }
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FILLERChange(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.SPSpecChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FactoryNameChange(Sender: TObject);
|
|||
|
begin
|
|||
|
TBFind.Click;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmDJGCLLIST := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|||
|
var
|
|||
|
Fsunhao: double;
|
|||
|
begin
|
|||
|
|
|||
|
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('sunhao').Index] = null then
|
|||
|
Exit;
|
|||
|
Fsunhao := AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('sunhao').Index];
|
|||
|
if AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('ZPPS').Index] = null then
|
|||
|
Exit;
|
|||
|
if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('ZPPS').Index]) > 0 then
|
|||
|
begin
|
|||
|
//<2F><><EFBFBD>ġ<EFBFBD>2% <20><>ɫ<EFBFBD><C9AB> <20><><EFBFBD>ġ<EFBFBD>2% ~ <20><>5% <20><>ɫ<EFBFBD><C9AB> <20><><EFBFBD>Ĵ<EFBFBD><C4B4>ڡ<EFBFBD>5% <20><>ɫ
|
|||
|
if Fsunhao < 0 then
|
|||
|
Fsunhao := -Fsunhao;
|
|||
|
if Fsunhao <= 2 then
|
|||
|
ACanvas.Brush.Color := clMoneyGreen;
|
|||
|
if (Fsunhao > 2) and (Fsunhao <= 5) then
|
|||
|
ACanvas.Brush.Color := $00FFFF80;
|
|||
|
if Fsunhao > 5 then
|
|||
|
ACanvas.Brush.Color := $008080FF;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.CheckBox1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while not eof do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' exec P_UPdate_LCKJY ''' + Trim(CDS_Main.fieldbyname('SPID').AsString) + '''');
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
CDS_Main.Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.cxTabControl1Change(Sender: TObject);
|
|||
|
begin
|
|||
|
SetStatus();
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.ToolButton2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
if CDS_Main.Locate('SSel', True, []) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while CDS_Main.Locate('SSel', True, []) do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' UPDATE CK_SXPB_CR SET ISXS=''1'' WHERE SPID=''' + Trim(CDS_Main.fieldbyname('SPID').AsString) + '''');
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
CDS_Main.Delete;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmDJGCLLIST.ToolButton3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Main.IsEmpty then
|
|||
|
Exit;
|
|||
|
if CDS_Main.Locate('SSel', True, []) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('û<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
Exit;
|
|||
|
end;
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
CDS_Main.DisableControls;
|
|||
|
with CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while CDS_Main.Locate('SSel', True, []) do
|
|||
|
begin
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' UPDATE CK_SXPB_CR SET ISXS=NULL WHERE SPID=''' + Trim(CDS_Main.fieldbyname('SPID').AsString) + '''');
|
|||
|
execsql;
|
|||
|
end;
|
|||
|
CDS_Main.Delete;
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
CDS_Main.EnableControls;
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>쳣!', '<27><>ʾ', 0);
|
|||
|
end;
|
|||
|
InitGrid();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|