234 lines
7.3 KiB
ObjectPascal
234 lines
7.3 KiB
ObjectPascal
unit U_TradeClothTransferInput;
|
||
|
||
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, dxSkinWXI,
|
||
dxScrollbarAnnotations, cxCheckBox, cxContainer, 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,
|
||
dxSkinXmas2008Blue;
|
||
|
||
type
|
||
TfrmTradeClothTransferInput = class(TfrmBaseInput)
|
||
ToolBar1: TToolBar;
|
||
TBSave: TToolButton;
|
||
TBClose: TToolButton;
|
||
DS_1: TDataSource;
|
||
CDS_Sub: TClientDataSet;
|
||
ADOQueryCmd: TADOQuery;
|
||
ADOQueryMain: TADOQuery;
|
||
ADOQueryTemp: TADOQuery;
|
||
GPM_1: TcxGridPopupMenu;
|
||
ToolButton1: TToolButton;
|
||
Pnl_F2: TPanel;
|
||
Label2: TLabel;
|
||
Label4: TLabel;
|
||
FromOrdNo: TcxTextEdit;
|
||
C_Name: TcxTextEdit;
|
||
cxGrid1: TcxGrid;
|
||
Tv1: TcxGridDBTableView;
|
||
Tv1Column13: TcxGridDBColumn;
|
||
v1Column6: TcxGridDBColumn;
|
||
v1Column2: TcxGridDBColumn;
|
||
v1Column4: TcxGridDBColumn;
|
||
v1Column14: TcxGridDBColumn;
|
||
Tv1Column11: TcxGridDBColumn;
|
||
Tv1Column20: TcxGridDBColumn;
|
||
v2Column1: TcxGridDBColumn;
|
||
v1Column8: TcxGridDBColumn;
|
||
Tv1Column4: TcxGridDBColumn;
|
||
v1Column13: TcxGridDBColumn;
|
||
v1Column11: TcxGridDBColumn;
|
||
Tv1Column6: TcxGridDBColumn;
|
||
v1Column15: TcxGridDBColumn;
|
||
v2Column6: TcxGridDBColumn;
|
||
v1Column3: TcxGridDBColumn;
|
||
v1Column5: TcxGridDBColumn;
|
||
Tv1Column19: TcxGridDBColumn;
|
||
v1Column19: TcxGridDBColumn;
|
||
v1Column12: TcxGridDBColumn;
|
||
v1Column20: TcxGridDBColumn;
|
||
Tv1Column3: TcxGridDBColumn;
|
||
Tv1Column5: TcxGridDBColumn;
|
||
Tv1Column1: TcxGridDBColumn;
|
||
Tv1Column21: TcxGridDBColumn;
|
||
Tv1Column2: TcxGridDBColumn;
|
||
Tv1Column10: TcxGridDBColumn;
|
||
Tv1Column8: TcxGridDBColumn;
|
||
Tv1Column9: TcxGridDBColumn;
|
||
Tv1Column14: TcxGridDBColumn;
|
||
cxGrid1Level1: TcxGridLevel;
|
||
Tv1Column7: TcxGridDBColumn;
|
||
Tv1Column12: TcxGridDBColumn;
|
||
ToolButton2: TToolButton;
|
||
ToolButton3: TToolButton;
|
||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||
procedure TBCloseClick(Sender: TObject);
|
||
procedure FormShow(Sender: TObject);
|
||
procedure TBSaveClick(Sender: TObject);
|
||
procedure ToolButton1Click(Sender: TObject);
|
||
procedure ToolButton2Click(Sender: TObject);
|
||
procedure ToolButton3Click(Sender: TObject);
|
||
private
|
||
{ Private declarations }
|
||
procedure InitGrid();
|
||
function SaveData(): Boolean;
|
||
public
|
||
{ Public declarations }
|
||
FBCId, FStkName, FMasterOrderNo: string;
|
||
end;
|
||
|
||
var
|
||
frmTradeClothTransferInput: TfrmTradeClothTransferInput;
|
||
|
||
implementation
|
||
|
||
uses
|
||
U_DataLink, U_RTFun;
|
||
|
||
{$R *.dfm}
|
||
procedure TfrmTradeClothTransferInput.InitGrid();
|
||
var
|
||
Msql, mbegdate, menddate: string;
|
||
SqlStr: string;
|
||
begin
|
||
|
||
SqlStr := ' select A.* ';
|
||
SqlStr := SqlStr + ',OutPiece=cast(0 as DECIMAL(18,2)),OutQty=cast(0 as DECIMAL(18,2)) ';
|
||
SqlStr := SqlStr + ' from BS_Cloth_IO A ';
|
||
SqlStr := SqlStr + ' where A.IOFlag=''<27><><EFBFBD><EFBFBD>'' and (isnull(StkQty,0)>0 or isnull(StkPiece,0)>0) ';
|
||
SqlStr := SqlStr + ' and isnull(stkName,'''')=''ó<>ײ<EFBFBD>ƥ'' ';
|
||
|
||
InitCDSData(ADOQueryTemp, CDS_Sub, Tv1, SqlStr, SGetFilters(Pnl_F2, 1, 2), 'STKID');
|
||
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.FormClose(Sender: TObject; var Action: TCloseAction);
|
||
begin
|
||
inherited;
|
||
Action := caFree;
|
||
end;
|
||
|
||
function TfrmTradeClothTransferInput.SaveData(): Boolean;
|
||
var
|
||
MBCIOID, Maxno: string;
|
||
begin
|
||
try
|
||
ADOQueryCmd.Connection.BeginTrans;
|
||
CDS_Sub.DisableControls;
|
||
with CDS_Sub do
|
||
begin
|
||
First;
|
||
while not eof do
|
||
begin
|
||
if CDS_Sub.fieldbyname('OutQty').AsFloat > 0 then
|
||
begin
|
||
if not GetLSNo(ADOQueryCmd, Maxno, 'Z', 'BS_Cloth_IO', 4, 1) then
|
||
raise Exception.Create('ȡȾɫ<C8BE><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
|
||
|
||
with ADOQueryCmd do
|
||
begin
|
||
Close;
|
||
Sql.Clear;
|
||
Sql.Add('exec P_BS_Cloth_OutMove ');
|
||
Sql.Add(' @StkID=' + quotedstr(Trim(CDS_Sub.fieldbyname('StkID').AsString)));
|
||
Sql.Add(' ,@BCIOID=' + quotedstr(Trim(Maxno)));
|
||
Sql.Add(' ,@MasterOrdNo=' + quotedstr(Trim(FMasterOrderNo)));
|
||
Sql.Add(' ,@Piece=' + Trim(CDS_Sub.fieldbyname('OutPiece').AsString));
|
||
Sql.Add(' ,@Qty=' + Trim(CDS_Sub.fieldbyname('OutQty').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)));
|
||
|
||
end;
|
||
|
||
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 TfrmTradeClothTransferInput.TBCloseClick(Sender: TObject);
|
||
begin
|
||
ModalResult := 1;
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.FormShow(Sender: TObject);
|
||
var
|
||
fsj: string;
|
||
begin
|
||
inherited;
|
||
ReadCxGrid(Trim(Self.Caption) + 'Tv1', Tv1, 'ó<><EFBFBD><D7BB>ֿܲ<DCB2>');
|
||
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.TBSaveClick(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
ToolBar1.SetFocus();
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.ToolButton1Click(Sender: TObject);
|
||
begin
|
||
WriteCxGrid(Trim(Self.Caption) + 'Tv1', Tv1, 'ó<><EFBFBD><D7BB>ֿܲ<DCB2>');
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.ToolButton2Click(Sender: TObject);
|
||
begin
|
||
InitGrid();
|
||
end;
|
||
|
||
procedure TfrmTradeClothTransferInput.ToolButton3Click(Sender: TObject);
|
||
begin
|
||
if CDS_Sub.IsEmpty then
|
||
Exit;
|
||
ToolBar1.SetFocus();
|
||
if SaveData() then
|
||
begin
|
||
Application.MessageBox('<27><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!', '<27><>ʾ', 0);
|
||
ModalResult := 1;
|
||
end;
|
||
end;
|
||
|
||
end.
|
||
|