unit U_TradePlanProfit;

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, 
   dxDateRanges, dxBarBuiltInMenu, U_BaseList, 
  dxScrollbarAnnotations, FrameDateSel, cxContainer, cxCurrencyEdit,
  dxSkinsCore, dxSkinsDefaultPainters, cxProgressBar;

type
  TfrmTradePlanProfit = class(TfrmBaseList)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBClose: TToolButton;
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    Panel1: TPanel;
    TBFind: TToolButton;
    ToolButton1: TToolButton;
    RM1: TRMGridReport;
    RMDB_1: TRMDBDataSet;
    cxGridPopupMenu2: TcxGridPopupMenu;
    CDS_P1: TClientDataSet;
    CDS_P2: TClientDataSet;
    RMDB_2: TRMDBDataSet;
    ADOQueryMain: TADOQuery;
    DataSource1: TDataSource;
    CDS_1: TClientDataSet;
    cxGrid1: TcxGrid;
    Tv1: TcxGridDBTableView;
    v1CustomerNoName: TcxGridDBColumn;
    v1OrdDate: TcxGridDBColumn;
    v1conno: TcxGridDBColumn;
    cxGrid1Level1: TcxGridLevel;
    cxStyleRepository1: TcxStyleRepository;
    cxStyle1: TcxStyle;
    Tv1Column14: TcxGridDBColumn;
    Tv1Column15: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Tv1Column6: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    Tv1Column9: TcxGridDBColumn;
    Tv1Column10: TcxGridDBColumn;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    CDS_P3: TClientDataSet;
    RMDB_3: TRMDBDataSet;
    CDS_P4: TClientDataSet;
    RMDB_4: TRMDBDataSet;
    CDS_P5: TClientDataSet;
    RMDB_5: TRMDBDataSet;
    RMDB_6: TRMDBDataSet;
    CDS_P6: TClientDataSet;
    CDS_P7: TClientDataSet;
    RMDB_7: TRMDBDataSet;
    frmFrameDateSel1: TfrmFrameDateSel;
    Label1: TLabel;
    Label4: TLabel;
    BuyName: TcxTextEdit;
    ConNo: TcxTextEdit;
    Tv1Column11: TcxGridDBColumn;
    Tv1Column12: TcxGridDBColumn;
    Tv1Column13: TcxGridDBColumn;
    Tv1Column16: TcxGridDBColumn;
    Tv1Column17: TcxGridDBColumn;
    Tv1Column18: TcxGridDBColumn;
    Tv1Column19: TcxGridDBColumn;
    Tv1Column20: TcxGridDBColumn;
    Tv1Column21: TcxGridDBColumn;
    Tv1Column22: TcxGridDBColumn;
    Tv1Column23: TcxGridDBColumn;
    Tv1Column24: TcxGridDBColumn;
    Tv1Column25: TcxGridDBColumn;
    Tv1Column26: TcxGridDBColumn;
    Tv1Column27: TcxGridDBColumn;
    Tv1Column28: TcxGridDBColumn;
    Tv1Column29: TcxGridDBColumn;
    Tv1Column30: TcxGridDBColumn;
    Tv1Column31: TcxGridDBColumn;
    Tv1Column32: TcxGridDBColumn;
    Tv1Column33: TcxGridDBColumn;
    Tv1Column34: TcxGridDBColumn;
    Tv1Column35: TcxGridDBColumn;
    Tv1Column36: TcxGridDBColumn;
    Tv1Column37: TcxGridDBColumn;
    Tv1Column38: TcxGridDBColumn;
    Tv1Column39: TcxGridDBColumn;
    Tv1Column40: TcxGridDBColumn;
    Tv1Column41: TcxGridDBColumn;
    Tv1Column42: TcxGridDBColumn;
    Tv1Column43: TcxGridDBColumn;
    Tv1Column44: TcxGridDBColumn;
    Tv1Column45: TcxGridDBColumn;
    Tv1Column46: TcxGridDBColumn;
    Tv1Column47: TcxGridDBColumn;
    Tv1Column48: TcxGridDBColumn;
    Tv1Column49: TcxGridDBColumn;
    Tv1Column50: TcxGridDBColumn;
    Tv1Column51: TcxGridDBColumn;
    Tv1Column52: TcxGridDBColumn;
    Tv1Column53: TcxGridDBColumn;
    Tv1Column54: TcxGridDBColumn;
    Tv1Column55: TcxGridDBColumn;
    Tv1Column56: TcxGridDBColumn;
    Tv1Column57: TcxGridDBColumn;
    Tv1Column58: TcxGridDBColumn;
    Tv1Column59: TcxGridDBColumn;
    Tv1Column60: TcxGridDBColumn;
    Tv1Column61: TcxGridDBColumn;
    Tv1Column62: TcxGridDBColumn;
    Tv1Column63: TcxGridDBColumn;
    Tv1Column64: TcxGridDBColumn;
    Tv1Column65: TcxGridDBColumn;
    Tv1Column66: TcxGridDBColumn;
    Tv1Column67: TcxGridDBColumn;
    Tv1Column68: TcxGridDBColumn;
    Tv1Column69: TcxGridDBColumn;
    Tv1Column70: TcxGridDBColumn;
    Tv1Column71: TcxGridDBColumn;
    Tv1Column72: TcxGridDBColumn;
    Tv1Column73: TcxGridDBColumn;
    Tv1Column74: TcxGridDBColumn;
    Tv1Column75: TcxGridDBColumn;
    Tv1Column76: TcxGridDBColumn;
    Tv1Column77: TcxGridDBColumn;
    Tv1Column78: TcxGridDBColumn;
    Tv1Column79: TcxGridDBColumn;
    Tv1Column80: TcxGridDBColumn;
    Tv1Column82: TcxGridDBColumn;
    Tv1Column83: TcxGridDBColumn;
    Tv1PurSId1: TcxGridDBColumn;
    Tv1Column84: TcxGridDBColumn;
    Tv1Column81: TcxGridDBColumn;
    Tv1SubId1: TcxGridDBColumn;
    Tv1SubId2: TcxGridDBColumn;
    Tv1SubId3: TcxGridDBColumn;
    Tv1PurSId2: TcxGridDBColumn;
    Tv1PurSId3: TcxGridDBColumn;
    Tv1ConSId: TcxGridDBColumn;
    Tv1Column85: TcxGridDBColumn;
    Tv1Column86: TcxGridDBColumn;
    Label2: TLabel;
    Saleser: TcxTextEdit;
    Tv1OrderNo3: TcxGridDBColumn;
    Tv1OrderNo1: TcxGridDBColumn;
    Tv1OrderNo2: TcxGridDBColumn;
    Tv1Column87: TcxGridDBColumn;
    Tv1Column88: TcxGridDBColumn;
    Tv1Column89: TcxGridDBColumn;
    Tv1Column90: TcxGridDBColumn;
    Tv1Column91: TcxGridDBColumn;
    Tv1Column92: TcxGridDBColumn;
    Tv1Column93: TcxGridDBColumn;
    Tv1Column94: TcxGridDBColumn;
    Tv1Column95: TcxGridDBColumn;
    Tv1Column96: TcxGridDBColumn;
    Tv1Column97: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
    procedure ToolButton5Click(Sender: TObject);
    procedure CustNamePropertiesChange(Sender: TObject);
    procedure v1CustomerNoNameCompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1PurSId1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column81CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1SubId1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1SubId2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1SubId3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1ConSIdCompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1PurSId2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1PurSId3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1Column84CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1OrderNo3CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1OrderNo2CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
    procedure Tv1OrderNo1CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
  private

    { Private declarations }

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

