406 lines
9.8 KiB
ObjectPascal
406 lines
9.8 KiB
ObjectPascal
![]() |
unit U_FCSMCK;
|
|||
|
|
|||
|
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,
|
|||
|
cxLookAndFeels, cxLookAndFeelPainters, cxNavigator;
|
|||
|
|
|||
|
type
|
|||
|
TfrmFCSMCK = class(TForm)
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
DS_MainSel: TDataSource;
|
|||
|
CDS_MainSel: TClientDataSet;
|
|||
|
cxGridPopupMenu4: TcxGridPopupMenu;
|
|||
|
cxGrid3: TcxGrid;
|
|||
|
Tv3: TcxGridDBTableView;
|
|||
|
cxGridDBColumn1: TcxGridDBColumn;
|
|||
|
v3Column3: TcxGridDBColumn;
|
|||
|
cxGridDBColumn4: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
Panel2: TPanel;
|
|||
|
Label5: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
Label9: TLabel;
|
|||
|
CKOrdNo: TEdit;
|
|||
|
BaoID: TEdit;
|
|||
|
CRTime: TDateTimePicker;
|
|||
|
KHName: TEdit;
|
|||
|
Button2: TButton;
|
|||
|
cxStyleRepository1: TcxStyleRepository;
|
|||
|
cxStyle1: TcxStyle;
|
|||
|
Label12: TLabel;
|
|||
|
CDS_Main: TClientDataSet;
|
|||
|
Button1: TButton;
|
|||
|
v3Column2: TcxGridDBColumn;
|
|||
|
Button3: TButton;
|
|||
|
CKType: TComboBox;
|
|||
|
Label1: TLabel;
|
|||
|
Edit1: TEdit;
|
|||
|
Label2: TLabel;
|
|||
|
Button4: TButton;
|
|||
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
procedure FormDestroy(Sender: TObject);
|
|||
|
procedure FormShow(Sender: TObject);
|
|||
|
procedure BaoIDKeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure Button2Click(Sender: TObject);
|
|||
|
procedure Button1Click(Sender: TObject);
|
|||
|
procedure Button3Click(Sender: TObject);
|
|||
|
procedure CKTypeChange(Sender: TObject);
|
|||
|
procedure Edit1Click(Sender: TObject);
|
|||
|
procedure Button4Click(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
FCKOrdNo, FRKOrdID: string;
|
|||
|
function JudgeSQD(): Boolean;
|
|||
|
function JudgeRKD(): Boolean;
|
|||
|
function JudgeRKDCX(): Boolean;
|
|||
|
procedure SaveCKData();
|
|||
|
procedure SaveCKDataCX();
|
|||
|
procedure InitCKGrid();
|
|||
|
public
|
|||
|
FSMStr: string;
|
|||
|
{ Public declarations }
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmFCSMCK: TfrmFCSMCK;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_Fun, MMSystem, U_ZdyAttachment, U_ZdyAttachGYS,
|
|||
|
U_FinishedClothKCList_SMCK;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
function TfrmFCSMCK.JudgeSQD(): Boolean;
|
|||
|
begin
|
|||
|
Result := false;
|
|||
|
try
|
|||
|
|
|||
|
if Trim(KHName.Text) = '' then
|
|||
|
raise Exception.Create('<27><>ѡ<EFBFBD><D1A1><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>λ!');
|
|||
|
|
|||
|
if Trim(CKOrdNo.Text) = '' then
|
|||
|
raise Exception.Create('<27><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>!');
|
|||
|
|
|||
|
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;
|
|||
|
|
|||
|
function TfrmFCSMCK.JudgeRKD(): Boolean;
|
|||
|
begin
|
|||
|
try
|
|||
|
if CKType.Text = '<27><><EFBFBD><EFBFBD><DEB3><EFBFBD>' then
|
|||
|
begin
|
|||
|
if Trim(KHName.Text) = '' then
|
|||
|
raise Exception.Create('<27><>ѡ<EFBFBD><D1A1><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>λ!');
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from WFB_MJJY A ');
|
|||
|
sql.Add('where RKOrdID=' + quotedstr(trim(FRKOrdID)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
if ADOQueryTemp.IsEmpty then
|
|||
|
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>!');
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('SELECT RKOrdID,CKOrdNo FROM CK_BanCP_CR where CRFlag=''<27><><EFBFBD><EFBFBD>'' and RKOrdID=' + quotedstr(trim(FRKOrdID)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if not ADOQueryTemp.IsEmpty then
|
|||
|
raise Exception.Create('<27><>ɨ<EFBFBD><C9A8>!');
|
|||
|
|
|||
|
Result := True;
|
|||
|
except
|
|||
|
Result := false;
|
|||
|
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmFCSMCK.JudgeRKDCX(): Boolean;
|
|||
|
begin
|
|||
|
try
|
|||
|
if Trim(CKOrdNo.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>!');
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('SELECT ckno FROM CK_Cloth_CR where CRFlag=''<27><><EFBFBD><EFBFBD>'' and jyid=' + quotedstr(FSMStr));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
if ADOQueryTemp.IsEmpty then
|
|||
|
raise Exception.Create('<27>ɳ<DEBF><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!');
|
|||
|
|
|||
|
Result := True;
|
|||
|
except
|
|||
|
Result := false;
|
|||
|
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.SaveCKData();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPDATE CK_Cloth_CR Set ');
|
|||
|
sql.add(' CRTime=getdate() ');
|
|||
|
sql.add(',CRType=' + quotedstr(Trim(CKType.Text)));
|
|||
|
sql.add(',CRFlag=''<27><><EFBFBD><EFBFBD>'' ');
|
|||
|
sql.add(',CKNo=' + Quotedstr(CKOrdNo.Text));
|
|||
|
sql.Add(' where CK_Cloth_CR.JYID=' + Quotedstr(Trim(FSMStr)));
|
|||
|
sql.Add('and CK_Cloth_CR.CRFlag=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'' ');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('UPDATE CK_Cloth_KC Set ');
|
|||
|
sql.add(' Valid=''N'' ');
|
|||
|
sql.Add(' where CK_Cloth_KC.JYID=' + Quotedstr(Trim(FSMStr)));
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
PlaySound('wav\<5C><>ȷ.wav', 0, SND_FILENAME or SND_ASYNC);
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.SaveCKDataCX();
|
|||
|
begin
|
|||
|
try
|
|||
|
ADOQueryCmd.Connection.BeginTrans;
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('Update CK_Cloth_CR Set CRFlag=''<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'',CRType=NULL,CRTime=NULL,CRNote=NULL,CKNo=NULL ');
|
|||
|
sql.Add(' where CK_Cloth_CR.JYID=' + Quotedstr(Trim(FSMStr)));
|
|||
|
sql.Add(' and CRFlag=''<27><><EFBFBD><EFBFBD>''');
|
|||
|
|
|||
|
sql.Add(' UPdate CK_Cloth_KC Set Valid=''Y'' ');
|
|||
|
sql.Add(' where CK_Cloth_KC.JYID=' + Quotedstr(Trim(FSMStr)));
|
|||
|
sql.Add(' and Valid=''N'' ');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('insert into SY_SysLog(operor,opertime,Model,acction,opevent,result) values( ');
|
|||
|
sql.Add(' ' + quotedstr(trim(DName)));
|
|||
|
sql.Add(',getdate() ');
|
|||
|
sql.Add(',' + quotedstr(''));
|
|||
|
sql.Add(',' + quotedstr(trim('<27><><EFBFBD><EFBFBD>ɨ<EFBFBD>賷<EFBFBD><E8B3B7>')));
|
|||
|
sql.Add(',' + quotedstr('<27><><EFBFBD><EFBFBD><EFBFBD>룺' + trim(FSMStr) + ' <20><><EFBFBD>ⵥ<EFBFBD>ţ<EFBFBD>' + trim(CKOrdNo.Text)));
|
|||
|
sql.Add(',' + quotedstr(trim('<27>ɹ<EFBFBD>')));
|
|||
|
sql.Add(')');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
except
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>', '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.InitCKGrid();
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('SELECT sum(jylen)Qty,CKNo,a.p_code,count(*)js FROM CK_Cloth_CR A ');
|
|||
|
sql.Add(' WHERE CRFlag=''<27><><EFBFBD><EFBFBD>''');
|
|||
|
|
|||
|
sql.Add(' and ckno=' + quotedstr(FCKOrdNo));
|
|||
|
sql.Add('group by CKNo,a.p_code ');
|
|||
|
|
|||
|
// ShowMessage(SQL.Text);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
SCreateCDS20(ADOQueryTemp, CDS_MainSel);
|
|||
|
SInitCDSData20(ADOQueryTemp, CDS_MainSel);
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.FormDestroy(Sender: TObject);
|
|||
|
begin
|
|||
|
frmFCSMCK := nil;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.FormShow(Sender: TObject);
|
|||
|
begin
|
|||
|
BaoID.SetFocus;
|
|||
|
ReadCxGrid('ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
|||
|
CRTime.DateTime := SGetServerDate(ADOQueryTemp);
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.BaoIDKeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
FRKOrdID := TRIM(BaoID.Text);
|
|||
|
FSMStr := Trim(BAOID.Text);
|
|||
|
BaoID.Text := '';
|
|||
|
if Edit1.Text = '' then
|
|||
|
begin
|
|||
|
|
|||
|
if not JudgeSQD() then
|
|||
|
exit;
|
|||
|
|
|||
|
SaveCKData();
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if not JudgeRKDCX() then
|
|||
|
exit;
|
|||
|
SaveCKDataCX();
|
|||
|
end;
|
|||
|
|
|||
|
InitCKGrid();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.Button2Click(Sender: TObject);
|
|||
|
begin
|
|||
|
Close;
|
|||
|
WriteCxGrid('ɨ<><C9A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', Tv3, '<27><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.Button1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if CKType.Text = '<27><><EFBFBD>۳<EFBFBD><DBB3><EFBFBD>' then
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZdyAttachment := TfrmZdyAttachment.Create(Application);
|
|||
|
with frmZdyAttachment do
|
|||
|
begin
|
|||
|
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
KHName.Text := Trim(CDS_HZ.fieldbyname('Name').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZdyAttachment.Free;
|
|||
|
end;
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
try
|
|||
|
frmZdyAttachGYS := TfrmZdyAttachGYS.Create(Application);
|
|||
|
with frmZdyAttachGYS do
|
|||
|
begin
|
|||
|
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
KHName.Text := Trim(CDS_HZ.fieldbyname('Name').AsString);
|
|||
|
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmZdyAttachGYS.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.Button3Click(Sender: TObject);
|
|||
|
begin
|
|||
|
if GetLSNo(ADOQueryTemp, FCKOrdNo, 'CK', 'CK_BanCP_CR', 4, 1) = False then
|
|||
|
begin
|
|||
|
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˮ<EFBFBD><CBAE><EFBFBD>쳣<EFBFBD><ECB3A3>', '<27><>ʾ', 0);
|
|||
|
exit;
|
|||
|
end;
|
|||
|
CKOrdNo.TEXT := FCKOrdNo;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.CKTypeChange(Sender: TObject);
|
|||
|
begin
|
|||
|
KHName.Text := '';
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.Edit1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
BaoID.SetFocus;
|
|||
|
if Edit1.Text = '<27><>' then
|
|||
|
begin
|
|||
|
Edit1.Text := '';
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
if Application.MessageBox('ȷ<><C8B7>Ҫɨ<D2AA><C9A8><EFBFBD>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>', '<27><>ʾ', 32 + 4) = IDYES then
|
|||
|
Edit1.Text := '<27><>';
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmFCSMCK.Button4Click(Sender: TObject);
|
|||
|
var
|
|||
|
MKey: Char;
|
|||
|
begin
|
|||
|
MKey := #13;
|
|||
|
if TRIM(SELF.CKOrdNo.Text) = '' then
|
|||
|
EXIT;
|
|||
|
try
|
|||
|
frmFinishedClothKCList_SMCK := TfrmFinishedClothKCList_SMCK.Create(self);
|
|||
|
with frmFinishedClothKCList_SMCK do
|
|||
|
begin
|
|||
|
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
while frmFinishedClothKCList_SMCK.CDS_Main.Locate('SSel', true, []) do
|
|||
|
begin
|
|||
|
self.baoID.Text := Trim(frmFinishedClothKCList_SMCK.CDS_Main.fieldbyname('JYID').AsString);
|
|||
|
self.baoIDKeyPress(self.baoID, MKey);
|
|||
|
frmFinishedClothKCList_SMCK.CDS_Main.Delete;
|
|||
|
sleep(500);
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmFinishedClothKCList_SMCK.Free;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|