unit U_DDLRCX;

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, cxDBLookupComboBox, cxGridBandedTableView, cxGridDBBandedTableView,
  cxLookAndFeels, cxLookAndFeelPainters, cxNavigator, dxSkinsCore,
  dxSkinsDefaultPainters, dxSkinscxPCPainter, cxMemo;

type
  TfrmDDLRCX = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    ToolButton2: TToolButton;
    ToolButton1: TToolButton;
    RM1: TRMGridReport;
    RMDBHZ: TRMDBDataSet;
    Label3: TLabel;
    CPName: TEdit;
    cxGridPopupMenu2: TcxGridPopupMenu;
    Label1: TLabel;
    EndDate: TDateTimePicker;
    Label4: TLabel;
    Label5: TLabel;
    Begdate: TDateTimePicker;
    Label2: TLabel;
    mxOrderNo: TEdit;
    ToolButton3: TToolButton;
    CDSPRTHZ: TClientDataSet;
    CDSPRTMX: TClientDataSet;
    RMDBMX: TRMDBDataSet;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    CDS_HZ: TClientDataSet;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    FactoryName: TComboBox;
    Label7: TLabel;
    lidan: TEdit;
    Label6: TLabel;
    ywy: TEdit;
    cxGrid2: TcxGrid;
    TV3: TcxGridDBTableView;
    cxGridDBColumn1: TcxGridDBColumn;
    cxGridDBColumn2: TcxGridDBColumn;
    cxGridDBColumn3: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    TV3Column1: TcxGridDBColumn;
    TV3Column2: TcxGridDBColumn;
    TV3Column3: TcxGridDBColumn;
    DataSource2: TDataSource;
    CDS_SUB: TClientDataSet;
    cxGrid3: TcxGrid;
    TV2: TcxGridDBBandedTableView;
    cxGridDBBandedColumn35: TcxGridDBBandedColumn;
    cxGridDBBandedColumn42: TcxGridDBBandedColumn;
    cxGridDBBandedColumn52: TcxGridDBBandedColumn;
    cxGridDBBandedColumn56: TcxGridDBBandedColumn;
    cxGridDBBandedColumn57: TcxGridDBBandedColumn;
    cxGridDBBandedColumn59: TcxGridDBBandedColumn;
    cxGridDBBandedColumn60: TcxGridDBBandedColumn;
    cxGridDBBandedColumn61: TcxGridDBBandedColumn;
    cxGridDBBandedColumn62: TcxGridDBBandedColumn;
    cxGridDBBandedColumn63: TcxGridDBBandedColumn;
    cxGridDBBandedColumn64: TcxGridDBBandedColumn;
    cxGridDBBandedColumn79: TcxGridDBBandedColumn;
    cxGridDBBandedColumn81: TcxGridDBBandedColumn;
    cxGridDBBandedColumn87: TcxGridDBBandedColumn;
    cxGridDBBandedColumn91: TcxGridDBBandedColumn;
    cxGridDBBandedColumn1: TcxGridDBBandedColumn;
    DBCOLOR: TcxGridDBBandedColumn;
    cxGridDBBandedColumn4: TcxGridDBBandedColumn;
    cxGridDBBandedColumn5: TcxGridDBBandedColumn;
    cxGridDBBandedColumn6: TcxGridDBBandedColumn;
    cxGridDBBandedColumn7: TcxGridDBBandedColumn;
    cxGridDBBandedColumn8: TcxGridDBBandedColumn;
    cxGridDBBandedColumn9: TcxGridDBBandedColumn;
    DBJGC: TcxGridDBBandedColumn;
    cxGridDBBandedColumn12: TcxGridDBBandedColumn;
    cxGridDBBandedColumn13: TcxGridDBBandedColumn;
    cxGridDBBandedColumn14: TcxGridDBBandedColumn;
    cxGridDBBandedColumn15: TcxGridDBBandedColumn;
    cxGridDBBandedColumn16: TcxGridDBBandedColumn;
    cxGridDBBandedColumn17: TcxGridDBBandedColumn;
    cxGridDBBandedColumn20: TcxGridDBBandedColumn;
    cxGridDBBandedColumn21: TcxGridDBBandedColumn;
    cxGridDBBandedColumn22: TcxGridDBBandedColumn;
    cxGridDBBandedColumn23: TcxGridDBBandedColumn;
    cxGridDBBandedColumn24: TcxGridDBBandedColumn;
    cxGridDBBandedColumn25: TcxGridDBBandedColumn;
    cxGridDBBandedColumn26: TcxGridDBBandedColumn;
    cxGridLevel2: TcxGridLevel;
    TV2Column1: TcxGridDBBandedColumn;
    TV2Column2: TcxGridDBBandedColumn;
    TV2Column3: TcxGridDBBandedColumn;
    TV2Column4: TcxGridDBBandedColumn;
    TV2Column5: TcxGridDBBandedColumn;
    TV2Column6: TcxGridDBBandedColumn;
    TV2Column7: TcxGridDBBandedColumn;
    TV2Column8: TcxGridDBBandedColumn;
    TV2Column9: TcxGridDBBandedColumn;
    TV2Column10: TcxGridDBBandedColumn;
    TV2Column11: TcxGridDBBandedColumn;
    TV2Column12: TcxGridDBBandedColumn;
    TV2Column13: TcxGridDBBandedColumn;
    TV2Column14: TcxGridDBBandedColumn;
    TV2Column15: TcxGridDBBandedColumn;
    TV2Column16: TcxGridDBBandedColumn;
    TV2Column17: TcxGridDBBandedColumn;
    TV2Column18: TcxGridDBBandedColumn;
    TV2Column19: TcxGridDBBandedColumn;
    TV2Column20: TcxGridDBBandedColumn;
    TV2Column21: TcxGridDBBandedColumn;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1CustomerNoName: TcxGridDBColumn;
    Tv1Column14: TcxGridDBColumn;
    Tv1Column15: TcxGridDBColumn;
    Tv1Column16: TcxGridDBColumn;
    v1OrdDate: TcxGridDBColumn;
    v1OrderNo: TcxGridDBColumn;
    v1MPRTCodeName: TcxGridDBColumn;
    v1MPRTSpec: TcxGridDBColumn;
    v1Column22: TcxGridDBColumn;
    v1Column1: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    v1Column3: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column7: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    v1Column11: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    v1Column14: TcxGridDBColumn;
    v1Column15: TcxGridDBColumn;
    Tv1Column4: TcxGridDBColumn;
    v1Column4: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    v1Column13: TcxGridDBColumn;
    v1Column16: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    v1Column17: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    Tv1Column12: TcxGridDBColumn;
    Tv1Column13: TcxGridDBColumn;
    v1Column18: TcxGridDBColumn;
    Tv1Column19: TcxGridDBColumn;
    Tv1Column20: TcxGridDBColumn;
    Tv1Column9: TcxGridDBColumn;
    Tv1Column10: TcxGridDBColumn;
    v1Column19: TcxGridDBColumn;
    v1Column20: TcxGridDBColumn;
    Tv1Column11: TcxGridDBColumn;
    Tv1Column17: TcxGridDBColumn;
    v1Column21: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column18: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    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 CPNameChange(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure v1OrderNoCompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
    procedure Tv1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column7CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column8CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column7CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column8CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column11CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column12CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column14CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column15CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column9CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column10CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column11CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure v1Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
    procedure cxGridDBBandedColumn60CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure cxGridDBBandedColumn1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure cxGridDBBandedColumn52CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure TV2Column5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure TV2Column13CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure TV2Column19CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure TV2Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure TV2Column10CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
  private

    { Private declarations }

    procedure InitGrid();
    procedure InitsubGrid();
  public
    fkhType: string;
    Fmanage: string;
    canshu1: string;
  end;

var
  frmDDLRCX: TfrmDDLRCX;

implementation

uses
  U_DataLink, U_Fun, U_ZDYHelp;

{$R *.dfm}
procedure TfrmDDLRCX.InitsubGrid();
begin
  try
    ADOQueryTemp.DisableControls;
    with ADOQueryTemp do
    begin
      Close;
      SQL.Clear;
      sql.Add('  SELECT  Y.FACTORYNAME,u.*  FROM YF_Money_CR  y INNER JOIN YF_Money_CR_Sub u ON y.YFID=u.YFID');
      SQL.Add('inner join CK_SXPB_CR i ON u.YFPZNO=i.SPID	WHERE y.CRType=''应付款登记'' AND i.CRType IN(''坯布入库'',''采购入库'')  AND KXTYPE<>''扣款'' and u.MXOrderNo = ' + QuotedStr((CDS_HZ.FIELDBYNAME('mxOrderNo').AsString)));
      SQL.Add('ORDER BY Y.FACTORYNAME');

//      ShowMessage(SQL.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryTemp, CDS_SUB);
    SInitCDSData20(ADOQueryTemp, CDS_SUB);
//    CDS_HZ.Last;
  finally
    ADOQueryTemp.EnableControls;
  end;
end;

procedure TfrmDDLRCX.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_VIEW_lR @Begdate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', Begdate.DateTime))));
      sql.Add(' ,@enddate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', EndDate.DateTime + 1))));
      if canshu1 = '查询' then
      begin
        sql.Add(',@canshu=' + QuotedStr(Trim(DName)));
      end;
