求一简单权限管理程序段。

Win32Boy 2004-12-24 03:02:30
要求:可以向数据库中添加新的用户或删除原来的用户记录;对数据库中用户名,密码,身份三个字段进行修改;在DBEdit中进行上面的操作,在DBGird中显示user表中所有记录,并可及时更新。ACCESS数据库;ADO动态连接。
...全文
284 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
boytomato 2004-12-25
  • 打赏
  • 举报
回复
http://www.jdon.com/jive/thread.jsp?forum=46&thread=2897&start=0&msRange=15
zzlazio 2004-12-25
  • 打赏
  • 举报
回复
这不一基本的数据库操作么..
这都求..其他的咋写?
coeltdit 2004-12-25
  • 打赏
  • 举报
回复
http://www.delphibox.com/article.asp?articleid=1515
-------------------------->这里有比较完整的用户权限管理演示, 抱括动态生成菜单;
Win32Boy 2004-12-25
  • 打赏
  • 举报
回复
我的E-mail:youjian01@eyou.com
Win32Boy 2004-12-25
  • 打赏
  • 举报
回复
在此非常感谢: langziwujia007(※刑警队长※) !
under 2004-12-25
  • 打赏
  • 举报
回复
关注
bmwyc 2004-12-25
  • 打赏
  • 举报
回复
……………………
symk0014 2004-12-24
  • 打赏
  • 举报
回复
呵呵 我生平做的第一个系统就有它的影子..
Rail100 2004-12-24
  • 打赏
  • 举报
回复
呵呵,网络真神奇啊,既然权限管理的需求都是相同的,那么写出来的代码一定是一样的。如果不一样证明你写的是错的。
zdq801104 2004-12-24
  • 打赏
  • 举报
回复
FaneAnn(十年等待) ,呵呵,那么巧?
gxgyj 2004-12-24
  • 打赏
  • 举报
回复
ding..
FaneAnn 2004-12-24
  • 打赏
  • 举报
回复
我服了,这不是我的毕业设计中,用户管理这个模块的设计吗??呵呵
langziwujia007 2004-12-24
  • 打赏
  • 举报
