unit U_StockScanInEdit; interface uses Windows, Messages, strUtils, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, ExtCtrls, ADODB, DBClient, cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, MMSystem, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, MovePanel, cxCheckBox, Menus, ComCtrls, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, U_BaseList, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, RM_Common, RM_Class, RM_GridReport, RM_Dataset, Vcl.ToolWin, 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; type TfrmStockScanInEdit = class(TfrmBaseList) GPM_1: TcxGridPopupMenu; CDS_1: TClientDataSet; DS_1: TDataSource; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; Panel1: TPanel; CDS_2: TClientDataSet; DS_2: TDataSource; GPM_2: TcxGridPopupMenu; DS_3: TDataSource; CDS_3: TClientDataSet; GPM_3: TcxGridPopupMenu; Panel2: TPanel; cxGrid3: TcxGrid; Tv3: TcxGridDBTableView; cxGridDBColumn4: TcxGridDBColumn; v3MJID: TcxGridDBColumn; v3Column3: TcxGridDBColumn; Tv3Column1: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; v3Column1: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; Panel3: TPanel; Label4: TLabel; Label5: TLabel; Label11: TLabel; CRTime: TDateTimePicker; InNo: TEdit; CRType: TComboBox; ToolBar3: TToolBar; ToolButton3: TToolButton; btnGetOutNo: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; edtScan: TEdit; Label6: TLabel; Tv3Column2: TcxGridDBColumn; Tv3Column3: TcxGridDBColumn; Label1: TLabel; IOPosition: TEdit; ToolButton5: TToolButton; Tv3Column4: TcxGridDBColumn; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure btnGetOutNoClick(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton8Click(Sender: TObject); procedure edtScanKeyPress(Sender: TObject; var Key: Char); procedure ToolButton5Click(Sender: TObject); private { Private declarations } FScan, FSubIds: string; procedure PlayWav(MWav: string); procedure InitKC(); procedure ScanKW(); procedure ScanCIID(); public { Public declarations } end; var frmStockScanInEdit: TfrmStockScanInEdit; implementation uses U_DataLink, U_RTFun, U_TradeClothWaitStorage, U_LabelPrint, U_PositionSel; {$R *.dfm} procedure TfrmStockScanInEdit.PlayWav(MWav: string); begin if FileExists(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav')) then PlaySound(PChar(ExtractFilePath(Application.ExeName) + 'wav\' + MWav + '.wav'), 0, SND_ASYNC); end; procedure TfrmStockScanInEdit.InitKC(); begin if IOPosition.Text = '' then exit; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select A.IOFlag,A.IONo,A.IOID,A.IOPosition,B.* from Trade_Cloth_IO A '); sql.Add('inner join Trade_Cloth_Stock B on A.StkId=B.StkId and A.IOCycles=B.StkCycles '); sql.Add('where A.IOFlag=''入库'' and B.StkExists=1 '); if IOPosition.Text <> '' then sql.add('and IOPosition =' + QuotedStr(TRIm(IOPosition.Text))) else sql.add('and 1=2'); Open; end; SCreateCDS(ADOQueryTemp, CDS_3); SInitCDSData(ADOQueryTemp, CDS_3); end; procedure TfrmStockScanInEdit.ScanKW(); var MStkIds: string; begin try with ADOQueryTemp do begin close; SQL.Clear; sql.Add('select * from Bs_Position where POSID =''' + trim(FScan) + ''' '); open; end; IOPosition.Text := ADOQueryTemp.FieldByName('posno').AsString; btnGetOutNo.Click; except end; end; procedure TfrmStockScanInEdit.ScanCIID(); var MStkIds: string; begin try if Trim(IOPosition.Text) = '' then raise Exception.Create('库位不能为空!'); if Trim(InNo.Text) = '' then raise Exception.Create('入库单号不能为空!'); MStkIds := FScan; try ADOQueryCmd.Connection.BeginTrans; with ADOQueryCmd do begin Close; Sql.Clear; Sql.Add('exec P_Market_Position_In '); Sql.Add('@StkIds=' + quotedstr(trim(MStkIds))); Sql.Add(',@IOTime=' + Quotedstr(FormatDateTime('yyyy-MM-dd', CRTime.DateTime))); Sql.Add(',@IOType=' + Quotedstr(crtype.Text)); Sql.Add(',@IONO=' + Quotedstr(InNo.Text)); Sql.Add(',@StkPosition=' + Quotedstr(IOPosition.Text)); Sql.Add(',@FillId=' + Quotedstr(DCode)); Sql.Add(',@Filler=' + Quotedstr(DName)); // ShowMessage(sql.Text); Open; end; if ADOQueryCmd.FieldByName('intReturn').AsInteger = -1 then begin raise Exception.Create(pchar(trim(ADOQueryCmd.FieldByName('ShowMsg').AsString))); end; ADOQueryCmd.Connection.CommitTrans; PlayWav('正确'); except ADOQueryCmd.Connection.RollbackTrans; raise Exception.Create(PChar(Exception(ExceptObject).Message)); end; except application.MessageBox(PChar(Exception(ExceptObject).Message), '提示信息', 0); // PlayWav('发货错误'); end; end; procedure TfrmStockScanInEdit.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := caFree; end; procedure TfrmStockScanInEdit.FormDestroy(Sender: TObject); begin inherited; frmStockScanInEdit := nil; end; procedure TfrmStockScanInEdit.FormShow(Sender: TObject); begin inherited; ReadCxGrid(self.caption + 'Tv3', Tv3, '成品仓库'); InitKC(); CRTime.DateTime := SGetServerDate(ADOQueryTemp); end; procedure TfrmStockScanInEdit.edtScanKeyPress(Sender: TObject; var Key: Char); var maxno, SMFlag, KYCKFlag, FMainId, ff: string; FFQty: Integer; begin if Key = #13 then begin FScan := TRIM(edtScan.Text); edtScan.Text := ''; if Copy(FScan, 1, 2) = 'KW' then begin ScanKW(); end else begin ScanCIID(); end; InitKC(); end; end; procedure TfrmStockScanInEdit.ToolButton3Click(Sender: TObject); begin if Trim(InNo.Text) = '' then Exit; try frmLabelPrint := TfrmLabelPrint.Create(Application); with frmLabelPrint do begin FLMType := 'TradeClothIn1'; FFiltration1 := Trim(Self.InNo.Text); if ShowModal = 1 then begin end; end; finally frmLabelPrint.Free; end; end; procedure TfrmStockScanInEdit.ToolButton5Click(Sender: TObject); begin inherited; try frmPositionSel := TfrmPositionSel.Create(Application); with frmPositionSel do begin if ShowModal = 1 then begin IOPosition.Text := CDS_1.FieldByName('POSNO').AsString; end; end; finally frmPositionSel.Free; btnGetOutNo.Click; initkc(); end; end; procedure TfrmStockScanInEdit.btnGetOutNoClick(Sender: TObject); var maxNo: string; begin if GetLSNo(ADOQueryCmd, maxNo, 'RK', 'Trade_Cloth_IO', 3, 1) = False then begin Application.MessageBox('取入库单号失败!', '提示', 0); Exit; end; InNo.Text := Trim(maxNo); CRTime.DateTime := SGetServerDate(ADOQueryTemp); InitKC(); end; procedure TfrmStockScanInEdit.ToolButton7Click(Sender: TObject); begin tv3.Controller.EditingController.ShowEdit(); Close; end; procedure TfrmStockScanInEdit.ToolButton8Click(Sender: TObject); begin WriteCxGrid(self.caption + 'Tv3', Tv3, '成品仓库'); end; end.