Выбор материала и расчет параметров обделок вертикальных стволов метрополитенов
Рефераты >> Технология >> Выбор материала и расчет параметров обделок вертикальных стволов метрополитенов

Integer): Boolean;

begin

if Table <> nil then

DataSource1.DataSet := Table

else begin

Table1.Open;

DataSource1.DataSet := Table1;

end;

if IsNew then begin

DataSource1.DataSet.Append;

DataSource1.DataSet.FieldByName('Stuff').AsInteger := Code;

end

else DataSource1.DataSet.Edit;

Result := ShowModal = mrOk;

if Result then

DataSource1.DataSet.Post

else

DataSource1.DataSet.Cancel;

end;

procedure TEdTubForm.FormCreate(Sender: TObject);

begin

Query1.Active := False;

Query1.ParamByName('St').AsInteger := FCode;

Query1.Active := True;

end;

end.

unit EditUser;

interface

uses

SysUtils, WinTypes, WinProcs, Classes, Graphics, Forms, Controls,

Buttons, StdCtrls, ExtCtrls, DBCtrls, Mask, DB, DBTables;

type

TEditUserDialog = class(TForm)

OKBtn: TBitBtn;

CancelBtn: TBitBtn;

UsersTable: TTable;

dsUsers: TDataSource;

NameEdit: TDBEdit;

FullNameEdit: TDBEdit;

GroupBox: TGroupBox;

PasswordEdit: TDBEdit;

ConfirmPassword: TEdit;

Label1: TLabel;

Label2: TLabel;

LevelGroup: TDBRadioGroup;

procedure OKBtnClick(Sender: TObject);

procedure CancelBtnClick(Sender: TObject);

procedure FormHide(Sender: TObject);

private

{ 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;

interface

type

TUserLevel = (ulInvalid, ulOperator, ulManager, ulAdministrator);

const

InvalidID = 0;

glUserLevel: TUserLevel = ulInvalid;

glUserName: string = '';

glUserID: Longint = InvalidID;

function cUserLevel(Code: Longint): TUserLevel;

implementation

function cUserLevel(Code: Longint): TUserLevel;

begin

Result := ulInvalid;

if (Code in [Integer(Low(TUserLevel)) Integer(High(TUserLevel))]) then

Result := TUserLevel(Code);

end;

end.

unit Global;

interface

type

TUserLevel = (ulInvalid, ulOperator, ulManager, ulAdministrator);

const

InvalidID = 0;

glUserLevel: TUserLevel = ulInvalid;

glUserName: string = '';

glUserID: Longint = InvalidID;

function cUserLevel(Code: Longint): TUserLevel;

implementation

function cUserLevel(Code: Longint): TUserLevel;

begin

Result := ulInvalid;

if (Code in [Integer(Low(TUserLevel)) Integer(High(TUserLevel))]) then

Result := TUserLevel(Code);

end;

end.

unit Main;

interface

uses

SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,

Controls, Forms, Dialogs, SpeedBar, Menus, ExtCtrls, Placemnt, DB,

DBSecur, DBTables;

type

TStaftForm = class(TForm)

SpeedBar: TSpeedBar;

ExitItem: TSpeedItem;

MainMenu: TMainMenu;

FileMenu: TMenuItem;

InsuranceMenuItem: TMenuItem;

FileMenuSeperator: TMenuItem;

PrinterSetupMenuItem: TMenuItem;

ExitMenuItem: TMenuItem;

DictSetupMenu: TMenuItem;

UserMenuItem: TMenuItem;

WindowMenu: TMenuItem;

TileMenuItem: TMenuItem;

CascadeMenuItem: TMenuItem;

MinimizeAllMenuItem: TMenuItem;

ArrangeAllMenuItem: TMenuItem;

HelpMenu: TMenuItem;

HelpContentsMenuItem: TMenuItem;

HelpMenuSeparator: TMenuItem;

AboutMenuItem: TMenuItem;

ChangePasswordItem: TSpeedItem;

PrintSetupItem: TSpeedItem;

CalcItem: TSpeedItem;

PrinterSetup: TPrinterSetupDialog;

TileWindowsItem: TSpeedItem;

CascadeWindowsItem: TSpeedItem;

HintPanel: TPanel;

DBSecurity1: TDBSecurity;

Database1: TDatabase;

EditItem: TMenuItem;

FormPlacement: TFormPlacement;

procedure ArrangeAllMenuItemClick(Sender: TObject);

procedure TileMenuItemClick(Sender: TObject);

procedure CascadeMenuItemClick(Sender: TObject);

procedure MinimizeAllMenuItemClick(Sender: TObject);

procedure AboutMenuItemClick(Sender: TObject);

procedure PrinterSetupMenuItemClick(Sender: TObject);

procedure ExitMenuItemClick(Sender: TObject);

procedure FormStorageRestorePlacement(Sender: TObject);


Страница: