RTFormwork/项目代码/RTBasicsV1/C01纱线加弹计划/U_YarnElasticityOrderInPut.pas
“ddf” 61630656e9 1
2024-07-07 09:35:27 +08:00

421 lines
11 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_YarnElasticityOrderInPut;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxMemo,
cxRichEdit, ComCtrls, cxContainer, cxTextEdit, cxMaskEdit, cxButtonEdit,
StdCtrls, ToolWin, DBClient, ADODB, ExtCtrls, BtnEdit, cxDropDownEdit,
StrUtils, cxPC, ShellAPI, cxCalendar, Math, Menus, cxGridCustomPopupMenu,
cxGridPopupMenu, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator,
dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges;
type
TfrmShuttleLSSCInPut = class(TForm)
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
ScrollBox1: TScrollBox;
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
CDS_Sanjiao: TClientDataSet;
DS_Sanjiao: TDataSource;
Label4: TLabel;
BatchNo: TEdit;
Label6: TLabel;
Y_Spec: TEdit;
FtyName: TBtnEditC;
Label8: TLabel;
Label9: TLabel;
Label3: TLabel;
YarnTubeWeight: TEdit;
Label11: TLabel;
PaperBoxWeight: TEdit;
Label1: TLabel;
BoxCount: TEdit;
Label5: TLabel;
YarnRackCount: TEdit;
Label2: TLabel;
Tv1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
Tv1Column1: TcxGridDBColumn;
cxGrid2: TcxGrid;
Tv2: TcxGridDBTableView;
cxGridDBColumn1: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
DataSource1: TDataSource;
ClientDataSet1: TClientDataSet;
DataSource2: TDataSource;
ClientDataSet2: TClientDataSet;
Label7: TLabel;
Y_Color: TEdit;
Y_Name: TBtnEditC;
YE_Name: TBtnEditC;
Label10: TLabel;
OrdQty: TEdit;
procedure TBCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TBSaveClick(Sender: TObject);
procedure FtyNameBtnUpClick(Sender: TObject);
procedure FtyNameBtnDnClick(Sender: TObject);
procedure Y_NameBtnDnClick(Sender: TObject);
procedure Y_NameBtnUpClick(Sender: TObject);
procedure YE_NameBtnDnClick(Sender: TObject);
procedure YE_NameBtnUpClick(Sender: TObject);
private
FXS, Fint: Integer;
procedure InitData();
function SaveData(): Boolean;
{ Private declarations }
public
PState, FCopyInt, fpd: Integer;
FMainId, FConNo, PType, FSubId: string;
{ Public declarations }
end;
var
frmShuttleLSSCInPut: TfrmShuttleLSSCInPut;
newh: hwnd;
implementation
uses
U_DataLink, U_ZDYHelp, U_RTFun, U_CompanySel, U_YarnInfoSel;
{$R *.dfm}
procedure TfrmShuttleLSSCInPut.TBCloseClick(Sender: TObject);
begin
ModalResult := 1;
end;
procedure TfrmShuttleLSSCInPut.InitData();
var
PBNO, PBFlag, fsj: string;
i: Integer;
begin
if fpd <> 1 then
begin
/////////////////ˢ<>²<EFBFBD>Ʒ<EFBFBD><C6B7>Ϣ/////////////////////////
with ADOQueryTemp do
begin
Close;
SQL.Clear;
sql.Add(' select A.* from YE_Plan_Main A');
if PState = 1 then
begin
sql.Add(' where A.MainId=' + Quotedstr(Trim(FMainId)));
end;
if PState = 0 then
begin
sql.Add(' where 1<>1 ');
end;
Open;
end;
SCSHData(ADOQueryTemp, ScrollBox1, 0);
Y_Name.TxtCode := ADOQueryTemp.FieldByName('Y_Code').AsString;
YE_Name.TxtCode := ADOQueryTemp.FieldByName('YE_Code').AsString;
FtyName.TxtCode := ADOQueryTemp.FieldByName('FtyNo').AsString;
end;
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YE_Plan_Rule where Mainid=''' + Trim(FMainId) + ''' and RType=''<27><>ɫ'' ');
Open;
end;
SCreateCDS(ADOQueryTemp, ClientDataSet1);
SInitCDSData(ADOQueryTemp, ClientDataSet1);
fsj := 'select Name=ColorName,Code=ColorName from YE_YarnTube_Color ';
SInitCxGridComboBoxBySql(ADOQueryTemp, Tv1Column1, fsj, 1, true, '');
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from YE_Plan_Rule where Mainid=''' + Trim(FMainId) + ''' and RType=''<27><>̨'' ');
Open;
end;
SCreateCDS(ADOQueryTemp, ClientDataSet2);
SInitCDSData(ADOQueryTemp, ClientDataSet2);
if ClientDataSet1.IsEmpty then
begin
for i := 1 to 10 do
begin
with ClientDataSet1 do
begin
Append;
Post;
end;
end;
end;
if ClientDataSet2.IsEmpty then
begin
for i := 1 to 10 do
begin
with ClientDataSet2 do
begin
Append;
Post;
end;
end;
end;
if PState = 0 then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select Top 1 * from YE_Plan_Main order by FillTime desc');
Open;
end;
YarnTubeWeight.Text := Trim(ADOQueryTemp.fieldbyname('YarnTubeWeight').AsString);
PaperBoxWeight.Text := Trim(ADOQueryTemp.fieldbyname('PaperBoxWeight').AsString);
BoxCount.Text := Trim(ADOQueryTemp.fieldbyname('BoxCount').AsString);
YarnRackCount.Text := Trim(ADOQueryTemp.fieldbyname('YarnRackCount').AsString);
end;
if FCopyInt = 1 then
begin
FMainId := '';
end;
end;
procedure TfrmShuttleLSSCInPut.FormShow(Sender: TObject);
begin
InitData();
end;
function TfrmShuttleLSSCInPut.SaveData(): Boolean;
var
maxno: string;
begin
try
ADOQueryCmd.Connection.BeginTrans;
if Trim(FMainId) = '' then
begin
if GetLSNo(ADOQueryCmd, maxno, 'YEM', 'YE_Plan_Main', 4, 1) = False then
begin
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD><EFBFBD><ECB3A3>', '<27><>ʾ', 0);
exit;
end;
end
else
begin
maxno := Trim(FMainId);
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
SQL.Add('select * from YE_Plan_Main where MainId=''' + Trim(maxno) + '''');
Open;
end;
with ADOQueryCmd do
begin
if Trim(FMainId) = '' then
begin
Append;
FieldByName('Filler').Value := Trim(DName);
FieldByName('FillTime').Value := SGetServerDateTime(ADOQueryTemp);
FieldByName('Status').Value := '0';
FieldByName('Y_Code').Value := Y_Name.TxtCode;
FieldByName('YE_Code').Value := YE_Name.TxtCode;
FieldByName('FtyNo').Value := FtyName.TxtCode;
end
else
begin
Edit;
FieldByName('Editer').Value := Trim(DName);
FieldByName('EditTime').Value := SGetServerDateTime(ADOQueryTemp);
end;
FieldByName('MainId').Value := Trim(maxno);
FieldByName('OrderNo').Value := Trim(maxno);
RTSetsavedata(ADOQueryCmd, 'YE_Plan_Main', ScrollBox1, 0);
Post;
end;
// with ADOQueryCmd do
// begin
// Close;
// sql.Clear;
// sql.Add('select * from YE_Plan_Main where isnull(BatchNo,'''')=''' + Trim(BatchNo.Text) + '''');
// Open;
// end;
// if ADOQueryCmd.RecordCount > 1 then
// begin
// ADOQueryCmd.Connection.RollbackTrans;
// Application.MessageBox('<27><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD><EFBFBD>ظ<EFBFBD>!', '<27><>ʾ', 0);
// Result := False;
// Exit;
// end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('delete YE_Plan_Rule where MainId=''' + Trim(maxno) + '''');
ExecSQL;
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('select * from YE_Plan_Rule where 1=2');
Open;
end;
ClientDataSet1.DisableControls;
with ClientDataSet1 do
begin
First;
while not Eof do
begin
with ADOQueryCmd do
begin
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('MainId').Value := Trim(maxno);
ADOQueryCmd.FieldByName('RType').Value := Trim('<27><>ɫ');
ADOQueryCmd.FieldByName('RName').Value := Trim(ClientDataSet1.fieldbyname('RName').AsString);
ADOQueryCmd.Post;
end;
Next;
end;
end;
ClientDataSet1.EnableControls;
ClientDataSet2.DisableControls;
with ClientDataSet2 do
begin
First;
while not Eof do
begin
with ADOQueryCmd do
begin
ADOQueryCmd.Append;
ADOQueryCmd.FieldByName('MainId').Value := Trim(maxno);
ADOQueryCmd.FieldByName('RType').Value := Trim('<27><>̨');
ADOQueryCmd.FieldByName('RName').Value := Trim(ClientDataSet2.fieldbyname('RName').AsString);
ADOQueryCmd.Post;
end;
Next;
end;
end;
ClientDataSet2.EnableControls;
ADOQueryCmd.Connection.CommitTrans;
FMainId := Trim(maxno);
Result := True;
except
Result := False;
ADOQueryCmd.Connection.RollbackTrans;
Application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ', 0);
end;
end;
procedure TfrmShuttleLSSCInPut.TBSaveClick(Sender: TObject);
var
FReal: Double;
maxConNo: string;
begin
FtyName.SetFocus;
if trim(FtyName.Text) = '' then
begin
Application.MessageBox('<27><><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if StrTofloatDef(OrdQty.Text, 0) = 0 then
begin
Application.MessageBox('<27>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>!', '<27><>ʾ', 0);
Exit;
end;
if SaveData() then
begin
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>', '<27><>ʾ', 0);
ModalResult := 1;
end;
end;
procedure TfrmShuttleLSSCInPut.FtyNameBtnUpClick(Sender: TObject);
begin
try
frmCompanySel := TfrmCompanySel.Create(Application);
with frmCompanySel do
begin
FCoType := '<27><>Ӧ<EFBFBD><D3A6>';
if ShowModal = 1 then
begin
FtyName.TxtCode := Trim(CDS_1.fieldbyname('CoCode').AsString);
FtyName.Text := Trim(CDS_1.fieldbyname('CoName').AsString);
end;
end;
finally
frmCompanySel.Free;
end;
end;
procedure TfrmShuttleLSSCInPut.FtyNameBtnDnClick(Sender: TObject);
begin
FtyName.Text := '';
end;
procedure TfrmShuttleLSSCInPut.Y_NameBtnDnClick(Sender: TObject);
begin
Self.Y_Name.TxtCode := '';
Self.Y_Name.Text := '';
Self.Y_Spec.Text := '';
Self.Y_Color.Text := '';
end;
procedure TfrmShuttleLSSCInPut.Y_NameBtnUpClick(Sender: TObject);
begin
try
frmYarnInfoSel := TfrmYarnInfoSel.Create(Application);
with frmYarnInfoSel do
begin
if ShowModal = 1 then
begin
Self.Y_Name.TxtCode := Trim(CDS_1.fieldbyname('Y_Code').AsString);
Self.Y_Name.Text := Trim(CDS_1.fieldbyname('Y_Name').AsString);
Self.Y_Spec.Text := Trim(CDS_1.fieldbyname('Y_Spec').AsString);
Self.Y_Color.Text := Trim(CDS_1.fieldbyname('Y_Color').AsString);
end;
end;
finally
frmYarnInfoSel.Free;
end;
end;
procedure TfrmShuttleLSSCInPut.YE_NameBtnDnClick(Sender: TObject);
begin
YE_Name.TxtCode := '';
YE_Name.Text := '';
end;
procedure TfrmShuttleLSSCInPut.YE_NameBtnUpClick(Sender: TObject);
begin
try
frmYarnInfoSel := TfrmYarnInfoSel.Create(Application);
with frmYarnInfoSel do
begin
if ShowModal = 1 then
begin
YE_Name.TxtCode := Trim(CDS_1.fieldbyname('Y_Code').AsString);
YE_Name.Text := Trim(CDS_1.fieldbyname('Y_Name').AsString);
end;
end;
finally
frmYarnInfoSel.Free;
end;
end;
end.