📄 custlogin.~pas
字号:
unit CustLogin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, XPMenu, StdCtrls, Buttons, ExtCtrls, jpeg, Mask, ADODB, DB,
DBCtrls;
type
TfrmCustLogin = class(TForm)
XPMenu1: TXPMenu;
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Bevel1: TBevel;
bit_Login: TBitBtn;
BitBtn2: TBitBtn;
CheckBox1: TCheckBox;
edt_PassWord: TMaskEdit;
BitBtn1: TBitBtn;
Bevel2: TBevel;
GroupBox1: TGroupBox;
Panel2: TPanel;
Image1: TImage;
Label3: TLabel;
Label4: TLabel;
edt_RegNum: TEdit;
edt_RegPassWord: TMaskEdit;
adoTblRegCuster: TADOTable;
adoQryMobilePhone: TADOQuery;
adoTblRegCusterRegMobilePhone: TWideStringField;
adoTblRegCusterRegPassWord: TWideStringField;
adoTblRegCusterRegFalg: TWideStringField;
DataSource1: TDataSource;
cbxMobilePhone: TComboBox;
adoUpdateMobilePhone: TADOQuery;
procedure FormShow(Sender: TObject);
procedure cbxMobilePhoneChange(Sender: TObject);
procedure bit_LoginClick(Sender: TObject);
procedure cbxMobilePhoneKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure edt_PassWordKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
function GetPar(var Par:string):Boolean;
procedure SearchMobilePhone;
{ Public declarations }
end;
var
frmCustLogin: TfrmCustLogin;
implementation
{$R *.dfm}
uses SM_Msgp, ADOSM_Data, SM_MsgDLL;
procedure TfrmCustLogin.SearchMobilePhone;
var
s:string;
begin
edt_PassWord.Clear;
s:=cbxMobilePhone.Text;
with adoQryMobilePhone do
begin
Close;
Parameters.ParamByName('FregMobilePhone').Value:=Trim(s);
Open;
end;
if adoQryMobilePhone.RecordCount>0 then
if adoQryMobilePhone.Fields[2].Value='1' then
begin
CheckBox1.Checked:=True;
edt_PassWord.Text:=adoQryMobilePhone.Fields[1].Value;
end else CheckBox1.Checked:=False;
end;
function TfrmCustLogin.GetPar(var Par:string):boolean;
begin
Result:=False;
if frmCustLogin.ShowModal=mrOk then
begin
Par:=cbxMobilePhone.Text;
Result:=True;
end;
end;
procedure TfrmCustLogin.FormShow(Sender: TObject);
begin
cbxMobilePhone.SetFocus;
cbxMobilePhone.Clear;
adoTblRegCuster.Open;
while not adoTblRegCuster.Eof do
begin
cbxMobilePhone.Items.Add(adoTblRegCuster.Fields[0].Value);
adoTblRegCuster.Next;
end;
SearchMobilePhone;
end;
procedure TfrmCustLogin.cbxMobilePhoneChange(Sender: TObject);
begin
SearchMobilePhone;
end;
procedure TfrmCustLogin.bit_LoginClick(Sender: TObject);
var
s:string;
begin
ModalResult:=mrNone;
s:=cbxMobilePhone.Text;
if s='' then
begin
ErrorMsg(1,'请选择登陆用户号码!');
cbxMobilePhone.SetFocus;
Abort;
end;
with adoQryMobilePhone do
begin
Close;
Parameters.ParamByName('FregMobilePhone').Value:=Trim(s);
Open;
end;
if adoQryMobilePhone.RecordCount=0 then
begin
ErrorMsg(1,'没有用户登记资料!');
Abort;
end else
if Trim(edt_PassWord.Text)<>Trim(adoQryMobilePhone.Fields[1].Text) then
begin
ErrorMsg(1,'登陆用户密码错误!');
edt_PassWord.SetFocus;
Abort;
end;
ModalResult:=mrOk;
end;
procedure TfrmCustLogin.cbxMobilePhoneKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Key=VK_RETURN) then
if Trim(cbxMobilePhone.Text)<>'' then
PostMessage(Handle,WM_NEXTDLGCTL,0,0) else
begin
cbxMobilePhone.SetFocus;
ErrorMsg(1,'请选择登陆用户号码!');
end;
end;
procedure TfrmCustLogin.edt_PassWordKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=VK_RETURN) then
bit_Login.OnClick(nil);
end;
procedure TfrmCustLogin.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked then
with adoUpdateMobilePhone do
begin
Close;
Parameters.ParamByName('FregFalg').Value:='1';
Parameters.ParamByName('FregMobilePhone').Value:=cbxMobilePhone.Text;
ExecSQL;
end;
if not CheckBox1.Checked then
with adoUpdateMobilePhone do
begin
Close;
Parameters.ParamByName('FregFalg').Value:='0';
Parameters.ParamByName('FregMobilePhone').Value:=cbxMobilePhone.Text;
ExecSQL;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -