unit U_YEYarnWaitReleased; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, StdCtrls, ADODB, DBClient, ComCtrls, ExtCtrls, cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses, cxControls, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, cxCheckBox, Menus, cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinsDefaultPainters, dxDateRanges, dxBarBuiltInMenu, Vcl.ToolWin; type TfrmYEYarnWaitReleased = class(TForm) Panel1: TPanel; Label2: TLabel; OrderNo: TEdit; Label3: TLabel; C_Color: TEdit; CDS_OrderSel: TClientDataSet; DataSource1: TDataSource; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; cxGridPopupMenu1: TcxGridPopupMenu; Label8: TLabel; CustName: TEdit; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; ToolBar3: TToolBar; ToolButton5: TToolButton; ToolButton8: TToolButton; ToolButton7: TToolButton; ToolButton1: TToolButton; Label1: TLabel; C_Name: TEdit; cxGrid1: TcxGrid; Tv2: TcxGridDBTableView; v2Column3: TcxGridDBColumn; Tv2Column2: TcxGridDBColumn; cxGridDBColumn2: TcxGridDBColumn; Tv2Column3: TcxGridDBColumn; Tv2Column4: TcxGridDBColumn; cxGridDBColumn3: TcxGridDBColumn; Tv2Column1: TcxGridDBColumn; v1Column10: TcxGridDBColumn; v1Column14: TcxGridDBColumn; Tv2Column5: TcxGridDBColumn; Tv2Column6: TcxGridDBColumn; Tv2Column7: TcxGridDBColumn; Tv2Column8: TcxGridDBColumn; Tv2Column9: TcxGridDBColumn; v1PRTMF: TcxGridDBColumn; v1PRTKZ: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton8Click(Sender: TObject); private { Private declarations } procedure InitGrid(); public { Public declarations } end; var frmYEYarnWaitReleased: TfrmYEYarnWaitReleased; implementation uses U_DataLink, U_RTFun; {$R *.dfm} procedure TfrmYEYarnWaitReleased.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end; procedure TfrmYEYarnWaitReleased.FormDestroy(Sender: TObject); begin frmYEYarnWaitReleased := nil; end; procedure TfrmYEYarnWaitReleased.FormShow(Sender: TObject); begin ReadCxGrid(trim(Self.Caption), Tv2, '成品仓库'); InitGrid(); end; procedure TfrmYEYarnWaitReleased.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Filtered := False; Close; sql.Clear; sql.Add('select A.* '); sql.Add(' from YE_Plan_Main A '); sql.Add(' where exists(select KC.MainID from YE_Yarn_Stock KC where KC.MainID=A.MainID and KC.StkExists=1)'); // ShowMessage(SQL.Text); Open; end; SCreateCDS(ADOQueryMain, CDS_OrderSel); SInitCDSData(ADOQueryMain, CDS_OrderSel); finally ADOQueryMain.EnableControls; end; end; procedure TfrmYEYarnWaitReleased.OrderNoChange(Sender: TObject); begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_OrderSel); SInitCDSData(ADOQueryMain, CDS_OrderSel); end; procedure TfrmYEYarnWaitReleased.ToolButton1Click(Sender: TObject); var KHName: string; begin if CDS_OrderSel.Locate('SSel', True, []) = False then begin Application.MessageBox('没有选择数据!', '提示', 0); Exit; end; CDS_OrderSel.DisableControls; KHName := ''; with CDS_OrderSel do begin First; while not Eof do begin if FieldByName('SSel').AsBoolean = True then begin // if Trim(KHName) = '' then // begin // KHName := Trim(fieldbyname('CustNo').AsString); // end // else // begin // if Trim(fieldbyname('CustNo').AsString) <> KHName then // begin // CDS_OrderSel.EnableControls; // Application.MessageBox('不能选择不同客户!', '提示', 0); // Exit; // end; // end; end; Next; end; end; CDS_OrderSel.EnableControls; ModalResult := 1; end; procedure TfrmYEYarnWaitReleased.ToolButton5Click(Sender: TObject); begin InitGrid(); end; procedure TfrmYEYarnWaitReleased.ToolButton7Click(Sender: TObject); begin Close; end; procedure TfrmYEYarnWaitReleased.ToolButton8Click(Sender: TObject); begin WriteCxGrid(trim(Self.Caption), Tv2, '成品仓库'); end; procedure TfrmYEYarnWaitReleased.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin ModalResult := 1; end; procedure TfrmYEYarnWaitReleased.N1Click(Sender: TObject); begin SelOKNo(CDS_OrderSel, True); end; procedure TfrmYEYarnWaitReleased.N2Click(Sender: TObject); begin SelOKNo(CDS_OrderSel, False); end; end.