unit U_GYSListPBMainSub; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxGraphics, cxCustomData, cxStyles, cxTL, cxMaskEdit, DB, ADODB, cxInplaceContainer, cxDBTL, cxControls, cxTLData, ComCtrls, ToolWin, StdCtrls, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData, DBClient, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, ExtCtrls, cxSplitter, cxGridLevel, cxClasses, cxGridCustomView, cxGrid, cxGridCustomPopupMenu, cxGridPopupMenu, RM_Dataset, RM_System, RM_Common, RM_Class, RM_GridReport, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdFTP,ShellAPI,IniFiles, cxCheckBox, cxCalendar, cxButtonEdit, cxTextEdit, cxPC, cxDropDownEdit, Menus; type TfrmGYSListPBMainSub = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBDel: TToolButton; TBClose: TToolButton; ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; Panel1: TPanel; ToolButton2: TToolButton; ADOQueryMain: TADOQuery; TBExport: TToolButton; zjm: TEdit; cxGridPopupMenu2: TcxGridPopupMenu; DS_HZ: TDataSource; CDS_HZ: TClientDataSet; Tadd: TToolButton; TBedit: TToolButton; ToolButton4: TToolButton; Label5: TLabel; KHNameJC: TEdit; cxGridPopupMenu3: TcxGridPopupMenu; DS_HZ2: TDataSource; CDS_HZ2: TClientDataSet; DS_HZ3: TDataSource; CDS_HZ3: TClientDataSet; cxGridPopupMenu4: TcxGridPopupMenu; Label2: TLabel; Tchk: TToolButton; TNochk: TToolButton; Label4: TLabel; SHStatus: TComboBox; Label1: TLabel; GYSCodeFW: TEdit; Label3: TLabel; YWY: TEdit; Panel3: TPanel; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; V2Column4: TcxGridDBColumn; cxGridDBKHMXName: TcxGridDBColumn; V2ZKHMXJC: TcxGridDBColumn; cxGridDBKHMXTel: TcxGridDBColumn; cxGridDBKHMXLXR: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; cxGrid3: TcxGrid; TV3: TcxGridDBTableView; V3BankName: TcxGridDBColumn; V3BankNo: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; cxGrid1: TcxGrid; TV1: TcxGridDBTableView; V1Column4: TcxGridDBColumn; V1Column1: TcxGridDBColumn; cxGYSName: TcxGridDBColumn; cxGridDBGYSNameZC: TcxGridDBColumn; B1GYSFZRen: TcxGridDBColumn; cxGridDBGYSTel: TcxGridDBColumn; V1SHStatus: TcxGridDBColumn; V1FZR: TcxGridDBColumn; V1GYSCodeFW: TcxGridDBColumn; V1GYSType: TcxGridDBColumn; cxGridLevel2: TcxGridLevel; ToolButton3: TToolButton; ToolButton5: TToolButton; PopupMenu1: TPopupMenu; PopupMenu2: TPopupMenu; MainEdit: TMenuItem; SubEdit: TMenuItem; SubDel: TMenuItem; V2Column1: TcxGridDBColumn; V2Column2: TcxGridDBColumn; MainView: TMenuItem; SubView: TMenuItem; V3Column2: TcxGridDBColumn; V3Column3: TcxGridDBColumn; MainBankAdd: TMenuItem; SubBankAdd: TMenuItem; PopupMenu3: TPopupMenu; BankEdit: TMenuItem; BankDel: TMenuItem; BankView: TMenuItem; cxSplitter1: TcxSplitter; Button1: TButton; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure TBDelClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure zjmChange(Sender: TObject); procedure TBExportClick(Sender: TObject); procedure TBeditClick(Sender: TObject); procedure TaddClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure cxTabControl1Change(Sender: TObject); procedure ToolButton4Click(Sender: TObject); procedure TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure TchkClick(Sender: TObject); procedure TNochkClick(Sender: TObject); procedure TV2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure MainEditClick(Sender: TObject); procedure SubEditClick(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure SubDelClick(Sender: TObject); procedure cxGridDBKHMXNameCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure MainViewClick(Sender: TObject); procedure SubViewClick(Sender: TObject); procedure TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure MainBankAddClick(Sender: TObject); procedure BankEditClick(Sender: TObject); procedure BankDelClick(Sender: TObject); procedure SubBankAddClick(Sender: TObject); procedure V3Column3CustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); procedure BankViewClick(Sender: TObject); procedure TV3DblClick(Sender: TObject); private { Private declarations } ColorInt:Integer; procedure InitGrid(); procedure setstatus(); procedure InitGridBankMain(); procedure InitGridBankSub(); procedure InitGridSub(); public fDEFstr5:string; canshu1,FGYSType:string; end; //var //frmGYSListPB: TfrmGYSListPB; implementation uses U_DataLink,U_Fun,U_ZDYHelp, U_FjList_RZ,U_PBGYSInPutMain,U_PBGYSInPut,U_PBGYSInPutSub,U_PBGYSInPutGR ,U_PBGYSInPutMainBank,U_PBGYSInPutSubBank; {$R *.dfm} procedure TfrmGYSListPBMainSub.setstatus(); begin tchk.Visible:=false; tnochk.Visible:=false; Tadd.Visible:=false; TBedit.Visible:=false; TBDel.Visible:=false; IF trim(Self.Caption)='坯布供应商录入(高)*'then begin Tadd.Visible:=True; TBedit.Visible:=True; TBDel.Visible:=True; tchk.Visible:=False; tNochk.Visible:=False; MainEdit.Visible:=True; MainView.Visible:=True; SubEdit.Visible:=True; SubDel.Visible:=True; SubView.Visible:=True; TBExport.Visible:=True; MainBankAdd.Visible:=True; SubBankAdd.Visible:=True; BankEdit.Visible:=True; BankDel.Visible:=True; end else IF trim(Self.Caption)='坯布供应商审核*'then begin Tadd.Visible:=false; TBedit.Visible:=false; TBDel.Visible:=false; tchk.Visible:=True; tNochk.Visible:=True; MainEdit.Visible:=False; MainView.Visible:=True; SubEdit.Visible:=False; SubDel.Visible:=false; SubView.Visible:=True; TBExport.Visible:=True; MainBankAdd.Visible:=false; SubBankAdd.Visible:=false; BankEdit.Visible:=false; BankDel.Visible:=false; end else IF trim(Self.Caption)='坯布供应商录入*'then begin Tadd.Visible:=True; TBedit.Visible:=True; TBDel.Visible:=False; tchk.Visible:=False; tNochk.Visible:=False; MainEdit.Visible:=True; MainView.Visible:=True; SubEdit.Visible:=True; SubDel.Visible:=True; SubView.Visible:=True; TBExport.Visible:=True; MainBankAdd.Visible:=True; SubBankAdd.Visible:=True; BankEdit.Visible:=True; BankDel.Visible:=True; end else IF trim(Self.Caption)='坯布供应商查询*'then begin Tadd.Visible:=False; TBedit.Visible:=False; TBDel.Visible:=False; tchk.Visible:=False; tNochk.Visible:=False; MainEdit.Visible:=False; MainView.Visible:=True; SubEdit.Visible:=False; SubDel.Visible:=False; SubView.Visible:=True; TBExport.Visible:=False; MainBankAdd.Visible:=False; SubBankAdd.Visible:=False; BankEdit.Visible:=False; BankDel.Visible:=False; end; end; procedure TfrmGYSListPBMainSub.InitGrid(); begin with ADOQueryMain do begin Filtered:=False; Close; SQL.Clear; sql.Add(' select *,zjm=dbo.getpinyin(KHName) '); sql.add(',SHStatus=(case when isnull(status,''0'')=''0'' then ''未审核'' else ''已审核'' end)'); sql.Add(' from KH_Main '); sql.add(' where isnull(KHType,'''')=''坯布'' and isnull(Valid,'''')=''Y'' '); if Trim(Self.Caption)='坯布供应商录入*' then begin sql.Add(' and Fillercode='''+Trim(DCode)+''''); end; Open; end; SCreateCDS20(ADOQueryMain,CDS_HZ); SInitCDSData20(ADOQueryMain,CDS_HZ); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub where KHMainid='''+Trim(CDS_HZ.fieldbyname('KHMainid').asstring)+''' and isnull(Valid,'''')=''Y'''); sql.Add(' order by XHNO'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ2); SInitCDSData20(ADOQueryTemp,CDS_HZ2); with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub_Bank where KHSubid='''+Trim(CDS_HZ2.fieldbyname('KHSubid').asstring)+''' and isnull(Valid,'''')=''Y'''); Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ3); SInitCDSData20(ADOQueryTemp,CDS_HZ3); end; procedure TfrmGYSListPBMainSub.FormDestroy(Sender: TObject); begin //frmGYSListPB:=nil; end; procedure TfrmGYSListPBMainSub.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmGYSListPBMainSub.TBCloseClick(Sender: TObject); begin WriteCxGrid('PBGYS11',Tv1,'供应商管理'); WriteCxGrid('PBGYS21',Tv2,'供应商管理'); WriteCxGrid('PBGYS31',Tv3,'供应商管理'); Close; end; procedure TfrmGYSListPBMainSub.TBDelClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; if CDS_HZ.Locate('ssel',true,[])=false then begin Application.MessageBox('没有选择数据!','提示',0); Exit; end; if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; try ADOQueryCmd.Connection.BeginTrans; CDS_HZ.DisableControls; with CDS_HZ do begin while Locate('SSel',True,[]) do begin with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('UPdate KH_Main Set Valid=''N'',DelTime=getdate(),Deler='''+Trim(DName)+''',DelerCode='''+Trim(DCode)+''''); sql.Add(' where KHMainID='''+Trim(CDS_HZ.fieldbyname('KHMainID').AsString)+''''); sql.Add('UPdate KH_Sub Set Valid=''N'',DelTime=getdate(),Deler='''+Trim(DName)+''',DelerCode='''+Trim(DCode)+''''); sql.Add(' where KHMainID='''+Trim(CDS_HZ.fieldbyname('KHMainID').AsString)+''''); sql.Add('UPdate KH_Sub_Bank Set Valid=''N'',DelTime=getdate(),Deler='''+Trim(DName)+''',DelerCode='''+Trim(DCode)+''''); sql.Add(' where KHMainID='''+Trim(CDS_HZ.fieldbyname('KHMainID').AsString)+''''); ExecSQL; end; CDS_HZ.Delete; end; end; CDS_HZ.EnableControls; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('操作失败!','提示',0); CDS_HZ.EnableControls; end; end; procedure TfrmGYSListPBMainSub.FormShow(Sender: TObject); begin ReadCxGrid('PBGYS11',Tv1,'供应商管理'); ReadCxGrid('PBGYS21',Tv2,'供应商管理'); ReadCxGrid('PBGYS31',Tv3,'供应商管理'); setstatus(); InitGrid(); end; procedure TfrmGYSListPBMainSub.TBRafreshClick(Sender: TObject); begin ToolBar1.SetFocus; InitGrid(); end; procedure TfrmGYSListPBMainSub.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 TfrmGYSListPBMainSub.zjmChange(Sender: TObject); begin ToolButton2.Click; end; procedure TfrmGYSListPBMainSub.TBExportClick(Sender: TObject); begin if ADOQueryMain.IsEmpty then Exit; TcxGridToExcel(self.Caption,cxgrid2); // SelExportData(Tv2,ADOQueryMain,'供应商资料列表'); end; procedure TfrmGYSListPBMainSub.TBeditClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; try frmPBGYSInPutSub:=TfrmPBGYSInPutSub.Create(Application); with frmPBGYSInPutSub do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainid').AsString); FKHSubId:=''; LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutSub.Free; end; end; procedure TfrmGYSListPBMainSub.TaddClick(Sender: TObject); begin try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=''; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end; procedure TfrmGYSListPBMainSub.FormCreate(Sender: TObject); begin canshu1:=trim(DParameters1); FGYSType:=trim(DParameters2); ReadCxGrid('GYS1',Tv1,'客户自定义'); ReadCxGrid('GYS2',Tv2,'客户自定义'); ReadCxGrid('GYS3',Tv3,'客户自定义'); end; procedure TfrmGYSListPBMainSub.cxTabControl1Change(Sender: TObject); begin setstatus(); InitGrid(); end; procedure TfrmGYSListPBMainSub.ToolButton4Click(Sender: TObject); begin if CDS_HZ.IsEmpty then Exit; try frmFjList_RZ:=TfrmFjList_RZ.Create(Application); with frmFjList_RZ do begin fkeyNO:=Trim(Self.CDS_HZ.fieldbyname('KHMainid').AsString); fType:='供应商资料'; if ShowModal=1 then begin end; end; finally frmFjList_RZ.Free; end; end; procedure TfrmGYSListPBMainSub.TV1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin ColorInt:=1; InitGridSub(); InitGridBankMain(); end; procedure TfrmGYSListPBMainSub.InitGridSub(); begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub where KHMainid='''+Trim(CDS_HZ.fieldbyname('KHMainid').asstring)+''''); if CDS_HZ.IsEmpty then begin sql.Add(' and 1=2'); end else begin sql.Add(' and valid=''Y'' '); end; sql.Add(' order by XHNO'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ2); SInitCDSData20(ADOQueryTemp,CDS_HZ2); end; procedure TfrmGYSListPBMainSub.InitGridBankMain(); begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub_Bank where KHMainid='''+Trim(CDS_HZ.fieldbyname('KHMainid').asstring)+''''); if CDS_HZ.IsEmpty then begin sql.Add(' and 1=2'); end else begin sql.Add(' and valid=''Y'' '); end; sql.Add(' order by XH'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ3); SInitCDSData20(ADOQueryTemp,CDS_HZ3); end; procedure TfrmGYSListPBMainSub.InitGridBankSub(); begin with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub_Bank where KHSubid='''+Trim(CDS_HZ2.fieldbyname('KHSubid').asstring)+''''); if CDS_HZ2.IsEmpty then begin sql.Add(' and 1=2'); end else begin sql.Add(' and valid=''Y'' '); end; sql.Add(' order by XH'); Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ3); SInitCDSData20(ADOQueryTemp,CDS_HZ3); end; procedure TfrmGYSListPBMainSub.TV1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if CDS_HZ.IsEmpty then Exit; try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); frmPBGYSInPutMain.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end; procedure TfrmGYSListPBMainSub.TchkClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; if CDS_HZ.Locate('ssel',true,[])=false then begin Application.MessageBox('没有选择数据!','提示',0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_HZ do begin DisableControls; First; while Locate('SSel',True,[]) do begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update KH_Main SET status=1,chker='''+trim(DName)+''',chkTime=getdate() '); sql.Add('where KHMainid='+quotedstr(trim(CDS_HZ.fieldbyname('KHMainid').AsString))); execsql; end; Edit; FieldByName('SSel').Value:=false; FieldByName('SHStatus').Value:='已审核'; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; CDS_HZ.EnableControls; application.MessageBox('审核失败!','提示信息',0); end; end; procedure TfrmGYSListPBMainSub.TNochkClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; if CDS_HZ.Locate('ssel',true,[])=false then begin Application.MessageBox('没有选择数据!','提示',0); Exit; end; try ADOQueryCmd.Connection.BeginTrans; with CDS_HZ do begin DisableControls; First; while Locate('SSel',True,[]) do begin with ADOQueryCmd do begin close; sql.Clear; sql.Add('update KH_Main SET status=0,chker='''',chkTime=null'); sql.Add('where KHMainid='+quotedstr(trim(CDS_HZ.fieldbyname('KHMainid').AsString))); execsql; end; Edit; FieldByName('SSel').Value:=false; FieldByName('SHStatus').Value:='未审核'; end; EnableControls; end; ADOQueryCmd.Connection.CommitTrans; except ADOQueryCmd.Connection.RollbackTrans; CDS_HZ.EnableControls; application.MessageBox('撤销审核失败!','提示信息',0); end; end; procedure TfrmGYSListPBMainSub.TV2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if Trim(CDS_HZ2.fieldbyname('KHMainId').AsString)=Trim(CDS_HZ2.fieldbyname('KHSubId').AsString) then begin ColorInt:=2; end else begin ColorInt:=3; end; with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from KH_Sub_Bank where KHSubid='''+Trim(CDS_HZ2.fieldbyname('KHSubid').asstring)+''' and valid=''Y'' '); if CDS_HZ2.IsEmpty then begin sql.Add(' and 1=2'); end; Open; end; SCreateCDS20(ADOQueryTemp,CDS_HZ3); SInitCDSData20(ADOQueryTemp,CDS_HZ3); end; procedure TfrmGYSListPBMainSub.MainEditClick(Sender: TObject); begin if CDS_HZ.IsEmpty then Exit; try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end; procedure TfrmGYSListPBMainSub.SubEditClick(Sender: TObject); begin if CDS_HZ2.IsEmpty then exit; if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='子公司' then begin try frmPBGYSInPutSub:=TfrmPBGYSInPutSub.Create(Application); with frmPBGYSInPutSub do begin FKHMainid:=Trim(Self.CDS_HZ2.fieldbyname('KHMainid').AsString); FKHSubId:=Trim(Self.CDS_HZ2.fieldbyname('KHSubId').AsString); LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutSub.Free; end; end else if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='个人' then begin try frmPBGYSInPutGR:=TfrmPBGYSInPutGR.Create(Application); with frmPBGYSInPutGR do begin FKHMainid:=Trim(Self.CDS_HZ2.fieldbyname('KHMainid').AsString); FKHSubId:=Trim(Self.CDS_HZ2.fieldbyname('KHSubId').AsString); LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutGR.Free; end; end; end; procedure TfrmGYSListPBMainSub.ToolButton3Click(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; try frmPBGYSInPutGR:=TfrmPBGYSInPutGR.Create(Application); with frmPBGYSInPutGR do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainid').AsString); FKHSubId:=''; LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutGR.Free; end; end; procedure TfrmGYSListPBMainSub.SubDelClick(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; end; procedure TfrmGYSListPBMainSub.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:=clMenuBar; end else begin ACanvas.Brush.Color:=clSkyBlue; end; end; procedure TfrmGYSListPBMainSub.MainViewClick(Sender: TObject); begin if CDS_HZ.IsEmpty then Exit; try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); frmPBGYSInPutMain.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end; procedure TfrmGYSListPBMainSub.SubViewClick(Sender: TObject); begin if CDS_HZ2.IsEmpty then exit; if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='主公司' then begin if CDS_HZ.IsEmpty then Exit; try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); frmPBGYSInPutMain.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end else if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='子公司' then begin try frmPBGYSInPutSub:=TfrmPBGYSInPutSub.Create(Application); with frmPBGYSInPutSub do begin FKHMainid:=Trim(Self.CDS_HZ2.fieldbyname('KHMainid').AsString); FKHSubId:=Trim(Self.CDS_HZ2.fieldbyname('KHSubId').AsString); LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); frmPBGYSInPutSub.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutSub.Free; end; end else if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='个人' then begin try frmPBGYSInPutGR:=TfrmPBGYSInPutGR.Create(Application); with frmPBGYSInPutGR do begin FKHMainid:=Trim(Self.CDS_HZ2.fieldbyname('KHMainid').AsString); FKHSubId:=Trim(Self.CDS_HZ2.fieldbyname('KHSubId').AsString); LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); frmPBGYSInPutGR.TBSave.Visible:=False; frmPBGYSInPutGR.TBadd.Visible:=False; frmPBGYSInPutGR.TBDel.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutGR.Free; end; end; end; procedure TfrmGYSListPBMainSub.TV2CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin if CDS_HZ2.IsEmpty then exit; if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='主公司' then begin if CDS_HZ.IsEmpty then Exit; try frmPBGYSInPutMain:=TfrmPBGYSInPutMain.Create(Application); with frmPBGYSInPutMain do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); frmPBGYSInPutMain.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutMain.Free; end; end else if Trim(CDS_HZ2.fieldbyname('DataType').AsString)='子公司' then begin try frmPBGYSInPutSub:=TfrmPBGYSInPutSub.Create(Application); with frmPBGYSInPutSub do begin FKHMainid:=Trim(Self.CDS_HZ2.fieldbyname('KHMainid').AsString); FKHSubId:=Trim(Self.CDS_HZ2.fieldbyname('KHSubId').AsString); LabGYSName.caption:=Trim(Self.CDS_HZ.fieldbyname('KHName').AsString); frmPBGYSInPutSub.TBSave.Visible:=False; if ShowModal=1 then begin TBRafresh.Click; end; end; finally frmPBGYSInPutSub.Free; end; end; end; procedure TfrmGYSListPBMainSub.MainBankAddClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; try frmPBGYSInPutMainBank:=TfrmPBGYSInPutMainBank.Create(Application); with frmPBGYSInPutMainBank do begin FKHMainid:=Trim(CDS_HZ.fieldbyname('KHMainId').AsString); PState:=0; if ShowModal=1 then begin Self.InitGridBankMain(); end; end; finally frmPBGYSInPutMainBank.Free; end; end; procedure TfrmGYSListPBMainSub.BankEditClick(Sender: TObject); begin if CDS_HZ3.IsEmpty then exit; if Trim(CDS_HZ3.fieldbyname('KHMainId').AsString)=Trim(CDS_HZ3.fieldbyname('KHSubId').AsString) then begin try frmPBGYSInPutMainBank:=TfrmPBGYSInPutMainBank.Create(Application); with frmPBGYSInPutMainBank do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); FBKID:=Trim(Self.CDS_HZ3.fieldbyname('BKID').AsString); PState:=1; if ShowModal=1 then begin Self.InitGridBankMain(); end; end; finally frmPBGYSInPutMainBank.Free; end; end else begin try frmPBGYSInPutSubBank:=TfrmPBGYSInPutSubBank.Create(Application); with frmPBGYSInPutSubBank do begin FKHMainid:=Trim(CDS_HZ3.fieldbyname('KHMainId').AsString); FKHSubid:=Trim(CDS_HZ3.fieldbyname('KHSubid').AsString); FBKID:=Trim(Self.CDS_HZ3.fieldbyname('BKID').AsString); PState:=1; if ShowModal=1 then begin Self.InitGridBankSub(); end; end; finally frmPBGYSInPutSubBank.Free; end; end; end; procedure TfrmGYSListPBMainSub.BankDelClick(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; end; procedure TfrmGYSListPBMainSub.SubBankAddClick(Sender: TObject); begin if CDS_HZ.IsEmpty then exit; if Trim(CDS_HZ2.fieldbyname('KHMainId').AsString)=Trim(CDS_HZ2.fieldbyname('KHSubId').AsString) then begin try frmPBGYSInPutMainBank:=TfrmPBGYSInPutMainBank.Create(Application); with frmPBGYSInPutMainBank do begin FKHMainid:=Trim(CDS_HZ.fieldbyname('KHMainId').AsString); PState:=0; if ShowModal=1 then begin Self.InitGridBankMain(); end; end; finally frmPBGYSInPutMainBank.Free; end; end else begin try frmPBGYSInPutSubBank:=TfrmPBGYSInPutSubBank.Create(Application); with frmPBGYSInPutSubBank do begin FKHMainid:=Trim(CDS_HZ2.fieldbyname('KHMainId').AsString); FKHSubid:=Trim(CDS_HZ2.fieldbyname('KHSubid').AsString); PState:=0; if ShowModal=1 then begin Self.InitGridBankSub(); end; end; finally frmPBGYSInPutSubBank.Free; end; end; end; procedure TfrmGYSListPBMainSub.V3Column3CustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin if ColorInt=1 then begin ACanvas.Brush.Color:=$0047D5FE; end else if ColorInt=2 then begin ACanvas.Brush.Color:=clMenuBar; end else if ColorInt=3 then begin ACanvas.Brush.Color:=clSkyBlue; end; end; procedure TfrmGYSListPBMainSub.BankViewClick(Sender: TObject); begin if CDS_HZ3.IsEmpty then exit; if Trim(CDS_HZ3.fieldbyname('KHMainId').AsString)=Trim(CDS_HZ3.fieldbyname('KHSubId').AsString) then begin try frmPBGYSInPutMainBank:=TfrmPBGYSInPutMainBank.Create(Application); with frmPBGYSInPutMainBank do begin FKHMainid:=Trim(Self.CDS_HZ.fieldbyname('KHMainId').AsString); FBKID:=Trim(Self.CDS_HZ3.fieldbyname('BKID').AsString); PState:=2; if ShowModal=1 then begin Self.InitGridBankMain(); end; end; finally frmPBGYSInPutMainBank.Free; end; end else begin try frmPBGYSInPutSubBank:=TfrmPBGYSInPutSubBank.Create(Application); with frmPBGYSInPutSubBank do begin FKHMainid:=Trim(CDS_HZ3.fieldbyname('KHMainId').AsString); FKHSubid:=Trim(CDS_HZ3.fieldbyname('KHSubid').AsString); FBKID:=Trim(Self.CDS_HZ3.fieldbyname('BKID').AsString); PState:=2; if ShowModal=1 then begin Self.InitGridBankSub(); end; end; finally frmPBGYSInPutSubBank.Free; end; end; end; procedure TfrmGYSListPBMainSub.TV3DblClick(Sender: TObject); begin BankView.Click; end; end.