610 lines
19 KiB
ObjectPascal
610 lines
19 KiB
ObjectPascal
![]() |
unit U_YarnOutEdit;
|
|||
|
|
|||
|
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, cxPC, dxScrollbarAnnotations;
|
|||
|
|
|||
|
type
|
|||
|
TfrmYarnOutEdit = class(TfrmBaseInput)
|
|||
|
ToolBar1: TToolBar;
|
|||
|
TBAdd: TToolButton;
|
|||
|
TBDel: TToolButton;
|
|||
|
TBSave: TToolButton;
|
|||
|
TBClose: TToolButton;
|
|||
|
DS_1: TDataSource;
|
|||
|
CDS_Sub: TClientDataSet;
|
|||
|
ADOQueryCmd: TADOQuery;
|
|||
|
ADOQueryMain: TADOQuery;
|
|||
|
ADOQueryTemp: TADOQuery;
|
|||
|
GPM_1: TcxGridPopupMenu;
|
|||
|
cxGrid1: TcxGrid;
|
|||
|
Tv1: TcxGridDBTableView;
|
|||
|
v1Column6: TcxGridDBColumn;
|
|||
|
v1Column2: TcxGridDBColumn;
|
|||
|
v1CRType: TcxGridDBColumn;
|
|||
|
v2Column1: TcxGridDBColumn;
|
|||
|
v1Column8: TcxGridDBColumn;
|
|||
|
v2Column6: TcxGridDBColumn;
|
|||
|
v1Column3: TcxGridDBColumn;
|
|||
|
v1Column12: TcxGridDBColumn;
|
|||
|
cxGrid1Level1: TcxGridLevel;
|
|||
|
v1Column1: TcxGridDBColumn;
|
|||
|
v1Column5: TcxGridDBColumn;
|
|||
|
v1Column7: TcxGridDBColumn;
|
|||
|
v1Column10: TcxGridDBColumn;
|
|||
|
ToolButton1: TToolButton;
|
|||
|
Tv1Column2: TcxGridDBColumn;
|
|||
|
Tv1Column3: TcxGridDBColumn;
|
|||
|
Tv1Column1: TcxGridDBColumn;
|
|||
|
Tv1Column4: TcxGridDBColumn;
|
|||
|
Tv1Column5: TcxGridDBColumn;
|
|||
|
Tv1Column6: TcxGridDBColumn;
|
|||
|
Tv1Column7: TcxGridDBColumn;
|
|||
|
Tv1Column8: TcxGridDBColumn;
|
|||
|
Tv1Column9: TcxGridDBColumn;
|
|||
|
Tv1Column10: TcxGridDBColumn;
|
|||
|
Tv1Column11: TcxGridDBColumn;
|
|||
|
cxPageControl1: TcxPageControl;
|
|||
|
cxTabSheet2: TcxTabSheet;
|
|||
|
Pnl_F2: TPanel;
|
|||
|
Label2: TLabel;
|
|||
|
Label4: TLabel;
|
|||
|
Edit1: TEdit;
|
|||
|
Edit2: TEdit;
|
|||
|
DS_2: TDataSource;
|
|||
|
CDS_2: TClientDataSet;
|
|||
|
GPM_2: TcxGridPopupMenu;
|
|||
|
ADO_2: TADOQuery;
|
|||
|
cxGrid2: TcxGrid;
|
|||
|
TV2: TcxGridDBTableView;
|
|||
|
v1OrderNo: TcxGridDBColumn;
|
|||
|
cxGridDBColumn1: TcxGridDBColumn;
|
|||
|
v1Column31: TcxGridDBColumn;
|
|||
|
cxGridDBColumn2: TcxGridDBColumn;
|
|||
|
cxGridDBColumn3: TcxGridDBColumn;
|
|||
|
v1Column19: TcxGridDBColumn;
|
|||
|
v1Column21: TcxGridDBColumn;
|
|||
|
cxGridDBColumn4: TcxGridDBColumn;
|
|||
|
v1Column20: TcxGridDBColumn;
|
|||
|
cxGridDBColumn5: TcxGridDBColumn;
|
|||
|
v1PRTMF: TcxGridDBColumn;
|
|||
|
cxGridDBColumn6: TcxGridDBColumn;
|
|||
|
v1PRTKZ: TcxGridDBColumn;
|
|||
|
cxGridDBColumn7: TcxGridDBColumn;
|
|||
|
v1Column22: TcxGridDBColumn;
|
|||
|
cxGridDBColumn8: TcxGridDBColumn;
|
|||
|
v1PRTOrderQty: TcxGridDBColumn;
|
|||
|
cxGridDBColumn9: TcxGridDBColumn;
|
|||
|
v1Column4: TcxGridDBColumn;
|
|||
|
cxGridLevel1: TcxGridLevel;
|
|||
|
TV2Column1: TcxGridDBColumn;
|
|||
|
TV2Column2: 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);
|
|||
|
procedure v2Column6PropertiesEditValueChanged(Sender: TObject);
|
|||
|
procedure TextEdit(Sender: TObject);
|
|||
|
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
|
|||
|
procedure TV2DblClick(Sender: TObject);
|
|||
|
private
|
|||
|
{ Private declarations }
|
|||
|
function SaveCKData(): Boolean;
|
|||
|
procedure InitReceipt();
|
|||
|
public
|
|||
|
{ Public declarations }
|
|||
|
FBCId, FStkName, FKHName: string;
|
|||
|
end;
|
|||
|
|
|||
|
var
|
|||
|
frmYarnOutEdit: TfrmYarnOutEdit;
|
|||
|
|
|||
|
implementation
|
|||
|
|
|||
|
uses
|
|||
|
U_DataLink, U_RTFun, U_ZDYHelp, U_YarnStkSel, U_CompanySel;
|
|||
|
|
|||
|
{$R *.dfm}
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.InitReceipt();
|
|||
|
var
|
|||
|
FWSql: string;
|
|||
|
begin
|
|||
|
|
|||
|
case cxPageControl1.ActivePageIndex of
|
|||
|
0:
|
|||
|
begin
|
|||
|
FWSql := SGetHintFilters(Pnl_F2, 1, 2);
|
|||
|
if FWSql <> '' then
|
|||
|
FWSql := ' and ' + FWSql;
|
|||
|
|
|||
|
with ADO_2 do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select A.*,B.* ');
|
|||
|
sql.Add(',SumPiece=(select Sum(X.Piece) from BS_Cloth_IO X where X.ToOrdNo=A.OrderNo )');
|
|||
|
sql.Add(',SumQty=(select Sum(X.Qty) from BS_Cloth_IO X where X.ToOrdNo=A.OrderNo )');
|
|||
|
sql.Add(' from knit_Plan_Main A inner join knit_Plan_Sub B on A.Mainid=B.MainId');
|
|||
|
sql.add('where Status=''9'' ');
|
|||
|
if Trim(FWSql) <> '' then
|
|||
|
sql.Add(FWSql);
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
SCreateCDS(ADO_2, CDS_2);
|
|||
|
SInitCDSData(ADO_2, CDS_2);
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.Edit1KeyPress(Sender: TObject; var Key: Char);
|
|||
|
begin
|
|||
|
if Key = #13 then
|
|||
|
begin
|
|||
|
InitReceipt();
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.FormClose(Sender: TObject; var Action: TCloseAction);
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
Action := caFree;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.TBAddClick(Sender: TObject);
|
|||
|
begin
|
|||
|
try
|
|||
|
frmYarnStkSel := TfrmYarnStkSel.Create(Application);
|
|||
|
with frmYarnStkSel do
|
|||
|
begin
|
|||
|
FstkName := Self.FstkName;
|
|||
|
if ShowModal = 1 then
|
|||
|
begin
|
|||
|
frmYarnStkSel.CDS_Main.DisableControls;
|
|||
|
with frmYarnStkSel.CDS_Main do
|
|||
|
begin
|
|||
|
First;
|
|||
|
while frmYarnStkSel.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 := frmYarnStkSel.CDS_Main.fieldbyname('BYIOID').Value;
|
|||
|
FieldByName('IOType').Value := '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|||
|
FieldByName('FromCoNo').Value := frmYarnStkSel.CDS_Main.fieldbyname('FromCoNo').Value; //<2F><><EFBFBD>Ե<EFBFBD>λ
|
|||
|
FieldByName('FromCoName').Value := frmYarnStkSel.CDS_Main.fieldbyname('FromCoName').Value;
|
|||
|
FieldByName('StkCoNo').Value := frmYarnStkSel.CDS_Main.fieldbyname('StkCoNo').Value; //<2F><><EFBFBD>ŵ<EFBFBD>λ
|
|||
|
FieldByName('StkCoName').Value := frmYarnStkSel.CDS_Main.fieldbyname('StkCoName').Value;
|
|||
|
FieldByName('ToCoNo').Value := frmYarnStkSel.CDS_Main.fieldbyname('StkCoNo').Value; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
FieldByName('ToCoName').Value := frmYarnStkSel.CDS_Main.fieldbyname('StkCoName').Value;
|
|||
|
|
|||
|
FieldByName('Brand').Value := frmYarnStkSel.CDS_Main.fieldbyname('Brand').Value;
|
|||
|
FieldByName('Y_Name').Value := frmYarnStkSel.CDS_Main.fieldbyname('Y_Name').Value;
|
|||
|
FieldByName('Y_Spec').Value := frmYarnStkSel.CDS_Main.fieldbyname('Y_Spec').Value;
|
|||
|
FieldByName('Y_Composition').Value := frmYarnStkSel.CDS_Main.fieldbyname('Y_Composition').Value;
|
|||
|
FieldByName('Y_Color').Value := frmYarnStkSel.CDS_Main.fieldbyname('Y_Color').Value;
|
|||
|
FieldByName('Denier').Value := frmYarnStkSel.CDS_Main.fieldbyname('Denier').Value;
|
|||
|
FieldByName('BatchNo').Value := frmYarnStkSel.CDS_Main.fieldbyname('BatchNo').Value;
|
|||
|
|
|||
|
FieldByName('Piece').Value := frmYarnStkSel.CDS_Main.fieldbyname('STKPiece').Value;
|
|||
|
FieldByName('PieceQty').Value := frmYarnStkSel.CDS_Main.fieldbyname('PieceQty').Value;
|
|||
|
FieldByName('Qty').Value := frmYarnStkSel.CDS_Main.fieldbyname('STKQTY').Value;
|
|||
|
FieldByName('Price').Value := frmYarnStkSel.CDS_Main.fieldbyname('Price').Value;
|
|||
|
|
|||
|
FieldByName('Amount').Value := RoundFloat(frmYarnStkSel.CDS_Main.fieldbyname('Price').Value * frmYarnStkSel.CDS_Main.fieldbyname('STKQTY').Value, 2);
|
|||
|
FieldByName('QtyUnit').Value := frmYarnStkSel.CDS_Main.fieldbyname('QtyUnit').Value;
|
|||
|
FieldByName('StkPosition').Value := frmYarnStkSel.CDS_Main.fieldbyname('StkPosition').Value;
|
|||
|
end;
|
|||
|
frmYarnStkSel.CDS_Main.Delete;
|
|||
|
end;
|
|||
|
end;
|
|||
|
frmYarnStkSel.CDS_Main.EnableControls;
|
|||
|
end;
|
|||
|
end;
|
|||
|
finally
|
|||
|
frmYarnStkSel.Free;
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
function TfrmYarnOutEdit.SaveCKData(): Boolean;
|
|||
|
var
|
|||
|
MBYIOID, 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 BS_Yarn_IO where BYIOID=''' + Trim(CDS_Sub.fieldbyname('BYIOID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
MBYIOID := Trim(ADOQueryTemp.fieldbyname('BYIOID').AsString);
|
|||
|
if Trim(MBYIOID) = '' then
|
|||
|
begin
|
|||
|
if not GetLSNo(ADOQueryCmd, Maxno, 'PC', 'BS_Yarn_IO', 3, 1) then
|
|||
|
raise Exception.Create('ȡȾɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
|||
|
end
|
|||
|
else
|
|||
|
begin
|
|||
|
Maxno := Trim(MBYIOID);
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from BS_Yarn_IO where BYIOID=''' + Trim(Maxno) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
if Trim(MBYIOID) = '' 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, 'BS_Yarn_IO', 0);
|
|||
|
FieldByName('STKName').Value := FSTKName;
|
|||
|
FieldByName('BYIOID').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('Update BS_Yarn_IO Set StkPiece=(select Sum(isnull(Piece,0)*IOQtyFlag) from BS_Yarn_IO A where A.STKID=BS_Yarn_IO.BYIOID)');
|
|||
|
sql.Add(',STKQty=(select Sum(isnull(Qty,0)*IOQtyFlag) from BS_Yarn_IO A where A.STKID=BS_Yarn_IO.BYIOID )');
|
|||
|
sql.Add('where BYIOID=''' + Trim(CDS_Sub.fieldbyname('STKID').AsString) + '''');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from BS_Yarn_IO where BYIOID=''' + Trim(CDS_Sub.fieldbyname('STKID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
|
|||
|
if ADOQueryTemp.FieldByName('StkPiece').Value < 0 then
|
|||
|
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1>棡');
|
|||
|
|
|||
|
if ADOQueryTemp.FieldByName('StkPiece').Value < 0 then
|
|||
|
raise Exception.Create('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1>棡');
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
Sql.Clear;
|
|||
|
Sql.Add('exec P_BS_Yarn_Move ');
|
|||
|
Sql.Add(' @BYIOID=' + quotedstr(Trim(Maxno)));
|
|||
|
Open;
|
|||
|
end;
|
|||
|
if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then
|
|||
|
raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString)));
|
|||
|
|
|||
|
with ADOQueryCmd do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
Sql.Clear;
|
|||
|
sql.Add('insert into Finance_Need_Up(UType,UDataId) values(''ɴ<>߳<EFBFBD><DFB3><EFBFBD>'',' + quotedstr(Trim(Maxno)) + ') ');
|
|||
|
ExecSQL;
|
|||
|
end;
|
|||
|
|
|||
|
Edit;
|
|||
|
FieldByName('BYIOID').Value := Trim(Maxno);
|
|||
|
Post;
|
|||
|
|
|||
|
Next;
|
|||
|
end;
|
|||
|
end;
|
|||
|
CDS_Sub.EnableControls;
|
|||
|
ADOQueryCmd.Connection.CommitTrans;
|
|||
|
Result := True;
|
|||
|
except
|
|||
|
Result := False;
|
|||
|
ADOQueryCmd.Connection.RollbackTrans;
|
|||
|
application.MessageBox(PChar(Exception(ExceptObject).Message), '<27><>ʾ<EFBFBD><CABE>Ϣ', 0);
|
|||
|
end;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.TBCloseClick(Sender: TObject);
|
|||
|
begin
|
|||
|
|
|||
|
Close;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.FormShow(Sender: TObject);
|
|||
|
var
|
|||
|
fsj: string;
|
|||
|
begin
|
|||
|
inherited;
|
|||
|
|
|||
|
ReadCxGrid(fSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
|
|||
|
ReadCxGrid(fSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>2', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
|
|||
|
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add(' select A.* ');
|
|||
|
sql.Add(' from BS_Yarn_IO A');
|
|||
|
sql.Add(' where BYIOID=''' + 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 TfrmYarnOutEdit.TBDelClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if CDS_Sub.IsEmpty then
|
|||
|
Exit;
|
|||
|
if Trim(CDS_Sub.fieldbyname('BYIOID').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_BS_Yarn_Out_Del ');
|
|||
|
Sql.Add(' @BYIOIDS=' + quotedstr(Trim(CDS_Sub.fieldbyname('BYIOID').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 TfrmYarnOutEdit.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 TfrmYarnOutEdit.ToolButton1Click(Sender: TObject);
|
|||
|
begin
|
|||
|
WriteCxGrid(fSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>1', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
|
|||
|
WriteCxGrid(fSTKName + '<27><><EFBFBD><EFBFBD><EFBFBD>Ǽ<EFBFBD>2', Tv1, '<27><><EFBFBD><EFBFBD><EFBFBD>ϲֿ<CFB2>');
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.TextEdit(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
FPiece, FPieceQty, FQty, FPrice, FAmount: Double; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۣ<EFBFBD><DBA3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
begin
|
|||
|
mvalue := TcxTextEdit(Sender).EditingText;
|
|||
|
if Trim(mvalue) = '' then
|
|||
|
begin
|
|||
|
mvalue := '0';
|
|||
|
end;
|
|||
|
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value := Trim(mvalue);
|
|||
|
Post;
|
|||
|
FPiece := Fieldbyname('Piece').AsFloat;
|
|||
|
FPieceQty := Fieldbyname('PieceQty').AsFloat;
|
|||
|
FQty := RoundFloat(FPiece * FPieceQty, 2);
|
|||
|
FPrice := Fieldbyname('Price').AsFloat;
|
|||
|
end;
|
|||
|
|
|||
|
FAmount := RoundFloat(FQty * FPrice, 2);
|
|||
|
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('Qty').Value := FQty;
|
|||
|
FieldByName('Price').Value := FPrice;
|
|||
|
FieldByName('Amount').Value := FAmount;
|
|||
|
Post;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.Tv1Column2PropertiesButtonClick(Sender: TObject; AButtonIndex: Integer);
|
|||
|
begin
|
|||
|
if trim(CDS_Sub.FieldByName('IOType').AsString) = '<27>ͻ<EFBFBD><CDBB>˻<EFBFBD>' then
|
|||
|
begin
|
|||
|
try
|
|||
|
frmCompanySel := TfrmCompanySel.Create(Application);
|
|||
|
with frmCompanySel do
|
|||
|
begin
|
|||
|
FCoType := '<27>ͻ<EFBFBD>';
|
|||
|
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
|
|||
|
else
|
|||
|
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;
|
|||
|
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.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('BYIOID').AsString) <> '' then
|
|||
|
begin
|
|||
|
with ADOQueryTemp do
|
|||
|
begin
|
|||
|
Close;
|
|||
|
sql.Clear;
|
|||
|
sql.Add('select * from BS_Yarn_IO where BYIOID=''' + Trim(CDS_Sub.fieldbyname('BYIOID').AsString) + '''');
|
|||
|
Open;
|
|||
|
end;
|
|||
|
FFSPID := Trim(ADOQueryTemp.fieldbyname('BYIOID').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;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.TV2DblClick(Sender: TObject);
|
|||
|
begin
|
|||
|
if not Self.CDS_Sub.IsEmpty then
|
|||
|
begin
|
|||
|
with Self.CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('ToOrdNo').Value := Trim(CDS_2.fieldbyname('OrderNo').AsString);
|
|||
|
FieldByName('ToMainId').Value := Trim(CDS_2.fieldbyname('MainId').AsString);
|
|||
|
FieldByName('ToSubId').Value := Trim(CDS_2.fieldbyname('SubId').AsString);
|
|||
|
end;
|
|||
|
end;
|
|||
|
end;
|
|||
|
|
|||
|
procedure TfrmYarnOutEdit.v2Column6PropertiesEditValueChanged(Sender: TObject);
|
|||
|
var
|
|||
|
mvalue, FFieldName: string;
|
|||
|
FQty, FPrice, FAmount: Double; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۣ<EFBFBD><DBA3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
begin
|
|||
|
mvalue := TcxTextEdit(Sender).EditingText;
|
|||
|
if Trim(mvalue) = '' then
|
|||
|
begin
|
|||
|
mvalue := '0';
|
|||
|
end;
|
|||
|
FFieldName := Trim(Tv1.Controller.FocusedColumn.DataBinding.FilterFieldName);
|
|||
|
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName(FFieldName).Value := Trim(mvalue);
|
|||
|
Post;
|
|||
|
FQty := Fieldbyname('Qty').AsFloat;
|
|||
|
FPrice := Fieldbyname('Price').AsFloat;
|
|||
|
end;
|
|||
|
FAmount := RoundFloat(FQty * FPrice, 2);
|
|||
|
|
|||
|
with CDS_Sub do
|
|||
|
begin
|
|||
|
Edit;
|
|||
|
FieldByName('Qty').Value := FQty;
|
|||
|
FieldByName('Price').Value := FPrice;
|
|||
|
FieldByName('Amount').Value := FAmount;
|
|||
|
Post;
|
|||
|
end;
|
|||
|
tv1.Controller.EditingController.ShowEdit();
|
|||
|
end;
|
|||
|
|
|||
|
end.
|
|||
|
|