436 lines
13 KiB
ObjectPascal
436 lines
13 KiB
ObjectPascal
unit U_YFFKListDZEY;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB,
|
||
cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls,
|
||
cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls,
|
||
cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common,
|
||
RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection,
|
||
IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit,
|
||
cxTextEdit, cxPC, cxGridBandedTableView, cxGridDBBandedTableView, BtnEdit,
|
||
cxLookAndFeels, cxLookAndFeelPainters, dxBarBuiltInMenu, cxNavigator,
|
||
dxSkinsCore,
|
||
dxSkinDarkRoom,
|
||
|
||
|
||
|
||
|
||
|
||
|
||
dxSkinOffice2013White,
|
||
dxSkinSharpPlus,
|
||
dxSkinSpringTime,
|
||
dxSkinsDefaultPainters,
|
||
dxSkinscxPCPainter;
|
||
|
||
type
|
||
TfrmYFFKListDZEY = class(TForm)
|
||
ToolBar1: TToolBar;
|
||
TBRafresh: TToolButton;
|
||
TBClose: TToolButton;
|
||
ADOQueryTemp: TADOQuery;
|
||
ADOQueryCmd: TADOQuery;
|
||
Panel1: TPanel;
|
||
ToolButton2: TToolButton;
|
||
ToolButton1: TToolButton;
|
||
RM1: TRMGridReport;
|
||
RMDB_Main: TRMDBDataSet;
|
||
cxGridPopupMenu2: TcxGridPopupMenu;
|
||
DS_HZ: TDataSource;
|
||
ADOQueryMain: TADOQuery;
|
||
CDS_HZ: TClientDataSet;
|
||
ToolButton3: TToolButton;
|
||
cxTabControl1: TcxTabControl;
|
||
cxGrid2: TcxGrid;
|
||
Tv2: TcxGridDBTableView;
|
||
v2Column6: TcxGridDBColumn;
|
||
v2SQMoney: TcxGridDBColumn;
|
||
v2YFMoney: TcxGridDBColumn;
|
||
v2FKMoney: TcxGridDBColumn;
|
||
v2BQMoney: TcxGridDBColumn;
|
||
v2Column4: TcxGridDBColumn;
|
||
v2Column7: TcxGridDBColumn;
|
||
v2Column8: TcxGridDBColumn;
|
||
v2ZJFKDate: TcxGridDBColumn;
|
||
v2ZJFKMoney: TcxGridDBColumn;
|
||
cxGridLevel1: TcxGridLevel;
|
||
Panel2: TPanel;
|
||
Label2: TLabel;
|
||
begdate: TDateTimePicker;
|
||
Panel3: TPanel;
|
||
Label4: TLabel;
|
||
FBegDate: TDateTimePicker;
|
||
Label5: TLabel;
|
||
FEndDate: TDateTimePicker;
|
||
Panel4: TPanel;
|
||
Label3: TLabel;
|
||
RadioGroup1: TRadioGroup;
|
||
FactoryNameGYS: TEdit;
|
||
v2Column1: TcxGridDBColumn;
|
||
v2Column2: TcxGridDBColumn;
|
||
v2Column3: TcxGridDBColumn;
|
||
v2Column5: TcxGridDBColumn;
|
||
Label1: TLabel;
|
||
FactoryNo: TEdit;
|
||
procedure FormDestroy(Sender: TObject);
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBRafreshClick(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
procedure cxTabControl1Change(Sender: TObject);
|
||
procedure RadioGroup1Click(Sender: TObject);
|
||
procedure FactoryNameGYSChange(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
public
|
||
fDParameters1: string;
|
||
{ Public declarations }
|
||
RKFlag, FCYID: string;
|
||
end;
|
||
|
||
//var
|
||
// frmYFFKListDZEY: TfrmYFFKListDZEY;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun, U_Fun, U_ZDYHelp, U_YFMXlistMonDayGQXEY, U_GYSListSelJJ;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrmYFFKListDZEY.InitGrid();
|
||
var
|
||
FYue, FDate: string;
|
||
FInt: Integer;
|
||
FHuiLv: Double;
|
||
begin
|
||
{if RadioGroup1.ItemIndex=0 then
|
||
begin
|
||
FInt:=cxTabControl1.TabIndex+1;
|
||
FYue:=Trim(IntToStr(FInt));
|
||
if FInt<10 then
|
||
begin
|
||
FYue:='0'+Trim(IntToStr(FInt));
|
||
end;
|
||
FDate:=Trim(FormatDateTime('yyyy',begdate.Date))+'-'+FYue;
|
||
FBegDate.Date:=StrToDate(FDate+'-01');
|
||
if FInt=12 then
|
||
FEndDate.Date:=StrToDate(Trim(FormatDateTime('yyyy',begdate.Date))+'-12-31')
|
||
else
|
||
FEndDate.Date:=StrToDate(Trim(FormatDateTime('yyyy',begdate.Date))+'-'+Trim(IntToStr(FInt+1))+'-01')-1;
|
||
end; }
|
||
if (RadioGroup1.ItemIndex = 0) or (RadioGroup1.ItemIndex = 2) then
|
||
begin
|
||
if cxTabControl1.TabIndex < 11 then
|
||
begin
|
||
FInt := cxTabControl1.TabIndex + 2;
|
||
end
|
||
else
|
||
begin
|
||
FInt := 1;
|
||
end;
|
||
FYue := Trim(IntToStr(FInt));
|
||
if FInt < 10 then
|
||
begin
|
||
FYue := '0' + Trim(IntToStr(FInt));
|
||
end;
|
||
if FInt <> 1 then
|
||
begin
|
||
FDate := Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + FYue;
|
||
end
|
||
else
|
||
begin
|
||
FDate := Trim(FormatDateTime('yyyy', begdate.Date));
|
||
FDate := IntToStr(strtoint(FDate) + 1);
|
||
FDate := FDate + '-' + FYue;
|
||
end;
|
||
|
||
FBegDate.Date := StrToDate(FDate + '-01');
|
||
if FInt = 12 then
|
||
FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-12-31')
|
||
else
|
||
begin
|
||
if FInt = 1 then
|
||
begin
|
||
FEndDate.Date := StrToDate(FDate + '-31');
|
||
end
|
||
else
|
||
begin
|
||
FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1;
|
||
end;
|
||
end;
|
||
end;
|
||
try
|
||
ADOQueryMain.DisableControls;
|
||
with ADOQueryMain do
|
||
begin
|
||
|
||
Close;
|
||
SQL.Clear;
|
||
Filtered := False;
|
||
if RadioGroup1.ItemIndex = 0 then
|
||
begin
|
||
sql.Add(' exec P_YFFK_Month :Fdate ');
|
||
Parameters.ParamByName('Fdate').Value := FDate;
|
||
end
|
||
else if RadioGroup1.ItemIndex = 1 then
|
||
begin
|
||
sql.Add(' exec P_YFFK_Day :FBegdate,:FEndDate ');
|
||
Parameters.ParamByName('FBegdate').Value := Trim(FormatDateTime('yyyy-MM-dd', FBegDate.Date));
|
||
Parameters.ParamByName('FEndDate').Value := Trim(FormatDateTime('yyyy-MM-dd', FEndDate.Date + 1));
|
||
end
|
||
else if RadioGroup1.ItemIndex = 2 then
|
||
begin
|
||
sql.Add(' exec P_YFFK_Month_GZ :Fdate ');
|
||
Parameters.ParamByName('Fdate').Value := FDate;
|
||
end;
|
||
Open;
|
||
end;
|
||
SCreateCDS20(ADOQueryMain, CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain, CDS_HZ);
|
||
finally
|
||
ADOQueryMain.EnableControls;
|
||
end;
|
||
//ToolButton2.Click;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.FormDestroy(Sender: TObject);
|
||
begin
|
||
//frmYFFKListDZEY:=nil;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
Action := caFree;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.TBCloseClick(Sender: TObject);
|
||
begin
|
||
WriteCxGrid('Ӧ<><D3A6><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>YXDZ', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
Close;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.FormShow(Sender: TObject);
|
||
var
|
||
fstr: string;
|
||
begin
|
||
ReadCxGrid('Ӧ<><D3A6><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>YXDZ', Tv2, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||
{begdate.DateTime:=SGetServerDateMBeg(ADOQueryTemp);
|
||
Fbegdate.DateTime:=SGetServerDate(ADOQueryTemp);
|
||
FEndDate.Date:=Fbegdate.DateTime;
|
||
fstr:=Trim(FormatDateTime('MM',begdate.Date));
|
||
cxTabControl1.TabIndex:=StrToInt(fstr)-1; }
|
||
Fbegdate.DateTime := SGetServerDate(ADOQueryTemp);
|
||
FEndDate.Date := Fbegdate.DateTime;
|
||
fstr := Trim(FormatDateTime('MM', Fbegdate.Date));
|
||
if StrToInt(fstr) = 1 then
|
||
begin
|
||
begdate.DateTime := SGetServerDateMBeg(ADOQueryTemp) - 40;
|
||
cxTabControl1.TabIndex := 11; //StrToInt(fstr)-1;
|
||
end
|
||
else
|
||
begin
|
||
begdate.DateTime := SGetServerDateMBeg(ADOQueryTemp);
|
||
cxTabControl1.TabIndex := StrToInt(fstr) - 2;
|
||
end;
|
||
cxTabControl1.Tabs[11].Caption := ' 1<>£<EFBFBD>' + inttostr(strtoint(FormatDateTime('yyyy', begdate.Date)) + 1) + '<27><>)';
|
||
Panel3.Visible := False;
|
||
// InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.TBRafreshClick(Sender: TObject);
|
||
begin
|
||
cxTabControl1.Tabs[11].Caption := ' 1<>£<EFBFBD>' + inttostr(strtoint(FormatDateTime('yyyy', begdate.Date)) + 1) + '<27><>)';
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.Active = False then
|
||
Exit;
|
||
SDofilter(ADOQueryMain, SGetFilters(Panel4, 1, 2));
|
||
SCreateCDS20(ADOQueryMain, CDS_HZ);
|
||
SInitCDSData20(ADOQueryMain, CDS_HZ);
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
if ADOQueryMain.IsEmpty then
|
||
Exit;
|
||
TcxGridToExcel('Ӧ<><D3A6><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>б<EFBFBD>DZ', cxGrid2);
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
|
||
var
|
||
FName, FNO: string;
|
||
FDate, FYue: string;
|
||
FInt: Integer;
|
||
FFBegDate, FFEndDate: TDate;
|
||
begin
|
||
if CDS_HZ.IsEmpty then
|
||
Exit;
|
||
if RadioGroup1.ItemIndex = 0 then
|
||
begin
|
||
if cxTabControl1.TabIndex < 11 then
|
||
begin
|
||
FInt := cxTabControl1.TabIndex + 2;
|
||
end
|
||
else
|
||
begin
|
||
FInt := 1;
|
||
end;
|
||
FYue := Trim(IntToStr(FInt));
|
||
if FInt < 10 then
|
||
begin
|
||
FYue := '0' + Trim(IntToStr(FInt));
|
||
end;
|
||
if FInt <> 1 then
|
||
begin
|
||
FDate := Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + FYue;
|
||
end
|
||
else
|
||
begin
|
||
FDate := Trim(FormatDateTime('yyyy', begdate.Date));
|
||
FDate := IntToStr(strtoint(FDate) + 1);
|
||
FDate := FDate + '-' + FYue;
|
||
end;
|
||
|
||
FFBegDate := StrToDate(FDate + '-01');
|
||
if FInt = 12 then
|
||
FFEndDate := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-12-31')
|
||
else
|
||
begin
|
||
if FInt = 1 then
|
||
begin
|
||
FFEndDate := StrToDate(FDate + '-31');
|
||
end
|
||
else
|
||
begin
|
||
FFEndDate := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1;
|
||
end;
|
||
end;
|
||
|
||
end
|
||
else if RadioGroup1.ItemIndex = 1 then
|
||
begin
|
||
FFBegDate := FBegDate.Date;
|
||
FFEndDate := FEndDate.Date;
|
||
end;
|
||
try
|
||
frmYFMXlistMonDayGQXEY := TfrmYFMXlistMonDayGQXEY.Create(Application);
|
||
with frmYFMXlistMonDayGQXEY do
|
||
begin
|
||
FMX := '99';
|
||
PState := Self.RadioGroup1.ItemIndex;
|
||
if Self.RadioGroup1.ItemIndex = 0 then
|
||
begin
|
||
frmYFMXlistMonDayGQXEY.begdate.DateTime := Self.begdate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.cxTabControl1.TabIndex := Self.cxTabControl1.TabIndex;
|
||
frmYFMXlistMonDayGQXEY.factoryName.Text := Self.CDS_HZ.fieldbyname('factoryName').AsString;
|
||
frmYFMXlistMonDayGQXEY.Fbegdate.DateTime := Self.Fbegdate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.FEnddate.DateTime := Self.FEnddate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.cxTabControl1.Tabs[11].Caption := Self.cxTabControl1.Tabs[11].Caption;
|
||
end
|
||
else if Self.RadioGroup1.ItemIndex = 1 then
|
||
begin
|
||
frmYFMXlistMonDayGQXEY.begdate.DateTime := Self.begdate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.Fbegdate.DateTime := Self.Fbegdate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.FEnddate.DateTime := Self.FEnddate.DateTime;
|
||
frmYFMXlistMonDayGQXEY.factoryName.Text := Self.CDS_HZ.fieldbyname('factoryName').AsString;
|
||
|
||
end;
|
||
frmYFMXlistMonDayGQXEY.factoryName.TxtCode := Self.CDS_HZ.fieldbyname('factoryNo').AsString;
|
||
frmYFMXlistMonDayGQXEY.Align := alClient;
|
||
frmYFMXlistMonDayGQXEY.LabGYS.Caption := Self.CDS_HZ.fieldbyname('factoryName').AsString;
|
||
if Self.Caption = '<27><>Ӧ<EFBFBD>̶<EFBFBD><CCB6>˵<EFBFBD><CBB5><EFBFBD>ѯ*' then
|
||
begin
|
||
frmYFMXlistMonDayGQXEY.cxGrid2.PopupMenu := frmYFMXlistMonDayGQXEY.PopupMenu2;
|
||
end
|
||
else
|
||
begin
|
||
frmYFMXlistMonDayGQXEY.cxGrid2.PopupMenu := frmYFMXlistMonDayGQXEY.PopupMenu1;
|
||
end;
|
||
if ShowModal = 1 then
|
||
begin
|
||
|
||
end;
|
||
end;
|
||
finally
|
||
frmYFMXlistMonDayGQXEY.Free;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.ToolButton3Click(Sender: TObject);
|
||
var
|
||
filepath, fsj: string;
|
||
mBegdate, mEnddate: string;
|
||
FName, FNameSX, FNameJX: string;
|
||
i: Integer;
|
||
begin
|
||
fsj := cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption;
|
||
mBegdate := FormatDateTime('yyyy', begdate.Date) + '<27><>' + Trim(Copy(fsj, 3, Length(fsj) - 2)) + '<27><>';
|
||
if CDS_HZ.IsEmpty then
|
||
exit;
|
||
try
|
||
filepath := ExtractFilePath(Application.ExeName) + 'report\Ӧ<><D3A6><EFBFBD><EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>YX.rmf';
|
||
if not FileExists(Pchar(filepath)) then
|
||
begin
|
||
application.MessageBox(pchar('<27>ļ<EFBFBD>[' + filepath + ']<5D><><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>'), '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_IConError);
|
||
exit;
|
||
end;
|
||
RmVariables['begDate'] := mBegdate;
|
||
RM1.LoadFromFile(filepath);
|
||
RM1.ShowReport;
|
||
finally
|
||
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.cxTabControl1Change(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.RadioGroup1Click(Sender: TObject);
|
||
begin
|
||
if RadioGroup1.ItemIndex = 0 then
|
||
begin
|
||
Panel2.Visible := True;
|
||
Panel3.Visible := False;
|
||
cxTabControl1.Visible := True;
|
||
v2SQMoney.Caption := Copy(v2SQMoney.Summary.GroupFormat, 1, 8);
|
||
v2YFMoney.Caption := Copy(v2YFMoney.Summary.GroupFormat, 1, 10);
|
||
v2FKMoney.Caption := Copy(v2FKMoney.Summary.GroupFormat, 1, 8);
|
||
v2BQMoney.Caption := Copy(v2BQMoney.Summary.GroupFormat, 1, 8);
|
||
end
|
||
else if RadioGroup1.ItemIndex = 1 then
|
||
begin
|
||
Panel2.Visible := False;
|
||
Panel3.Visible := True;
|
||
cxTabControl1.Visible := False;
|
||
v2SQMoney.Caption := Copy(v2SQMoney.Summary.GroupFormat, 10, 8);
|
||
v2YFMoney.Caption := Copy(v2YFMoney.Summary.GroupFormat, 12, 10);
|
||
v2FKMoney.Caption := Copy(v2FKMoney.Summary.GroupFormat, 10, 8);
|
||
v2BQMoney.Caption := Copy(v2BQMoney.Summary.GroupFormat, 10, 8);
|
||
end;
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmYFFKListDZEY.FactoryNameGYSChange(Sender: TObject);
|
||
begin
|
||
ToolButton2.Click;
|
||
end;
|
||
|
||
end.
|
||
|