《仓库管理系统delphi源码(DOC68页)[68页].docx》由会员分享,可在线阅读,更多相关《仓库管理系统delphi源码(DOC68页)[68页].docx(68页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、最新资料推荐unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB, jpeg, ExtCtrls;type TForm1 = class(TForm) ADOConnection1: TADOConnection; ADOQuery1: TADOQuery; Edit1: TEdit; Edit2: TEdit; Button1: TButton; Button2: TButton; ADOT
2、able1: TADOTable; Image1: TImage; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Button3: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private Private declarations public count:integer; Public dec
3、larations end;var Form1: TForm1;implementationuses Unit12,Unit19;$R *.dfmprocedure TForm1.Button1Click(Sender: TObject); var yonghu:string;begin yonghu:=trim(edit1.Text);/trim去除字符串空格 count:=count+1;/登陆次数 with adoquery1 do begin Close; SQL.Clear; SQL.text:=select * from 用户信息表 where 用户名=+yonghu+; open
4、; if (adoQuery1.RecordCount0) and (edit2.Text) and (adoQuery1.FieldByName(密码).AsString= edit2.Text) then begin if adoQuery1.FieldByName(是否管理员).AsString =True then begin form12.SpeedButton1.Visible:=true; form12.Button13.Visible:=true; application.MessageBox(密码正确,即将进入系统。,提示,mb_ok); form1.Hide; form12
5、.Show; end else begin form12.SpeedButton1.Visible:=false; form12.Button13.Visible:=false; application.MessageBox(密码正确,即将进入系统。,提示,mb_ok); form1.Hide; form12.Show; end; end else begin if (count=1) then begin application.MessageBox(用户名或密码错误,还剩2次机会,提示,mb_ok); edit1.SetFocus;/光标是向左对齐的 也就是在编辑框的最左边 end; if
6、(count=2) then begin application.MessageBox(您还有最后一次机会,请仔细核对用户名和密码,提示,mb_ok); edit1.Clear; edit2.clear; edit1.SetFocus; end; if (count=3) then begin application.MessageBox(密码错误超过三次系统即将关闭,提示,mb_ok); application.Terminate;/退出程序 end; end; end;end;procedure TForm1.Button2Click(Sender: TObject);begin appl
7、ication.Terminate;end;procedure TForm1.Button3Click(Sender: TObject);begin form19.ShowModal;end;End.unit Unit2;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, DBGrids, jpeg, ExtCtrls, DB, ADODB;type TForm2 = class(TForm) Image1: TIma
8、ge; Label1: TLabel; GroupBox1: TGroupBox; DBGrid1: TDBGrid; Button1: TButton; GroupBox2: TGroupBox; GroupBox3: TGroupBox; GroupBox4: TGroupBox; Label3: TLabel; Label4: TLabel; Edit1: TEdit; Edit2: TEdit; Label5: TLabel; RadioButton1: TRadioButton; RadioButton2: TRadioButton; Button2: TButton; Label6
9、: TLabel; Label7: TLabel; Edit3: TEdit; RadioButton3: TRadioButton; RadioButton4: TRadioButton; Button3: TButton; ADOConnection1: TADOConnection; ADOTable1: TADOTable; ADOQuery1: TADOQuery; ADOQuery2: TADOQuery; DataSource1: TDataSource; procedure Button1Click(Sender: TObject); procedure Button2Clic
10、k(Sender: TObject); procedure Button3Click(Sender: TObject); procedure FormShow(Sender: TObject); private Private declarations public Public declarations end;var Form2: TForm2;implementation$R *.dfmprocedure TForm2.Button1Click(Sender: TObject);begin if application.MessageBox(请确认是否要删除, 超市仓库管理系统, mb_
11、iconinformation +mb_yesno) = idyes then/MB_ICONINFORMATION是显示出的对话框里会有一个“i”图标,mb_yesno同时显示确定和取消按钮,idyes单击”是“按钮 ADOtable1.Delete;end;procedure TForm2.Button2Click(Sender: TObject);var yonghuming,mima:string; quanxian:boolean;begin if (edit1.Text) and (edit2.Text) and (radiobutton1.Checked xor radiobut
12、ton2.Checked) then begin yonghuming:=edit1.Text; adoquery1.Close; adoquery1.SQL.Text := select * from 用户信息表 where 用户名= +yonghuming+ ; adoquery1.open; if not adoquery1.Eof then/判断表是否为空 begin MessageBox(handle, 此用户名已存在!, 提示, mb_IconInformation + mb_Ok); exit; end; mima:=edit2.Text; if radiobutton1.Che
13、cked=true then quanxian:=true else quanxian:=false; adotable1.InsertRecord(yonghuming,mima,quanxian); adotable1.Close; /把ADOTable控件对应的数据源关闭 adotable1.Open;/重新打开ADOTable控件对应的数据源,这样做的目的是刷新数据源 showmessage(新建用户添加成功); edit1.Clear; edit2.Clear; radiobutton1.Checked:=false; radiobutton2.Checked:=false; end
14、 else showmessage(信息填写不全);end;procedure TForm2.Button3Click(Sender: TObject);var yonghuming:string; quanxian:boolean;begin if (edit3.Text) and (radiobutton3.Checked xor radiobutton4.Checked) then begin yonghuming:=edit3.Text; adoquery1.Close; adoquery1.SQL.Text := select * from 用户信息表 where 用户名= +yon
15、ghuming+ ; adoquery1.open; if adoquery1.RecordCount = 0 then begin showmessage(不存在此用户,请重新输入); edit3.SetFocus; exit; end; if radiobutton3.Checked=true then quanxian:=true else quanxian:=false; if application.MessageBox(请确认是否要修改, 超市仓库管理系统, mb_iconinformation + mb_yesno) = idyes then begin adotable1.Lo
16、cate(用户名,yonghuming,); adotable1.Edit; adotable1是否管理员:=quanxian; adotable1.Post; adotable1.Close; adotable1.Open;/更改一个已经从数据库中读取的数据库表格 showmessage(修改成功); end; end else showmessage(信息填写不全);end; procedure TForm2.FormShow(Sender: TObject);beginadoconnection1:=TADOConnection.Create(nil);/动态创建ADO控件adoconn
17、ection1.LoginPrompt:=false;/如果不加这句的话,每次连接数据库时都会跳出一个身份验证对话框,要求你输入用户名和密码adoconnection1.Connected:=false;/释放连接adoconnection1.ConnectionString:=Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=天天;Data Source=WIN-RNSK1TMAK9L;adoconnection1.Connected:=true;adotable1:=TADOTable.Cr
18、eate(nil);adotable1.Connection:=adoconnection1;adotable1.TableName:=用户信息表;adotable1.Open;datasource1.DataSet:=adotable1;adoquery1:=TADOQuery.Create(nil);adoquery1.Connection:=adoconnection1;adoquery2:=TADOQuery.Create(nil);adoquery2.Connection:=adoconnection1;end;end.unit Unit3;interfaceuses Windows
19、, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ADODB, DB, StdCtrls, Grids, DBGrids, jpeg, ExtCtrls;type TForm3 = class(TForm) GroupBox1: TGroupBox; GroupBox2: TGroupBox; GroupBox3: TGroupBox; Image1: TImage; Label1: TLabel; DBGrid1: TDBGrid; Button1: TButton; Button2: T
20、Button; Button3: TButton; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Edit6: TEdit; Edit7: TEdit; ComboBox1: TComboBox; ComboBox2
21、: TComboBox; Label11: TLabel; ComboBox3: TComboBox; Edit8: TEdit; Button4: TButton; Button5: TButton; Button6: TButton; ADOConnection1: TADOConnection; ADOTable1: TADOTable; DataSource1: TDataSource; ADOQuery1: TADOQuery; procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObjec
22、t); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure FormShow(Sender: TObject); private Private declarations public Public declarations end;var Form3: TForm3;implementation$R
23、*.dfm procedure TForm3.FormShow(Sender: TObject);begin adoconnection1:=TADOConnection.Create(nil);adoconnection1.LoginPrompt:=false;adoconnection1.Connected:=false;adoconnection1.ConnectionString:=Provider=SQLOLEDB.1;Password=411114;Persist Security Info=True;User ID=sa;Initial Catalog=天天;Data Sourc
24、e=win-rnsk1tmak9l;adoconnection1.Connected:=true;adotable1:=TADOTable.Create(nil);adotable1.Connection:=adoconnection1;adotable1.TableName:=商品信息表;adotable1.Open;datasource1.DataSet:=adotable1;adoquery1:=TADOQuery.Create(nil);adoquery1.Connection:=adoconnection1;adoquery1.Close;adoquery1.SQL.Clear;ad
25、oquery1.SQL.Text:=select 仓库名称 from 仓库信息表;adoquery1.Open; while not adoquery1.Eof do begin combobox2.Items.Add(adoquery1仓库名称); adoquery1.Next; end;end;procedure TForm3.Button2Click(Sender: TObject);begin adotable1.Edit;end;procedure TForm3.Button1Click(Sender: TObject);begin if application.MessageBox
26、(确定要删除?, 超市仓库管理系统, mb_iconinformation + mb_yesno) = idyes thenbegin adotable1.Delete; showmessage(删除成功); end;end;procedure TForm3.Button3Click(Sender: TObject);begin adotable1.Post; showmessage(修改成功);end;procedure TForm3.Button4Click(Sender: TObject); vartemp:string; juti:string;begin juti:=edit8.Te
27、xt; if(combobox3.Text)and(edit8.Text) then begin if (combobox3.ItemIndex=0) then/ItemIndex=0列表标号从0开始 begin adotable1.Filtered:=false; adotable1.Filter:=商品编号=+juti+; adotable1.Filtered:=true; end; if (combobox3.ItemIndex=1) then begin adotable1.Filtered:=false;/ 解除过滤 temp:=trim(%+juti+%); adotable1.F
28、ilter:=商品名称 like +temp+; adotable1.Filtered:=true; end; if (combobox3.ItemIndex=2) then begin adotable1.Filtered:=false; adotable1.Filter:=型号=+juti+; adotable1.Filtered:=true; end; if (combobox3.ItemIndex=3) then begin adotable1.Filtered:=false; adotable1.Filter:=仓库名称=+juti+; adotable1.Filtered:=tru
29、e; end; end;end;procedure TForm3.Button5Click(Sender: TObject);begin adotable1.Filtered:=false;adotable1.Close;adotable1.Open;end;procedure TForm3.Button6Click(Sender: TObject);begin if (edit1.Text) and (edit2.Text) and (edit3.Text) and (edit4.Text) and (edit5.Text) and (edit6.Text) and (edit7.Text)
30、 and (combobox1.Text) and (combobox2.Text) then begin if application.MessageBox(确定要添加?, 超市仓库管理系统, mb_iconinformation + mb_yesno) = idyes then begin adotable1.InsertRecord(edit1.Text,edit2.Text,edit3.Text,combobox1.Text,edit4.Text,edit5.Text,combobox2.Text,edit6.Text,edit7.Text); adotable1.Close; ado
31、table1.Open; showmessage(新商品添加成功); end; end else showmessage(信息未填全);end;end.unit Unit4;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ADODB, DB, StdCtrls, Grids, DBGrids, jpeg, ExtCtrls;type TForm4 = class(TForm) Image1: TImage; Label1: TLabel; Grou
32、pBox1: TGroupBox; GroupBox2: TGroupBox; DBGrid1: TDBGrid; DBGrid2: TDBGrid; Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; DataSource1: TDataSource; DataSource2: TDataSource; ADOConnection1: TADOConnection
33、; ADOTable1: TADOTable; ADOQuery1: TADOQuery; ADOQuery2: TADOQuery; ADOQuery3: TADOQuery; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedu
34、re Button4Click(Sender: TObject); procedure Edit3KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DBGrid1CellClick(Column: TColumn); procedure FormShow(Sender: TObject); private Private declarations public Public declarations end;var Form4: TForm4;implementation$R *.dfmprocedure
35、TForm4.Button1Click(Sender: TObject);begin if application.MessageBox(请确认是否要删除, 超市仓库管理系统, mb_iconinformation + mb_yesno) = idyes then begin adotable1.Delete; end;end;procedure TForm4.Button2Click(Sender: TObject);begin adotable1.Edit;end;procedure TForm4.Button3Click(Sender: TObject);begin adotable1.
36、Post;showmessage(修改成功);end;procedure TForm4.Button4Click(Sender: TObject);var cangku,dizhi,bianhao:string;begin if (edit1.Text) and (edit2.Text) and (edit3.Text) then begin cangku:=edit1.Text; dizhi:=edit2.Text; bianhao:=edit3.Text; adoquery1.Close; adoquery1.SQL.Text := select * from 仓库信息表 where 仓库
37、名称= +cangku+ ; adoquery1.open; if not adoquery1.Eof then begin MessageBox(handle, 此仓库名已存在!, 提示, mb_IconInformation + mb_Ok); exit; end; adoquery1.Close; adoquery1.SQL.Text := select * from 员工信息表 where 编号= +bianhao+ ; adoquery1.open; if adoquery1.RecordCount = 0 then begin showmessage(不存在此用户,请重新输入);
38、edit3.SetFocus; exit; end; if application.MessageBox(确定要添加新仓库?, 超市仓库管理系统, mb_iconinformation + mb_yesno) = idyes then begin adotable1.InsertRecord(cangku,dizhi,bianhao); adotable1.Close; adotable1.Open; showmessage(新仓库添加成功); end; end else showmessage(信息未填全);end;procedure TForm4.Edit3KeyUp(Sender: TO
39、bject; var Key: Word; Shift: TShiftState); var bianhao:string;begin bianhao:=edit3.Text; with adoquery2 dobegin close; sql.clear; sql.add(select 姓名 from 员工信息表 where 编号=+bianhao+); open; edit4.Text:=Fieldbyname(姓名).AsString; close; sql.clear; sql.add(select 电话 from 员工信息表 where 编号=+bianhao+); open; ed
40、it5.Text:=Fieldbyname(电话).AsString;end;end;procedure TForm4.DBGrid1CellClick(Column: TColumn);vartemp:variant;workerId:string;begintemp:=DataSource1.DataSet.FieldValues负责人编号;workerID:=VarToStr(temp);adoquery3.Close;adoquery3.SQL.Clear;adoquery3.SQL.Text:=select 编号,姓名,性别,电话,地址,出生日期,部门,职务 from 员工信息表 w
41、here 编号=+workerid+;adoquery3.Open; dbgrid2.Columns0.Width:=100; dbgrid2.Columns1.Width:=100; dbgrid2.Columns2.Width:=100; dbgrid2.Columns3.Width:=100; dbgrid2.Columns4.Width:=100; dbgrid2.Columns5.Width:=100; dbgrid2.Columns6.Width:=100; dbgrid2.Columns7.Width:=100;end; procedure TForm4.FormShow(Sender: TObject);beginadoconnection1:=TADOConnection.Create(nil);adoconnection1.LoginPrompt:=false;adoconnection1.Connected:=false;adoc