unit U_YSSKListRMBMJDZEY; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB, cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls, cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP, ShellAPI, IniFiles, cxCheckBox, cxCalendar, cxButtonEdit, cxTextEdit, cxPC, cxGridBandedTableView, cxGridDBBandedTableView, BtnEdit, cxLookAndFeels, cxLookAndFeelPainters, dxBarBuiltInMenu, cxNavigator, RM_e_Xls; type TfrmYSSKListRMBMJDZEY = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBClose: TToolButton; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; Panel1: TPanel; ToolButton2: TToolButton; ToolButton1: TToolButton; RM1: TRMGridReport; RMDB_Main: TRMDBDataSet; cxGridPopupMenu2: TcxGridPopupMenu; DS_HZ: TDataSource; ADOQueryMain: TADOQuery; CDS_HZ: TClientDataSet; ToolButton3: TToolButton; cxTabControl1: TcxTabControl; cxGrid2: TcxGrid; Tv2: TcxGridDBTableView; v2Column6: TcxGridDBColumn; v2SQMoney: TcxGridDBColumn; v2YFMoney: TcxGridDBColumn; v2FKMoney: TcxGridDBColumn; v2BQMoney: TcxGridDBColumn; v2Column4: TcxGridDBColumn; v2Column7: TcxGridDBColumn; v2Column8: TcxGridDBColumn; v2ZJFKDate: TcxGridDBColumn; v2ZJFKMoney: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; cxTabControl2: TcxTabControl; Panel2: TPanel; Label2: TLabel; begdate: TDateTimePicker; Panel3: TPanel; Label4: TLabel; FBegDate: TDateTimePicker; Label5: TLabel; FEndDate: TDateTimePicker; Panel4: TPanel; Label3: TLabel; Label1: TLabel; HuiLv: TEdit; RadioGroup1: TRadioGroup; v2Column1: TcxGridDBColumn; FactoryNameGYS: TEdit; v2Column2: TcxGridDBColumn; v2Column3: TcxGridDBColumn; v2Column5: TcxGridDBColumn; v2Column9: TcxGridDBColumn; v2Column10: TcxGridDBColumn; Label6: TLabel; YWY: TEdit; Label7: TLabel; LiDan: TEdit; RMXLSExport1: TRMXLSExport; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure FactoryNameChange(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure ToolButton3Click(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure RadioGroup1Click(Sender: TObject); procedure FactoryNameGYSBtnClick(Sender: TObject); procedure FactoryNameGYSChange(Sender: TObject); private { Private declarations } FFEndDate, FFBegDate: TDateTime; procedure InitGrid(); public fDParameters1: string; { Public declarations } RKFlag, FCYID: string; end; //var //frmYSSKListRMBMJDZEY: TfrmYSSKListRMBMJDZEY; implementation uses U_DataLink, U_RTFun, U_Fun, U_ZDYHelp, U_YSMXlistMonDayDZ, U_KHListSelJJ, U_KHSKListView, U_YSMXlistMonDayDZEY; {$R *.dfm} procedure TfrmYSSKListRMBMJDZEY.InitGrid(); var FYue, FDate: string; FInt: Integer; FHuiLv: Double; begin if cxTabControl2.TabIndex = 2 then begin if Trim(HuiLv.Text) = '' then begin Application.MessageBox('汇率不能为空!', '提示', 0); Exit; end; if TryStrToFloat(HuiLv.Text, FHuiLv) = False then begin Application.MessageBox('汇率非法数字!', '提示', 0); Exit; end; end; if RadioGroup1.ItemIndex = 0 then begin if cxTabControl1.TabIndex < 11 then begin FInt := cxTabControl1.TabIndex + 2; end else begin FInt := 1; end; FYue := Trim(IntToStr(FInt)); if FInt < 10 then begin FYue := '0' + Trim(IntToStr(FInt)); end; if FInt <> 1 then begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + FYue; end else begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)); FDate := IntToStr(strtoint(FDate) + 1); FDate := FDate + '-' + FYue; end; FBegDate.Date := StrToDate(FDate + '-01'); if FInt = 12 then FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-12-31') else begin if FInt = 1 then begin FEndDate.Date := StrToDate(FDate + '-31'); end else begin FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1; end; end; end; //FEndDate.Date:=StrToDate(Trim(FormatDateTime('yyyy',begdate.Date))+'-'+Trim(IntToStr(FInt+1))+'-01')-1; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; SQL.Clear; Filtered := False; if RadioGroup1.ItemIndex = 0 then begin if cxTabControl2.TabIndex <> 2 then begin sql.Add(' exec P_YSSK_Month_BZ :Fdate,:BZType,:HuiLv'); end else begin sql.Add(' exec P_YSSK_Month_RMB :Fdate,:HuiLv '); end; if cxTabControl2.TabIndex = 0 then begin Parameters.ParamByName('BZType').Value := '¥'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 1 then begin Parameters.ParamByName('BZType').Value := '$'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 2 then begin Parameters.ParamByName('HuiLv').Value := HuiLv.Text; end; Parameters.ParamByName('Fdate').Value := FDate; end else begin if cxTabControl2.TabIndex <> 2 then begin sql.Add(' exec P_YSSK_Day_BZ :FBegdate,:FEndDate,:BZType,:HuiLv,:KHFlag'); end else begin sql.Add(' exec P_YSSK_Day_RMB :FBegdate,:FEndDate,:HuiLv,:KHFlag '); end; if cxTabControl2.TabIndex = 0 then begin Parameters.ParamByName('BZType').Value := '¥'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 1 then begin Parameters.ParamByName('BZType').Value := '$'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 2 then begin Parameters.ParamByName('HuiLv').Value := HuiLv.Text; end; if RadioGroup1.ItemIndex = 1 then begin Parameters.ParamByName('KHFlag').Value := ''; end else if RadioGroup1.ItemIndex = 2 then begin Parameters.ParamByName('KHFlag').Value := '1'; end; Parameters.ParamByName('FBegdate').Value := Trim(FormatDateTime('yyyy-MM-dd', FBegDate.Date)); Parameters.ParamByName('FEndDate').Value := Trim(FormatDateTime('yyyy-MM-dd', FEndDate.Date + 1)); end; Open; end; SCreateCDS20(ADOQueryMain, CDS_HZ); SInitCDSData20(ADOQueryMain, CDS_HZ); finally ADOQueryMain.EnableControls; end; //ToolButton2.Click; end; procedure TfrmYSSKListRMBMJDZEY.FormDestroy(Sender: TObject); begin //frmYSSKListRMBMJDZEY:=nil; end; procedure TfrmYSSKListRMBMJDZEY.FormClose(Sender: TObject; var Action: TCloseAction); begin Action := caFree; end; procedure TfrmYSSKListRMBMJDZEY.TBCloseClick(Sender: TObject); begin WriteCxGrid('应收款统计报表YX1', Tv2, '财务管理'); Close; end; procedure TfrmYSSKListRMBMJDZEY.FormShow(Sender: TObject); var fstr: string; begin ReadCxGrid('应收款统计报表YX1', Tv2, '财务管理'); Fbegdate.DateTime := SGetServerDate(ADOQueryTemp); FEndDate.Date := Fbegdate.DateTime; fstr := Trim(FormatDateTime('MM', Fbegdate.Date)); if StrToInt(fstr) = 1 then begin begdate.DateTime := SGetServerDateMBeg(ADOQueryTemp) - 40; cxTabControl1.TabIndex := 11; //StrToInt(fstr)-1; end else begin begdate.DateTime := SGetServerDateMBeg(ADOQueryTemp); cxTabControl1.TabIndex := StrToInt(fstr) - 2; end; cxTabControl1.Tabs[11].Caption := ' 1月(' + inttostr(strtoint(FormatDateTime('yyyy', begdate.Date)) + 1) + '年)'; //cxTabControl1.TabIndex:=StrToInt(fstr)-1; Panel3.Visible := False; // InitGrid(); end; procedure TfrmYSSKListRMBMJDZEY.TBRafreshClick(Sender: TObject); begin cxTabControl1.Tabs[11].Caption := ' 1月(' + inttostr(strtoint(FormatDateTime('yyyy', begdate.Date)) + 1) + '年)'; InitGrid(); ToolButton2.Click; {CDS_HZ.IndexFieldNames:='FactoryName'; with CDS_HZ do begin with IndexDefs do begin Clear; with AddIndexDef do begin Name := 'Fld1Indx'; Fields := 'FactoryName'; Options := [ixDescending]; //降序 end; end; end; } end; procedure TfrmYSSKListRMBMJDZEY.ToolButton2Click(Sender: TObject); begin if ADOQueryMain.Active = False then Exit; SDofilter(ADOQueryMain, SGetFilters(Panel4, 1, 2)); SCreateCDS20(ADOQueryMain, CDS_HZ); SInitCDSData20(ADOQueryMain, CDS_HZ); end; procedure TfrmYSSKListRMBMJDZEY.FactoryNameChange(Sender: TObject); begin ToolButton2.Click; end; procedure TfrmYSSKListRMBMJDZEY.ToolButton1Click(Sender: TObject); begin if ADOQueryMain.IsEmpty then Exit; //SelExportData(Tv2,ADOQueryMain,'应收款收款统计列表'); TcxGridToExcel('应收款收款统计列表', cxGrid2); end; procedure TfrmYSSKListRMBMJDZEY.Tv2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); var FName, FDate, FYue: string; FInt: Integer; begin if cxTabControl2.TabIndex > 1 then Exit; if CDS_HZ.IsEmpty then Exit; FName := Tv2.Controller.FocusedColumn.DataBinding.FilterFieldName; if Trim(FName) = 'FKMoney999999' then begin if RadioGroup1.ItemIndex = 0 then begin if cxTabControl1.TabIndex < 11 then begin FInt := cxTabControl1.TabIndex + 2; end else begin FInt := 1; end; FYue := Trim(IntToStr(FInt)); if FInt < 10 then begin FYue := '0' + Trim(IntToStr(FInt)); end; if FInt <> 1 then begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + FYue; end else begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)); FDate := IntToStr(strtoint(FDate) + 1); FDate := FDate + '-' + FYue; end; FFBegDate := StrToDate(FDate + '-01'); if FInt = 12 then FFEndDate := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-12-31') else begin if FInt = 1 then begin FFEndDate := StrToDate(FDate + '-31'); end else begin FFEndDate := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1; end; end; end else begin FFBegDate := FBegDate.Date; FFEndDate := FEndDate.Date; end; try frmKHSKListView := TfrmKHSKListView.Create(Application); with frmKHSKListView do begin FKHNO := Trim(Self.CDS_HZ.fieldbyname('FactoryNo').AsString); frmKHSKListView.begdate.Date := Self.FFBegDate; frmKHSKListView.Enddate.Date := Self.FFEndDate; FactoryNameHZ.Text := Trim(Self.CDS_HZ.fieldbyname('FactoryName').AsString); if ShowModal = 1 then begin end; end; finally frmKHSKListView.Free; end; Exit; end; try frmYSMXlistMonDayDZEY := TfrmYSMXlistMonDayDZEY.Create(Application); with frmYSMXlistMonDayDZEY do begin FMX := '99'; PState := Self.RadioGroup1.ItemIndex; // ShowMessage('1'); if Self.cxTabControl2.TabIndex = 0 then begin frmYSMXlistMonDayDZEY.FBZ := '¥' end else if Self.cxTabControl2.TabIndex = 1 then begin frmYSMXlistMonDayDZEY.FBZ := '$' end; if Self.RadioGroup1.ItemIndex = 0 then begin frmYSMXlistMonDayDZEY.begdate.DateTime := Self.begdate.DateTime; frmYSMXlistMonDayDZEY.cxTabControl1.TabIndex := Self.cxTabControl1.TabIndex; frmYSMXlistMonDayDZEY.factoryName.Text := Self.CDS_HZ.fieldbyname('factoryName').AsString; frmYSMXlistMonDayDZEY.Fbegdate.DateTime := Self.Fbegdate.DateTime; frmYSMXlistMonDayDZEY.FEnddate.DateTime := Self.FEnddate.DateTime; frmYSMXlistMonDayDZEY.cxTabControl1.Tabs[11].Caption := Self.cxTabControl1.Tabs[11].Caption; end else //if Self.RadioGroup1.ItemIndex=1 then begin frmYSMXlistMonDayDZEY.begdate.DateTime := Self.begdate.DateTime; frmYSMXlistMonDayDZEY.Fbegdate.DateTime := Self.Fbegdate.DateTime; frmYSMXlistMonDayDZEY.FEnddate.DateTime := Self.FEnddate.DateTime; frmYSMXlistMonDayDZEY.factoryName.Text := Self.CDS_HZ.fieldbyname('factoryName').AsString; end; frmYSMXlistMonDayDZEY.factoryName.TxtCode := Self.CDS_HZ.fieldbyname('factoryNo').AsString; frmYSMXlistMonDayDZEY.Align := alClient; frmYSMXlistMonDayDZEY.LabGYS.Caption := Self.CDS_HZ.fieldbyname('factoryName').AsString; if Self.Caption = '客户对账单查询*' then begin frmYSMXlistMonDayDZEY.cxGrid2.PopupMenu := frmYSMXlistMonDayDZEY.PopupMenu2; end else begin frmYSMXlistMonDayDZEY.cxGrid2.PopupMenu := frmYSMXlistMonDayDZEY.PopupMenu1; end; // ShowMessage('2'); if ShowModal = 1 then begin end; end; finally frmYSMXlistMonDayDZEY.Free; end; end; procedure TfrmYSSKListRMBMJDZEY.ToolButton3Click(Sender: TObject); var filepath, fsj: string; mBegdate, mEnddate: string; FName, FNameSX, FNameJX: string; i: Integer; FYue, FDate: string; FInt: Integer; FHuiLv: Double; begin {for i:=0 to Tv2.ColumnCount-1 do begin FName:=Tv2.Columns[i].DataBinding.FilterFieldName; FNameSX:=Trim(FName)+'-1'; FNameJX:=Trim(FName)+'-2'; CDS_HZ.AddIndex(FNameSX, FName, []); // 正序 CDS_HZ.AddIndex(FNameJX, FName, [ixDescending]); // 倒序 if Tv2.Columns[i].SortOrder=soDescending then begin CDS_HZ.IndexName:=FNameJX; end else if Tv2.Columns[i].SortOrder=soAscending then begin CDS_HZ.IndexName:=FNameSX; end; end; } if RadioGroup1.ItemIndex = 0 then begin if cxTabControl1.TabIndex < 11 then begin FInt := cxTabControl1.TabIndex + 2; end else begin FInt := 1; end; FYue := Trim(IntToStr(FInt)); if FInt < 10 then begin FYue := '0' + Trim(IntToStr(FInt)); end; if FInt <> 1 then begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + FYue; end else begin FDate := Trim(FormatDateTime('yyyy', begdate.Date)); FDate := IntToStr(strtoint(FDate) + 1); FDate := FDate + '-' + FYue; end; FBegDate.Date := StrToDate(FDate + '-01'); if FInt = 12 then FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-12-31') else begin if FInt = 1 then begin FEndDate.Date := StrToDate(FDate + '-31'); end else begin FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1; end; end; end; // FEndDate.Date := StrToDate(Trim(FormatDateTime('yyyy', begdate.Date)) + '-' + Trim(IntToStr(FInt + 1)) + '-01') - 1; try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; SQL.Clear; Filtered := False; if RadioGroup1.ItemIndex = 0 then begin if cxTabControl2.TabIndex <> 2 then begin sql.Add(' exec P_YSSK_Month_BZ1 :Fdate,:BZType,:HuiLv'); end else begin sql.Add(' exec P_YSSK_Month_RMB :Fdate,:HuiLv '); end; if cxTabControl2.TabIndex = 0 then begin Parameters.ParamByName('BZType').Value := '¥'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 1 then begin Parameters.ParamByName('BZType').Value := '$'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 2 then begin Parameters.ParamByName('HuiLv').Value := HuiLv.Text; end; Parameters.ParamByName('Fdate').Value := FDate; end else begin if cxTabControl2.TabIndex <> 2 then begin sql.Add(' exec P_YSSK_Day_BZ :FBegdate,:FEndDate,:BZType,:HuiLv,:KHFlag'); end else begin sql.Add(' exec P_YSSK_Day_RMB :FBegdate,:FEndDate,:HuiLv,:KHFlag '); end; if cxTabControl2.TabIndex = 0 then begin Parameters.ParamByName('BZType').Value := '¥'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 1 then begin Parameters.ParamByName('BZType').Value := '$'; Parameters.ParamByName('HuiLv').Value := 1; end else if cxTabControl2.TabIndex = 2 then begin Parameters.ParamByName('HuiLv').Value := HuiLv.Text; end; if RadioGroup1.ItemIndex = 1 then begin Parameters.ParamByName('KHFlag').Value := ''; end else if RadioGroup1.ItemIndex = 2 then begin Parameters.ParamByName('KHFlag').Value := '1'; end; Parameters.ParamByName('FBegdate').Value := Trim(FormatDateTime('yyyy-MM-dd', FBegDate.Date)); Parameters.ParamByName('FEndDate').Value := Trim(FormatDateTime('yyyy-MM-dd', FEndDate.Date + 1)); end; Open; end; SCreateCDS20(ADOQueryMain, CDS_HZ); SInitCDSData20(ADOQueryMain, CDS_HZ); finally ADOQueryMain.EnableControls; end; ToolButton2.Click; fsj := cxTabControl1.Tabs[cxTabControl1.TabIndex].Caption; mBegdate := FormatDateTime('yyyy', begdate.Date) + '年' + Trim(Copy(fsj, 3, Length(fsj) - 2)) + '份'; if CDS_HZ.IsEmpty then exit; try filepath := ExtractFilePath(Application.ExeName) + 'report\应收款统计报表YX.rmf'; if not FileExists(Pchar(filepath)) then begin application.MessageBox(pchar('文件[' + filepath + ']不存在!'), '提示信息', MB_IConError); exit; end; RmVariables['begDate'] := mBegdate; RM1.LoadFromFile(filepath); RM1.ShowReport; finally InitGrid(); ToolButton2.Click; end; end; procedure TfrmYSSKListRMBMJDZEY.cxTabControl1Change(Sender: TObject); begin {if cxTabControl2.TabIndex=2 then begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; SQL.Clear; Filtered:=False; sql.Add(' exec P_YSSK_Month_BZ :Fdate,:BZType,:HuiLv ') ; Parameters.ParamByName('BZType').Value:='无'; Parameters.ParamByName('HuiLv').Value:=1; Parameters.ParamByName('Fdate').Value:='2000-01'; Open; end; SCreateCDS20(ADOQueryMain,CDS_HZ); SInitCDSData20(ADOQueryMain,CDS_HZ); finally ADOQueryMain.EnableControls; end; end; } InitGrid(); ToolButton2.Click; end; procedure TfrmYSSKListRMBMJDZEY.RadioGroup1Click(Sender: TObject); begin if RadioGroup1.ItemIndex = 0 then begin Panel2.Visible := True; Panel3.Visible := False; cxTabControl1.Visible := True; v2SQMoney.Caption := Copy(v2SQMoney.Summary.GroupFormat, 1, 8); v2YFMoney.Caption := Copy(v2YFMoney.Summary.GroupFormat, 1, 8); v2FKMoney.Caption := Copy(v2FKMoney.Summary.GroupFormat, 1, 8); v2BQMoney.Caption := Copy(v2BQMoney.Summary.GroupFormat, 1, 8); end else if RadioGroup1.ItemIndex = 1 then begin Panel2.Visible := False; Panel3.Visible := True; cxTabControl1.Visible := False; v2SQMoney.Caption := Copy(v2SQMoney.Summary.GroupFormat, 10, 8); v2YFMoney.Caption := Copy(v2YFMoney.Summary.GroupFormat, 10, 8); v2FKMoney.Caption := Copy(v2FKMoney.Summary.GroupFormat, 10, 8); v2BQMoney.Caption := Copy(v2BQMoney.Summary.GroupFormat, 10, 8); end else if RadioGroup1.ItemIndex = 2 then begin Panel2.Visible := False; Panel3.Visible := True; cxTabControl1.Visible := False; v2SQMoney.Caption := Copy(v2SQMoney.Summary.GroupFormat, 10, 8); v2YFMoney.Caption := Copy(v2YFMoney.Summary.GroupFormat, 10, 8); v2FKMoney.Caption := Copy(v2FKMoney.Summary.GroupFormat, 10, 8); v2BQMoney.Caption := Copy(v2BQMoney.Summary.GroupFormat, 10, 8); FBegDate.Date := SGetServerDate(ADOQueryTemp); FEndDate.Date := FBegDate.Date; end; InitGrid(); end; procedure TfrmYSSKListRMBMJDZEY.FactoryNameGYSBtnClick(Sender: TObject); begin {try frmKHListSelJJ:=TfrmKHListSelJJ.Create(Application); with frmKHListSelJJ do begin frmKHListSelJJ.canshu2:='高权限'; if ShowModal=1 then begin Self.FactoryNameGYS.Text:=Trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNameJC').AsString); Self.FactoryNameGYS.TxtCode:=Trim(frmKHListSelJJ.CDS_HZ.fieldbyname('KHNO').AsString); end; end; finally frmKHListSelJJ.Free; end; } end; procedure TfrmYSSKListRMBMJDZEY.FactoryNameGYSChange(Sender: TObject); begin ToolButton2.Click; end; end.