⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit5.pas

📁 用DELPHI来编写的图书管理系统
💻 PAS
字号:
unit Unit5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, DB, ADODB, jpeg, ExtCtrls;

type
  TForm5 = class(TForm)
    Image1: TImage;
    StaticText1: TStaticText;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    StaticText2: TStaticText;
    StaticText3: TStaticText;
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Edit5: TEdit;
    StaticText4: TStaticText;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ADOTable1: TADOTable;
    ADOTable2: TADOTable;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    StaticText5: TStaticText;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

uses Unit1,Unit2;
{$R *.dfm}

procedure TForm5.BitBtn1Click(Sender: TObject);
begin
if  RadioButton1.Checked then
begin
  if (edit1.Text='') or (edit2.Text='')then
  begin
    edit5.Text:='';
    edit4.Text:='';
    application.MessageBox('请输入教师编号和姓名!','提示',64);
  end
  else
  begin
    ADOQuery1.Close;
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Add('select * from 教师图书馆帐号表 where 帐号='''+edit3.Text+'''');
    ADOQuery1.Open;
    if ADOQuery1.Recordset.RecordCount<>0 then
    begin
      edit5.Text:='';
      edit4.Text:='';
      application.MessageBox('该帐号已经存在!','提示',64);
    end
    else
    begin
      ADOQuery1.Close;
      ADOQuery1.SQL.Clear;
      ADOQuery1.SQL.Add('select * from 教师信息表 where 编号='''+edit1.Text+'''and 姓名='''+Edit2.Text+'''');
      ADOQuery1.Open;
      if ADOQuery1.Recordset.RecordCount=0 then
      begin
        edit5.Text:='';
        edit4.Text:='';
        application.MessageBox('教师编号或名字不对,请检查后再输入!','提示',96);
      end
      else
      begin
        if edit3.Text='' then
        begin
          edit5.Text:='';
          edit4.Text:='';
          application.MessageBox('请输入帐号!','提示',64);
        end
        else
        begin
          if(edit4.Text='')  then
          begin
            edit5.Text:='';
            edit4.Text:='';
            application.MessageBox('请输新密码!','提示',64);
          end
          else
          begin
            if edit5.Text='' then
            begin
              application.MessageBox('请再次输入密码以确认!','提示',64);
            end
            else
            begin
              if edit4.Text<>edit5.Text then
              begin
                edit5.Text:='';
                edit4.Text:='';
                application.MessageBox('两次密码不正确,请重试!','提示',64);
              end
              else
              begin
                ADOQuery1.Close;
                ADOQuery1.SQL.Clear;
                ADOQuery1.SQL.Add('select * from 教师图书馆帐号表 where 编号='''+edit1.Text+'''and 姓名='''+Edit2.Text+'''');
                ADOQuery1.Open;
                if ADOQuery1.Recordset.RecordCount<>0 then
                begin
                  edit5.Text:='';
                  edit4.Text:='';
                  application.MessageBox('该教师帐号已经存在,请检查正后,再输入!','提示',96)
                end
                else
                begin
                  adotable2.Append;
                  adotable2.FieldByName('编号').AsString:=edit1.Text;
                  adotable2.FieldByName('姓名').AsString:=edit2.Text;
                  adotable2.FieldByName('帐号').AsString:=edit3.Text;
                  adotable2.FieldByName('密码').AsString:=edit4.Text;
                  adotable2.Post;
                  application.MessageBox('恭喜你注册成功!','提示',64);
                end
              end
            end
          end
        end
      end
    end
  end
end
else
if  RadioButton2.Checked then
begin
  if (edit1.Text='') or (edit2.Text='')then
  begin
    edit5.Text:='';
    edit4.Text:='';
    application.MessageBox('请输入学号和姓名!','提示',64);
  end
  else
  begin
    ADOQuery1.Close;
    ADOQuery1.SQL.Clear;
    ADOQuery1.SQL.Add('select * from 学生图书馆帐号表 where 帐号='''+edit3.Text+'''');
    ADOQuery1.Open;
    if ADOQuery1.Recordset.RecordCount<>0 then
    begin
      edit5.Text:='';
      edit4.Text:='';
      application.MessageBox('该帐号已经存在!','提示',64);
    end
    else
    begin
      ADOQuery1.Close;
      ADOQuery1.SQL.Clear;
      ADOQuery1.SQL.Add('select * from 学生信息表 where 学号='''+edit1.Text+'''and 姓名='''+Edit2.Text+'''');
      ADOQuery1.Open;
      if ADOQuery1.Recordset.RecordCount=0 then
      begin
        edit5.Text:='';
        edit4.Text:='';
        application.MessageBox('学生学号或名字不对,请检查后再输入!','提示',96);
      end
      else
      begin
        if edit3.Text='' then
        begin
          edit5.Text:='';
          edit4.Text:='';
          application.MessageBox('请输入帐号!','提示',64);
        end
        else
        begin
          if(edit4.Text='')  then
          begin
            edit5.Text:='';
            edit4.Text:='';
            application.MessageBox('请输新密码!','提示',64);
          end
          else
          begin
            if edit5.Text='' then
            begin
              application.MessageBox('请再次输入密码以确认!','提示',64);
            end
            else
            begin
              if edit4.Text<>edit5.Text then
              begin
                edit5.Text:='';
                edit4.Text:='';
                application.MessageBox('两次密码不正确,请重试!','提示',64);
              end
              else
              begin
                ADOQuery1.Close;
                ADOQuery1.SQL.Clear;
                ADOQuery1.SQL.Add('select * from 学生图书馆帐号表 where 学号='''+edit1.Text+'''and 姓名='''+Edit2.Text+'''');
                ADOQuery1.Open;
                if ADOQuery1.Recordset.RecordCount<>0 then
                begin
                  edit5.Text:='';
                  edit4.Text:='';
                  application.MessageBox('该学生帐号已经存在,请检查正后,再输入!','提示',96)
                end
                else
                begin
                  adotable2.Append;
                  adotable2.FieldByName('学号').AsString:=edit1.Text;
                  adotable2.FieldByName('姓名').AsString:=edit2.Text;
                  adotable2.FieldByName('帐号').AsString:=edit3.Text;
                  adotable2.FieldByName('密码').AsString:=edit4.Text;
                  adotable2.Post;
                  application.MessageBox('恭喜你注册成功!','提示',64);
                end
              end
            end
          end
        end
      end
    end
  end
end
end;

procedure TForm5.BitBtn2Click(Sender: TObject);
begin
  form5.Close;
  form1.Show;
end;

procedure TForm5.RadioButton1Click(Sender: TObject);
begin
StaticText1.Caption:='  教师编号';
end;

procedure TForm5.RadioButton2Click(Sender: TObject);
begin
StaticText1.Caption:='  学   号';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -