unit U_ZdyAttInputGYS; 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 TfrmZdyAttInputGYS = class(TForm) ADOQueryTemp: TADOQuery; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; cxGridPopupMenu2: TcxGridPopupMenu; DS_HZ: TDataSource; CDS_HZ: TClientDataSet; cxGridPopupMenu1: TcxGridPopupMenu; DS_HZ2: TDataSource; CDS_HZ2: TClientDataSet; ADOQueryMain2: TADOQuery; cxGridPopupMenu3: TcxGridPopupMenu; DS_HZ3: TDataSource; ADOQueryMain3: TADOQuery; CDS_HZ3: TClientDataSet; Panel4: TPanel; Label1: TLabel; Label9: TLabel; Panel3: TPanel; ToolBar3: TToolBar; ToolButton5: TToolButton; ToolButton6: TToolButton; cxGrid3: TcxGrid; TV3: TcxGridDBTableView; cxGridDBBankNo: TcxGridDBColumn; cxGridDBBankName: TcxGridDBColumn; cxGridLevel3: TcxGridLevel; Panel8: TPanel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label10: TLabel; GYSName: TEdit; GYSFZRen: TEdit; GYSNameZC: TEdit; GYSTel: TEdit; GYSCodeFW: TMemo; Note: TMemo; GYSAdd: TMemo; ToolBar1: TToolBar; ToolButton3: TToolButton; Panel1: TPanel; Label2: TLabel; GYSNo: TEdit; Panel9: TPanel; ToolBar4: TToolBar; ToolButton1: TToolButton; Panel10: TPanel; Label21: TLabel; cxGrid2: TcxGrid; TV2: TcxGridDBTableView; V2KHMXNo: TcxGridDBColumn; cxGridDBKHMXName: TcxGridDBColumn; V2ZKHMXJC: TcxGridDBColumn; cxGridDBCKHMXSH: TcxGridDBColumn; cxGridDBKHMXTel: TcxGridDBColumn; cxGridDBKHMXLXR: TcxGridDBColumn; cxGridDBKHMXNote: TcxGridDBColumn; cxGridLevel1: TcxGridLevel; V2KHMXAdd: TcxGridDBColumn; V2KHMXSJAdd: TcxGridDBColumn; ToolButton7: TToolButton; ToolButton8: TToolButton; ToolButton9: TToolButton; Label23: TLabel; Edit1: TEdit; Label24: TLabel; Edit2: TEdit; Button2: TButton; TBFJ: TToolButton; Panel7: TPanel; Label15: TLabel; Label16: TLabel; Label13: TLabel; Label17: TLabel; Label18: TLabel; Label19: TLabel; Label20: TLabel; Label22: TLabel; KHMXAdd: TMemo; KHMXSJAdd: TMemo; KHMXLXR: TEdit; KHMXTel: TEdit; KHMXName: TEdit; KHMXJC: TEdit; KHMXSH: TEdit; KHSubid: TEdit; Button1: TButton; KHMXNote: TEdit; Button3: TButton; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure TBFJClick(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure ToolButton6Click(Sender: TObject); procedure TV2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure ToolButton1Click(Sender: TObject); procedure ToolButton8Click(Sender: TObject); procedure ToolButton7Click(Sender: TObject); procedure ToolButton9Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } procedure InitGrid(); function SaveData():Boolean; function SaveData2():Boolean; procedure SSetsaveSqlNewTClient(ADOQueryCmd:TClientDataSet; Myparent:TWinControl;MyTag:integer); procedure SCSHDataNewTclient(ADOQueryTmp:TClientDataSet;mParent:TWinControl;FTag:Integer); public { Public declarations } RKFlag,FKHMainid,formid:String; fDEFstr5:string; end; var frmZdyAttInputGYS: TfrmZdyAttInputGYS; implementation uses U_DataLink,U_Fun,U_ZDYHelp,U_FjList_RZ; {$R *.dfm} procedure TfrmZdyAttInputGYS.InitGrid(); begin with ADOQueryMain do begin Filtered:=False; Close; SQL.Clear; sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+''''); Open; end; //主表 if ADOQueryMain.IsEmpty=false then SCSHDataNew(ADOQueryMain,panel8,2) else begin //GYSFZRen.Text:=Trim(DName); end; //表2 with ADOQueryMain2 do begin Filtered:=False; Close; SQL.Clear; sql.Add(' select * from KH_Sub where KHMainid='''+Trim(FKHMainid)+''''); sql.Add(' order by XHNO'); Open; end; SCreateCDS20(ADOQueryMain2,CDS_HZ2); SInitCDSData20(ADOQueryMain2,CDS_HZ2); //表3 with ADOQueryMain3 do begin Filtered:=False; Close; SQL.Clear; sql.Add(' select * from KH_Sub_Bank where KHSubid='''+Trim(KHSubid.Text)+''''); Open; end; SCreateCDS20(ADOQueryMain3,CDS_HZ3); SInitCDSData20(ADOQueryMain3,CDS_HZ3); if CDS_HZ3.IsEmpty then begin with CDS_HZ3 do begin append; post; end; end; end; procedure TfrmZdyAttInputGYS.FormDestroy(Sender: TObject); begin frmZdyAttInputGYS:=nil; end; procedure TfrmZdyAttInputGYS.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmZdyAttInputGYS.TBCloseClick(Sender: TObject); begin WriteCxGrid('坯布供应商资料录入1',Tv2,'客户自定义'); WriteCxGrid('坯布供应商资料录入2',Tv3,'客户自定义'); Close; end; procedure TfrmZdyAttInputGYS.FormShow(Sender: TObject); begin ReadCxGrid('坯布供应商资料录入1',Tv2,'客户自定义'); ReadCxGrid('坯布供应商资料录入2',Tv3,'客户自定义'); InitGrid(); end; procedure TfrmZdyAttInputGYS.TBRafreshClick(Sender: TObject); begin InitGrid(); end; procedure TfrmZdyAttInputGYS.SSetsaveSqlNewTClient(ADOQueryCmd:TClientDataSet; Myparent:TWinControl;MyTag:integer); var i:Integer; MCode:String; begin with Myparent do begin for i:=0 to ControlCount-1 do begin if Controls[i].Tag=MyTag then begin if Controls[i] is TEdit then begin if Trim(TEdit(Controls[i]).Text)<>'' then ADOQueryCmd.FieldByName(Controls[i].Name).Value:=Trim(TEdit(Controls[i]).Text) else ADOQueryCmd.FieldByName(Controls[i].Name).Value:=Null; end else if Controls[i] is TRichEdit then begin ADOQueryCmd.FieldByName(Controls[i].Name).Value:=TRichEdit(Controls[i]).Text; end else if Controls[i] is TCheckBox then begin if TCheckBox(Controls[i]).Checked=True then ADOQueryCmd.FieldByName(Controls[i].Name).Value:=1 else ADOQueryCmd.FieldByName(Controls[i].Name).Value:=0; end else if Controls[i] is TMemo then begin ADOQueryCmd.FieldByName(Controls[i].Name).Value:=TMemo(Controls[i]).Text; end else if Controls[i] is TComboBox then begin ADOQueryCmd.FieldByName(Controls[i].Name).Value:=Trim(TComboBox(Controls[i]).Text); end else if Controls[i] is TDateTimePicker then begin if TDateTimePicker(Controls[i]).ShowCheckbox then begin if TDateTimePicker(Controls[i]).Checked then ADOQueryCmd.FieldByName(Controls[i].Name).Value:=TDateTimePicker(Controls[i]).DateTime else ADOQueryCmd.FieldByName(Controls[i].Name).Value:=null; end else ADOQueryCmd.FieldByName(Controls[i].Name).Value:=TDateTimePicker(Controls[i]).DateTime; end else if Controls[i] is TcxButtonEdit then begin if (TcxButtonEdit(Controls[i]).BeepOnEnter=True) or (TcxButtonEdit(Controls[i]).ParentShowHint=True) then ADOQueryCmd.FieldByName(Controls[i].Name).Value:=Trim(TcxButtonEdit(Controls[i]).Text); if TcxButtonEdit(Controls[i]).ParentShowHint=False then begin MCode:=Copy(Trim(Controls[i].Name),1,Length(Trim(Controls[i].Name))-4); ADOQueryCmd.FieldByName(MCode).Value:=Trim(TcxButtonEdit(Controls[i]).Hint); end; end; end; end; end; end; function TfrmZdyAttInputGYS.SaveData():Boolean; var maxId,CRID,fzdyCode,FYSSubId,maxno,maxnum,FMXNO:String; begin ///取maxId result:=false; ADOQueryCmd.Connection.BeginTrans; if Trim(FKHMainid)='' then begin if GetLSNo(ADOQueryCmd,maxId,'KH','KH_Main',4,1)=False then begin Result:=False; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; if GetLSNo(ADOQueryCmd,fzdyCode,'PB','KH_Main',4,0)=False then begin Result:=False; ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取最大号失败!','提示',0); Exit; end; GYSNo.Text:=Trim(fzdyCode); end else begin maxId:=Trim(FKHMainid); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from KH_Main where KHMainID='''+Trim(FKHMainid)+''''); Open; If IsEmpty then begin append; FieldByName('Filler').Value:=Trim(DName); FieldByName('fillcode').Value:=Trim(DCode); end else begin Edit; FieldByName('Editer').Value:=Trim(DName); FieldByName('Edittime').Value:=SGetServerDateTime(ADOQueryTemp); end; FieldByName('KHMainID').Value:=Trim(maxId); FieldByName('GYSType').Value:='坯布'; SSetsaveSqlNew(ADOQueryCmd,'KH_Main',panel8,2); post; end; if FKHMainid='' then begin if GetLSNo(ADOQueryCmd,maxno,'HB','KH_Sub',4,1)=False then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取系人最大ID失败!','提示',0); Exit; end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from KH_Sub where KHSubid='''+Trim(maxno)+''''); Open; If IsEmpty then begin append; FieldByName('XHNo').Value:=1; end else begin Edit; end; FieldByName('KHSubid').Value:=Trim(maxno); FieldByName('KHMainID').Value:=Trim(maxId); FieldByName('KHMXName').Value:=Trim(GYSName.Text); FieldByName('KHMXJC').Value:=Trim(GYSNameZC.Text); FieldByName('KHMXLXR').Value:=Trim(GYSFZRen.Text); FieldByName('KHMXTel').Value:=Trim(GYSTel.Text); FieldByName('KHMXAdd').Value:=Trim(GYSAdd.Text); FieldByName('KHMXSJAdd').Value:=Trim(GYSAdd.Text); FieldByName('KHMXNo').Value:=Trim(fzdyCode); //FieldByName('KHMXNote').Value:=Trim(Note.Text); post; end; end; FKHMainid:=maxId; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from KH_Main where GYSName='''+Trim(GYSName.Text)+''''); sql.Add(' and GYSType=''坯布'' '); 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_Main where GYSNameZC='''+Trim(GYSNameZC.Text)+''''); sql.Add(' and GYSType=''坯布'' '); Open; end; if ADOQueryCmd.RecordCount>1 then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('供应商简称重复!','提示',0); Exit; end; ///表2 with CDS_HZ2 do begin First; while not eof do begin if CDS_HZ2.FieldByName('KHSubid').AsString='' then begin if GetLSNo(ADOQueryCmd,maxno,'ZH','KH_Sub',4,1)=False then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取系人最大ID失败!','提示',0); Exit; end; if GetLSNo(ADOQueryCmd,FMXNO,'MX','KH_Sub',4,0)=False then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取系人最大ID失败!','提示',0); Exit; end; end else 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; If IsEmpty then begin append; FieldByName('XHNo').Value:=99; FieldByName('KHMXNo').Value:=Trim(FMXNO); end else begin Edit; end; RTSetSaveDataCDS(ADOQueryCmd,Tv2,CDS_HZ2,'KH_Sub',0); FieldByName('KHSubid').Value:=Trim(maxno); FieldByName('KHMainID').Value:=Trim(maxId); post; end; with ADOQueryCmd do begin Close; sql.Clear; sql.Add('select * from KH_Sub where KHMXName='''+Trim(CDS_HZ2.FieldByName('KHMXName').AsString)+''''); //sql.Add(' and GYSType=''坯布'' '); 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 KHMXJC='''+Trim(CDS_HZ2.FieldByName('KHMXJC').AsString)+''''); //sql.Add(' and GYSType=''坯布'' '); Open; end; if ADOQueryCmd.RecordCount>1 then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('供应商简称重复!','提示',0); Exit; end; Next; end; end; //表3 with CDS_HZ3 do begin CDS_HZ3.First; while not Eof do begin if Trim(CDS_HZ3.fieldbyname('BKID').AsString)='' then begin if GetLSNo(ADOQueryCmd,maxnum,'BK','KH_Sub_Bank',4,1)=False then begin ADOQueryCmd.Connection.RollbackTrans; Application.MessageBox('取系人最大ID失败!','提示',0); Exit; end; end else begin maxnum:=Trim(CDS_HZ3.fieldbyname('BKID').AsString); end; with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from KH_Sub_Bank where BKID='''+Trim(maxnum)+''''); Open; If IsEmpty then begin append; end else begin Edit; end; RTSetSaveDataCDS(ADOQueryCmd,Tv3,CDS_HZ3,'KH_Sub_Bank',0); FieldByName('BKID').Value:=Trim(maxnum); FieldByName('KHMainID').Value:=Trim(maxId); FieldByName('KHSubid').Value:=Trim(KHSubid.Text); post; end; CDS_HZ3.Next; end; end; ADOQueryCmd.Connection.CommitTrans; result:=true; end; procedure TfrmZdyAttInputGYS.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 TfrmZdyAttInputGYS.ToolButton5Click(Sender: TObject); begin ToolBar3.SetFocus; with CDS_HZ3 do begin Append; post; end; end; procedure TfrmZdyAttInputGYS.ToolButton6Click(Sender: TObject); begin IF CDS_HZ3.IsEmpty then exit; CDS_HZ3.DisableControls; with CDS_HZ3 do begin if Trim(CDS_HZ3.fieldbyname('BKID').AsString)<>'' then begin if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; with ADOQueryMain3 do begin Close; SQL.Clear; sql.Add('delete from KH_Sub_Bank where BKID ='''+Trim(CDS_HZ3.fieldbyname('BKID').AsString)+''''); ExecSQL; end; end; Delete; end; CDS_HZ3.EnableControls; end; function TfrmZdyAttInputGYS.SaveData2():Boolean; var maxId,CRID,fzdyCode,FYSSubId,maxno:String; begin ///判断、生成主键 with CDS_HZ3 do begin CDS_HZ3.First; while not Eof do begin FYSSubId:=Trim(CDS_HZ3.fieldbyname('LXFS_ZJ').AsString); if Trim(FYSSubId)='' then begin if GetLSNo(ADOQueryMain3,maxno,'LX','LXFS_ZJ',4,1)=False then begin // ADOQueryCmd.Connection.RollbackTrans; //回滚事务 Application.MessageBox('取系人最大ID失败!','提示',0); Exit; end; end else begin maxno:=Trim(FYSSubId); end; ADOQueryCmd.Connection.BeginTrans; //代表开始事务 with ADOQueryCmd do begin Close; SQL.Clear; sql.Add('select * from GYS_LXFS where LXFS_ZJ='''+Trim(maxno)+''''); Open; If Trim(FYSSubId)='' then begin append; end else begin Edit; end; FieldByName('LXFS_BH').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_BH').AsString); FieldByName('LXFS_LXR').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_LXR').AsString); FieldByName('LXFS_SJ').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_SJ').AsString); FieldByName('LXFS_DZ').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_DZ').AsString); FieldByName('LXFS_DH').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_DH').AsString); FieldByName('LXFS_CZ').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_CZ').AsString); FieldByName('LXFS_BZ').Value:=Trim(CDS_HZ3.fieldbyname('LXFS_BZ').AsString); FieldByName('LXFS_ZJ').Value:=Trim(maxno); FieldByName('KHMainID').Value:=Trim(CDS_HZ2.fieldbyname('KHMainID').AsString); FieldByName('KHSubid').Value:=Trim(CDS_HZ2.fieldbyname('KHSubid').AsString); post; end; CDS_HZ3.Next; end; end; ADOQueryCmd.Connection.CommitTrans; //代表完结事务 result:=true; end; procedure TfrmZdyAttInputGYS.SCSHDataNewTclient(ADOQueryTmp:TClientDataSet;mParent:TWinControl;FTag:Integer); var i,idx:integer; mfield,mfieldCode:string; ma:TA; begin with ADOQueryTmp do begin if isEmpty then exit; with mParent do begin for i:=0 to ControlCount-1 do begin if Controls[i] is TLabel then continue; if Controls[i].Tag<>FTag then continue; mfield:=Controls[i].Name; if Controls[i] is TEdit then begin if Trim(fieldByName(mfield).AsString)<>'' then TEdit(Controls[i]).Text:=trim(fieldByName(mfield).AsString) else TEdit(Controls[i]).Text:=''; end else if Controls[i] is TRichEdit then begin if Trim(fieldByName(mfield).AsString)<>'' then TRichEdit(Controls[i]).Text:=trim(fieldByName(mfield).AsString); end else if Controls[i] is TComboBox then begin if TComboBox(Controls[i]).Items.Count>0 then begin idx:=TComboBox(Controls[i]).Items.IndexOf(trim(fieldByName(mfield).AsString)); end else idx:=-1; TComboBox(Controls[i]).ItemIndex:=idx; end else if Controls[i] is TDateTimePicker then begin if Trim(fieldByName(mfield).AsString)='' then begin TDateTimePicker(Controls[i]).Checked:=False; end else TDateTimePicker(Controls[i]).DateTime:=fieldByName(mfield).AsDateTime; end else if Controls[i] is Tmemo then begin Tmemo(Controls[i]).Text :=trim(fieldByName(mfield).AsString); end else if Controls[i] is TcxDateEdit then begin if not IsEmpty and not fieldByName(mfield).IsNull then TcxDateEdit(Controls[i]).text :=fieldByName(mfield).AsString; end else if Controls[i] is TcheckBox then begin if FieldByName(mfield).Value=null then TcheckBox(Controls[i]).Checked:=False else TcheckBox(Controls[i]).Checked:=fieldByName(mfield).asBoolean; end else if Controls[i] is TcxButtonEdit then begin TcxButtonEdit(Controls[i]).Text:=Trim(fieldbyname(mfield).AsString); if TcxButtonEdit(Controls[i]).ParentShowHint=False then begin mfieldCode:=Trim(Copy(mfield,1,Length(mfield)-4)); TcxButtonEdit(Controls[i]).Hint:=Trim(fieldbyname(mfieldCode).AsString); end; end; end; // end for end; // end with end; //end for with end; procedure TfrmZdyAttInputGYS.TV2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if CDS_HZ3.IsEmpty=False then begin if (CDS_HZ3.Locate('BKID',NULL,[])=true) and (CDS_HZ3.Locate('BankNo',NULL,[])=true) and (CDS_HZ3.Locate('BKID','',[])=true) and (CDS_HZ3.Locate('BankNo','',[])=true) then begin if application.MessageBox('明细确定不保存吗','提示',1)=2 then exit; end; end; if CDS_HZ2.IsEmpty then exit; SCSHDataNewTclient(CDS_HZ2,panel7,2); Button1.Caption:='修改确定'; with ADOQueryMain3 do begin Close; sql.Clear; sql.Add('select * from KH_Sub_Bank where KHSubid='''+Trim(CDS_HZ2.fieldbyname('KHSubid').asstring)+''''); Open; end; SCreateCDS20(ADOQueryMain3,CDS_HZ3); SInitCDSData20(ADOQueryMain3,CDS_HZ3); end; procedure TfrmZdyAttInputGYS.ToolButton1Click(Sender: TObject); var maxId:String; i:Integer; begin Panel7.SetFocus; with Panel7 do begin for i:=0 to Panel7.ControlCount-1 do begin if Controls[i] is TEdit then begin TEdit(Controls[i]).Text:=''; end; if Controls[i] is TMemo then begin TMemo(Controls[i]).Text:=''; end; end; end; Button1.Caption:='新增确定'; end; procedure TfrmZdyAttInputGYS.ToolButton8Click(Sender: TObject); begin WriteCxGrid('坯布供应商资料录入1',Tv2,'客户自定义'); WriteCxGrid('坯布供应商资料录入2',Tv3,'客户自定义'); Close; end; procedure TfrmZdyAttInputGYS.ToolButton7Click(Sender: TObject); begin Panel4.SetFocus; IF trim(GYSName.Text)='' then begin application.MessageBox('供应商不能为空!','提示信息',MB_ICONERROR); exit; end; if Trim(GYSNameZC.Text)='' then begin application.MessageBox('简称不能为空!','提示信息',MB_ICONERROR); exit; end; if Application.MessageBox('确定要保存数据吗?','提示',32+4)<>IDYES then Exit; if SaveData() then begin Application.MessageBox('保存成功!','提示',0); ModalResult:=1; end; end; procedure TfrmZdyAttInputGYS.ToolButton9Click(Sender: TObject); begin IF KHSubid.Text='' then exit; if Application.MessageBox('确定要删除数据吗?','提示',32+4)<>IDYES then Exit; with ADOQueryMain2 do begin Close; SQL.Clear; sql.Add('delete from KH_Sub where KHSubid ='''+Trim(KHSubid.Text)+''''); ExecSQL; end; end; procedure TfrmZdyAttInputGYS.Button1Click(Sender: TObject); var maxId:String; i:Integer; begin Panel7.SetFocus; if KHMXName.Text='' then begin application.MessageBox('应付款单位(个人)不能为空','提示'); exit; end; if KHMXJC.Text='' then begin application.MessageBox('简称不能为空','提示'); exit; end; if Button1.Caption='新增确定' then begin if CDS_HZ2.Locate('KHMXName',KHMXName.Text,[])=True then begin Application.MessageBox('应付款单位(个人)已存在','提示'); exit; end; end; with CDS_HZ2 do begin if Button1.Caption='新增确定' then append else edit; SSetsaveSqlNewTClient(CDS_HZ2,panel7,2); post; end; with Panel7 do begin for i:=0 to Panel7.ControlCount-1 do begin if Controls[i] is TEdit then begin TEdit(Controls[i]).Text:=''; end; if Controls[i] is TMemo then begin TMemo(Controls[i]).Text:=''; end; end; end; Button1.Caption:='新增确定'; end; end.