unit U_ClothInfoSel; 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, cxTL, cxMaskEdit, cxTLdxBarBuiltInMenu, cxCheckBox, cxInplaceContainer, cxDBTL, cxTLData, math, 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, cxImageList, cxContainer; type TfrmClothInfoSel = class(TfrmBaseHelp) ToolBar1: TToolBar; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; DS_1: TDataSource; CDS_1: TClientDataSet; TBSave: TToolButton; TBClose: TToolButton; ToolButton1: TToolButton; ADOConnection1: TADOConnection; GPM_1: TcxGridPopupMenu; ImageList1: TImageList; cxDBTreeList1: TcxDBTreeList; cxDBTreeList1cxDBTreeListColumn2: TcxDBTreeListColumn; DS_Tree: TDataSource; CDS_Tree: TClientDataSet; ADOQueryTree: TADOQuery; Panel3: TPanel; Panel7: TPanel; Panel4: TPanel; Label14: TLabel; LBCPAP1: TLabel; Button1: TButton; Button2: TButton; TCBNOR1: TComboBox; Panel1: TPanel; Label3: TLabel; Label4: TLabel; Label9: TLabel; Label8: TLabel; C_Code: TcxTextEdit; C_Name: TcxTextEdit; C_GramWeight: TcxTextEdit; C_Composition: TcxTextEdit; ThreeColorBase: TcxStyleRepository; SHuangSe: TcxStyle; SkyBlue: TcxStyle; Default: TcxStyle; QHuangSe: TcxStyle; Red: TcxStyle; FontBlue: TcxStyle; TextSHuangSe: TcxStyle; FonePurple: TcxStyle; FoneClMaroon: TcxStyle; FoneRed: TcxStyle; RowColor: TcxStyle; handBlack: TcxStyle; cxBlue: TcxStyle; SHuangSeCu: TcxStyle; cxImageList_bar: TcxImageList; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1SSel: TcxGridDBColumn; v1Column12: TcxGridDBColumn; v1CYNo: TcxGridDBColumn; v1Column9: TcxGridDBColumn; v1Column3: TcxGridDBColumn; v1Column1: TcxGridDBColumn; Tv1Column8: TcxGridDBColumn; Tv1Column2: TcxGridDBColumn; Tv1Column4: TcxGridDBColumn; Tv1Column1: TcxGridDBColumn; Tv1Column10: TcxGridDBColumn; v1Column11: TcxGridDBColumn; Tv1Column5: TcxGridDBColumn; Tv1Column9: TcxGridDBColumn; Tv1Column6: TcxGridDBColumn; Tv1Column7: TcxGridDBColumn; Tv1Column11: TcxGridDBColumn; Tv1Column13: TcxGridDBColumn; Tv1Column23: TcxGridDBColumn; Tv1Column3: TcxGridDBColumn; Tv1Column12: TcxGridDBColumn; Tv1Column14: TcxGridDBColumn; Tv1Column15: TcxGridDBColumn; Tv1Column16: TcxGridDBColumn; Tv1Column17: TcxGridDBColumn; Tv1Column18: TcxGridDBColumn; Tv1Column22: TcxGridDBColumn; Tv1Column19: TcxGridDBColumn; Tv1Column20: TcxGridDBColumn; Tv1Column21: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; Label1: TLabel; Label2: TLabel; Label5: TLabel; Label6: TLabel; GC_Name: TcxTextEdit; CraftCode: TcxTextEdit; C_Spec: TcxTextEdit; C_EComposition: TcxTextEdit; Label7: TLabel; Label10: TLabel; CraftEName: TcxTextEdit; CraftName: TcxTextEdit; GroupBox1: TGroupBox; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; cxGridDBColumn4: TcxGridDBColumn; cxGridDBColumn5: TcxGridDBColumn; cxGridDBColumn6: TcxGridDBColumn; cxGridDBColumn7: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; GPM_2: TcxGridPopupMenu; CDS_Selok: TClientDataSet; DS_2: TDataSource; cxtxtdtscan: TcxTextEdit; Label11: TLabel; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure TBSaveClick(Sender: TObject); procedure TV1DblClick(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure TCBNOR1Change(Sender: TObject); procedure C_NameChange(Sender: TObject); procedure TBCloseClick(Sender: TObject); procedure cxDBTreeList1DblClick(Sender: TObject); procedure cxtxtdtscanKeyPress(Sender: TObject; var Key: Char); procedure GC_NameKeyPress(Sender: TObject; var Key: Char); private IsOnShow: Boolean; CurrentPage, RecordsNumber: Integer; procedure InitGrid(PType: string); procedure InitTree(); { Private declarations } public IsMultipleSelection: Boolean; FCTType: string; { Public declarations } end; var frmClothInfoSel: TfrmClothInfoSel; implementation uses U_DataLink, U_RTFun; {$R *.dfm} procedure TfrmClothInfoSel.InitTree(); var i: Integer; begin with ADOQueryTree do begin Close; SQL.Clear; SQL.Add('select * from BS_Cloth_Type '); if Trim(FCTType) = '全部' then begin end else if FCTType = '坯布' then begin SQL.Add(' where CTType in (''梭织'',''针织'') '); end else begin SQL.Add(' where CTType=' + quotedstr(FCTType)); end; Open; end; SCreateCDS(ADOQueryTree, CDS_Tree); SInitCDSData(ADOQueryTree, CDS_Tree); cxDBTreeList1.Items[0].Expand(false); end; procedure TfrmClothInfoSel.FormCreate(Sender: TObject); begin inherited; try with ADOConnection1 do begin Connected := false; ConnectionString := DConString; Connected := true; end; ADOQueryBaseCmd.Connection := ADOConnection1; ADOQueryBaseTemp.Connection := ADOConnection1; except {if Application.MessageBox('网络连接失败,是否要再次连接?','提示',32+4)=IDYES then begin try with ADOConnection1 do begin Connected:=false; ConnectionString:=DConString; //ConnectionString:='23242'; Connected:=true; end; except end; end; } //frmZDYHelp.Free; end; end; procedure TfrmClothInfoSel.Button1Click(Sender: TObject); begin if CurrentPage > 1 then CurrentPage := CurrentPage - 1; InitGrid(''); end; procedure TfrmClothInfoSel.Button2Click(Sender: TObject); begin if CurrentPage < CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber then CurrentPage := CurrentPage + 1; InitGrid(''); end; procedure TfrmClothInfoSel.cxDBTreeList1DblClick(Sender: TObject); begin InitGrid(''); end; procedure TfrmClothInfoSel.cxtxtdtscanKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin SClearData(Panel1, 2); C_Code.Text := cxtxtdtscan.Text; InitGrid('回车'); if CDS_1.RecordCount = 1 then begin MoveCDS(CDS_1, CDS_Selok); end; cxtxtdtscan.Text := ''; C_Code.Text := ''; end; end; procedure TfrmClothInfoSel.C_NameChange(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 TfrmClothInfoSel.FormClose(Sender: TObject; var Action: TCloseAction); begin C_Code.SetFocus; Action := cahide; end; procedure TfrmClothInfoSel.InitGrid(PType: string); var fwhere, MBCIID, Pwhere: string; begin if not CDS_1.IsEmpty then MBCIID := Trim(CDS_1.FieldByName('BCIID').AsString) else MBCIID := ''; Pwhere := SGetFilters(Panel1, 1, 2); if trim(Pwhere) <> '' then begin if fwhere <> '' then fwhere := fwhere + ' and ' + trim(Pwhere) else fwhere := ' where ' + trim(Pwhere); end; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; Filtered := False; sql.Clear; sql.Add(' exec P_BS_CloInfo_Get '); if PType = '回车' then sql.Add(' @CTID= ''''') else sql.Add(' @CTID=' + quotedstr(Trim(CDS_Tree.fieldbyname('CTID').AsString))); sql.Add(',@pageIndex=' + inttostr(CurrentPage)); sql.Add(',@pageSize=' + inttostr(RecordsNumber)); sql.Add(',@criteria= ' + quotedstr(fwhere)); // ShowMessage(sql.Text); Open; end; SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2)); SCreateCDS(ADOQueryMain, CDS_1); SInitCDSData(ADOQueryMain, CDS_1); if IsOnShow then SCreateCDS(ADOQueryMain, CDS_Selok); IsOnShow := False; TV1.DataController.Filter.Clear; LBCPAP1.Caption := inttostr(CurrentPage) + '/' + inttostr(ceil(CDS_1.FieldByName('TotalCount').AsInteger / RecordsNumber)); finally ADOQueryMain.EnableControls; TV1.DataController.Filter.Clear; end; if MBCIID <> '' then CDS_1.Locate('BCIID', MBCIID, []); end; procedure TfrmClothInfoSel.FormShow(Sender: TObject); begin inherited; IsOnShow := true; if IsMultipleSelection then GroupBox1.Visible := True; RecordsNumber := 500; CurrentPage := 1; if Trim(FCTType) = '' then FCTType := '通用'; ReadCxGrid(trim(self.Caption) + 'TV1', TV1, '自定义数据'); ReadCxGrid(trim(self.Caption) + 'TV2', TV2, '自定义数据'); InitTree(); InitGrid(''); end; procedure TfrmClothInfoSel.GC_NameKeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin InitGrid('回车'); end; end; procedure TfrmClothInfoSel.TBCloseClick(Sender: TObject); begin Close; end; procedure TfrmClothInfoSel.TBSaveClick(Sender: TObject); begin WriteCxGrid(trim(self.Caption) + 'TV1', TV1, '自定义数据'); WriteCxGrid(trim(self.Caption) + 'TV2', TV2, '自定义数据'); end; procedure TfrmClothInfoSel.TCBNOR1Change(Sender: TObject); begin RecordsNumber := StrToInt(TCBNOR1.Text); CurrentPage := 1; C_Code.SetFocus; InitGrid(''); end; procedure TfrmClothInfoSel.ToolButton1Click(Sender: TObject); begin ModalResult := 1; end; procedure TfrmClothInfoSel.TV1DblClick(Sender: TObject); begin if IsMultipleSelection then begin if not CDS_Selok.Locate('C_Code', CDS_1.FieldByName('C_Code').AsString, []) then MoveCDS(CDS_1, CDS_Selok) end else ModalResult := 1; end; procedure TfrmClothInfoSel.FormDestroy(Sender: TObject); begin inherited; frmClothInfoSel := nil; end; end.