我的loginfrm
全部原代码:
unit loginform;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, Buttons;
type
Tloginfrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Query1: TQuery;
Database1: TDatabase;
ComboBox1: TComboBox;
procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
function openfrm:boolean;
private
{ Private declarations }
public
{ Public declarations }
end;
var
loginfrm: Tloginfrm;
LoginUser:String;
implementation
uses adminform, passwordchangeform, mainform, queryform, operatorform;
{$R *.DFM}
procedure Tloginfrm.BitBtn2Click(Sender: TObject);
begin
application.Terminate ;
end;
procedure Tloginfrm.FormShow(Sender: TObject);
var
i :integer;
begin
with query1 do
begin
sql.Text:='select distinct username from passcheck';
open;
comboBox1.Items.Clear;
for i:=1 to recordcount do
begin
comboBox1.Items.Add(fieldbyname('username').asstring);
next;
end;
close;
end;
end;
procedure Tloginfrm.BitBtn1Click(Sender: TObject);
var
a:string;
begin
with query1 do
begin
close;
sql.clear;
sql.Add('SELECT username,password FROM passcheck WHERE username=''' +COMBOBOX1.TEXT +'''');
open;
end;
if query1.eof then
begin
showmessage(' 无此用户!! ');
combobox1.SetFocus;
end
else
begin
a := edit1.text;
trim(a);
//a:=query1.fieldbyname('password').asstring;
LoginUser:=COMBOBOX1.Text;
if a <> query1.fieldbyname('password').asstring then
begin
showmessage(' 密码错误!!');
edit1.SetFocus;
end
else
MODALRESULT := mrok;
end;
end;
function tloginfrm.openfrm: boolean;
begin
if showModal = mrok then
result:=true
else
result:=false;
end;
procedure Tloginfrm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=chr(13) then
begin
key:=chr(0);
BitBtn1.click;
end;
end;
end.
我的passwordchangefrm全部原代码
unit passwordchangeform;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Db, DBTables;
type
Tpasswordchangefrm = class(TForm)
Label1: TLabel;
Label2: TLabel;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Query1: TQuery;
Database1: TDatabase;
Edit1: TEdit;
Edit2: TEdit;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
passwordchangefrm: Tpasswordchangefrm;
implementation
uses loginform;
{$R *.DFM}
procedure Tpasswordchangefrm.BitBtn1Click(Sender: TObject);
var
asql:string;
begin
if trim(edit1.Text)='' then
begin
messagedlg('请输入新密码!',mtinformation,[mbok],0);
edit1.SetFocus;
end
else
if trim(edit2.Text)='' then
begin
messagedlg('请确认新密码!',mtinformation,[mbok],0);
edit2.SetFocus;
end
else
if trim(edit1.Text)<>trim(edit2.Text) then
begin
messagedlg('两次输入结果不一致!',mterror,[mbok],0);
edit1.SetFocus;
end
else
begin
query1.Close;
query1.sql.clear;
asql:='update passcheck set password='+#39+edit1.Text+#39+' where username='+#39+loginfrm.ComboBox1.Text+#39;
query1.SQL.Text:=asql;
try
query1.ExecSQL;
messagedlg('密码修改成功!请记住新密码.',mtinformation,[mbok],0);
edit1.Clear;
edit2.Clear;
passwordchangefrm.Hide;
query1.Close;
except
messagedlg('密码修改失败!',mtinformation,[mbok],0);
abort;
end;
end;
end;
procedure Tpasswordchangefrm.BitBtn2Click(Sender: TObject);
begin
self.Close;
end;
procedure Tpasswordchangefrm.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=chr(13) then
begin
key:=chr(0);
BitBtn1.click;
end;
end;
end.
我的工程(project)的全部代码:
program mycar;
uses
Forms,
mainform in 'mainform.pas' {mainfrm},
loginform in 'loginform.pas' {loginfrm},
passwordchangeform in 'passwordchangeform.pas' {passwordchangefrm},
carqueryform in 'carqueryform.pas' {carqueryfrm},
company_query in 'company_query.pas' {companyqueryfrm},
weihuform in 'weihuform.pas' {weihufrm},
type_query in 'type_query.pas' {typequeryfrm},
pai_query in 'pai_query.pas' {paiqueryfrm},
nianshen_query in 'nianshen_query.pas' {nianshenqueryfrm},
usedate_query in 'usedate_query.pas' {usedatequeryfrm},
baofei_query in 'baofei_query.pas' {baifeiqueryfrm},
operatorform in 'operatorform.pas' {operatorfrm},
queryform in 'queryform.pas' {queryfrm},
cheliangxiuli_frm1 in 'E:/canproject/cheliangxiuli_frm1.pas' {cheliangxiuli_frm},
cheliangluru_frm1 in 'cheliangluru_frm1.pas' {cheliangluru_frm},
operator_add in 'operator_add.pas' {operatoraddfrm},
cheliang_add1 in 'cheliang_add1.pas' {cheliang_add},
report_companyform in 'report_companyform.pas' {report_companyfrm: TQuickRep},
report_typeform in 'report_typeform.pas' {report_typefrm: TQuickRep},
report_paiform in 'report_paiform.pas' {report_paifrm: TQuickRep},
report_nianfenform in 'report_nianfenform.pas' {report_nianfenfrm: TQuickRep},
report_nianshenform in 'report_nianshenform.pas' {report_nianshenfrm: TQuickRep},
report_baofeiform in 'report_baofeiform.pas' {report_baofeifrm: TQuickRep};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(Tloginfrm, loginfrm);
if loginfrm.openfrm then
begin
loginfrm.free;
if loginuser='administrator' then
Application.CreateForm(Tmainfrm,mainfrm);
if Loginuser='operator' then
Application.CreateForm(Toperatorfrm, operatorfrm);
if loginuser='user' then
Application.CreateForm(Tcarqueryfrm, carqueryfrm);
Application.CreateForm(Tpasswordchangefrm, passwordchangefrm);
Application.CreateForm(Tcarqueryfrm, carqueryfrm);
Application.CreateForm(Tcompanyqueryfrm, companyqueryfrm);
Application.CreateForm(Tweihufrm, weihufrm);
Application.CreateForm(Ttypequeryfrm, typequeryfrm);
Application.CreateForm(Tpaiqueryfrm, paiqueryfrm);
Application.CreateForm(Tnianshenqueryfrm, nianshenqueryfrm);
Application.CreateForm(Tusedatequeryfrm, usedatequeryfrm);
Application.CreateForm(Tbaifeiqueryfrm, baifeiqueryfrm);
Application.CreateForm(Tcheliangxiuli_frm, cheliangxiuli_frm);
Application.CreateForm(Tcheliangluru_frm, cheliangluru_frm);
Application.CreateForm(Toperatoraddfrm, operatoraddfrm);
Application.CreateForm(Tcheliang_add, cheliang_add);
Application.CreateForm(Treport_companyfrm, report_companyfrm);
Application.CreateForm(Treport_typefrm, report_typefrm);
Application.CreateForm(Treport_paifrm, report_paifrm);
Application.CreateForm(Treport_nianfenfrm, report_nianfenfrm);
Application.CreateForm(Treport_nianshenfrm, report_nianshenfrm);
Application.CreateForm(Treport_baofeifrm, report_baofeifrm);
Application.Run;
end;
end.