RTFormwork/项目代码/RTBasicsV1/C02纱线加弹检验/U_YEClothInspList.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

656 lines
17 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_YEClothInspList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, MovePanel, cxTextEdit,
cxContainer, cxCurrencyEdit, BtnEdit, RM_e_main, RM_e_htm, RM_e_Graphic,
RM_e_Jpeg, RM_e_txt, RM_e_csv, Math, Clipbrd, cxPC, cxLookAndFeels,
cxLookAndFeelPainters, cxNavigator, dxBarBuiltInMenu, dxSkinsCore,
dxSkinsDefaultPainters, dxDateRanges, U_BaseList, dxDateTimeWheelPicker;
type
TfrmYEClothInspList = class(TfrmBaseList)
ToolBar1: TToolBar;
TBRafresh: TToolButton;
TBClose: TToolButton;
GPM_1: TcxGridPopupMenu;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
DS_1: TDataSource;
TBExport: TToolButton;
Order_Main: TClientDataSet;
btnEdit: TToolButton;
TBZF: TToolButton;
btnJBQ: TToolButton;
RM1: TRMGridReport;
RMDB_1: TRMDBDataSet;
ADOQueryPrint: TADOQuery;
MovePanel2: TMovePanel;
btnJYBG: TToolButton;
ToolButton1: TToolButton;
PM_1: TPopupMenu;
N1: TMenuItem;
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column22: TcxGridDBColumn;
v1Column21: TcxGridDBColumn;
v1Column8: TcxGridDBColumn;
v1Column28: TcxGridDBColumn;
v1Column20: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
v1Column42: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
Panel6: TPanel;
Label31: TLabel;
LBCPAP: TLabel;
BTLP: TButton;
BTNP: TButton;
TCBNOR: TComboBox;
Panel1: TPanel;
Label3: TLabel;
Label7: TLabel;
Label8: TLabel;
Label10: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label20: TLabel;
Label23: TLabel;
Label1: TLabel;
BegDate: TDateTimePicker;
EndDate: TDateTimePicker;
OrderNo: TEdit;
conNO: TEdit;
YIID: TEdit;
Grade: TComboBox;
C_Name: TEdit;
CIIOFlag: TComboBox;
Filler: TComboBox;
C_Color: TEdit;
IsJYTime: TCheckBox;
C_Pattern: TEdit;
C_Code: TEdit;
PCId: TEdit;
Tv1Column1: TcxGridDBColumn;
Tv1Column2: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Tv1Column10: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
Tv1Column13: TcxGridDBColumn;
Tv1Column14: TcxGridDBColumn;
Tv1Column15: TcxGridDBColumn;
Tv1Column16: TcxGridDBColumn;
Tv1Column17: TcxGridDBColumn;
Tv1Column18: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure TBRafreshClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure btnEditClick(Sender: TObject);
procedure TBZFClick(Sender: TObject);
procedure btnJBQClick(Sender: TObject);
procedure OrderNoKeyPress(Sender: TObject; var Key: Char);
procedure BTLPClick(Sender: TObject);
procedure BTNPClick(Sender: TObject);
procedure TCBNORChange(Sender: TObject);
procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
procedure conNOKeyPress(Sender: TObject; var Key: Char);
procedure CIIOFlagChange(Sender: TObject);
procedure GradeChange(Sender: TObject);
procedure KHConNOKeyPress(Sender: TObject; var Key: Char);
procedure RKOrdIDKeyPress(Sender: TObject; var Key: Char);
procedure btnJYBGClick(Sender: TObject);
procedure Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
procedure cxPageControl1Change(Sender: TObject);
procedure chkZFClick(Sender: TObject);
procedure TBExportClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
DQdate: TDateTime;
FLeft, FTop: Integer;
CurrentPage, RecordsNumber: Integer;
procedure InitGrid();
function Savedata(): Boolean;
procedure SetStatus();
{ Private declarations }
public
FFInt: Integer;
canshu1, FWorkshop: string;
{ Public declarations }
end;
implementation
uses
U_DataLink, U_RTFun, U_YEInspEdit, U_ZDYHelp, U_LabelPrint;
{$R *.dfm}
procedure TfrmYEClothInspList.SetStatus();
begin
end;
procedure TfrmYEClothInspList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmYEClothInspList.FormCreate(Sender: TObject);
begin
inherited;
cxgrid1.Align := alClient;
DQdate := SGetServerDate(ADOQueryTemp);
FWorkshop := trim(Self.fParameters3);
end;
procedure TfrmYEClothInspList.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmYEClothInspList.TBExportClick(Sender: TObject);
begin
if ADOQueryMain.IsEmpty then
Exit;
TcxGridToExcel(self.Caption, cxgrid1);
end;
procedure TfrmYEClothInspList.InitGrid();
var
WSql: string;
begin
MovePanel2.Left := (self.Width - MovePanel2.Width) div 2;
MovePanel2.Visible := True;
MovePanel2.Refresh;
WSql := SGetFilters(Panel1, 1, 2);
if trim(WSql) <> '' then
begin
WSql := ' and ' + trim(WSql);
end;
if trim(FWorkshop) <> '' then
WSql := WSql + ' and A.Workshop=''' + trim(FWorkshop) + '''';
if IsJYTime.Checked then
begin
WSql := WSql + ' and A.Filltime>' + quotedstr(FormatDateTime('yyyy-MM-dd', BegDate.DateTime));
WSql := WSql + ' and A.Filltime<=' + quotedstr(FormatDateTime('yyyy-MM-dd', enddate.DateTime + 1));
end
else
begin
if trim(WSql) <> '' then
WSql := ' and 1=1' + trim(WSql)
else
WSql := WSql + ' and 1=2 ';
end;
if trim(WSql) = 'and 1=2' then
Application.MessageBox('<27><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
try
ADOQueryMain.DisableControls;
with ADOQueryMain do
begin
Filtered := False;
Close;
sql.Clear;
sql.Add('exec P_YE_Yarn_Get_Page ');
sql.Add('@pageIndex=' + inttostr(CurrentPage));
sql.Add(',@pageSize=' + inttostr(RecordsNumber));
sql.Add(',@criteria= ' + quotedstr(WSql));
Open;
end;
SCreateCDS(ADOQueryMain, Order_Main);
SInitCDSData(ADOQueryMain, Order_Main);
LBCPAP.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber));
MovePanel2.Visible := false;
finally
ADOQueryMain.EnableControls;
MovePanel2.Visible := false;
TV1.DataController.Filter.Clear;
end;
end;
procedure TfrmYEClothInspList.TBRafreshClick(Sender: TObject);
begin
OrderNo.SetFocus;
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEClothInspList.FormShow(Sender: TObject);
var
fsj: string;
begin
inherited;
canshu1 := self.fParameters1;
CurrentPage := 1;
RecordsNumber := 500;
ReadCxGrid(Trim(self.Caption) + 'Tv1', Tv1, <>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
EndDate.DateTime := SGetServerDate(ADOQueryTemp);
BegDate.DateTime := EndDate.DateTime;
fsj := 'select distinct(Filler) name from YE_Yarn_Inspect ';
SInitComBoxBySql(ADOQueryCmd, Filler, False, fsj);
// Filler.ItemIndex := Filler.Items.IndexOf(trim(DName));
InitGrid();
SetStatus();
InitGrid();
end;
procedure TfrmYEClothInspList.Tv1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FLeft := X;
FTop := Y;
end;
procedure TfrmYEClothInspList.btnEditClick(Sender: TObject);
begin
if Order_Main.IsEmpty then
exit;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YE_Yarn_IO where IOFlag=''<27><><EFBFBD><EFBFBD>'' and StkId=''' + Trim(Order_Main.fieldbyname('YIID').AsString) + '''');
Open;
end;
if ADOQueryTemp.IsEmpty = False then
begin
Order_Main.EnableControls;
Application.MessageBox('<27>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ܱ༭!', '<27><>ʾ', 0);
Exit;
end;
try
frmYEInspEdit := TfrmYEInspEdit.Create(Application);
with frmYEInspEdit do
begin
YIID.Text := Trim(Self.Order_Main.fieldbyname('YIID').AsString);
if ShowModal = 1 then
begin
end;
end;
finally
frmYEInspEdit.Free;
end;
end;
procedure TfrmYEClothInspList.TBZFClick(Sender: TObject);
var
MYIIDS: string;
begin
if Order_Main.Locate('ssel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
if Application.MessageBox(<><C8B7>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD><CFBA><EFBFBD><EFBFBD>ݲ<EFBFBD><DDB2>ָܻ<DCBB><D6B8><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while not Eof do
begin
if Order_Main.FieldByName('SSel').AsBoolean = True then
begin
MYIIDS := MYIIDS + Trim(Order_Main.fieldbyname('YIID').AsString) + ',';
Order_Main.Delete;
end
else
Next;
end;
end;
Order_Main.EnableControls;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('insert into YE_Need_Up(UType,UDataId) values(''<27><><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>'',' + quotedstr(MYIIDS) + ') ');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_YE_Yarn_Del ');
Sql.Add('@YIIDS=' + quotedstr(Trim(MYIIDS)));
Sql.Add(',@DCode=' + Quotedstr(DCode));
Sql.Add(',@DName=' + Quotedstr(DName));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
ADOQueryCmd.Connection.CommitTrans;
CurrentPage := 1;
InitGrid();
application.MessageBox(<><C9BE><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ');
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmYEClothInspList.btnJBQClick(Sender: TObject);
var
fPrintFile, FLBName: string;
begin
if Order_Main.IsEmpty then
Exit;
if Order_Main.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
Order_Main.DisableControls;
with Order_Main do
begin
First;
while not Eof do
begin
if Order_Main.FieldByName('SSel').AsBoolean = True then
begin
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('Update YE_Yarn_Inspect Set PrtCount=PrtCount+1,PrtDate=getdate(),Prter=''' + Trim(DName) + '''');
sql.Add('where YIID=''' + Trim(Order_Main.fieldbyname('YIID').AsString) + '''');
ExecSQL;
end;
with ADOQueryPrint do
begin
Close;
SQL.Clear;
sql.Add(' EXEC P_YE_Yarn_Prt_Lab ');
SQL.Add(' @YIID=''' + Trim(Order_Main.fieldbyname('YIID').AsString) + '''');
Open;
end;
if ADOQueryPrint.IsEmpty then
begin
application.MessageBox('<27><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', MB_ICONERROR);
exit;
end;
FLBName := Trim(ADOQueryPrint.fieldbyname('LBName').AsString);
ExportFtErpFile(FLBName + '.rmf', ADOQueryTemp);
fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + FLBName + '.rmf';
if FileExists(fPrintFile) then
begin
RM1.LoadFromFile(fPrintFile);
Rm1.DefaultCopies := 2;
RM1.PrintReport;
end
else
begin
Application.MessageBox(PChar(<><C3BB><EFBFBD><EFBFBD>' + fPrintFile), '<27><>ʾ', 0);
end;
end;
Next;
end;
end;
Order_Main.EnableControls;
end;
function TfrmYEClothInspList.Savedata(): Boolean;
var
maxno, LLID: string;
HXPS: Integer;
HXQty, HXMQty: Double;
begin
HXPS := 0;
HXQty := 0;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1 * from Contract_Cloth_LL where OrdSubId=''' + Trim(Order_Main.fieldbyname('SubId').AsString) + '''');
sql.Add(' and FirstName=''' + Trim(Order_Main.fieldbyname('AOrddefstr4').AsString) + '''');
Open;
end;
LLID := Trim(ADOQueryTemp.fieldbyname('LLID').AsString);
if Trim(LLID) = '' then
begin
Result := False;
Application.MessageBox(<><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ļӹ<C4BC><D3B9><EFBFBD>!', '<27><>ʾ', 0);
Exit;
end;
try
ADOQueryCmd.Connection.BeginTrans;
if GetLSNo(ADOQueryCmd, maxno, 'HX', 'Contract_Cloth_BefChkHX', 2, 1) = False then
begin
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>!', '<27><>ʾ', 0);
Exit;
end;
with Order_Main do
begin
First;
while not Eof do
begin
if Order_Main.FieldByName('SSel').AsBoolean = True then
begin
HXPS := HXPS + 1;
HXQty := HXQty + Order_Main.FieldByName('MJLen').Value;
end;
Next;
end;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('');
Open;
end;
except
end;
end;
procedure TfrmYEClothInspList.OrderNoKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
CurrentPage := 1;
InitGrid();
end;
end;
procedure TfrmYEClothInspList.BTLPClick(Sender: TObject);
begin
if CurrentPage > 1 then
CurrentPage := CurrentPage - 1;
InitGrid();
end;
procedure TfrmYEClothInspList.BTNPClick(Sender: TObject);
begin
if CurrentPage < Order_Main.FieldByName('TotalCount').AsInteger / RecordsNumber then
CurrentPage := CurrentPage + 1;
InitGrid();
end;
procedure TfrmYEClothInspList.TCBNORChange(Sender: TObject);
begin
RecordsNumber := StrToInt(TCBNOR.Text);
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEClothInspList.ToolButton1Click(Sender: TObject);
begin
WriteCxGrid(Trim(self.Caption) + 'Tv1', Tv1, <>׼<EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure TfrmYEClothInspList.Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmYEClothInspList.chkZFClick(Sender: TObject);
begin
inherited;
CurrentPage := 1;
SetStatus();
InitGrid();
end;
procedure TfrmYEClothInspList.conNOKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
CurrentPage := 1;
InitGrid();
end;
end;
procedure TfrmYEClothInspList.cxPageControl1Change(Sender: TObject);
begin
CurrentPage := 1;
SetStatus();
InitGrid();
end;
procedure TfrmYEClothInspList.CIIOFlagChange(Sender: TObject);
begin
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEClothInspList.GradeChange(Sender: TObject);
begin
CurrentPage := 1;
InitGrid();
end;
procedure TfrmYEClothInspList.KHConNOKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
CurrentPage := 1;
InitGrid();
end;
end;
procedure TfrmYEClothInspList.N1Click(Sender: TObject);
begin
Clipboard.SetTextBuf(PChar(Trim(Order_Main.fieldbyname(TV1.Controller.FocusedColumn.DataBinding.FilterFieldName).AsString)));
end;
procedure TfrmYEClothInspList.RKOrdIDKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
CurrentPage := 1;
InitGrid();
end;
end;
procedure TfrmYEClothInspList.btnJYBGClick(Sender: TObject);
var
WSql: string;
begin
if Order_Main.IsEmpty then
Exit;
WSql := '';
Order_Main.DisableControls;
with Order_Main do
begin
First;
while not Eof do
begin
if Order_Main.fieldbyname('SSel').AsBoolean then
begin
if WSql <> '' then
begin
WSql := WSql + ',' + QuotedStr(Trim(Order_Main.fieldbyname('YIID').AsString));
end
else
begin
WSql := QuotedStr(Trim(Order_Main.fieldbyname('YIID').AsString));
end;
end;
Next;
end;
end;
Order_Main.Locate('SSel', True, []);
Order_Main.EnableControls;
try
frmLabelPrint := TfrmLabelPrint.Create(Application);
with frmLabelPrint do
begin
FLMType := 'YEYarnInsp';
FFiltration1 := WSql;
if ShowModal = 1 then
begin
// Self.InitGrid();
end;
end;
finally
frmLabelPrint.Free;
end;
if Order_Main.Locate('SSel', True, []) = False then
begin
Application.MessageBox(<><C3BB>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 0);
Exit;
end;
end;
procedure TfrmYEClothInspList.Tv1CustomDrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
FValue: string;
FBounds: TRect;
begin
FBounds := AViewInfo.Bounds;
if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
begin
ACanvas.FillRect(FBounds);
ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, [bBottom, bLeft, bRight], 1);
FValue := IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index + 1);
InflateRect(FBounds, -3, -2); //Platform specific. May not work on Linux.
ACanvas.Font.Color := clBlack;
ACanvas.Brush.Style := bsClear;
ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
ADone := True;
end;
end;
end.