2025-03-01 10:55:52 +08:00
unit U_WBSpecInPut;
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, StdCtrls, ExtCtrls,
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxDateRanges,
dxBarBuiltInMenu, U_BaseInput, U_BaseList, System. ImageList, Vcl. ImgList,
cxMemo, dxScrollbarAnnotations, cxContainer, dxSkinsCore,
2025-04-17 15:21:14 +08:00
dxSkinsDefaultPainters, cxImageList, dxSkinBasic, dxSkinBlack, dxSkinBlue,
dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkroom, dxSkinDarkSide,
dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
dxSkinOffice2013White, dxSkinOffice2016Colorful, dxSkinOffice2016Dark,
dxSkinOffice2019Black, dxSkinOffice2019Colorful, dxSkinOffice2019DarkGray,
dxSkinOffice2019White, dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic,
dxSkinSharp, dxSkinSharpPlus, dxSkinSilver, dxSkinSpringtime, dxSkinStardust,
dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinTheBezier, dxSkinValentine,
dxSkinVisualStudio2013Blue, dxSkinVisualStudio2013Dark,
dxSkinVisualStudio2013Light, dxSkinVS2010, dxSkinWhiteprint, dxSkinWXI,
dxSkinXmas2008Blue, cxMaskEdit;
2025-03-01 10:55:52 +08:00
type
TfrmWBSpecInPut = class( TfrmBaseInput)
cxGrid1: TcxGrid;
Tv1: TcxGridDBTableView;
v1SPName: TcxGridDBColumn;
cxGrid1Level1: TcxGridLevel;
ToolBar1: TToolBar;
TBSave: TToolButton;
TBClose: TToolButton;
DS_1: TDataSource;
CDS_Sub: TClientDataSet;
ADOQueryCmd: TADOQuery;
ADOQueryMain: TADOQuery;
ADOQueryTemp: TADOQuery;
GPM_1: TcxGridPopupMenu;
v1Column12: TcxGridDBColumn;
v1SPSpec: TcxGridDBColumn;
v1Column1: TcxGridDBColumn;
v1Column18: TcxGridDBColumn;
v1Column10: TcxGridDBColumn;
v1Column15: TcxGridDBColumn;
v1Column3: TcxGridDBColumn;
ToolButton1: TToolButton;
Tv1Column1: TcxGridDBColumn;
ScrollBox1: TScrollBox;
Label7: TLabel;
Label3: TLabel;
WB_Code: TcxTextEdit;
ToolBar2: TToolBar;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
Label4: TLabel;
Label8: TLabel;
WB_YarnQty: TcxTextEdit;
WB_Move: TcxTextEdit;
Tv1Column2: TcxGridDBColumn;
Label1: TLabel;
Label2: TLabel;
WB_Name: TcxTextEdit;
WB_ReedNote: TcxTextEdit;
Label5: TLabel;
WB_YarnArr: TcxTextEdit;
Label6: TLabel;
WB_YarnStripRemainder: TcxTextEdit;
Label9: TLabel;
WB_YarnStripQty: TcxTextEdit;
Label10: TLabel;
WB_ReedNo: TcxTextEdit;
Label11: TLabel;
WB_Width: TcxTextEdit;
Label12: TLabel;
WB_YarnLen: TcxTextEdit;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
WB_Arg_SDWZ: TcxTextEdit;
WB_Arg_PXDS: TcxTextEdit;
Label16: TLabel;
WB_Arg_QJZL: TcxTextEdit;
Tv1Column3: TcxGridDBColumn;
WB_YarnArrNote: TcxMemo;
Note: TcxMemo;
btn1: TToolButton;
Tv1Column4: TcxGridDBColumn;
Label17: TLabel;
WB_YarnDensity: TcxTextEdit;
Tv1Column5: TcxGridDBColumn;
Tv1Column6: TcxGridDBColumn;
Tv1Column7: TcxGridDBColumn;
2025-04-17 15:21:14 +08:00
Label18: TLabel;
ISSizing: TcxComboBox;
2025-03-01 10:55:52 +08:00
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 ToolButton1Click( Sender: TObject) ;
procedure Tv1Column2PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer ) ;
procedure btn1Click( Sender: TObject) ;
2025-04-17 15:21:14 +08:00
procedure GYNoDblClick( Sender: TObject) ;
2025-03-01 10:55:52 +08:00
private
{ Private declarations }
function SaveData( ) : Boolean ;
public
{ Public declarations }
FWBSID, FSTKName: string ;
end ;
var
frmWBSpecInPut: TfrmWBSpecInPut;
implementation
uses
2025-04-17 15:21:14 +08:00
U_DataLink, U_RTFun, U_ZDYHelp, U_YarnInfoSel, U_TatClothInfoSel, U_TatGYSel,
U_CompanySel;
2025-03-01 10:55:52 +08:00
{$R *.dfm}
procedure TfrmWBSpecInPut. btn1Click( Sender: TObject) ;
begin
try
frmTatClothInfoSel : = TfrmTatClothInfoSel. Create( Application) ;
with frmTatClothInfoSel do
begin
if ShowModal = 1 then
begin
Self. WB_YarnQty. Text : = frmTatClothInfoSel. CDS_1. fieldbyname( 'C_YarnQty' ) . AsString;
Self. WB_ReedNo. Text : = frmTatClothInfoSel. CDS_1. fieldbyname( 'C_ReedNo' ) . AsString;
with Self. ADOQueryTemp do
begin
Close;
sql. Clear;
sql. Add( 'select A.* from BS_Cloth_Yarn A inner join Bs_Cloth_Info B on A.BCIID=B.BCIID' ) ;
sql. Add( ' where A.YRType=' '<27> <> ˿' ' and B.C_Code=' '' + Trim( frmTatClothInfoSel. CDS_1. fieldbyname( 'C_Code' ) . AsString) + '' '' ) ;
Open;
First;
Self. CDS_Sub. EmptyDataSet;
while not Eof do
begin
with Self. CDS_Sub do
begin
Append;
FieldByName( 'RowNo' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'RowNo' ) . value;
FieldByName( 'Y_Code' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'Y_Code' ) . value;
FieldByName( 'Y_Name' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'Y_Name' ) . value;
FieldByName( 'Y_Spec' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'Y_Spec' ) . value;
FieldByName( 'Y_Color' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'Y_Color' ) . value;
FieldByName( 'YarnQty' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'YarnQty' ) . value;
FieldByName( 'CycleYarnQty' ) . Value : = Self. ADOQueryTemp. fieldbyname( 'CycleYarnQty' ) . value;
end ;
Next;
end ;
end ;
end ;
end ;
finally
frmTatClothInfoSel. Free;
end ;
end ;
procedure TfrmWBSpecInPut. FormClose( Sender: TObject; var Action: TCloseAction) ;
begin
inherited ;
Action : = caFree;
end ;
procedure TfrmWBSpecInPut. TBAddClick( Sender: TObject) ;
begin
try
frmYarnInfoSel : = TfrmYarnInfoSel. Create( Application) ;
with frmYarnInfoSel do
begin
FSTKName : = 'ɴ<> <C9B4> ' ;
if ShowModal = 1 then
begin
with Self. CDS_Sub do
begin
Append;
FieldByName( 'Y_Color' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Color' ) . value;
FieldByName( 'Y_Code' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Code' ) . value;
FieldByName( 'Y_Name' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Name' ) . value;
FieldByName( 'Y_Spec' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Spec' ) . value;
FieldByName( 'FF' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'FF' ) . value;
FieldByName( 'ND' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'ND' ) . value;
FieldByName( 'Denier' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Denier' ) . value;
FieldByName( 'Y_Ratio' ) . Value : = 0 ;
end ;
end ;
end ;
finally
frmYarnInfoSel. Free;
end ;
end ;
function TfrmWBSpecInPut. SaveData( ) : Boolean ;
var
MaxNo, MaxYRId: string ;
begin
try
ADOQueryCmd. Connection. BeginTrans;
if Trim( FWBSID) = '' then
begin
if GetLSNo( ADOQueryCmd, MaxNo, 'QJ' , 'Tat_WB_Spec' , 5 , 0 ) = False then
raise Exception. Create( 'ȡ<> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> ' ) ;
WB_Code. Text : = MaxNo;
end
else
begin
MaxNo : = Trim( FWBSID) ;
end ;
with ADOQueryCmd do
begin
Close;
SQL. Clear;
sql. Add( 'select * from Tat_WB_Spec where WBSID=' '' + Trim( MaxNo) + '' '' ) ;
Open;
end ;
with ADOQueryCmd do
begin
if Trim( FWBSID) = '' then
begin
Append;
FieldByName( 'FillId' ) . Value : = Trim( DCode) ;
FieldByName( 'Filler' ) . Value : = Trim( DName) ;
end
else
begin
Edit;
FieldByName( 'EditId' ) . Value : = Trim( DCode) ;
FieldByName( 'Editer' ) . Value : = Trim( DName) ;
FieldByName( 'Edittime' ) . Value : = SGetServerDateTime( ADOQueryTemp) ;
end ;
FieldByName( 'WBSID' ) . Value : = Trim( MaxNo) ;
RTSetsavedata( ADOQueryCmd, 'Tat_WB_Spec' , ScrollBox1, 2 ) ;
Post;
end ;
with ADOQueryCmd do
begin
Close;
sql. Clear;
sql. Add( 'select * from Tat_WB_Spec where WB_Code=' + quotedstr( trim( WB_Code. Text ) ) ) ;
Open;
end ;
if ADOQueryCmd. RecordCount > 1 then
raise Exception. Create( '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> ظ<EFBFBD> !' ) ;
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_Formula ' ) ;
sql. Add( 'where WBSID=' '' + Trim( MaxNo) + '' '' ) ;
sql. Add( 'and YRId=' '' + Trim( CDS_Sub. fieldbyname( 'YRId' ) . AsString) + '' '' ) ;
open;
end ;
MaxYRId : = Trim( ADOQueryTemp. fieldbyname( 'YRId' ) . AsString) ;
if Trim( MaxYRId) = '' then
begin
if GetLSNo( ADOQueryCmd, MaxYRId, 'P' , 'Tat_WB_Formula' , 4 , 0 ) = False then
raise Exception. Create( 'ȡ<> <C8A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> ' ) ;
end
else
begin
MaxYRId : = Trim( MaxYRId) ;
end ;
with ADOQueryCmd do
begin
Close;
sql. Clear;
sql. Add( 'select * from Tat_WB_Formula where YRId=' '' + Trim( MaxYRId) + '' '' ) ;
Open;
end ;
with ADOQueryCmd do
begin
if Trim( MaxYRId) = '' then
begin
Append;
FieldByName( 'Fillid' ) . Value : = Trim( Dcode) ;
FieldByName( 'Filler' ) . Value : = Trim( DName)
end
else
begin
Edit;
FieldByName( 'Editid' ) . Value : = Trim( Dcode) ;
FieldByName( 'Editer' ) . Value : = Trim( DName) ;
FieldByName( 'EditTime' ) . Value : = SGetServerDate( ADOQueryTemp) ;
end ;
FieldByName( 'WBSID' ) . Value : = Trim( MaxNo) ;
FieldByName( 'YRId' ) . Value : = Trim( MaxYRId) ;
RTSetSaveDataCDS( ADOQueryCmd, Tv1, CDS_Sub, 'Tat_WB_Formula' , 0 ) ;
Post;
end ;
Edit;
FieldByName( 'YRId' ) . Value : = Trim( MaxYRId) ;
Post;
Next;
end ;
end ;
CDS_Sub. EnableControls;
with ADOQueryCmd do
begin
Close;
sql. Clear;
sql. Add( 'update Tat_WB_Spec set WB_Name=' ) ; // X.RowNo
sql. Add( ' SUBSTRING(CAST((select ' '+' '+X.Y_Name from Tat_WB_Formula X where isnull(X.Y_Name,' '' ')<>' '' ' and X.WBSID=Tat_WB_Spec.WBSID order by RowNo for xml path(' '' ') ) AS VARCHAR(200)) , 2, 200)' ) ;
sql. Add( 'where isnull(WB_Name,' '' ')=' '' ' and WBSID=' '' + Trim( MaxNo) + '' '' ) ;
// ShowMessage(SQL.Text);
ExecSQL;
end ;
ADOQueryCmd. Connection. CommitTrans;
Result : = True ;
except
Result : = False ;
ADOQueryCmd. Connection. RollbackTrans;
application. MessageBox( PChar( Exception( ExceptObject) . Message ) , '<27> <> ʾ <EFBFBD> <CABE> Ϣ' , 0 ) ;
end ;
end ;
procedure TfrmWBSpecInPut. TBCloseClick( Sender: TObject) ;
begin
Close;
end ;
procedure TfrmWBSpecInPut. FormShow( Sender: TObject) ;
var
fsj: string ;
begin
inherited ;
ReadCxGrid( trim( self. Caption) , Tv1, '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֿ<EFBFBD> ' ) ;
with ADOQueryTemp do
begin
Close;
SQL. Clear;
sql. Add( ' select * from Tat_WB_Spec ' ) ;
sql. Add( ' where WBSID=' '' + Trim( FWBSID) + '' '' ) ;
Open;
end ;
SCSHData( ADOQueryTemp, ScrollBox1, 2 ) ;
with ADOQueryTemp do
begin
Close;
sql. Clear;
sql. Add( ' select * from Tat_WB_Formula ' ) ;
sql. Add( ' where WBSID=' '' + Trim( FWBSID) + '' '' ) ;
Open;
end ;
SCreateCDS( ADOQueryTemp, CDS_Sub) ;
SInitCDSData( ADOQueryTemp, CDS_Sub) ;
if FWBSID = '' then
begin
with CDS_Sub do
begin
Append;
FieldByName( 'RowNo' ) . Value : = 'A' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'B' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'C' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'D' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'E' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'F' ;
Post;
Append;
FieldByName( 'RowNo' ) . Value : = 'G' ;
Post;
end ;
end ;
end ;
2025-04-17 15:21:14 +08:00
procedure TfrmWBSpecInPut. GYNoDblClick( Sender: TObject) ;
begin
inherited ;
TcxButtonEdit( Sender) . Properties. LookupItems. Text : = '' ;
TcxButtonEdit( Sender) . Text : = '' ;
end ;
2025-03-01 10:55:52 +08:00
procedure TfrmWBSpecInPut. TBDelClick( Sender: TObject) ;
begin
if CDS_Sub. IsEmpty then
Exit;
if Trim( CDS_Sub. fieldbyname( 'YRId' ) . AsString) < > '' then
begin
if Application. MessageBox( 'ȷ<> <C8B7> Ҫɾ<D2AA> <C9BE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ' , '<27> <> ʾ ' , 3 2 + 4 ) < > IDYES then
Exit;
try
ADOQueryCmd. Connection. BeginTrans;
with ADOQueryCmd do
begin
Close;
sql. Clear;
sql. Add( ' delete Tat_WB_Formula where YRId=' '' + Trim( CDS_Sub. fieldbyname( 'YRId' ) . AsString) + '' '' ) ;
ExecSQL;
end ;
ADOQueryCmd. Connection. CommitTrans;
CDS_Sub. Delete;
except
ADOQueryCmd. Connection. RollbackTrans;
Application. MessageBox( 'ɾ<> <C9BE> <EFBFBD> 쳣!' , '<27> <> ʾ ' , 0 ) ;
end ;
end
else
begin
CDS_Sub. Delete;
end ;
end ;
procedure TfrmWBSpecInPut. TBSaveClick( Sender: TObject) ;
begin
ToolBar1. SetFocus;
if StrToFloatDef( WB_YarnDensity. Text , 0 ) = 0 then
begin
Application. MessageBox( '<27> <> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> ȷ<EFBFBD> ľ<EFBFBD> <C4BE> <EFBFBD> !' , '<27> <> ʾ ' , 0 ) ;
Exit;
end ;
if StrToFloatDef( WB_Width. Text , 0 ) = 0 then
begin
Application. MessageBox( '<27> <> <EFBFBD> <EFBFBD> д<EFBFBD> <D0B4> ȷ<EFBFBD> ľ<EFBFBD> <C4BE> <EFBFBD> <EFBFBD> ŷ<EFBFBD> !' , '<27> <> ʾ ' , 0 ) ;
Exit;
end ;
with CDS_Sub do
begin
CDS_Sub. First;
while not Eof do
begin
if trim( CDS_Sub. fieldbyname( 'Y_Code' ) . asstring) < > '' then
begin
if StrToFloatDef( Trim( CDS_Sub. fieldbyname( 'YarnQty' ) . AsString) , 0 ) = 0 then
begin
Application. MessageBox( '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> !' , '<27> <> ʾ ' , 0 ) ;
Exit;
end ;
end ;
if trim( CDS_Sub. fieldbyname( 'Y_Code' ) . asstring) < > '' then
begin
if StrToFloatDef( Trim( CDS_Sub. fieldbyname( 'CycleYarnQty' ) . AsString) , 0 ) = 0 then
begin
Application. MessageBox( 'ѭ<> <D1AD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> <CEAA> !' , '<27> <> ʾ ' , 0 ) ;
Exit;
end ;
end ;
CDS_Sub. Next;
end ;
end ;
if SaveData( ) then
begin
Application. MessageBox( '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> ɹ<EFBFBD> !' , '<27> <> ʾ ' , 0 ) ;
ModalResult : = 1 ;
Exit;
end ;
end ;
procedure TfrmWBSpecInPut. ToolButton1Click( Sender: TObject) ;
begin
WriteCxGrid( trim( self. Caption) , Tv1, '<27> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֿ<EFBFBD> ' ) ;
end ;
procedure TfrmWBSpecInPut. Tv1Column2PropertiesButtonClick( Sender: TObject; AButtonIndex: Integer ) ;
begin
try
frmYarnInfoSel : = TfrmYarnInfoSel. Create( Application) ;
with frmYarnInfoSel do
begin
FSTKName : = 'ɴ<> <C9B4> ' ;
if ShowModal = 1 then
begin
with Self. CDS_Sub do
begin
Edit;
FieldByName( 'Y_Color' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Color' ) . value;
FieldByName( 'Y_Code' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Code' ) . value;
FieldByName( 'Y_Name' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Name' ) . value;
FieldByName( 'Y_Spec' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Y_Spec' ) . value;
FieldByName( 'FF' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'FF' ) . value;
FieldByName( 'ND' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'ND' ) . value;
FieldByName( 'Denier' ) . Value : = frmYarnInfoSel. CDS_1. fieldbyname( 'Denier' ) . value;
FieldByName( 'Y_Ratio' ) . Value : = 0 ;
end ;
end ;
end ;
finally
frmYarnInfoSel. Free;
end ;
end ;
end .