RTFormwork/项目代码/RTBasicsV1/D03针织坯布仓库/U_KnitClothDROutEdit.pas
“ddf” b5fbedfd26 1
2024-08-08 16:35:41 +08:00

552 lines
16 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_KnitClothDROutEdit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, ADODB, DBClient,
cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView,
cxGrid, MovePanel, cxCheckBox, Menus, ComCtrls, BtnEdit, ShellAPI, cxTextEdit,
RM_Common, RM_Class, RM_GridReport, RM_System, RM_Dataset, RM_e_Xls,
cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters,
cxNavigator, dxDateRanges, dxBarBuiltInMenu, U_BaseList, 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, dxScrollbarAnnotations,
cxContainer, cxButtons, dxCore, cxDateUtils, cxMaskEdit, cxDropDownEdit,
cxCalendar;
type
TfrmKnitClothDROutEdit = class(TfrmBaseList)
ADOQueryTemp: TADOQuery;
ADOQueryCmd: TADOQuery;
DS_MainSel: TDataSource;
CDS_MainSel: TClientDataSet;
GPM_1: TcxGridPopupMenu;
Panel2: TPanel;
Label5: TLabel;
Label4: TLabel;
Label9: TLabel;
edtScan: TcxTextEdit;
ToCoName: TcxTextEdit;
cxStyleRepository1: TcxStyleRepository;
cxStyle1: TcxStyle;
Label12: TLabel;
CDS_Main: TClientDataSet;
CRType: TcxTextEdit;
RMXLSExport1: TRMXLSExport;
RMDBMX: TRMDBDataSet;
RM1: TRMGridReport;
CDS_JuanPRT: TClientDataSet;
Label10: TLabel;
edtIsSMTH: TcxTextEdit;
ds1: TClientDataSet;
ds2: TDataSource;
Panel1: TPanel;
cxGrid3: TcxGrid;
Tv3: TcxGridDBTableView;
cv3Column3: TcxGridDBColumn;
VC_MJXH: TcxGridDBColumn;
v3Column1: TcxGridDBColumn;
v3Column2: TcxGridDBColumn;
cv3Column4: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
cxGrid1: TcxGrid;
TV4: TcxGridDBTableView;
cCXCONNO: TcxGridDBColumn;
cV4Column1: TcxGridDBColumn;
cCXCOLOR: TcxGridDBColumn;
VC_SQQTY: TcxGridDBColumn;
cCXFHPS: TcxGridDBColumn;
cxGridLevel2: TcxGridLevel;
TV4Column1: TcxGridDBColumn;
Tv3Column1: TcxGridDBColumn;
TV4Column2: TcxGridDBColumn;
TV4Column3: TcxGridDBColumn;
OutNo: TcxTextEdit;
GPM_2: TcxGridPopupMenu;
TV4Column5: TcxGridDBColumn;
Tv3Column4: TcxGridDBColumn;
TV4Column4: TcxGridDBColumn;
Pnl_msg: TPanel;
Button1: TcxButton;
btn1: TcxButton;
Button2: TcxButton;
CRTime: TcxDateEdit;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure edtScanKeyPress(Sender: TObject; var Key: Char);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure edtIsSMTHClick(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure TV4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
FCKNO, FSMStr, JXFlag, CZZT, fcuowu: string;
procedure InitCKGrid();
procedure InitSQGrid();
procedure PlayWav(MWav: string);
procedure SetMsg(MMsg: string);
function JudgeSQD(): Boolean;
function SaveCKJTM(MStkIds: string): Boolean;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
procedure SaveCKJTMCX(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public
{ Public declarations }
end;
var
frmKnitClothDROutEdit: TfrmKnitClothDROutEdit;
implementation
uses
U_DataLink, U_RTFun, MMSystem, U_KnitDRSel;
procedure TfrmKnitClothDROutEdit.SetMsg(MMsg: string);
begin
if (MMsg = '<27><><EFBFBD><EFBFBD>') or (MMsg = '<27><>ȷ') then
Pnl_msg.Visible := False
else
begin
Pnl_msg.Visible := true;
Pnl_msg.Caption := MMsg;
end;
end;
procedure TfrmKnitClothDROutEdit.PlayWav(MWav: string);
begin
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav')) then
begin
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav'), 0, SND_ASYNC);
end
else
begin
MWav := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav')) then
PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav'), 0, SND_ASYNC);
end;
end;
procedure TfrmKnitClothDROutEdit.SaveCKJTMCX();
begin
try
if Trim(OutNo.Text) = '' then
raise Exception.Create('<27><><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>!');
if CDS_MainSel.IsEmpty then
raise Exception.Create('<27>޿ɳ<DEBF><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule) ');
sql.Add('values(''<27><>֯<EFBFBD><D6AF>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(OutNo.Text));
sql.Add(',''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(dname));
sql.Add(',' + quotedstr(self.Caption));
sql.Add(') ');
Sql.Add('exec P_Knit_Cloth_ReOut ');
Sql.Add(' @StkIds=' + quotedstr(trim(FSMStr)));
Sql.Add(',@IOIDS=' + quotedstr(trim('')));
Sql.Add(',@FillId=' + Quotedstr(DCode));
Sql.Add(',@Filler=' + 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;
PlayWav('<27><>ȷ');
except
ADOQueryCmd.Connection.RollbackTrans;
raise Exception.Create(PChar(Exception(ExceptObject).Message));
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Knit_Cloth_DR @OutNoS=' + Quotedstr(Trim(OutNo.Text)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
except
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
if trim(Exception(ExceptObject).Message) = '<27><><EFBFBD><EFBFBD><EBB2BB><EFBFBD><EFBFBD>' then
PlayWav('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
end;
procedure TfrmKnitClothDROutEdit.TV4MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
inherited;
InitCKGrid();
end;
function TfrmKnitClothDROutEdit.SaveCKJTM(MStkIds: string): Boolean;
begin
try
if Trim(OutNo.Text) = '' then
raise Exception.Create('<27><><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>Ϊ<EFBFBD><CEAA>');
with ADOQueryTemp do
begin
Close;
Sql.Clear;
Sql.Add(' select A.StkID from Knit_Cloth_Stock A inner join [dbo].[F_Tool_SplitString](' + Quotedstr(MStkIds) + ','','') B ');
Sql.Add(' on A.STKID=B.RTValue ');
Sql.Add(' and not EXISTS( select * from Knit_Cloth_DR_Sub X ');
Sql.Add(' where X.MainId=A.MainID and X.Loom=A.Loom and isnull(X.BatchNo,'''')=isnull(A.BatchNo,'''') and DRMID=' + Quotedstr(OutNo.Text) + ') ');
Open;
end;
if not ADOQueryTemp.IsEmpty then
begin
raise Exception.Create(pchar('<27><><EFBFBD>ݲ<EFBFBD><DDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EBB7B6><CEA7>'));
end;
with ADOQueryTemp do
begin
Close;
Sql.Clear;
Sql.Add('select * from Knit_Cloth_DR_Sub X where DlyPiece>=Piece and DRMID=' + Quotedstr(OutNo.Text));
Sql.Add('and EXISTS(select A.StkID from Knit_Cloth_Stock A inner join [dbo].[F_Tool_SplitString](' + Quotedstr(MStkIds) + ','','') B on A.STKID=B.RTValue ');
Sql.Add('where X.MainId=A.MainID and X.Loom=A.Loom and isnull(X.BatchNo,'''')=isnull(A.BatchNo,'''') ) ');
Open;
end;
if not ADOQueryTemp.IsEmpty then
begin
raise Exception.Create(pchar('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'));
end;
try
ADOQueryCmd.Connection.BeginTrans;
with ADOQueryCmd do
begin
Close;
Sql.Clear;
sql.Add('insert into Finance_Need_Up(UType,UDataId,UOperation,UOperator,UModule) ');
sql.Add('values(''<27><>֯<EFBFBD><D6AF>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(OutNo.Text));
sql.Add(',''<27><><EFBFBD><EFBFBD>'' ');
sql.Add(',' + quotedstr(dname));
sql.Add(',' + quotedstr(self.Caption));
sql.Add(') ');
Sql.Add('exec P_Knit_Cloth_Out ');
Sql.Add(' @StkIds=' + quotedstr(trim(MStkIds)));
Sql.Add(',@IOTime=' + Quotedstr(FormatDateTime('yyyy-MM-dd', CRTime.Date)));
Sql.Add(',@IOType=' + Quotedstr(crtype.Text));
Sql.Add(',@IONO=' + Quotedstr(OutNo.Text));
Sql.Add(',@FillId=' + Quotedstr(DCode));
Sql.Add(',@Filler=' + 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;
except
ADOQueryCmd.Connection.RollbackTrans;
raise Exception.Create(PChar(Exception(ExceptObject).Message));
end;
with ADOQueryCmd do
begin
Close;
sql.Clear;
sql.Add('exec P_Knit_Cloth_DR @OutNoS=' + Quotedstr(Trim(OutNo.Text)));
Open;
end;
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
begin
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
end;
PlayWav('<27><>ȷ');
Result := True;
except
Result := False;
SetMsg(PChar(Exception(ExceptObject).Message));
PlayWav(PChar(Exception(ExceptObject).Message));
end;
end;
{$R *.dfm}
function TfrmKnitClothDROutEdit.JudgeSQD(): Boolean;
begin
Result := false;
try
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * from Knit_Cloth_DR_Main A inner join Knit_Cloth_DR_Sub B on A.DRMID=B.DRMID where A.DRMID=''' + Trim(FSMStr) + '''');
Open;
end;
if ADOQueryTemp.IsEmpty then
raise Exception.Create('<27><><EFBFBD><EFBFBD><EBB5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>!');
if Trim(OutNo.Text) <> '' then
begin
FCKNO := Trim(OutNo.Text);
end;
OutNo.Text := Trim(FSMStr);
if FSMStr <> FCKNO then
begin
InitCKGrid();
InitSQGrid();
end;
Result := True;
except
Result := false;
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
// PlaySound('δɨ<CEB4><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB5A5>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>.wav', 0, SND_FILENAME or SND_ASYNC);
end;
end;
procedure TfrmKnitClothDROutEdit.FormClose(Sender: TObject; var Action: TCloseAction);
begin
inherited;
Action := caFree;
end;
procedure TfrmKnitClothDROutEdit.FormDestroy(Sender: TObject);
begin
inherited;
frmKnitClothDROutEdit := nil;
end;
procedure TfrmKnitClothDROutEdit.FormShow(Sender: TObject);
begin
inherited;
edtScan.SetFocus;
ReadCxGrid(<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv4', Tv4, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
ReadCxGrid(<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv3', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
CRTime.Date := SGetServerDate(ADOQueryTemp);
end;
procedure TfrmKnitClothDROutEdit.edtScanKeyPress(Sender: TObject; var Key: Char);
var
maxno, SMFlag, KYCKFlag, FMainId, ff: string;
FFQty: Integer;
begin
if Key = #13 then
begin
if TRIM(edtScan.Text) = '' then
Exit;
SetMsg('<27><><EFBFBD><EFBFBD>');
FSMStr := TRIM(edtScan.Text);
if Copy(FSMStr, 1, 2) = 'DM' then
begin
if not JudgeSQD() then
exit;
end
else
begin
if Trim(edtIsSMTH.Text) = '' then
begin
if Copy(FSMStr, 1, 2) = 'BI' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add(' select StkIdS=CAST((select distinct lTRIM(rTRIM(X.StkId)) + '','' ');
sql.Add(' from Knit_Cloth_Stock X where X.PacketId=' + quotedstr(FSMStr) + ' for xml path('''') ) AS NVARCHAR(MAX)) ');
Open;
end;
if SaveCKJTM(ADOQueryTemp.FieldByName('StkIdS').AsString) then
begin
PlayWav('<27><>ȷ');
end
else
exit;
end
else
begin
if SaveCKJTM(FSMStr) then
begin
PlayWav('<27><>ȷ');
end
else
exit;
end;
end
else
begin
SaveCKJTMCX();
end;
InitSQGrid();
InitCKGrid();
end;
edtScan.Text := '';
end;
end;
procedure TfrmKnitClothDROutEdit.Button2Click(Sender: TObject);
begin
WriteCxGrid(<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv4', Tv4, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
WriteCxGrid(<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tv3', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
Close;
end;
procedure TfrmKnitClothDROutEdit.Button1Click(Sender: TObject);
var
MKey: Char;
begin
MKey := #13;
try
frmKnitDRSel := TfrmKnitDRSel.Create(self);
with frmKnitDRSel do
begin
if ShowModal = 1 then
begin
edtScan.Text := Trim(Order_Main.fieldbyname('DRMID').AsString);
edtScanKeyPress(edtScan, MKey);
end;
end;
finally
frmKnitDRSel.Free;
end;
end;
procedure TfrmKnitClothDROutEdit.edtIsSMTHClick(Sender: TObject);
begin
if Trim(edtIsSMTH.Text) = '' then
edtIsSMTH.Text := '<27><>'
else
edtIsSMTH.Text := '';
end;
procedure TfrmKnitClothDROutEdit.btn1Click(Sender: TObject);
var
MKey: Char;
begin
MKey := #13;
CZZT := 'ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
fcuowu := '1';
// try
// frmCKProductCPKCListSel := TfrmCKProductCPKCListSel.Create(Application);
// with frmCKProductCPKCListSel do
// begin
//// CustomerNoName.text := trim(Self.KHName.text);
// if ShowModal = 1 then
// begin
// with frmCKProductCPKCListSel.CDS_Main do
// begin
// First;
// while not Eof do
// begin
// if Fieldbyname('ssel').AsBoolean then
// begin
//
// Self.edtScan.Text := Trim(Fieldbyname('JYID').AsString);
// edtScanKeyPress(Self.edtScan, MKey);
// if fcuowu = '<27><><EFBFBD><EFBFBD>' then
// begin
// Break;
// end;
// Sleep(200);
// end;
// Next;
// end;
// end;
// end;
// end;
// finally
// frmCKProductCPKCListSel.Free;
// end;
InitCKGrid();
end;
procedure TfrmKnitClothDROutEdit.InitSQGrid();
begin
if OutNo.Text <> '' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('SELECT * FROM Knit_Cloth_DR_Sub B');
sql.Add('inner join Knit_Cloth_DR_Main A ON A.DRMID=B.DRMID ');
sql.Add('WHERE B.DRMID=''' + Trim(OutNo.Text) + '''');
Open;
end;
SCreateCDS(ADOQueryTemp, DS1);
SInitCDSData(ADOQueryTemp, DS1);
crtype.Text := Trim(ADOQueryTemp.FieldByName('OutType').AsString);
ToCoName.Text := Trim(ADOQueryTemp.FieldByName('ToCoName').AsString);
end;
end;
procedure TfrmKnitClothDROutEdit.InitCKGrid();
begin
if OutNo.Text <> '' then
begin
with ADOQueryTemp do
begin
Close;
sql.Clear;
sql.Add('select * ');
sql.Add(' from Knit_Cloth_Stock A inner join Knit_Cloth_IO B on A.STKID=B.StkId ');
sql.Add(' where B.IONO=''' + Trim(OutNo.Text) + '''');
Open;
end;
SCreateCDS(ADOQueryTemp, CDS_MainSel);
SInitCDSData(ADOQueryTemp, CDS_MainSel);
end;
end;
end.