小弟想编辑一个以数据库技术为内核的小软件.其中要求对于不同的用户赋予不同的权限,既查看权限和修改权限,但不知怎样下手.敢问那位老哥作过这方面的程序,可不可以将相关的代码告诉小弟.不胜感激.如方便可将代码发送到

解决方案 »

  1.   

    权限表里的权限怎么填写呀?
    结构
    结构如下:Id        names         password     权限?
    1         abc             12345      ???
      

  2.   

    这是其中主要的代码,你自己试试看再说吧!
     temp:=edit1.Text;
       pwd1:=edit2.Text;
       pwd2:=edit3.Text;
       quanx:=combobox1.Text;
       if (temp='') or (pwd1='') or (pwd2='') then
         begin
         application.MessageBox(' 用户名,密码不能为空   ','信息提示',MB_IconInformation+mb_ok);
         edit1.SetFocus;
         end
       else
       if trim(edit2.Text)<>trim(edit3.Text) then
         begin
         application.MessageBox(' 两次密码输入不一致   ','信息提示',MB_IconInformation+mb_ok);
         edit2.SetFocus;
         end
       else
        if in_up=1 then        //执行纪录插入
         begin
         adoquery1.Close;
         adoquery1.SQL.Clear;
         adoquery1.SQL.Add('select * from users_tab where name=:parm');
         adoquery1.Parameters.ParamByName('parm').Value:=trim(edit1.Text);
         adoquery1.Open;
         if adoquery1.Eof  then
           begin
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('insert into users_tab (name,pwd,authority) values(:user1,:pwd1,:auth) ');
           adoquery1.Parameters.ParamByName('user1').Value:=trim(edit1.Text);
           adoquery1.Parameters.ParamByName('pwd1').Value:=trim(edit2.Text);
           adoquery1.Parameters.ParamByName('auth').Value:=trim(combobox1.Text);
           adoquery1.ExecSQL;
           edit1.Text:='';
           edit2.Text:='';
           edit3.Text:='';
           edit1.SetFocus;
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('select * from users_tab');
           adoquery1.open;
           end
         else
           begin
           application.MessageBox(' 该用户已存在 ','信息提示',MB_IconInformation+mb_ok);
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('select * from users_tab');
           adoquery1.Open;
           edit1.Text:='';
           end;
         end
       else
        if in_up=0 then         //执行纪录修改
         begin
         adoquery1.Close;
         adoquery1.SQL.Clear;
         adoquery1.SQL.Add('select * from users_tab where name=:parm1');
         adoquery1.Parameters.ParamByName('parm1').Value:=trim(edit1.Text);
         adoquery1.Open;
         if adoquery1.Eof  then
          begin
          adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Add('update users_tab set name=:nam0,pwd=:pwd0,authority=:auth0 where name='''+nam+'''');
          adoquery1.Parameters.ParamByName('nam0').Value:=trim(edit1.Text);
          adoquery1.Parameters.ParamByName('pwd0').Value:=trim(edit2.Text);
          adoquery1.Parameters.ParamByName('auth0').Value:=trim(combobox1.Text);
          adoquery1.ExecSQL;
          edit1.Text:='';
          edit2.Text:='';
          edit3.Text:='';
          edit1.SetFocus;
          adoquery1.Close;
          adoquery1.SQL.Clear;
          adoquery1.SQL.Add('select * from users_tab');
          adoquery1.open;
          in_up:=1;
          end
          else
          if nam=trim(edit1.Text) then
           begin
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('update users_tab set pwd=:pwd0,authority=:auth0 where name='''+nam+'''');
           adoquery1.Parameters.ParamByName('pwd0').Value:=trim(edit2.Text);
           adoquery1.Parameters.ParamByName('auth0').Value:=trim(combobox1.Text);
           adoquery1.ExecSQL;
           //application.MessageBox(' 该用户已存在 ','信息提示',MB_IconInformation+mb_ok);
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('select * from users_tab ');
           adoquery1.Open;
           edit1.Text:='';
           edit2.Text:='';
           edit3.Text:='';
           edit1.SetFocus;
           end
           else
           begin
           application.MessageBox(' 该用户名已被使用  ','信息提示',MB_IconInformation+mb_ok);
           adoquery1.Close;
           adoquery1.SQL.Clear;
           adoquery1.SQL.Add('select * from users_tab ');
           adoquery1.Open;
           edit1.SetFocus;
           end
          end
         end;
    //end;procedure Tusersetupform.But_delClick(Sender: TObject);
    var
    ptext:PCHAR;
    begin
       if adoquery1.RecordCount=0 then exit;
       ptext:=PCHAR('你真的要删除当前纪录吗?');
       if messagebox(Handle,ptext,'删除询问',4+32+512)=6 then
         adoquery1.Delete;
         in_up:=1;
         edit1.Text:='';
         edit2.Text:='';
         edit3.Text:='';
         edit1.SetFocus;
    end;