📄 unit_mater_syspass.~pas
字号:
unit Unit_Mater_SysPass;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, Db, DBTables;
type
TForm_Mater_SysPass = class(TForm)
ComboBox_Employ: TComboBox;
Edit_Check: TEdit;
BitBtn_Mod: TBitBtn;
RadioGroup1: TRadioGroup;
BitBtn_ModPost: TBitBtn;
BitBtn_Ins: TBitBtn;
Qry_Login: TQuery;
BitBtn_InsPost: TBitBtn;
Panel1: TPanel;
Edit_NewPass: TEdit;
Edit3_TwicePass: TEdit;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Edit_Name: TEdit;
Panel6: TPanel;
Edit_DateBegin: TEdit;
Edit_DateEnd: TEdit;
Panel7: TPanel;
Panel8: TPanel;
Memo1: TMemo;
Panel9: TPanel;
bbExit: TButton;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure BitBtn_InsClick(Sender: TObject);
procedure BitBtn_ModClick(Sender: TObject);
procedure BitBtn_InsPostClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure BitBtn_ModPostClick(Sender: TObject);
procedure bbExitClick(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure ComboBox_EmployClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
s_OldName:string;
public
{ Public declarations }
end;
var
Form_Mater_SysPass: TForm_Mater_SysPass;
implementation
uses Unit_Mater_Main, IniFiles, UnitSysSet;
{$R *.DFM}
procedure TForm_Mater_SysPass.FormCreate(Sender: TObject);
begin
bbExit.Width:=0;
bbExit.height:=0;
ComboBox_Employ.ItemIndex:= 0;
end;
procedure TForm_Mater_SysPass.BitBtn_InsClick(Sender: TObject);
begin
Edit_Name.Enabled:=true;
Edit_NewPass.Enabled:=true;
Edit3_TwicePass.Enabled:=true;
Edit_DateBegin.Enabled:=true;
Edit_DateEnd.Enabled:=true;
RadioGroup1.Enabled:=true;
Edit_Name.Color:=clwindow;
Edit_Name.SetFocus;
Edit_NewPass.Color:=clwindow;
Edit3_TwicePass.Color:=clwindow;
Edit_DateBegin.Color:=clwindow;
Edit_DateEnd.Color:=clwindow;
BitBtn_ModPost.Enabled:=false;
BitBtn_InsPost.Enabled:=true;
BitBtn_Mod.Enabled:=false;
BitBtn_Ins.Enabled:=false;
ComboBox_Employ.Enabled:=false;
Edit_Check.Enabled:=false;
ComboBox_Employ.color:=clbtnface;
Edit_Check.color:=clbtnface;
end;
procedure TForm_Mater_SysPass.BitBtn_ModClick(Sender: TObject);
begin
if ComboBox_Employ.Items.Count = 0 then
begin
showmessage('还没有任何人员注册!');
Exit;
end;
s_OldName:=ComboBox_Employ.text;
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表 ');
sql.Add('where 姓名 = :v_name ');
parambyname('v_name').asstring:=ComboBox_Employ.text;
open;
if fieldbyname('密码').asstring <> Edit_Check.text then
begin
showmessage('密码错误!');
Edit_Check.text:='';
Edit_Check.SetFocus;
exit;
end; // if
Edit_Name.text:=fieldbyname('姓名').asstring;
Edit_DateBegin.text:=fieldbyname('任职日期').asstring;
Edit_DateEnd.text:=fieldbyname('离职日期').asstring;
if fieldbyname('职务').asstring = '其他人员' then
RadioGroup1.ItemIndex:=0;
if fieldbyname('职务').asstring = '保管员' then
RadioGroup1.ItemIndex:=1;
if fieldbyname('职务').asstring = '会计' then
RadioGroup1.ItemIndex:=2;
if fieldbyname('职务').asstring = '炼胶车间' then
RadioGroup1.ItemIndex:=3;
if fieldbyname('职务').asstring = '密码维护' then
RadioGroup1.ItemIndex:=4;
if fieldbyname('职务').asstring = '总经理' then
RadioGroup1.ItemIndex:=5;
if fieldbyname('职务').asstring = '硫化车间' then
RadioGroup1.ItemIndex:=6;
if fieldbyname('职务').asstring = '成品仓库' then
RadioGroup1.ItemIndex:=7;
if fieldbyname('职务').asstring = '订单计划' then
RadioGroup1.ItemIndex:=8;
if fieldbyname('职务').asstring = '整修车间' then
RadioGroup1.ItemIndex:=9;
end; // with
Edit_Name.Enabled:=true;
Edit_NewPass.Enabled:=true;
Edit3_TwicePass.Enabled:=true;
Edit_DateBegin.Enabled:=true;
Edit_DateEnd.Enabled:=true;
RadioGroup1.Enabled:=true;
Edit_Name.Color:=clwindow;
Edit_NewPass.Color:=clwindow;
Edit3_TwicePass.Color:=clwindow;
Edit_DateBegin.Color:=clwindow;
Edit_DateEnd.Color:=clwindow;
BitBtn_ModPost.Enabled:=true;
BitBtn_InsPost.Enabled:=false;
BitBtn_Mod.Enabled:=false;
BitBtn_Ins.Enabled:=false;
ComboBox_Employ.Enabled:=false;
Edit_Check.Enabled:=false;
ComboBox_Employ.color:=clbtnface;
Edit_Check.color:=clbtnface;
end;
procedure TForm_Mater_SysPass.BitBtn_InsPostClick(Sender: TObject);
begin
//必须填写姓名
if Edit_Name.text = '' then
begin
showmessage('请填写姓名');
exit;
end; //if
//两次密码一致
if Edit_NewPass.text <> Edit3_TwicePass.text then
begin
showmessage('两次输入的密码不一致!');
Edit3_TwicePass.text:='';
Edit3_TwicePass.SetFocus;
exit;
end; //if
//姓名唯一
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表');;
sql.Add('where 姓名 = :v_name ');
parambyname('v_name').asstring:=Edit_Name.text;
open;
if recordcount <>0 then
begin
showmessage('该姓名已经登录');
Edit_Name.text:='';
Edit_Name.SetFocus;
exit;
end;//if
end; //with
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表');;
sql.Add('where 密码 = :v_mima ');
parambyname('v_mima').asstring:=Edit_NewPass.text;
open;
if recordcount <>0 then
begin
showmessage('该密码不适宜,请另选密码!');
Edit_NewPass.text:='';
Edit3_TwicePass.Text:='';
Edit_NewPass.SetFocus;
exit;
end;//if
end; //with
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('insert into 人员登陆表 (姓名,密码,职务,任职日期,离职日期) ');;
sql.Add('values (:v_name, :v_pass, :v_Identify, :v_datebegin, :v_dateend) ');
parambyname('v_name').asstring:=Edit_Name.text;
parambyname('v_pass').asstring:=Edit_NewPass.text;
parambyname('v_Identify').asstring:=RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
parambyname('v_datebegin').asstring:=Edit_DateBegin.text;
parambyname('v_dateend').asstring:=Edit_DateEnd.text;
execsql;
end; //with
showmessage('注册完毕!');
close;
end;
procedure TForm_Mater_SysPass.FormShow(Sender: TObject);
begin
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表 ');
open;
ComboBox_Employ.clear;
while not eof do
begin
ComboBox_Employ.Items.Add(fieldbyname('姓名').asstring);
next;
end;//while
end;//with
ComboBox_Employ.ItemIndex:=0;
Edit_Name.Enabled:=false;
Edit_NewPass.Enabled:=false;
Edit3_TwicePass.Enabled:=false;
Edit_DateBegin.Enabled:=false;
Edit_DateEnd.Enabled:=false;
RadioGroup1.Enabled:=false;
Edit_Name.Color:=clbtnface;
Edit_NewPass.Color:=clbtnface;
Edit3_TwicePass.Color:=clbtnface;
Edit_DateBegin.Color:=clbtnface;
Edit_DateEnd.Color:=clbtnface;
Edit_Name.text:='';
Edit_NewPass.text:='';
Edit3_TwicePass.text:='';
Edit_DateBegin.text:='';
Edit_DateEnd.text:='';
Edit_Check.Text:='';
BitBtn_ModPost.Enabled:=false;
BitBtn_InsPost.Enabled:=false;
BitBtn_Mod.Enabled:=true;
BitBtn_Ins.Enabled:=true;
ComboBox_Employ.Enabled:=true;
Edit_Check.Enabled:=true;
ComboBox_Employ.color:=clwindow;
Edit_Check.color:=clwindow;
end;
procedure TForm_Mater_SysPass.BitBtn_ModPostClick(Sender: TObject);
begin
//必须填写姓名
if Edit_Name.text = '' then
begin
showmessage('请填写姓名');
exit;
end; //if
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('update 人员登陆表 set 密码 = :v_pass ');
sql.Add('where 姓名 = :v_OldName ');
parambyname('v_pass').asstring:='';
parambyname('v_OldName').asstring:=Edit_Name.text;
execsql;
end; //with
//两次密码一致
if Edit_NewPass.text <> Edit3_TwicePass.text then
begin
showmessage('两次输入的密码不一致!');
Edit3_TwicePass.text:='';
Edit3_TwicePass.SetFocus;
exit;
end; //if
//姓名唯一
if edit_name.text <> s_OldName then
begin
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表');;
sql.Add('where 姓名 = :v_name ');
parambyname('v_name').asstring:=Edit_Name.text;
open;
if recordcount = 1 then
begin
showmessage('该姓名已经登录');
Edit_Name.text:='';
Edit_Name.SetFocus;
exit;
end;//if
end; //with
end;//if
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表');;
sql.Add('where 密码 = :v_mima ');
parambyname('v_mima').asstring:=Edit_NewPass.text;
open;
if recordcount <>0 then
begin
showmessage('该密码不适宜,请另选密码!');
Edit_NewPass.text:='';
Edit3_TwicePass.Text:='';
Edit_NewPass.SetFocus;
exit;
end;//if
end; //with
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('update 人员登陆表 set 姓名= :v_name,密码 = :v_pass, 职务= :v_identify, ');;
sql.Add('任职日期=:v_datebegin, 离职日期 = :v_dateend ');
sql.Add('where 姓名 = :v_OldName ');
parambyname('v_name').asstring:=Edit_Name.text;
parambyname('v_pass').asstring:=Edit_NewPass.text;
parambyname('v_Identify').asstring:=RadioGroup1.Items.Strings[RadioGroup1.ItemIndex];
parambyname('v_datebegin').asstring:=Edit_DateBegin.text;
parambyname('v_dateend').asstring:=Edit_DateEnd.text;
parambyname('v_OldName').asstring:=s_OldName;
execsql;
end; //with
showmessage('修改完毕!');
close;
end;
procedure TForm_Mater_SysPass.bbExitClick(Sender: TObject);
begin
close;
end;
procedure TForm_Mater_SysPass.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
begin
key:=#0;
perform(WM_NEXTDLGCTL,0,0);
end; //if
end;
procedure TForm_Mater_SysPass.ComboBox_EmployClick(Sender: TObject);
begin
RadioGroup1.Enabled:=true;
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表');;
sql.Add('where 姓名 = :v_name ');
parambyname('v_name').asstring:=ComboBox_Employ.text;
open;
if fieldbyname('职务').asstring = '其他人员' then
RadioGroup1.ItemIndex:=0;
if fieldbyname('职务').asstring = '保管员' then
RadioGroup1.ItemIndex:=1;
if fieldbyname('职务').asstring = '会计' then
RadioGroup1.ItemIndex:=2;
if fieldbyname('职务').asstring = '炼胶车间' then
RadioGroup1.ItemIndex:=3;
if fieldbyname('职务').asstring = '密码维护' then
RadioGroup1.ItemIndex:=4;
if fieldbyname('职务').asstring = '总经理' then
RadioGroup1.ItemIndex:=5;
if fieldbyname('职务').asstring = '硫化车间' then
RadioGroup1.ItemIndex:=6;
if fieldbyname('职务').asstring = '成品仓库' then
RadioGroup1.ItemIndex:=7;
if fieldbyname('职务').asstring = '订单计划' then
RadioGroup1.ItemIndex:=8;
if fieldbyname('职务').asstring = '整修车间' then
RadioGroup1.ItemIndex:=9;
end;
RadioGroup1.Enabled:=false;
end;
procedure TForm_Mater_SysPass.Button2Click(Sender: TObject);
begin
if messagedlg('会删除“'+ComboBox_Employ.text+'”的记录 要继续吗?',mtWarning,[mbYes,mbNo],0) = mrNo then
exit;
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('delete from 人员登陆表');;
sql.Add('where 姓名 = :v_name ');
parambyname('v_name').asstring:=ComboBox_Employ.text;
execsql;
end;
with Qry_Login do
begin
close;
sql.Clear;
sql.Add('select * from 人员登陆表 ');
open;
ComboBox_Employ.clear;
while not eof do
begin
ComboBox_Employ.Items.Add(fieldbyname('姓名').asstring);
next;
end;//while
end;//with
end;
procedure TForm_Mater_SysPass.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
frmSysSet.show;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -