unit U_PBCGRKList_RCDJ;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, DBClient, cxCheckBox, cxCalendar, cxSplitter, RM_Dataset, RM_System,
  RM_Common, RM_Class, RM_GridReport, RM_e_Xls, Menus, cxButtonEdit,
  cxDropDownEdit, cxPC, Buttons, cxTextEdit, cxLookAndFeels,
  cxLookAndFeelPainters, cxNavigator, dxSkinsCore, dxSkinDarkRoom,
  dxSkinOffice2013White, dxSkinSharpPlus, dxSkinSpringTime,
  dxSkinsDefaultPainters, dxSkinscxPCPainter, dxSkinBlack, dxSkinBlue,
  dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMetropolis,
  dxSkinMetropolisDark, dxSkinMoneyTwins, dxSkinOffice2007Black,
  dxSkinOffice2007Blue, dxSkinOffice2007Green, dxSkinOffice2007Pink,
  dxSkinOffice2007Silver, dxSkinOffice2010Black, dxSkinOffice2010Blue,
  dxSkinOffice2010Silver, dxSkinOffice2013DarkGray, dxSkinOffice2013LightGray,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSilver,
  dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld, dxSkinValentine,
  dxSkinVS2010, dxSkinWhiteprint, dxSkinXmas2008Blue;

