unit U_KnitPlanSel; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu, System.ImageList, U_BaseInput, cxCheckBox, cxCalendar, Vcl.Menus, 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, cxContainer; type TfrmKnitPlanSel = class(TfrmBaseHelp) ToolBar1: TToolBar; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; DS_1: TDataSource; CDS_1: TClientDataSet; TBSave: TToolButton; TBClose: TToolButton; ToolButton1: TToolButton; ADOConnection1: TADOConnection; Panel1: TPanel; GPM_1: TcxGridPopupMenu; ImageList1: TImageList; cxStyleRepository1: TcxStyleRepository; cxStyle1: TcxStyle; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1Column7: TcxGridDBColumn; v1OrderNo: TcxGridDBColumn; v1ConNo: TcxGridDBColumn; Tv1Column11: TcxGridDBColumn; v1OrdDefStr1: TcxGridDBColumn; v1MPRTCodeName: TcxGridDBColumn; v1MPRTSpec: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; v1MPRTMF: TcxGridDBColumn; v1MPRTKZ: TcxGridDBColumn; v1PRTColor: TcxGridDBColumn; v1Column1: TcxGridDBColumn; v1Column6: TcxGridDBColumn; v1PRTOrderQty: TcxGridDBColumn; v1Column4: TcxGridDBColumn; v1Column5: TcxGridDBColumn; v1DeliveryDate: TcxGridDBColumn; v1Column3: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; Tv1Column4: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; Tv1Column2: TcxGridDBColumn; Label3: TLabel; Label2: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; OrderNo: TcxTextEdit; C_Name: TcxTextEdit; C_Color: TcxTextEdit; C_ColorNo: TcxTextEdit; C_Pattern: TcxTextEdit; C_Code: TcxTextEdit; ConNo: TcxTextEdit; Label1: TLabel; CustName: TcxTextEdit; Tv1Column6: TcxGridDBColumn; Tv1Column7: TcxGridDBColumn; Tv1Column8: TcxGridDBColumn; Tv1Column9: TcxGridDBColumn; Tv1Column10: TcxGridDBColumn; PopupMenu1: TPopupMenu; N1: TMenuItem; N2: TMenuItem; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure OrderNoChange(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Tv1DblClick(Sender: TObject); procedure N1Click(Sender: TObject); procedure N2Click(Sender: TObject); private procedure InitGrid(); { Private declarations } public FCoType, FAuthority: string; { Public declarations } end; var frmKnitPlanSel: TfrmKnitPlanSel; implementation uses U_DataLink, U_RTFun; {$R *.dfm} procedure TfrmKnitPlanSel.FormCreate(Sender: TObject); begin inherited; try with ADOConnection1 do begin Connected := false; ConnectionString := DConString; Connected := true; end; ADOQueryBaseCmd.Connection := ADOConnection1; ADOQueryBaseTemp.Connection := ADOConnection1; except application.MessageBox('网络连接失败!', '提示信息'); end; end; procedure TfrmKnitPlanSel.FormDestroy(Sender: TObject); begin inherited; frmKnitPlanSel := nil; end; procedure TfrmKnitPlanSel.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := cahide; end; procedure TfrmKnitPlanSel.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; sql.Clear; sql.Add('select A.* ,B.SumStkGrossWeight,B.SumPiece,B.BatchNo,B.Loom from V_Knit_Plan A '); sql.add('LEFT JOIN (select MainId,SumStkGrossWeight=sum(X.StkGrossWeight),SumPiece=COUNT(X.STKID),X.BatchNo,X.Loom '); sql.add('from Knit_Cloth_Stock X where X.StkExists=1 GROUP BY X.MainId,X.BatchNo,X.Loom) B on A.MainId=B.MainId'); // ShowMessage(sql.Text); Open; end; SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); finally ADOQueryMain.EnableControls; end; end; procedure TfrmKnitPlanSel.N1Click(Sender: TObject); begin SelOKNo(CDS_1, true); end; procedure TfrmKnitPlanSel.N2Click(Sender: TObject); begin SelOKNo(CDS_1, False); end; procedure TfrmKnitPlanSel.OrderNoChange(Sender: TObject); begin if ADOQueryMain.Active then begin SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); end; end; procedure TfrmKnitPlanSel.FormShow(Sender: TObject); begin inherited; ReadCxGrid('单位名称' + Trim(FCoType), TV1, '自定义数据'); InitGrid(); end; procedure TfrmKnitPlanSel.TBCloseClick(Sender: TObject); begin inherited; Close; end; procedure TfrmKnitPlanSel.TBSaveClick(Sender: TObject); begin WriteCxGrid('单位名称' + Trim(FCoType), TV1, '自定义数据'); end; procedure TfrmKnitPlanSel.ToolButton1Click(Sender: TObject); begin ModalResult := 1; end; procedure TfrmKnitPlanSel.Tv1DblClick(Sender: TObject); begin ModalResult := 1; end; end.