//       ShowMessage(SQL.Text);
      Open;
    end;
    SCreateCDS20(ADOQueryMain, CDS_HZ);
    SInitCDSData20(ADOQueryMain, CDS_HZ);
//    CDS_HZ.Last;
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmDDLRCX.FormDestroy(Sender: TObject);
begin
  frmDDLRCX := nil;
end;

procedure TfrmDDLRCX.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TfrmDDLRCX.TBCloseClick(Sender: TObject);
begin
  WriteCxBandedGrid(trim(self.caption), tv2, '利润表22');
  Close;
end;

procedure TfrmDDLRCX.FormShow(Sender: TObject);
var
  fsj: string;
begin
  ReadCxBandedGrid(trim(self.caption), tv2, '利润表22');
  fsj := 'select distinct(FactoryName) Name from YF_Money_CR where CRType=''应收款登记''  order by FactoryName ';
  SInitComBoxBySql(ADOQueryCmd, FactoryName, False, fsj);
//  InitGrid();
end;

procedure TfrmDDLRCX.TBRafreshClick(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmDDLRCX.ToolButton2Click(Sender: TObject);
begin
  if ADOQueryMain.Active then
  begin
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, CDS_HZ);
    SInitCDSData20(ADOQueryMain, CDS_HZ);
  end;