type
  TfrmPBCGRKList_RCDJ = class(TForm)
    ToolBar1: TToolBar;
    TBRafresh: TToolButton;
    TBFind: TToolButton;
    TBAdd: TToolButton;
    TBClose: TToolButton;
    Tv1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGridPopupMenu1: TcxGridPopupMenu;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    ADOQueryTemp: TADOQuery;
    DataSource1: TDataSource;
    TBExport: TToolButton;
    Order_Main: TClientDataSet;
    ToolButton1: TToolButton;
    Panel1: TPanel;
    v1Column1: TcxGridDBColumn;
    Label34: TLabel;
    v1Column7: TcxGridDBColumn;
    v1Column9: TcxGridDBColumn;
    KHNameHZ: TEdit;
    BegDate: TDateTimePicker;
    EndDate: TDateTimePicker;
    RM1: TRMGridReport;
    RMDBMain: TRMDBDataSet;
    RMXLSExport2: TRMXLSExport;
    CDS_PRT: TClientDataSet;
    v1Column17: TcxGridDBColumn;
    v1Column5: TcxGridDBColumn;
    Label2: TLabel;
    MYName: TEdit;
    v1Column3: TcxGridDBColumn;
    v1Column2: TcxGridDBColumn;
    Label1: TLabel;
    Note: TEdit;
    labMYType: TLabel;
    Panel2: TPanel;
    SpeedButton1: TSpeedButton;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    CheckBox1: TCheckBox;
    v1MYMDPrice: TcxGridDBColumn;
    v1MYMDMoney: TcxGridDBColumn;
    v1JCDanWeiJC: TcxGridDBColumn;
    Label3: TLabel;
    JCDanWeiJC: TEdit;
    v1filler: TcxGridDBColumn;
    Label4: TLabel;
    filler: TEdit;
    ToolButton2: TToolButton;
    ClientDataSet1: TClientDataSet;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    SpeedButton6: TSpeedButton;
    SpeedButton7: TSpeedButton;
    SpeedButton8: TSpeedButton;
    SpeedButton9: TSpeedButton;
    SpeedButton10: TSpeedButton;
    SpeedButton11: TSpeedButton;
    SpeedButton12: TSpeedButton;
    SpeedButton13: TSpeedButton;
    SpeedButton14: TSpeedButton;
    SpeedButton15: TSpeedButton;
    Image2: TImage;
    v1Column4: TcxGridDBColumn;
    v1Column6: TcxGridDBColumn;
    v1Column8: TcxGridDBColumn;
    v1Column10: TcxGridDBColumn;
    Label5: TLabel;
    MYTypeFlag: TComboBox;
    v1Column11: TcxGridDBColumn;
    v1Column12: TcxGridDBColumn;
    Label6: TLabel;
    MLOrderNo: TEdit;
    Label7: TLabel;
    KHNameHZZ: TEdit;
    v1Column13: TcxGridDBColumn;
    Tv1Column1: TcxGridDBColumn;
    Label8: TLabel;
    PBBatchNo: TEdit;
    Tv1Column2: TcxGridDBColumn;
    Tv1Column3: TcxGridDBColumn;
    Tv1Column4: TcxGridDBColumn;
    Tv1Column5: TcxGridDBColumn;
    Label9: TLabel;
    MYColor: TEdit;
    Tv1Column6: TcxGridDBColumn;
    Tv1Column7: TcxGridDBColumn;
    Tv1Column8: TcxGridDBColumn;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure TBCloseClick(Sender: TObject);
    procedure TBFindClick(Sender: TObject);
    procedure TBExportClick(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBAddClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CheckBox1Click(Sender: TObject);
    procedure CheckBox2Click(Sender: TObject);
    procedure ToolButton1Click(Sender: TObject);
    procedure CustomerNoNameChange(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure cxTabControl1Change(Sender: TObject);
    procedure ZJStatusChange(Sender: TObject);
    procedure Tv1DblClick(Sender: TObject);
    procedure Image2Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure v1Column1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
    procedure v1Column17CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
    procedure v1Column3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
  private
    FGXName: string;
    DQdate: TDateTime;
    procedure InitGrid();
    procedure InitForm();
    function DelData(): Boolean;
    procedure initGX();
    { Private declarations }
  public
    FFInt, FCloth: Integer;
    canshu1: string;

    { Public declarations }
  end;

//var
  //frmPBCGRKList_RCDJ: TfrmPBCGRKList_RCDJ;

implementation

uses
  U_DataLink, U_RTFun, U_ZDYHelp, U_LLRKInPutMH_RCCG;

{$R *.dfm}

procedure TfrmPBCGRKList_RCDJ.FormDestroy(Sender: TObject);
begin
  //frmPBCGRKList_RCDJ:=nil;
end;

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

procedure TfrmPBCGRKList_RCDJ.FormCreate(Sender: TObject);
begin
  cxgrid1.Align := alClient;
  canshu1 := Trim(DParameters1);
end;

procedure TfrmPBCGRKList_RCDJ.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('加工码单', Tv1, '贸易生产管理');
  Close;
end;

procedure TfrmPBCGRKList_RCDJ.InitGrid();
begin
  try
    ADOQueryMain.DisableControls;
    with ADOQueryMain do
    begin
      Filtered := False;
      Close;
      sql.Clear;
      sql.Add('select AA.* ');
      sql.Add(',KHNameHZ=dbo.getpinyin(isnull(AA.KHNameJC,''''))+AA.GYSNo+isnull(AA.KHNameJC,'''')');
      sql.Add('from(');
      sql.Add(' select A.* ');
      sql.Add(',KHNameJC=(select Top 1 B.KHNameJC from KH_Main B ');
      sql.Add(' where isnull(B.KHFlag,'''')=''GYS'' and isnull(B.Valid,'''')=''Y'' and B.KHNO=A.GYSNo)');
      sql.Add(',KHNameJCDH=(select Top 1 B.KHNameJC from KH_Main B ');
      sql.Add(' where isnull(B.KHFlag,'''')=''GYS'' and isnull(B.Valid,'''')=''Y'' and B.KHNO=A.ToGYSNo)');
      sql.Add(',KHNameHZZ=dbo.getpinyin(isnull(KM.KHNameJC,''''))+B.KHNO+isnull(KM.KHNameJC,'''')');
      sql.Add(',KHNameJCZ=KM.KHNameJC,B.MLOrderNo,KHNOKH=B.KHNO');
//      sql.Add(',PS1=(select count(MXID) from CK_MYSC_CR_MX D where D.MYID=A.MYID )');


      sql.Add(',FHQty=(select X.FHQty from FHSQ_Sub X where X.FSId=A.scdsubid)');
//                      sql.Add(',FHPS=(select X.FHPS from FHSQ_Sub X where X.FSId=A.scdsubid)');


      sql.Add(' from CK_MYSC_CR A  ');
      sql.Add(' left join ML_OrderMainNew B on A.MainId=B.NewMLID');
      sql.Add(' left join KH_Main KM on KM.KHNO=B.KHNO ');
      sql.Add(' where 1=1 ');
      if CheckBox1.Checked = False then
      begin
        sql.Add(' and A.CRTime>=''' + Trim(FormatDateTime('yyyy-MM', now) + '-01') + '''');
        sql.Add(' and A.CRTime<''' + Trim(FormatDateTime('yyyy-MM-dd', now + 1)) + '''');
        BegDate.Visible := false;
        EndDate.Visible := false;
      end
      else
      begin
        sql.Add(' and A.CRTime>=''' + Trim(FormatDateTime('yyyy-MM-dd', BegDate.Date)) + '''');
        sql.Add(' and A.CRTime<''' + Trim(FormatDateTime('yyyy-MM-dd', EndDate.Date + 1)) + '''');
        BegDate.Visible := true;
        EndDate.Visible := true;
      end;
      sql.Add(' and isnull(CRType,'''')=''加工码单'' ');
      if canshu1 <> '高权限' then
      begin
        sql.add(' and A.filler=''' + trim(DName) + '''');
      end;
      sql.Add(')AA');
      Open;
    end;
    SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
    SCreateCDS20(ADOQueryMain, Order_Main);
    SInitCDSData20(ADOQueryMain, Order_Main);
  finally
    ADOQueryMain.EnableControls;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.InitForm();
var
  fsj: string;
begin
  BegDate.Date := StrToDate(formatdatetime('yyyy-MM', SGetServerDate(ADOQueryTemp)) + '-01');
  EndDate.Date := SGetServerDate(ADOQueryTemp);
  ReadCxGrid('加工码单', Tv1, '贸易生产管理');
  fsj := 'select Name=ZDYName,Code=Null from KH_Zdy where Type=''JGGongXu'' ';
  SInitComBoxBySql(ADOQueryTemp, MYTypeFlag, False, fsj);
  InitGrid();
end;

procedure TfrmPBCGRKList_RCDJ.TBFindClick(Sender: TObject);
begin
  if ADOQueryMain.Active = False then
    Exit;
  SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  SCreateCDS20(ADOQueryMain, Order_Main);
  SInitCDSData20(ADOQueryMain, Order_Main);
end;

function TfrmPBCGRKList_RCDJ.DelData(): Boolean;
begin
  try
    Result := false;
    ADOQueryCmd.Connection.BeginTrans;
    Order_Main.DisableControls;
    with Order_Main do
    begin
      //First;
     // while Order_Main.Locate('SSel',True,[]) do
      begin
        with ADOQueryCmd do
        begin
          Close;
          sql.Clear;
          sql.Add(' delete YS_Money_CR where YFTypeId=''' + Trim(Order_Main.fieldbyname('MYID').AsString) + '''');
          sql.Add(' insert into CK_MYSC_CR_Log  ');
          sql.Add(' select * from CK_MYSC_CR where MYID=''' + Trim(Order_Main.fieldbyname('MYID').AsString) + '''');
          sql.Add(' UPdate CK_MYSC_CR_Log Set DelTime=getdate(),DelerCode=''' + Trim(DCode) + ''',Deler=''' + Trim(DName) + '''');
          sql.Add(' where MYID=''' + Trim(Order_Main.fieldbyname('MYID').AsString) + '''');
          sql.Add(' Delete CK_MYSC_CR  where MYId=''' + Trim(Order_Main.fieldbyname('MYId').AsString) + '''');
          sql.Add(' delete from TP_File where WBID=''' + trim(Order_Main.fieldbyname('MYId').AsString) + ''' ');
          sql.Add(' and TFType=''加工码单''');
          ExecSQL;
        end;
        Order_Main.Delete;
      end;
    end;
    Order_Main.EnableControls;
    ADOQueryCmd.Connection.CommitTrans;
    Result := True;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    Result := False;
    Application.MessageBox('数据删除异常！', '提示', 0);
  end;
end;

procedure TfrmPBCGRKList_RCDJ.TBExportClick(Sender: TObject);
begin
  if ADOQueryMain.IsEmpty then
    Exit;
  TcxGridToExcel(Self.Caption, cxGrid1);
end;

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

procedure TfrmPBCGRKList_RCDJ.TBAddClick(Sender: TObject);
begin
  Panel2.Visible := True;
  initGX();
end;

procedure TfrmPBCGRKList_RCDJ.initGX();
var
  BB: array[0..100] of string;
  i, j: Integer;
begin

  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select ZDYName from KH_Zdy where Type=''JGGongXu''  '); //order by ZDYName
    Open;
  end;
  if ADOQueryTemp.IsEmpty then
  begin
    Application.MessageBox('没有定义数据！', '提示', 0);
    Exit;
  end;
  with ADOQueryTemp do
  begin
    First;
    i := 0;
    while not Eof do
    begin
      BB[i] := Trim(fieldbyname('ZDYName').AsString);
      i := i + 1;
      Next;
    end;
  end;
  i := i - 1;
  if i > 14 then
  begin
    i := 14;
  end;
  for j := 0 to i do
  begin
    with Panel2 do
    begin
      TSpeedButton(Controls[j]).Visible := True;
      TSpeedButton(Controls[j]).Caption := BB[j];
    end;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.FormShow(Sender: TObject);
begin
  InitForm();
end;

procedure TfrmPBCGRKList_RCDJ.CheckBox1Click(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmPBCGRKList_RCDJ.CheckBox2Click(Sender: TObject);
begin
  TBRafresh.Click;
end;

procedure TfrmPBCGRKList_RCDJ.ToolButton1Click(Sender: TObject);
var
  FFMYType: string;
begin
  FFMYType := Trim(Order_Main.fieldbyname('MYType').AsString);
  try
    frmLLRKInPutMH_RCCG := TfrmLLRKInPutMH_RCCG.Create(Application);
    with frmLLRKInPutMH_RCCG do
    begin
      PState := 1;
      FMainId := Trim(Self.Order_Main.fieldbyname('MYId').AsString);
      FMYType := Trim(Self.Order_Main.fieldbyname('MYType').AsString);
      FMYTypeFlag := Trim(Self.Order_Main.fieldbyname('MYTypeFlag').AsString);
      labMYType.Caption := Trim(Self.Order_Main.fieldbyname('MYTypeFlag').AsString);
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmLLRKInPutMH_RCCG.Free;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.CustomerNoNameChange(Sender: TObject);
begin
  if ADOQueryMain.Active = False then
    Exit;
  SDofilter(ADOQueryMain, SGetFilters(Panel1, 1, 2));
  SCreateCDS20(ADOQueryMain, Order_Main);
  SInitCDSData20(ADOQueryMain, Order_Main);
end;

procedure TfrmPBCGRKList_RCDJ.N2Click(Sender: TObject);
begin
  if Order_Main.IsEmpty then
    Exit;
  if Trim(canshu1) <> '高权限' then
  begin
//    if Order_Main.FieldByName('filltime').AsDateTime+1<Now then
//    begin
//      application.MessageBox('超过一天不能删除','提示');
//      Exit;
//    end;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from YS_Money_CR where YFTypeId=''' + Trim(Self.Order_Main.fieldbyname('MYId').AsString) + '''');
    sql.Add(' and ChkStatusP=''已审核''');
    Open;
  end;
  if ADOQueryTemp.IsEmpty = false then
  begin
    Application.MessageBox('应付款已审核不能操作', '提示');
    exit;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from YS_Money_CR where YFTypeId=''' + trim(Order_Main.fieldbyname('MYID').AsString) + '''');
    sql.Add(' and (isnull(ChkerP,'''')<>'''' ');
    sql.Add(' or isnull(ChkerQ,'''')<>'''') ');
    Open;
  end;
  if ADOQueryTemp.IsEmpty = false then
  begin
    Application.MessageBox('应付款已审核,不能删除', '提示');
    exit;
  end;
  if Application.MessageBox('确定要删除数据吗？', '提示', 32 + 4) <> IDYES then
    Exit;
  if DelData() then
  begin

  end;
end;

procedure TfrmPBCGRKList_RCDJ.N1Click(Sender: TObject);
var
  FFMYType: string;
begin
  if Order_Main.IsEmpty then
    Exit;
  if Trim(canshu1) <> '高权限' then
  begin
//    if Order_Main.FieldByName('filltime').AsDateTime+1<Now then
//    begin
//      application.MessageBox('超过一天不能修改','提示');
//      Exit;
//    end;
  end;
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from YS_Money_CR where YFTypeId=''' + Trim(Self.Order_Main.fieldbyname('MYId').AsString) + '''');
    sql.Add(' and ChkStatusP=''已审核''');
    Open;
  end;
  if ADOQueryTemp.IsEmpty = false then
  begin
    Application.MessageBox('应付款已审核不能操作', '提示');
    exit;
  end;
  FFMYType := Trim(Order_Main.fieldbyname('MYType').AsString); //加限制财务ChkerP=''已审核''
  try
    frmLLRKInPutMH_RCCG := TfrmLLRKInPutMH_RCCG.Create(Application);
    with frmLLRKInPutMH_RCCG do
    begin
      PState := 1;
      FMainId := Trim(Self.Order_Main.fieldbyname('MYId').AsString);
      FMYType := Trim(Self.Order_Main.fieldbyname('MYType').AsString);
      FMYTypeFlag := Trim(Self.Order_Main.fieldbyname('MYTypeFlag').AsString);
      labMYType.Caption := Trim(Self.Order_Main.fieldbyname('MYTypeFlag').AsString) + '加工码单';
      if ShowModal = 1 then
      begin
        InitGrid();
      end;
    end;
  finally
    frmLLRKInPutMH_RCCG.Free;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.cxTabControl1Change(Sender: TObject);
begin
  InitGrid();
end;

procedure TfrmPBCGRKList_RCDJ.ZJStatusChange(Sender: TObject);
begin
  TBFind.Click;
end;

procedure TfrmPBCGRKList_RCDJ.Tv1DblClick(Sender: TObject);
begin
  ToolButton1.Click;
end;

procedure TfrmPBCGRKList_RCDJ.Image2Click(Sender: TObject);
begin
  Panel2.Visible := False;

end;

procedure TfrmPBCGRKList_RCDJ.SpeedButton1Click(Sender: TObject);
begin
  Panel2.Visible := False;
  FGXName := TSpeedButton(Sender).Caption;
  try
    frmLLRKInPutMH_RCCG := TfrmLLRKInPutMH_RCCG.Create(Application);
    with frmLLRKInPutMH_RCCG do
    begin
      PState := 0;
      FMainId := '';
      FMYType := FGXName;
      FMYTypeFlag := FGXName;
      labMYType.Caption := Trim(FGXName) + '加工码单';
      if ShowModal = 1 then
      begin
        InitGrid();
      end;
    end;
  finally
    frmLLRKInPutMH_RCCG.Free;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.ToolButton2Click(Sender: TObject);
begin
  try
    frmZDYHelp := TfrmZDYHelp.Create(Application);
    with frmZDYHelp do
    begin
      flag := 'JGGongXu';
      flagname := '工序';
      //fnote:=True;
      //V1Note.Caption:='坯布联系号';
      if ShowModal = 1 then
      begin

      end;
    end;
  finally
    frmZDYHelp.Free;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.v1Column1CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id, Id10: Integer;
begin
//  Id:=TV1.GetColumnByFieldName('PS1').Index;
  Id := TV1.GetColumnByFieldName('PS').Index;
  Id10 := TV1.GetColumnByFieldName('MXHZPS').Index;
  if (AViewInfo.GridRecord.Values[Id]) <> (AViewInfo.GridRecord.Values[Id10]) then
  begin
    ACanvas.Brush.Color := clRed;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.v1Column17CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id, Id10: Integer;
begin
  Id := TV1.GetColumnByFieldName('KgQty').Index;
  Id10 := TV1.GetColumnByFieldName('MXHZKgQty').Index;
  if (AViewInfo.GridRecord.Values[Id]) <> (AViewInfo.GridRecord.Values[Id10]) then
  begin
    ACanvas.Brush.Color := clRed;
  end;
end;

procedure TfrmPBCGRKList_RCDJ.v1Column3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  Id, Id10: Integer;
begin
  Id := TV1.GetColumnByFieldName('Qty').Index;
  Id10 := TV1.GetColumnByFieldName('MXHZQty').Index;
  if (AViewInfo.GridRecord.Values[Id]) <> (AViewInfo.GridRecord.Values[Id10]) then
  begin
    ACanvas.Brush.Color := clRed;
  end;
end;

end.