var
  frmTradePlanProfit: TfrmTradePlanProfit;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp, U_TradePlanProfitDetails, U_LabelPrint;

{$R *.dfm}

procedure TfrmTradePlanProfit.InitGrid();
begin
  try
    tv1.BeginUpdate() ;
    CDS_1.DisableControls;
    with ADOQueryMain do
    begin
      Close;
      SQL.Clear;
      sql.Add(' exec P_Trade_Profit_Plan @Begdate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Begdate.Date))));
      sql.Add(' ,@enddate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.EndDate.Date + 1))));
      if canshu1 = '查询' then
      begin
        sql.Add(',@canshu=' + QuotedStr(Trim(DName)));
      end;
      Open;
    end;
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS(ADOQueryMain, CDS_1);
    SInitCDSData(ADOQueryMain, CDS_1);
  finally
    CDS_1.EnableControls;
    tv1.EndUpdate;
  end;
end;

procedure TfrmTradePlanProfit.FormDestroy(Sender: TObject);
begin
  inherited;
  frmTradePlanProfit := nil;
end;

procedure TfrmTradePlanProfit.CustNamePropertiesChange(Sender: TObject);
begin
  TBFind.Click;
end;

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

procedure TfrmTradePlanProfit.TBCloseClick(Sender: TObject);
begin

  Close;
end;

procedure TfrmTradePlanProfit.FormShow(Sender: TObject);
var
  fsj: string;
begin
  inherited;
  ReadCxGrid(trim(self.caption), Tv1, '合同利润表');
  HiddenTVColumn(Tv1, 'ConSId');
  HiddenTVColumn(Tv1, 'PurSId1');
  HiddenTVColumn(Tv1, 'PurSId2');
  HiddenTVColumn(Tv1, 'PurSId3');
  HiddenTVColumn(Tv1, 'SubId1');
  HiddenTVColumn(Tv1, 'SubId2');
  HiddenTVColumn(Tv1, 'SubId3');
  InitGrid();
end;

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

procedure TfrmTradePlanProfit.TBFindClick(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 TfrmTradePlanProfit.ToolButton3Click(Sender: TObject);
begin
  WriteCxGrid(trim(self.caption), Tv1, '合同利润表');
end;

procedure TfrmTradePlanProfit.ToolButton4Click(Sender: TObject);
begin
  try
    frmTradePlanProfitDetails := TfrmTradePlanProfitDetails.Create(Application);
    with frmTradePlanProfitDetails do
    begin

      FConNo := Trim(Self.CDS_1.fieldbyname('ConNo').AsString);
      if ShowModal = 1 then
      begin
        InitGrid();
      end;
    end;
  finally
    frmTradePlanProfitDetails.Free;
  end;
end;

procedure TfrmTradePlanProfit.ToolButton5Click(Sender: TObject);
var
  WSql: string;
begin

  WSql := ' @Begdate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.Begdate.Date)));
  WSql := WSql + ' ,@enddate=' + quotedstr(trim(FormatDateTime('yyyy-MM-dd', frmFrameDateSel1.EndDate.Date + 1)));
  if canshu1 = '查询' then
  begin
    WSql := WSql + ',@canshu=' + QuotedStr(Trim(DName));
  end;

  try
    frmLabelPrint := TfrmLabelPrint.Create(Application);
    with frmLabelPrint do
    begin
      IsSql1 := True;
      FLMType := 'TradePlanProfit';
      FFiltration1 := WSql;
      if ShowModal = 1 then
      begin
//        Self.InitGrid();
      end;
    end;
  finally
    frmLabelPrint.Free;
  end;

end;

procedure TfrmTradePlanProfit.Tv1DblClick(Sender: TObject);
begin
  ToolButton4.Click;
end;

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

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

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

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

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

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

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

end;

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

end;

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

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

procedure TfrmTradePlanProfit.Tv1Column84CompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin
  if (ARow1.Values[Tv1Column81.Index] = ARow2.Values[Tv1Column81.Index]) and (ARow1.Values[v1conno.Index] = ARow2.Values[v1conno.Index]) and (ARow1.Values[Tv1Column84.Index] = ARow2.Values[Tv1Column84.Index]) then
    AAreEqual := True
  else
    AAreEqual := False;
end;

procedure TfrmTradePlanProfit.Tv1ConSIdCompareRowValuesForCellMerging(Sender: TcxGridColumn; ARow1: TcxGridDataRow; AProperties1: TcxCustomEditProperties; const AValue1: Variant; ARow2: TcxGridDataRow; AProperties2: TcxCustomEditProperties; const AValue2: Variant; var AAreEqual: Boolean);
begin

  if ARow1.Values[Tv1ConSId.Index] = ARow2.Values[Tv1ConSId.Index] then
    AAreEqual := True
  else
    AAreEqual := False;
end;

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

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

procedure TfrmTradePlanProfit.FormCreate(Sender: TObject);
begin
  inherited;
  canshu1 := Trim(DParameters1);
  frmFrameDateSel1.EndDate.Date := SGetServerDate(ADOQueryTemp);
  frmFrameDateSel1.BegDate.Date := frmFrameDateSel1.EndDate.Date - 365;


end;

end.

