Выбор материала и расчет параметров обделок вертикальных стволов метрополитеновСтраница 26
{ Private declarations }
public
{ Public declarations }
function EditUser(const UserName: string; Table: TTable; IsNew:
Boolean): Boolean;
end;
var
EditUserDialog: TEditUserDialog;
function EditUserData(const UserName: string; Table: TTable;
IsNew: Boolean): Boolean;
implementation
uses
Global, Crypt;
{$R *.DFM}
const
SNotFound = 'Записей не обнаружено';
SNoConfirmPassword = 'Вы ввели разные пароли. Проверьте
правильность ввода';
function EditUserData(const UserName: string; Table: TTable;
IsNew: Boolean): Boolean;
var
SUName: string;
begin
Result := False;
SUName := UserName;
if glUserLevel <> ulAdministrator then begin
Table := nil;
SUName := glUserName;
end;
with TEditUserDialog.Create(Application) do
try
Result := EditUser(SUName, Table, IsNew);
finally
Free;
end;
end;
{ TEditUserDialog }
function TEditUserDialog.EditUser(const UserName: string; Table:
Ttable; IsNew: Boolean): Boolean;
begin
NameEdit.Enabled := (glUserLevel = ulAdministrator);
LevelGroup.Enabled := (glUserLevel = ulAdministrator);
if Table <> nil then begin
dsUsers.DataSet := Table;
UsersTable.Close;
end
else begin
UsersTable.Open;
if UserName <> '' then begin
if not UsersTable.FindKey([UserName]) then
raise Exception.Create(SNotFound);
end;
dsUsers.DataSet := UsersTable;
end;
if IsNew then dsUsers.DataSet.Append
else dsUsers.DataSet.Edit;
ConfirmPassword.Text := PasswordEdit.Text;
Result := ShowModal = mrOk;
end;
procedure TEditUserDialog.OKBtnClick(Sender: TObject);
begin
if PasswordEdit.Text <> ConfirmPassword.Text then
raise Exception.Create(SNoConfirmPassword);
dsUsers.DataSet.Post;
ModalResult := mrOk;
end;
procedure TEditUserDialog.CancelBtnClick(Sender: TObject);
begin
dsUsers.DataSet.Cancel;
ModalResult := mrCancel;
end;
procedure TEditUserDialog.FormHide(Sender: TObject);
begin
dsUsers.DataSet.Cancel;
UsersTable.Close;
end;
end.
unit Global;