【delphi开源代码栏目提醒】:网学会员--在 delphi开源代码编辑为广大网友搜集整理了:corp.pas绩等信息,祝愿广大网友取得需要的信息,参考学习。
unit corp;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB,corpinfo_unit, Buttons, DBClient, Grids,
DBGrids;
type
Tcorpfrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Corp_DBGrid: TDBGrid;
Corp_DataSource: TDataSource;
Corp_ClientDataSet: TClientDataSet;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
corpinfo:Tcorpinfo;
{ Private declarations }
public
{ Public declarations }
end;
var
corpfrm: Tcorpfrm;
implementation
{$R *.dfm}
procedure Tcorpfrm.Button1Click(Sender: TObject);
var
insertsql:string;
begin
//实例化类
corpinfo:=Tcorpinfo.create ;
//保存时厂商编号必须输入
if Edit1.text='' then
begin
showmessage('厂商编号不能为空!');
exit;
end;
//判断输入的厂商编号位数是否正确
if length(Edit1.text)<>3 then
begin
showmessage('对不起,厂商编号位数不对!');
exit;
end;
//调用类中方法从厂商基本信息表中查看该厂商编号是否存在
if corpinfo.CorpRec(Edit1.text) then
begin
showmessage('该厂商编号已经存在,请核查!');
exit;
end;
//如果不存在则执行插入操作过程
insertsql:='insert into CORPINFO(CORPID,CORPNAME,'
+'LINKMAN,LINKPHONE,ADDRESS,FAX)values('''+Edit1.text+''','
+''''+EDIT2.Text+''','''+EDIT3.Text+''','''+EDIT4.Text+''','
+''''+EDIT5.Text+''','''+EDIT6.Text+''')';
corpinfo.CorpInfoInsert(insertsql);
Corp_ClientDataSet.Data:=corpinfo.CorpRecs();
showmessage('添加成功!');
//释放实例
corpinfo.Free;
end;
procedure Tcorpfrm.Button2Click(Sender: TObject);
begin
//实例化类
corpinfo:=Tcorpinfo.create ;
if application.MessageBox('要删除吗?','警告:',mb_yesno+mb_iconquestion)=idyes then
begin
//删除时根据厂商编号来进行,所以不能为空
if Edit1.text='' then
begin
showmessage('请输入要删除记录厂商编号!');
exit;
end;
//判断厂商编号位数是否正确
if length(Edit1.text)<>3 then
begin
showmessage('对不起,厂商编号位数不对!');
exit;
end;
//删除前调用类中方法查看该记录信息是否存在
if corpinfo.CorpRec(Edit1.text)=false then
begin
showmessage('该厂商编号不存在,请核查!');
exit;
end;
//若存在则执行类中删除操作过程
corpinfo.CorpInfoDel(Edit1.text);
//清除掉文本框中原有的数据信息
Edit1.text:=''; EDIT2.Text:='';EDIT3.Text:='';
EDIT4.Text:='';EDIT5.Text:='';EDIT6.Text:='';
showmessage('删除成功!');
end;
corpinfo.Free;
end;
procedure Tcorpfrm.Button3Click(Sender: TObject);
begin
//实例化类
corpinfo:=Tcorpinfo.create ;
//查询时根据厂商编号来进行,所以不能为空
if Edit1.text='' then
begin
showmessage('请输入要查询记录厂商编号!');
exit;
end;
//判断厂商编号位数是否正确
if length(Edit1.text)<>3 then
begin
showmessage('对不起,厂商编号位数不对!');
exit;
end;
//
查询该记录信息是否存在
if corpinfo.CorpRec(Edit1.text)=false then
begin
showmessage('该厂商编号不存在,请核查!');
exit;
end;
//如果查询到记录信息则取出对应的内容值
EDIT2.Text:=corpinfo.GetCorpName(Edit1.text);
EDIT3.Text:=corpinfo.GetLinkMan(Edit1.text);
EDIT4.Text:=corpinfo.GetLinkPhone(Edit1.text);
EDIT5.Text:=corpinfo.GetAddress(Edit1.text);
EDIT6.Text:=corpinfo.GetFax(Edit1.text);
//释放实例
corpinfo.Free;
end;
procedure Tcorpfrm.Button4Click(Sender: TObject);
var
mod
sql:string;
begin
//实例化类
corpinfo:=Tcorpinfo.create ;
if application.MessageBox('要修改吗?','提示:',mb_yesno+mb_iconquestion)=idyes then
begin
//修改时必须知道记录的厂商编号,所以不能为空
if Edit1.text='' then
begin
showmessage('请输入要修改记录的厂商编号,查询到相应记录后修改!');
exit;
end;
//判断厂商编号位数是否正确
if length(Edit1.text)<>3 then
begin
showmessage('对不起,厂商编号位数不对!');
exit;
end;
//查看该厂商编号是否已经存在,若不存在则不能执行修改操作
if corpinfo.CorpRec(Edit1.text)=false then
begin
showmessage('该厂商编号不存在,请核查!');
exit;
end;
//执行修改操作
modsql:='update CORPINFO set CORPNAME='''+EDIT2.Text+''', '
+'LINKMAN='''+EDIT3.Text+''',LINKPHONE='''+EDIT4.Text+''',ADDRESS='''+EDIT5.Text+''','
+'FAX='''+EDIT6.Text+''' where CORPID='''+Edit1.text+''' ';
corpinfo.CorpInfoUpdate(modsql);
showmessage('修改成功!');
end;
corpinfo.Free;
end;
end.