unit U_PBGYSInPut;

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, cxDropDownEdit, cxPC;

type
  TfrmPBGYSInPut = class(TForm)
    ADOQueryTemp: TADOQuery;
    ADOQueryCmd: TADOQuery;
    ADOQueryMain: TADOQuery;
    cxGridPopupMenu1: TcxGridPopupMenu;
    DS_HZ2: TDataSource;
    CDS_HZ2: TClientDataSet;
    cxGridPopupMenu3: TcxGridPopupMenu;
    DS_HZ3: TDataSource;
    CDS_HZ3: TClientDataSet;
    Label9: TLabel;
    Panel3: TPanel;
    cxGrid3: TcxGrid;
    TV3: TcxGridDBTableView;
    cxGridDBBankNo: TcxGridDBColumn;
    cxGridDBBankName: TcxGridDBColumn;
    cxGridLevel3: TcxGridLevel;
    Button2: TButton;
    Panel7: TPanel;
    Label15: TLabel;
    Label16: TLabel;
    Label13: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label22: TLabel;
    KHAddMX: TMemo;
    KHSJAddMX: TMemo;
    KHLXRMX: TEdit;
    KHTelMX: TEdit;
    KHNameMX: TEdit;
    KHNameJCMX: TEdit;
    KHSHMX: TEdit;
    KHSubid: TEdit;
    Button1: TButton;
    KHNoteMX: TEdit;
    Panel2: TPanel;
    Label23: TLabel;
    Label24: TLabel;
    BankNo: TEdit;
    BankName: TEdit;
    Button3: TButton;
    LabKHMXName: TLabel;
    Panel9: TPanel;
    ToolBar4: TToolBar;
    ToolButton1: TToolButton;
    ToolButton9: TToolButton;
    TBFJ: TToolButton;
    ToolButton2: TToolButton;
    ToolButton4: TToolButton;
    ToolButton8: TToolButton;
    Panel10: TPanel;
    LabGYSName: TLabel;
    cxGrid2: TcxGrid;
    TV2: TcxGridDBTableView;
    cxGridDBKHMXName: TcxGridDBColumn;
    V2ZKHMXJC: TcxGridDBColumn;
    cxGridDBCKHMXSH: TcxGridDBColumn;
    cxGridDBKHMXTel: TcxGridDBColumn;
    cxGridDBKHMXLXR: TcxGridDBColumn;
    cxGridDBKHMXNote: TcxGridDBColumn;
    cxGridLevel1: TcxGridLevel;
    V2Column1: TcxGridDBColumn;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure TBCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TBRafreshClick(Sender: TObject);
    procedure TBFJClick(Sender: TObject);
    procedure TV2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ToolButton1Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure TV2CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure cxGridDBKHMXNameCustomDrawCell(
      Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
    procedure TV3CellDblClick(Sender: TcxCustomGridTableView;
      ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
      AShift: TShiftState; var AHandled: Boolean);
    procedure Button3Click(Sender: TObject);
    procedure TV3MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure TV2FocusedRecordChanged(Sender: TcxCustomGridTableView;
      APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
      ANewItemRecordFocusingChanged: Boolean);
    procedure TV3FocusedRecordChanged(Sender: TcxCustomGridTableView;
      APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
      ANewItemRecordFocusingChanged: Boolean);
  private
    { Private declarations }
    procedure InitGrid();
    procedure InitGridBank();
    function  SaveData():Boolean;
    function  SaveDataBank():Boolean;
  public
    { Public declarations }
    FKHMainid,SJFlagTv2,SJFlagTv3,CKFlag:string;
  end;
var
  frmPBGYSInPut: TfrmPBGYSInPut;

implementation
uses
  U_DataLink,U_Fun,U_ZDYHelp,U_FjList_RZ;

{$R *.dfm}

procedure TfrmPBGYSInPut.InitGrid();
begin
  with ADOQueryTemp do
  begin
    Close;
    SQL.Clear;
    sql.Add(' select * from KH_Sub where KHMainid='''+Trim(FKHMainid)+''' and Valid=''Y'' ');
    sql.Add(' order by XHNO');
    Open;
  end;
  SCreateCDS20(ADOQueryTemp,CDS_HZ2);
  SInitCDSData20(ADOQueryTemp,CDS_HZ2);
end;
procedure TfrmPBGYSInPut.InitGridBank();
begin
  with ADOQueryTemp do
  begin
    Close;
    SQL.Clear;
    if CDS_HZ2.IsEmpty=False then
    begin
      sql.Add(' select * from KH_Sub_Bank where KHSubid='''+Trim(CDS_HZ2.fieldbyname('KHSubid').AsString)+'''');
    end else
    begin
      sql.Add(' select * from KH_Sub_Bank where 1=2');
    end;
    Open;
  end;
  SCreateCDS20(ADOQueryTemp,CDS_HZ3);
  SInitCDSData20(ADOQueryTemp,CDS_HZ3);
end;

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

procedure TfrmPBGYSInPut.TBCloseClick(Sender: TObject);
begin
  WriteCxGrid('坯布供应商资料录入1',Tv2,'客户自定义');
  WriteCxGrid('坯布供应商资料录入2',Tv3,'客户自定义');
  Close;
end;
procedure TfrmPBGYSInPut.FormShow(Sender: TObject);
begin
  ReadCxGrid('坯布供应商1',Tv2,'客户自定义');
  ReadCxGrid('坯布供应商2',Tv3,'客户自定义');
  InitGrid();
  Panel9.Align:=alClient;
  if CKFlag='99' then
  begin
    ToolButton1.Visible:=False;
    ToolButton2.Visible:=False;
    ToolButton4.Visible:=False;
    ToolButton9.Visible:=False;
  end;
end;

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



function TfrmPBGYSInPut.SaveData():Boolean;
var
  maxno:String;
begin
  result:=false;
  try
    ADOQueryCmd.Connection.BeginTrans;
    if Trim(Button1.Caption)='新增保存' then
    begin
      if GetLSNo(ADOQueryCmd,maxno,'KS','KH_Sub',4,1)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('付款单位最大ID失败!','提示',0);
        Exit;
      end;
    end else
    if Trim(Button1.Caption)='修改保存' then
    begin
      maxno:=Trim(CDS_HZ2.FieldByName('KHSubid').AsString);
    end;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('select * from KH_Sub where KHSubid='''+Trim(maxno)+'''');
      Open;
    end;
    with ADOQueryCmd do
    begin
      if Trim(Button1.Caption)='新增保存' then
      begin
        Append;
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
        FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
        FieldByName('Valid').Value:='Y';
      end else
      if Trim(Button1.Caption)='修改保存' then
      begin
        Edit;
        FieldByName('Editer').Value:=Trim(DName);
        FieldByName('EditerCode').Value:=Trim(DCode);
        FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTemp);
      end;
      FieldByName('KHMainId').Value:=Trim(FKHMainid);
      FieldByName('KHSubId').Value:=Trim(maxno);
      RTSetsavedata(ADOQueryCmd,'KH_Sub',Panel7,2);
      Post;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('UPdate KH_Sub Set XHNO=(select Max(XHNO)+1 from KH_Sub A where A.KHMainId=KH_Sub.KHMainId)');
      sql.Add(' where KHSubId='''+Trim(maxno)+'''');
      ExecSQL;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from KH_Sub where KHNameMX='''+Trim(KHNameMX.Text)+'''');
      sql.Add(' and KHMainId='''+Trim(FKHMainid)+''' and valid=''Y'' ');
      Open;
    end;
    if ADOQueryCmd.RecordCount>1 then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('应付单位(个人)重复!','提示',0);
      Exit;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from KH_Sub where KHNameJCMX='''+Trim(KHNameJCMX.Text)+'''');
      sql.Add(' and KHMainId='''+Trim(FKHMainid)+''' and valid=''Y'' ');
      Open;
    end;
    if ADOQueryCmd.RecordCount>1 then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('简称重复!','提示',0);
      Exit;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    with CDS_HZ2 do
    begin
      if Button1.Caption='新增保存' then
      begin
        Append;
      end else
      if Button1.Caption='修改保存' then
      begin
        edit;
      end;
      FieldByName('KHSubId').Value:=maxno;
      FieldByName('KHNameMX').Value:=Trim(KHNameMX.Text);
      FieldByName('KHNameJCMX').Value:=Trim(KHNameJCMX.Text);
      FieldByName('KHSHMX').Value:=Trim(KHSHMX.Text);
      FieldByName('KHTelMX').Value:=Trim(KHTelMX.Text);
      FieldByName('KHLXRMX').Value:=Trim(KHLXRMX.Text);
      FieldByName('KHNoteMX').Value:=Trim(KHNoteMX.Text);
      Post;
    end;
    result:=true;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('数据保存失败!','提示',0);
  end;
end;
function TfrmPBGYSInPut.SaveDataBank():Boolean;
var
  maxno:String;
begin
  result:=false;
  try
    ADOQueryCmd.Connection.BeginTrans;
    if Trim(Button3.Caption)='新增保存' then
    begin
      if GetLSNo(ADOQueryCmd,maxno,'BK','KH_Sub_Bank',4,1)=False then
      begin
        ADOQueryCmd.Connection.RollbackTrans;
        Application.MessageBox('开户行最大ID失败!','提示',0);
        Exit;
      end;
    end else
    if Trim(Button3.Caption)='修改保存' then
    begin
      maxno:=Trim(CDS_HZ3.FieldByName('BKID').AsString);
    end;
    with ADOQueryCmd do
    begin
      Close;
      SQL.Clear;
      sql.Add('select * from KH_Sub_Bank where BKID='''+Trim(maxno)+'''');
      Open;
    end;
    with ADOQueryCmd do
    begin
      if Trim(Button3.Caption)='新增保存' then
      begin
        Append;
        FieldByName('Filler').Value:=Trim(DName);
        FieldByName('FillerCode').Value:=Trim(DCode);
        FieldByName('FillTime').Value:=SGetServerDateTime(ADOQueryTemp);
        FieldByName('Valid').Value:='Y';
      end else
      if Trim(Button3.Caption)='修改保存' then
      begin
        Edit;
        FieldByName('Editer').Value:=Trim(DName);
        FieldByName('EditerCode').Value:=Trim(DCode);
        FieldByName('EditTime').Value:=SGetServerDateTime(ADOQueryTemp);
      end;
      FieldByName('KHMainId').Value:=Trim(FKHMainid);
      FieldByName('KHSubId').Value:=Trim(CDS_HZ2.fieldbyname('KHSubId').AsString);
      FieldByName('BKID').Value:=Trim(maxno);
      RTSetsavedata(ADOQueryCmd,'KH_Sub_Bank',Panel2,2);
      Post;
    end;

    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from KH_Sub_Bank where BankName='''+Trim(BankName.Text)+'''');
      sql.Add(' and KHSubId='''+Trim(maxno)+''' and valid=''Y'' ');
      Open;
    end;
    if ADOQueryCmd.RecordCount>1 then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('开户行重复!','提示',0);
      Exit;
    end;
    with ADOQueryCmd do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from KH_Sub_Bank where BankNo='''+Trim(BankNo.Text)+'''');
      sql.Add(' and KHSubId='''+Trim(maxno)+''' and valid=''Y'' ');
      Open;
    end;
    if ADOQueryCmd.RecordCount>1 then
    begin
      ADOQueryCmd.Connection.RollbackTrans;
      Application.MessageBox('账号重复!','提示',0);
      Exit;
    end;
    ADOQueryCmd.Connection.CommitTrans;
    with CDS_HZ3 do
    begin
      if Button3.Caption='新增保存' then
      begin
        Append;
      end else
      if Button3.Caption='修改保存' then
      begin
        edit;
      end;
      FieldByName('KHSubId').Value:=Trim(CDS_HZ2.fieldbyname('KHSubId').AsString);;
      FieldByName('BKId').Value:=maxno;
      FieldByName('BankName').Value:=Trim(BankName.Text);
      FieldByName('BankNo').Value:=Trim(BankNo.Text);
      FieldByName('Valid').Value:='Y';
      Post;
    end;
    result:=true;
  except
    ADOQueryCmd.Connection.RollbackTrans;
    Application.MessageBox('数据保存失败!','提示',0);
  end;
end;

procedure TfrmPBGYSInPut.TBFJClick(Sender: TObject);
begin
  if KHSubid.Text='' then
  begin
    Application.MessageBox('请保存数据','提示');
    exit;
  end;
  try
    frmFjList_RZ:=TfrmFjList_RZ.Create(Application);
    with frmFjList_RZ do
    begin
      fkeyNO:=Trim(KHSubid.Text);
      fType:='供应商财务';
      if ShowModal=1 then
      begin

      end;
    end;
  finally
    frmFjList_RZ.Free;
  end;
end;





procedure TfrmPBGYSInPut.TV2MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  Panel3.Visible:=True;
  Panel9.Align:=alTop;
  Panel9.Height:=245;
  InitGridBank();
  Panel2.Visible:=False;
  if Panel7.Visible=True then
  begin
    with ADOQueryTemp do
    begin
      Close;
      sql.Clear;
      sql.Add('select * from KH_Sub where KHSubId='''+Trim(CDS_HZ2.fieldbyname('KHSubId').AsString)+'''');
      Open;
    end;
    SCSHDataNew(ADOQueryTemp,Panel7,2);
    if SJFlagTv2<>'99' then
    begin
      Button1.Visible:=False;
    end else
    begin
      Button1.Visible:=True;
    end;

    if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='主' then
    begin
      KHNameMX.Color:=clMenuBar;
      KHNameMX.ReadOnly:=True;
      KHNameJCMX.Color:=clMenuBar;
      KHNameJCMX.ReadOnly:=True;
      KHLXRMX.Color:=clMenuBar;
      KHLXRMX.ReadOnly:=True;
      KHTelMX.Color:=clMenuBar;
      KHTelMX.ReadOnly:=True;
    end else
    begin
      KHNameMX.Color:=clWindow;
      KHNameMX.ReadOnly:=False;
      KHNameJCMX.Color:=clWindow;
      KHNameJCMX.ReadOnly:=False;
      KHLXRMX.Color:=clWindow;
      KHLXRMX.ReadOnly:=False;
      KHTelMX.Color:=clWindow;
      KHTelMX.ReadOnly:=False;
    end;
  end;
  if CKFlag='99' then
  begin
    Button1.Visible:=False;
  end;
end;

procedure TfrmPBGYSInPut.ToolButton1Click(Sender: TObject);
begin
  Panel9.Align:=alTop;
  Panel9.Height:=245;
  Panel7.Visible:=True;
  Button1.Caption:='新增保存';
  SClearData(Panel7,2);
  Panel2.Visible:=False;
end;

procedure TfrmPBGYSInPut.ToolButton8Click(Sender: TObject);
begin
  WriteCxGrid('坯布供应商1',Tv2,'客户自定义');
  WriteCxGrid('坯布供应商2',Tv3,'客户自定义');
  Close;
end;

procedure TfrmPBGYSInPut.ToolButton9Click(Sender: TObject);
begin
  IF CDS_HZ2.IsEmpty then exit;
  if CDS_HZ2.FieldByName('XHNO').AsInteger=1 then
  begin
    Application.MessageBox('主信息不能删除!','提示',0);
    Exit;
  end;
  if Application.MessageBox('确定要删除数据吗？','提示',32+4)<>IDYES then Exit;
  with ADOQueryCmd do
  begin
    Close;
    SQL.Clear;
    sql.Add('Update KH_Sub Set Valid=''N'',DelTime=getdate(),Deler='''+Trim(DName)+''',DelerCode='''+Trim(DCode)+'''');
    sql.add('where KHSubid ='''+Trim(CDS_HZ2.fieldbyname('KHSubid').AsString)+'''');
    ExecSQL;
  end;
  CDS_HZ2.Delete;
  {Panel7.Visible:=False;
  Panel3.Visible:=False;
  Panel9.Align:=alClient; }
end;

procedure TfrmPBGYSInPut.Button1Click(Sender: TObject);
begin
  Panel7.SetFocus;
  if Trim(KHNameMX.Text)='' then
  begin
    application.MessageBox('应付款单位(个人)不能为空','提示');
    exit;
  end;
  if Trim(KHNameJCMX.Text)='' then
  begin
    application.MessageBox('简称不能为空','提示');
    exit;
  end;
  if Button1.Caption='新增确定' then
  begin
    if CDS_HZ2.Locate('KHMXName',KHNameMX.Text,[])=True then
    begin
      Application.MessageBox('应付款单位(个人)已存在','提示');
      exit;
    end;
    if CDS_HZ2.Locate('KHNameJCMX',KHNameJCMX.Text,[])=True then
    begin
      Application.MessageBox('简称已存在','提示');
      exit;
    end;
  end;
  if SaveData() then
  begin
    Application.MessageBox('保存成功!','提示',0);
    Button1.Visible:=False;
    SJFlagTv2:='';
    Exit;
  end;
end;

procedure TfrmPBGYSInPut.TV2CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  Panel7.Visible:=True;
  SJFlagTv2:='99';
  with ADOQueryTemp do
  begin
    Close;
    sql.Clear;
    sql.Add('select * from KH_Sub where KHSubId='''+Trim(CDS_HZ2.fieldbyname('KHSubId').AsString)+'''');
    Open;
  end;
  SCSHDataNew(ADOQueryTemp,Panel7,2);
  if CKFlag<>'99' then
  begin
    Button1.Visible:=True;
    Button1.Caption:='修改保存';
  end;

end;

procedure TfrmPBGYSInPut.ToolButton4Click(Sender: TObject);
begin
  IF CDS_HZ3.IsEmpty then exit;
  if Application.MessageBox('确定要删除开户行数据吗？','提示',32+4)<>IDYES then Exit;
  with ADOQueryCmd do
  begin
    Close;
    SQL.Clear;
    sql.Add('Update KH_Sub_Bank Set Valid=''N'',DelTime=getdate(),Deler='''+Trim(DName)+''',DelerCode='''+Trim(DCode)+'''');
    sql.add('where BKID='''+Trim(CDS_HZ3.fieldbyname('BKID').AsString)+'''');
    ExecSQL;
  end;
  CDS_HZ3.Delete;
  //Panel2.Visible:=False;
end;

procedure TfrmPBGYSInPut.ToolButton2Click(Sender: TObject);
begin
  Panel7.Visible:=False;
  Panel3.Visible:=True;
  Panel2.Visible:=True;
  LabKHMXName.Caption:=Trim(CDS_HZ2.fieldbyname('KHNameMX').AsString);
  Button3.Caption:='新增保存';
end;

procedure TfrmPBGYSInPut.cxGridDBKHMXNameCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  id:Integer;
begin
   Id:=TV2.GetColumnByFieldName('XHNO').Index;//;-TV1.GroupedItemCount;
  if AViewInfo.GridRecord.Values[Id]=1 then
  begin
    ACanvas.Brush.Color:=clSkyBlue;
  end;
end;

procedure TfrmPBGYSInPut.TV3CellDblClick(Sender: TcxCustomGridTableView;
  ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
  AShift: TShiftState; var AHandled: Boolean);
begin
  if CDS_HZ3.IsEmpty then
  begin
    Panel2.Visible:=False;
    Exit;
  end;
  Panel2.Visible:=True;
  SJFlagTv3:='99';
  BankName.Text:=Trim(CDS_HZ3.fieldbyname('BankName').AsString);
  BankNo.Text:=Trim(CDS_HZ3.fieldbyname('BankNo').AsString);
  if CKFlag<>'99' then
  begin
    Button3.Visible:=True;
    Button3.Caption:='修改保存';
  end;
end;

procedure TfrmPBGYSInPut.Button3Click(Sender: TObject);
begin
  if Trim(BankName.Text)='' then
  begin
    application.MessageBox('开户行不能为空','提示');
    exit;
  end;
  if Trim(BankNo.Text)='' then
  begin
    application.MessageBox('账号不能为空','提示');
    exit;
  end;
  if Button3.Caption='新增确定' then
  begin
    if CDS_HZ3.Locate('BankName',BankName.Text,[])=True then
    begin
      Application.MessageBox('开户行已存在','提示');
      exit;
    end;
    if CDS_HZ3.Locate('BankNo',BankNo.Text,[])=True then
    begin
      Application.MessageBox('账号已存在','提示');
      exit;
    end;
  end;
  if SaveDataBank() then
  begin
    Application.MessageBox('保存成功!','提示',0);
    Button3.Visible:=False;
    SJFlagTv3:='';
    Exit;
  end;
end;

procedure TfrmPBGYSInPut.TV3MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Panel2.Visible=true then
  begin
    if CDS_HZ3.IsEmpty=False then
    begin
      BankName.Text:=Trim(CDS_HZ3.fieldbyname('BankName').AsString);
      BankNo.Text:=Trim(CDS_HZ3.fieldbyname('BankNo').AsString);
      if SJFlagTv3<>'99' then
      begin
        Button3.Visible:=False;
      end else
      begin
        Button3.Visible:=True;
      end;

    end else
    begin
      BankName.Text:='';
      BankNo.Text:='';
    end;
    if CKFlag='99' then
    begin
      Button3.Visible:=False;
    end;
    LabKHMXName.Caption:=Trim(CDS_HZ2.fieldbyname('KHNameMX').AsString)
  end;
end;

procedure TfrmPBGYSInPut.TV2FocusedRecordChanged(
  Sender: TcxCustomGridTableView; APrevFocusedRecord,
  AFocusedRecord: TcxCustomGridRecord;
  ANewItemRecordFocusingChanged: Boolean);
begin
  SJFlagTv2:='';
end;

procedure TfrmPBGYSInPut.TV3FocusedRecordChanged(
  Sender: TcxCustomGridTableView; APrevFocusedRecord,
  AFocusedRecord: TcxCustomGridRecord;
  ANewItemRecordFocusingChanged: Boolean);
begin
  SJFlagTv3:='';
end;

end.
