RTFormwork/项目代码/RTBasicsV1/E02梭织经轴仓库/U_WarpBeamOutEdit.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

382 lines
12 KiB
ObjectPascal
Raw 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_WarpBeamOutEdit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxCalendar, cxDropDownEdit, ComCtrls, ToolWin,
cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu,
cxGridPopupMenu, ADODB, DBClient, cxButtonEdit, cxTextEdit, cxSpinEdit,
StdCtrls, ExtCtrls, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore,
dxSkinsDefaultPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu,
U_BaseInput, System.ImageList, Vcl.ImgList;
type
TfrmWarpBeamOutEdit = class(TfrmBaseInput)
ToolBar1: TToolBar;
TBAdd: TToolButton;
TBDel: TToolButton;
TBSave: TToolButton;
TBClose: TToolButton;
DataSource3: TDataSource;
CDS_Sub: TClientDataSet;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
cxGridPopupMenu2: TcxGridPopupMenu;
cxGrid2: TcxGrid;
Tv1: TcxGridDBTableView;
v1Column6: TcxGridDBColumn;
v1Column2: TcxGridDBColumn;
v1CRType: TcxGridDBColumn;
v2Column6: TcxGridDBColumn;
v1Column12: TcxGridDBColumn;
cxGrid2Level1: TcxGridLevel;
v1Column1: TcxGridDBColumn;
v1Column5: TcxGridDBColumn;
ToolButton1: TToolButton;
Tv1Column2: TcxGridDBColumn;
Tv1Column3: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
Tv1Column1: TcxGridDBColumn;
Tv1Column4: TcxGridDBColumn;
Tv1Column5: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
Tv1Column8: TcxGridDBColumn;
Tv1Column9: TcxGridDBColumn;
Tv1Column10: TcxGridDBColumn;
Tv1Column15: TcxGridDBColumn;
Tv1Column17: TcxGridDBColumn;
Tv1Column11: TcxGridDBColumn;
Tv1Column12: TcxGridDBColumn;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure TBAddClick(Sender: TObject);
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBDelClick(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure ToolButton1Click(Sender: TObject);
procedure Tv1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
private
{ Private declarations }
function SaveCKData(): Boolean;
public
{ Public declarations }
FBCId, FStkName, FKHName: string;
end;
var
frmWarpBeamOutEdit: TfrmWarpBeamOutEdit;
implementation
uses
U_DataLink, U_RTFun, U_ZDYHelp, U_WarpBeamStkSel, U_CompanySel;
{$R *.dfm}
procedure TfrmWarpBeamOutEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmWarpBeamOutEdit.TBAddClick(Sender: TObject);
begin
try
frmWarpBeamStkSel := TfrmWarpBeamStkSel.Create(Application);
with frmWarpBeamStkSel do
begin
FstkName := Self.FstkName;
if ShowModal = 1 then
begin
frmWarpBeamStkSel.CDS_Main.DisableControls;
with frmWarpBeamStkSel.CDS_Main do
begin
First;
while frmWarpBeamStkSel.CDS_Main.Locate('SSel', True, []) do
begin
with Self.CDS_Sub do
begin
Append;
FieldByName('IOTime').Value := Trim(FormatDateTime('yyyy-MM-dd', Now));
FieldByName('STKID').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('TWIOID').Value;
FieldByName('IOType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
FieldByName('FromCoNo').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('FromCoNo').Value; //<2F><><EFBFBD>Ե<EFBFBD>λ
FieldByName('FromCoName').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('FromCoName').Value;
FieldByName('StkCoNo').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('StkCoNo').Value; //<2F><><EFBFBD>ŵ<EFBFBD>λ
FieldByName('StkCoName').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('StkCoName').Value;
FieldByName('ToCoNo').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('StkCoNo').Value; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
FieldByName('ToCoName').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('StkCoName').Value;
FieldByName('WBNo').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WBNo').AsString);
FieldByName('WBCID').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WBCID').AsString);
FieldByName('WB_Type').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_Type').AsString);
FieldByName('WB_YarnArr').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_YarnArr').AsString);
FieldByName('WB_MachNo').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_MachNo').AsString);
FieldByName('WB_Len').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_Len').AsString);
FieldByName('WB_Macher').Value := Trim(frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_Macher').AsString);
FieldByName('WB_YarnQty').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_YarnQty').Value;
FieldByName('Qty').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('Qty').Value;
FieldByName('StkPosition').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('StkPosition').Value;
FieldByName('WB_Code').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_Code').Value;
FieldByName('WB_Spec').Value := frmWarpBeamStkSel.CDS_Main.fieldbyname('WB_Spec').Value;
end;
frmWarpBeamStkSel.CDS_Main.Delete;
end;
end;
frmWarpBeamStkSel.CDS_Main.EnableControls;
end;
end;
finally
frmWarpBeamStkSel.Free;
end;
end;
function TfrmWarpBeamOutEdit.SaveCKData(): Boolean;
var
MTWIOID, Maxno: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
CDS_Sub.DisableControls;
with CDS_Sub do
begin
First;
while not eof do
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Tat_WB_IO where TWIOID=''' + Trim(CDS_Sub.fieldbyname('TWIOID').AsString) + '''');
Open;
end;
MTWIOID := Trim(ADOQueryTemp.fieldbyname('TWIOID').AsString);
if Trim(MTWIOID) = '' then
begin
if not GetLSNo(ADOQueryCmd, Maxno, 'ZC', 'Tat_WB_IO', 4, 1) then
raise Exception.Create(<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end
else
begin
Maxno := Trim(MTWIOID);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from Tat_WB_IO where TWIOID=''' + Trim(Maxno) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(MTWIOID) = '' then
begin
Append;
FieldByName('Filler').Value := Trim(DName)
end
else
begin
Edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditTime').Value := SGetServerDate(ADOQueryTemp);
end;
RTSetSaveDataCDS(ADOQueryCmd, Tv1, CDS_Sub, 'Tat_WB_IO', 0);
FieldByName('STKName').Value := FSTKName;
FieldByName('TWIOID').Value := Trim(Maxno);
FieldByName('IOFlag').Value := '<27><><EFBFBD><EFBFBD>';
FieldByName('IOQtyFlag').Value := -1;
FieldByName('STKID').Value := CDS_Sub.fieldbyname('STKID').Value;
FieldByName('FromCoNo').Value := CDS_Sub.fieldbyname('FromCoNo').Value;
FieldByName('FromCoName').Value := CDS_Sub.fieldbyname('FromCoName').Value;
FieldByName('StkCoNo').Value := CDS_Sub.fieldbyname('StkCoNo').Value;
FieldByName('ToCoNo').Value := CDS_Sub.fieldbyname('ToCoNo').Value;
Post;
end;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_TatWB_Stk @TWIOID=' + quotedstr(Trim(Maxno)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
Edit;
FieldByName('TWIOID').Value := Trim(Maxno);
Post;
Next;
end;
end;
CDS_Sub.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
Result := True;
except
Result := False;
CDS_Sub.EnableControls;
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end;
procedure TfrmWarpBeamOutEdit.TBCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmWarpBeamOutEdit.FormShow(Sender: TObject);
var
fsj: string;
begin
inherited;
ReadCxGrid(FSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select A.* ');
sql.Add(' from Tat_WB_IO A');
sql.Add(' where TWIOID=''' + Trim(FBCId) + '''');
Open;
end;
SCreateCDS(ADOQueryTemp, CDS_Sub);
SInitCDSData(ADOQueryTemp, CDS_Sub);
// fsj:='select name=CJName ,Code=null from CheJian';
// SInitCxGridComboBoxBySql(ADOQueryTemp,v1CheJian,fsj,0,True,'');
end;
procedure TfrmWarpBeamOutEdit.TBDelClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then
Exit;
if Trim(CDS_Sub.fieldbyname('TWIOID').AsString) <> '' then
begin
if Application.MessageBox(<><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) <> IDYES then
Exit;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
Sql.Add('exec P_TatWB_Out_Del ');
Sql.Add(' @TWIOIDS=' + quotedstr(Trim(CDS_Sub.fieldbyname('TWIOID').AsString)));
Sql.Add(',@DCode=' + quotedstr(Trim(DCode)));
Sql.Add(',@DName=' + quotedstr(Trim(DName)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
ADOQueryCmd.Connection.CommitTrans;
CDS_Sub.Delete;
except
ADOQueryCmd.Connection.RollbackTrans;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
end;
end
else
CDS_Sub.Delete;
end;
procedure TfrmWarpBeamOutEdit.TBSaveClick(Sender: TObject);
begin
if CDS_Sub.IsEmpty then
Exit;
if CDS_Sub.Locate('IOTime', null, []) = True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4B2BB>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if CDS_Sub.Locate('IOType', null, []) = True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if CDS_Sub.Locate('Qty', null, []) = True then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if SaveCKData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
//ModalResult:=1;
Exit;
end;
end;
procedure TfrmWarpBeamOutEdit.ToolButton1Click(Sender: TObject);
begin
WriteCxGrid(fSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
end;
procedure TfrmWarpBeamOutEdit.Tv1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
if ShowModal = 1 then
begin
with Self.CDS_Sub do
begin
Edit;
FieldByName('ToCoNo').Value := Trim(CDS_1.fieldbyname('CoCode').AsString);
FieldByName('ToCoName').Value := Trim(CDS_1.fieldbyname('CoAbbrName').AsString);
end;
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmWarpBeamOutEdit.Tv1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
FFSPID: string;
begin
if CDS_Sub.IsEmpty then
Exit;
if Trim(CDS_Sub.fieldbyname('TWIOID').AsString) <> '' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Tat_WB_IO where TWIOID=''' + Trim(CDS_Sub.fieldbyname('TWIOID').AsString) + '''');
Open;
end;
FFSPID := Trim(ADOQueryTemp.fieldbyname('TWIOID').AsString);
if Trim(FFSPID) <> '' then
begin
v1CRType.Options.Editing := False;
end
else
begin
v1CRType.Options.Editing := True;
end;
end
else
begin
v1CRType.Options.Editing := True;
end;
end;
end.