RTFormwork/项目代码/RTBasicsV1/C03纱线加弹仓库/U_YEYarnOutList.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

495 lines
13 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

unit U_YEYarnOutList;
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, MovePanel, Math, Clipbrd,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, cxTextEdit, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, U_BaseList, cxPC,
System.StrUtils;
type
TfrmYEYarnOutList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBExport: TToolButton;
TBClose: TToolButton;
Panel1: TPanel;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DS_1: TDataSource;
GPM_1: TcxGridPopupMenu;
Label2: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
CDS_1: TClientDataSet;
TBRKCX: TToolButton;
begtime: TDateTimePicker;
endTime: TDateTimePicker;
IsJYTime: TCheckBox;
ToolButton2: TToolButton;
ToolButton4: TToolButton;
Panel6: TPanel;
Label31: TLabel;
LBCPAP: TLabel;
BTLP: TButton;
BTNP: TButton;
TCBNOR: TComboBox;
Label3: TLabel;
Label7: TLabel;
Label10: TLabel;
Label5: TLabel;
Label20: TLabel;
Label23: TLabel;
OrderNo: TEdit;
conNO: TEdit;
STKID: TEdit;
C_Name: TEdit;
C_Color: TEdit;
C_Pattern: TEdit;
C_Code: TEdit;
PM_1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
ToolButton1: TToolButton;
N3: TMenuItem;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column22: TcxGridDBColumn;
v1Column21: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column28: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column42: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Tv1Column2: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column10: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
Tv1Column13: TcxGridDBColumn;
Tv1Column14: TcxGridDBColumn;
Tv1Column15: TcxGridDBColumn;
Tv1Column16: TcxGridDBColumn;
Tv1Column17: TcxGridDBColumn;
Tv1Column18: TcxGridDBColumn;
Tv1Column19: TcxGridDBColumn;
Tv1Column20: TcxGridDBColumn;
Tv1Column21: TcxGridDBColumn;
Tv1Column22: TcxGridDBColumn;
Tv1Column23: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
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 orderNoKeyPress(Sender: TObject; var Key: Char);
procedure TBRKCXClick(Sender: TObject);
procedure BTNPClick(Sender: TObject);
procedure BTLPClick(Sender: TObject);
procedure TCBNORChange(Sender: TObject);
procedure JYTypeChange(Sender: TObject);
procedure ToolButton2Click(Sender: TObject);
procedure cxPageControl1Change(Sender: TObject);
procedure CDS_1BeforeOpen(DataSet: TDataSet);
procedure Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
procedure Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
procedure ToolButton4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure N3Click(Sender: TObject);
private
CurrentPage, RecordsNumber: Integer;
lstCust: TStringList;
procedure InitGrid();
procedure SetStatus();
{ Private declarations }
public
canshu1, canshu2, FWorkshop: string;
{ Public declarations }
end;
implementation
uses
U_DataLink, U_RTFun, U_LabelPrint;
{$R *.dfm}
procedure TfrmYEYarnOutList.SetStatus();
begin
TBRKCX.Enabled := False;
if canshu1 = '<27><><EFBFBD><EFBFBD>' then
TBRKCX.Enabled := true;
end;
procedure TfrmYEYarnOutList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
FreeAndNil(lstCust);
Action := caFree;
end;
procedure TfrmYEYarnOutList.FormCreate(Sender: TObject);
begin
inherited;
lstCust := TStringList.Create;
EndDate.DateTime := SGetServerDateTime(ADOQueryTemp);
BegDate.DateTime := EndDate.DateTime - 20;
end;
procedure TfrmYEYarnOutList.InitGrid();
var
WSql: string;
begin
WSql := SGetFilters(Panel1, 1, 2);
if Trim(WSql) <> '' then
WSql := ' and ' + WSql;
if IsJYTime.Checked then
begin
WSql := WSql + ' and IOTime>=' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
WSql := WSql + ' and IOTime<' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
end;
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add(' select top ' + inttostr(RecordsNumber) + ' * ');
sql.Add(' from ');
sql.Add('(select rownumber=cast((row_number() over(order by A.IOTime desc)) as int)');
sql.Add(',COUNT(1) OVER() AS TotalCount');
sql.Add(',* from V_YE_Yarn_IO A where A.IOFlag = ''<27><><EFBFBD><EFBFBD>'' ' + WSql);
sql.Add(') temp_row');
sql.Add(' where rownumber> ' + inttostr(((CurrentPage - 1) * RecordsNumber)));
sql.Add(' order by rownumber');
// showmessage(sql.text);
Open;
end;
SCreateCDS(ADOQueryMain, CDS_1);
SInitCDSData(ADOQueryMain, CDS_1);
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber));
finally
ADOQueryMain.EnableControls;
TV1.DataController.Filter.Clear;
end;
end;
procedure TfrmYEYarnOutList.TBRafreshClick(Sender: TObject);
begin
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEYarnOutList.CDS_1BeforeOpen(DataSet: TDataSet);
begin
lstCust.Clear;
end;
procedure TfrmYEYarnOutList.ConNoMChange(Sender: TObject);
begin
if ADOQueryMain.Active then
begin
SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
end;
end;
procedure TfrmYEYarnOutList.cxPageControl1Change(Sender: TObject);
begin
CurrentPage := 1;
SetStatus();
InitGrid();
end;
procedure TfrmYEYarnOutList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmYEYarnOutList.FormShow(Sender: TObject);
begin
inherited;
ReadCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27>ӵ<EFBFBD>ɴ<EFBFBD>ֿ߲<DFB2>');
CurrentPage := 1;
RecordsNumber := 500;
canshu1 := self.fParameters1;
canshu2 := self.fParameters3;
FWorkshop := self.fParameters3;
SetStatus();
end;
procedure TfrmYEYarnOutList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
exit;
TcxGridToExcel(Self.Caption, cxGrid1);
end;
procedure TfrmYEYarnOutList.orderNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
CurrentPage := 1;
InitGrid();
end;
end;
procedure TfrmYEYarnOutList.TBRKCXClick(Sender: TObject);
var
MIOIDS, MStkIds, MOutNos: string;
begin
if CDS_1.IsEmpty then
Exit;
if not CDS_1.Locate('SSel', True, []) then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
MIOIDS := '';
MStkIds := '';
MOutNos := '';
CDS_1.DisableControls;
with CDS_1 do
begin
First;
while not Eof do
begin
if CDS_1.fieldbyname('SSel').AsBoolean then
begin
MIOIDS := MIOIDS + (Trim(CDS_1.fieldbyname('IOID').AsString)) + ',';
MStkIds := MStkIds + (Trim(CDS_1.fieldbyname('STKID').AsString)) + ',';
MOutNos := MOutNos + (Trim(CDS_1.fieldbyname('IONO').AsString)) + ',';
end;
Next;
end;
end;
MIOIDS := leftBstr(trim(MIOIDS), length(MIOIDS) - 1);
MStkIds := leftBstr(trim(MStkIds), length(MStkIds) - 1);
MOutNos := leftBstr(trim(MOutNos), length(MOutNos) - 1);
CDS_1.Locate('SSel', True, []);
CDS_1.EnableControls;
if Application.MessageBox(<><C8B7>Ҫִ<D2AA>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IdyeS then
Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
sql.Add('insert into YE_Need_Up(UType,UDataId) values(''ӡȾ<D3A1><C8BE>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'',' + quotedstr(MOutNos) + ') ');
Sql.Add('exec P_YE_Yarn_ReOut ');
Sql.Add('@StkIds=' + quotedstr(trim(MStkIds)));
Sql.Add(',@IOIDS=' + quotedstr(trim(MIOIDS)));
Sql.Add(',@FillId=' + Quotedstr(DCode));
Sql.Add(',@Filler=' + Quotedstr(DName));
// ShowMessage(SQL.Text);
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_YE_Yarn_DR @OutNo=' + Quotedstr(Trim(MOutNos)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
sql.Add(' ' + quotedstr(trim(DName)));
sql.Add(',getdate() ');
sql.Add(',' + quotedstr(trim(self.Caption)));
sql.Add(',' + quotedstr(trim('<27>ӵ<EFBFBD>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2B3B7>')));
sql.Add(',' + quotedstr(trim(MIOIDS)));
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
sql.Add(')');
ExecSQL;
end;
ADOQueryCmd.Connection.CommitTrans;
InitGrid();
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYEYarnOutList.Tv1DataControllerFilterBeforeChange(Sender: TcxDBDataFilterCriteria; ADataSet: TDataSet; const AFilterText: string);
begin
lstCust.Clear;
end;
procedure TfrmYEYarnOutList.Tv1TcxGridDBDataControllerTcxDataSummaryFooterSummaryItems6GetText(Sender: TcxDataSummaryItem; const AValue: Variant; AIsFooter: Boolean; var AText: string);
begin
if lstCust <> nil then
AText := IntToStr(lstCust.Count);
end;
procedure TfrmYEYarnOutList.BTNPClick(Sender: TObject);
begin
if CurrentPage < CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber then
CurrentPage := CurrentPage + 1;
InitGrid();
end;
procedure TfrmYEYarnOutList.BTLPClick(Sender: TObject);
begin
if CurrentPage > 1 then
CurrentPage := CurrentPage - 1;
InitGrid();
end;
procedure TfrmYEYarnOutList.TCBNORChange(Sender: TObject);
begin
RecordsNumber := StrToInt(TCBNOR.Text);
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEYarnOutList.JYTypeChange(Sender: TObject);
begin
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEYarnOutList.N1Click(Sender: TObject);
begin
SelOKNo(CDS_1, true);
end;
procedure TfrmYEYarnOutList.N2Click(Sender: TObject);
begin
SelOKNo(CDS_1, false);
end;
procedure TfrmYEYarnOutList.N3Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(CDS_1.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmYEYarnOutList.ToolButton1Click(Sender: TObject);
begin
if CDS_1.IsEmpty then
Exit;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'YEYarnOut1';
FFiltration1 := Trim(self.CDS_1.fieldbyname('IONO').AsString);
if ShowModal = 1 then
begin
end;
end;
finally
frmLabelPrint.Free;
end;
end;
procedure TfrmYEYarnOutList.ToolButton2Click(Sender: TObject);
var
WSql: string;
begin
if CDS_1.IsEmpty then
Exit;
if not CDS_1.Locate('SSel', True, []) then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
WSql := '';
CDS_1.DisableControls;
with CDS_1 do
begin
First;
while not Eof do
begin
if CDS_1.fieldbyname('SSel').AsBoolean then
begin
if WSql <> '' then
begin
WSql := WSql + ',' + QuotedStr(Trim(CDS_1.fieldbyname('YIID').AsString));
end
else
begin
WSql := QuotedStr(Trim(CDS_1.fieldbyname('YIID').AsString));
end;
end;
Next;
end;
end;
CDS_1.Locate('SSel', True, []);
CDS_1.EnableControls;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'YEYarnOut2';
FFiltration1 := WSql;
if ShowModal = 1 then
begin
end;
end;
finally
frmLabelPrint.Free;
end;
end;
procedure TfrmYEYarnOutList.ToolButton4Click(Sender: TObject);
begin
WriteCxGrid(trim(self.Caption) + 'Tv1', Tv1, '<27>ӵ<EFBFBD>ɴ<EFBFBD>ֿ߲<DFB2>');
end;
end.