回复
procedure TFrmoperator.BitBtn2Click(Sender: TObject);
begin
with adodm.Qopname do
begin
close;
sql.clear;
sql.add('select * from operator where opname='+''''+editopname.Text+'''');
open;
if recordcount<>0 then
begin
MessageBox(0,'¶Ô²»Æ𣬸ÃÓû§ÃûÒѾ­´æÔÚ£¡','',MB_OK+MB_ICONINFORMATION);
editopname.SetFocus;
exit;
end;
end;
if (main.userqx='¹ÜÀíÔ±') and ((combobox1.Text='¹ÜÀíÔ±')or(combobox1.Text='³¬¼¶¹ÜÀíÔ±')) then
begin
MessageBox(0,'¶Ô²»Æð£¬Äú²»ÄÜÌí¼Ó¹ÜÀíÔ±£¬ÇëÁªÏµ³¬¼¶¹ÜÀíÔ±£¡','',MB_OK+MB_ICONINFORMATION);
combobox1.SetFocus;
exit;
end
else begin
with adodm.Toprator do
begin
try
append;
fieldbyname('operatorid').asinteger:=strtoint(editopid.text);
fieldbyname('opname').asstring:=editopname.text;
fieldbyname('dept').asstring:=editopdept.text;
fieldbyname('optel').asstring:=editoptel.text;
fieldbyname('adress').asstring:=editadress.text;
fieldbyname('authority').asstring:=combobox1.Text;
if checkbox1.Checked then
fieldbyname('state').asstring:='ÊÇ'
else
fieldbyname('state').asstring:='·ñ';
post;


MessageBox(0,'Ô±¹¤Êý¾Ý³É¹¦Ìí¼Ó£¡£¡','',MB_OK+MB_ICONINFORMATION);
BitBtn4Click(Sender);
except
cancel;
MessageBox(0,'Ô±¹¤Êý¾ÝÌí¼Óʧ°Ü£¬Çë¼ì²éÊý¾ÝÊÇ·ñºÏ·¨£¬²¢Ã»ÓÐÖظ´µÄÔ±¹¤±àºÅ£¡','',MB_OK+MB_ICONINFORMATION);
end;
end;
end;
end;

procedure TFrmoperator.BitBtn3Click(Sender: TObject);
begin
if combobox1.Text='³¬¼¶¹ÜÀíÔ±' then
begin
MessageBox(0,'¶Ô²»Æ𣬸üǼ²»ÄÜɾ³ý£¡','',MB_OK+MB_ICONINFORMATION);
exit;
end;
if (main.userqx='¹ÜÀíÔ±') and (combobox1.Text='¹ÜÀíÔ±') then
begin
MessageBox(0,'¶Ô²»Æð£¬Äú²»ÄÜɾ³ý¹ÜÀíÔ±¼Ç¼£¬ÇëÁªÏµ³¬¼¶¹ÜÀíÔ±£¡','',MB_OK+MB_ICONINFORMATION);
combobox1.SetFocus;
exit;
end
else
begin
with adodm.Toprator do
begin
try
if MessageBox(0,'ÄúÈ·¶¨ÒªÉ¾³ý¸Ã¼Ç¼Âð£¿','¼Ç¼ɾ³ýÈ·ÈÏ',MB_YesNo+MB_ICONQuestion)=idyes then

begin
delete;
MessageBox(0,'³É¹¦É¾³ýÊý¾Ý£¡','',MB_OK+MB_ICONINFORMATION);
BitBtn4Click(Sender);
end;
except
cancel;
MessageBox(0,'ɾ³ýÊý¾Ýʧ°Ü£¡','',MB_OK+MB_ICONINFORMATION);
end;
end;
end;
end;

procedure TFrmoperator.BitBtn4Click(Sender: TObject);
begin
editopid.Text:='';
editopname.Text:='';
editopdept.Text:='';
editadress.Text:='';
editoptel.Text:='';
checkbox1.Checked:=false;
combobox1.Text:='';
editremark.Text:='';
end;

procedure TFrmoperator.BitBtn5Click(Sender: TObject);
begin
close;
end;

procedure TFrmoperator.FormCreate(Sender: TObject);
begin
adodm.Toprator.Active:=true;
end;

procedure TFrmoperator.DBGrid1CellClick(Column: TColumn);
begin
with adodm.Toprator do
begin
editopid.Text:=fieldbyname('operatorid').asstring;
editopname.Text:=fieldbyname('opname').asstring;
editopdept.Text:=fieldbyname('dept').asstring;
editoptel.Text:=fieldbyname('optel').asstring;
editadress.Text:=fieldbyname('adress').asstring;
editopid.Text:=fieldbyname('operatorid').asstring;
if fieldbyname('state').AsString='ÊÇ' then
checkbox1.Checked:=true
else checkbox1.Checked:=false;
if fieldbyname('authority').AsString='¹ÜÀíÔ±' then
combobox1.text:='¹ÜÀíÔ±'
else if fieldbyname('authority').AsString='²Ù×÷Ô±' then
combobox1.text:='²Ù×÷Ô±'
else if fieldbyname('authority').AsString='³¬¼¶¹ÜÀíÔ±' then
combobox1.text:='³¬¼¶¹ÜÀíÔ±'
else combobox1.itemindex:=-1;
end;
bitbtn1.Enabled:=true;
bitbtn3.Enabled:=true;
bitbtn4.Enabled:=true;
end;

procedure TFrmoperator.EditopidChange(Sender: TObject);
begin
bitbtn2.Enabled:=true;
end;

procedure TFrmoperator.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
adodm.Toprator.Close;
end;

end.
langziwujia007 2004-12-24
  • 打赏
  • 举报
回复
这个是我刚学习delphi时候的第一个程序,笨拙了点,但是我觉的很可爱。呵呵……
unit operator;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, ExtCtrls;

type
TFrmoperator = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
DBGrid1: TDBGrid;
Editopid: TEdit;
Editopname: TEdit;
Editopdept: TEdit;
Editadress: TEdit;
Editremark: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
Editoptel: TEdit;
CheckBox1: TCheckBox;
ComboBox1: TComboBox;
BitBtn3: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure EditopidChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Frmoperator: TFrmoperator;

implementation
uses dataunit,main;
{$R *.dfm}

procedure TFrmoperator.BitBtn1Click(Sender: TObject);
begin

if (main.userqx='¹ÜÀíÔ±') and ((combobox1.Text='¹ÜÀíÔ±')or(combobox1.Text='³¬¼¶¹ÜÀíÔ±')) then
begin
MessageBox(0,'¶Ô²»Æð£¬Äú²»ÄÜÐ޸ĹÜÀíÔ±¼Ç¼£¬ÇëÁªÏµ³¬¼¶¹ÜÀíÔ±£¡','',MB_OK+MB_ICONINFORMATION);
combobox1.SetFocus;
exit;
end
else
begin
with adodm.Toprator do
begin
try
edit;
fieldbyname('operatorid').asinteger:=strtoint(editopid.text);
fieldbyname('opname').asstring:=editopname.text;
fieldbyname('dept').asstring:=editopdept.text;
fieldbyname('optel').asstring:=editoptel.text;
fieldbyname('adress').asstring:=editadress.text;
fieldbyname('authority').asstring:=combobox1.Text;
//fieldbyname('keyword').asstring:=editpassword.Text;
if checkbox1.Checked then
fieldbyname('state').asstring:='ÊÇ'
else
fieldbyname('state').asstring:='·ñ';
post;
MessageBox(0,'Ô±¹¤Êý¾Ý³É¹¦Ð޸ģ¡','',MB_OK+MB_ICONINFORMATION);
BitBtn4Click(Sender);
except
cancel;
MessageBox(0,'Ô±¹¤Êý¾ÝÐÞ¸Äʧ°Ü£¬Çë¼ì²éÊý¾ÝÊÇ·ñºÏ·¨£¬²¢Ã»ÓÐÖظ´µÄÔ±¹¤±àºÅ£¡','',MB_OK+MB_ICONINFORMATION);
end;
end;
end;
end;

langziwujia007 2004-12-24
  • 打赏
  • 举报
回复
我倒是有个现成的,不过是我的毕业设计,现在感觉不是很好。但是功能都实现了,告诉我你的邮箱,我给你发过去。
postfxj 2004-12-24
  • 打赏
  • 举报
回复
那不是很簡單嗎,要例子做什麼呀。
chengchong1979 2004-12-24
  • 打赏
  • 举报
回复
帮你UP,没现成的

2,498

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