end;

procedure TfrmDDLRCX.CPNameChange(Sender: TObject);
begin
  ToolButton2.Click;
end;

procedure TfrmDDLRCX.ToolButton1Click(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  TcxGridToExcel(self.Caption, cxgrid3);
end;

procedure TfrmDDLRCX.FormCreate(Sender: TObject);
begin
  canshu1 := Trim(DParameters1);
  EndDate.DateTime := SGetServerDate10(ADOQueryTemp);
  BegDate.DateTime := EndDate.DateTime - 90;
end;

procedure TfrmDDLRCX.ToolButton3Click(Sender: TObject);
var
  fPrintFile, fPrintFile10, FMainID, FKHName, FFPNo: string;
  i: Integer;
begin
  ExportFtErpFile('跟进表.rmf', ADOQueryTemp);
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.add('exec P_Print_CRJD_HZ ');
    sql.add('@MainId=' + quotedstr(Trim(CDS_HZ.fieldbyname('MainId').AsString)));
    Open;
  end;
  SCreateCDS20(ADOQueryTemp, CDSPRTHZ);
  SInitCDSData20(ADOQueryTemp, CDSPRTHZ);

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.add('exec P_Print_CRJD_CD ');
    sql.add('@MainId=' + quotedstr(Trim(CDS_HZ.fieldbyname('MainId').AsString)));
    Open;
  end;
  RMVariables['HZCD'] := ADOQueryTemp.fieldbyname('HZCD').Value;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.add('exec P_Print_CRJD ');
    sql.add('@MainId=' + quotedstr(Trim(CDS_HZ.fieldbyname('MainId').AsString)));
    sql.add(',@Falg=''明细''');
    Open;
  end;
  SCreateCDS20(ADOQueryTemp, CDSPRTMX);
  SInitCDSData20(ADOQueryTemp, CDSPRTMX);

  fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\跟进表.rmf';
  if FileExists(fPrintFile) then
  begin
    RM1.LoadFromFile(fPrintFile);
    RM1.ShowReport;
  end
  else
  begin
    Application.MessageBox(PChar('没有找到' + fPrintFile), '提示', 0);
  end;
end;

procedure TfrmDDLRCX.v1OrderNoCompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
  if (AViewInfo.GridRecord.Values[TcxGridDBTableView(Sender).GetColumnByFieldName('keyNO').Index]) mod 2 = 0 then
  begin
    ACanvas.Brush.Color := clSkyBlue;
  end;
end;

procedure TfrmDDLRCX.Tv1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column6.Index] = ARow2.Values[Tv1Column6.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column7CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column7.Index] = ARow2.Values[Tv1Column7.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column8CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column8.Index] = ARow2.Values[Tv1Column8.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column7CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column7.Index] = ARow2.Values[v1Column7.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column8CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column8.Index] = ARow2.Values[v1Column8.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column3.Index] = ARow2.Values[Tv1Column3.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column11CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column11.Index] = ARow2.Values[v1Column11.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column12CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column12.Index] = ARow2.Values[v1Column12.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column14CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column14.Index] = ARow2.Values[v1Column14.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column15CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column15.Index] = ARow2.Values[v1Column15.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column4.Index] = ARow2.Values[Tv1Column4.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column4CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column4.Index] = ARow2.Values[v1Column4.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column9CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column9.Index] = ARow2.Values[v1Column9.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column10CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column10.Index] = ARow2.Values[v1Column10.Index]) and (ARow1.Values[v1Column22.Index] = ARow2.Values[v1Column22.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column3.Index] = ARow2.Values[v1Column3.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column2.Index] = ARow2.Values[Tv1Column2.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column5.Index] = ARow2.Values[v1Column5.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column6CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column6.Index] = ARow2.Values[v1Column6.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column2.Index] = ARow2.Values[v1Column2.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column1.Index] = ARow2.Values[v1Column1.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1Column11CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[Tv1Column11.Index] = ARow2.Values[Tv1Column11.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.v1Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[v1OrderNo.Index] = ARow2.Values[v1OrderNo.Index]) and (ARow1.Values[v1Column20.Index] = ARow2.Values[v1Column20.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.Tv1FocusedRecordChanged(Sender: TcxCustomGridTableView; APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
  InitsubGrid();
end;

procedure TfrmDDLRCX.cxGridDBBandedColumn60CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.cxGridDBBandedColumn1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[DBCOLOR.Index] = ARow2.Values[DBCOLOR.Index]) and (ARow1.Values[DBJGC.Index] = ARow2.Values[DBJGC.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.cxGridDBBandedColumn52CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[cxGridDBBandedColumn52.Index] = ARow2.Values[cxGridDBBandedColumn52.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.TV2Column5CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[TV2Column5.Index] = ARow2.Values[TV2Column5.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.TV2Column13CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[TV2Column13.Index] = ARow2.Values[TV2Column13.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.TV2Column19CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[TV2Column18.Index] = ARow2.Values[TV2Column18.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.TV2Column20CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[TV2Column20.Index] = ARow2.Values[TV2Column20.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmDDLRCX.TV2Column10CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[cxGridDBBandedColumn62.Index] = ARow2.Values[cxGridDBBandedColumn62.Index]) and (ARow1.Values[TV2Column10.Index] = ARow2.Values[TV2Column10.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

end.

