Файл: Проектирование операций бизнес-процесса «Анализ и изучение конкуренции».pdf

ВУЗ: Не указан

Категория: Курсовая работа

Дисциплина: Не указана

Добавлен: 18.05.2023

Просмотров: 214

Скачиваний: 2

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

ADOQuery1: TADOQuery;

produre BitBtn3Click(Send: TObject);

produre Edt1Change(Send: TObject);

produre Edt2Change(Send: TObject);

produre BitBtn1Click(Send: TObject);

produre BitBtn2Click(Send: TObject);

produre FrmClose(Send: TObject; var Action: TCloseAction);

produre BitBtn4Click(Send: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Frm2: TFrm2;

implementation

Uses main;

{$R *.dfm}

produre TFrm2.BitBtn3Click(Send: TObject);

begin

Frm2.Close;

end;

produre TFrm2.Edt1Change(Send: TObject);

begin

if not (copy(caption,length(caption)-1,1) = '*') then caption:=caption+'*';

end;

produre TFrm2.Edt2Change(Send: TObject);

begin

if not (copy(caption,length(caption)-1,1) = '*') then caption:=caption+'*';

end;

produre TFrm2.BitBtn1Click(Send: TObject);

begin

openDialog1.InitialDir := GetCurrentDir;

if opendialog1.Execute then

begin

if FileExists(opendialog1.FileName) then

begin

Edt2.Text:=Opendialog1.FileName;

end;

end;

end;

produre TFrm2.BitBtn2Click(Send: TObject);

begin

if Edt1.text='' then begin showmessage('Имя шаблона не может быть пустым'); Edt1.SetFocus; exit; end;

if Edt2.text='' then begin showmessage('Необходимо выбрать файл'); BitBtn1.SetFocus; exit; end;

if not (FileExists(ExtractFilePath(ParamStr(0))+'shablon\'+Edt2.Text)) or (FileExists(Edt2.Text)) then begin showmessage('Указанный файл шаблона не найден'); BitBtn1.SetFocus; exit; end;

if OpenDialog1.filename='' then OpenDialog1.filename:=ExtractFilePath(ParamStr(0))+'shablon\'+Edt2.Text;

With AdoQuery1 do

begin

close;

SQl.clear;

SQL.add('UPDATE shablon SET caption = :caption, path = :path WHERE id = :id');

Parameters.ParamByName('caption').value:=Edt1.text;

Parameters.ParamByName('path').value:=ExtractFileName(OpenDialog1.Filename);

Parameters.ParamByName('id').value:=label3.caption;

execSQL;

end;

CopyFile(Pchar(Edt2.text), Pchar(ExtractFilePath(ParamStr(0))+'shablon\'+ExtractFileName(OpenDialog1.Filename)), true) ;

caption:=copy(caption,0,length(caption)-2);

close;

Frm1.N7.Click;

end;

produre TFrm2.FrmClose(Send: TObject; var Action: TCloseAction);

begin

if copy(caption,length(caption)-1,1) = '*' then

begin

If MessageBox(Handle,PChar('Данные были изменены. Сохранить изменения?'),PChar('Подтверждение'),MB_ICONINFRMATION+MB_YESNO+MB_DEFBUTTON2)=IdYes

then BitBtn2.Click;

end;

end;

produre TFrm2.BitBtn2Click(Send: TObject);

begin

if Edt1.text='' then begin showmessage('Имя шаблона не может быть пустым'); Edt1.SetFocus; exit; end;

if Edt2.text='' then begin showmessage('Необходимо выбрать файл'); BitBtn1.SetFocus; exit; end;

if not (FileExists(ExtractFilePath(ParamStr(0))+'shablon\'+Edt2.Text)) or (FileExists(Edt2.Text)) then begin showmessage('Указанный файл шаблона не найден'); BitBtn1.SetFocus; exit; end;

if OpenDialog1.filename='' then OpenDialog1.filename:=ExtractFilePath(ParamStr(0))+'shablon\'+Edt2.Text;

With AdoQuery1 do

begin

close;

SQl.clear;

SQL.add('UPDATE shablon SET caption = :caption, path = :path WHERE id = :id');

Parameters.ParamByName('caption').value:=Edt1.text;

Parameters.ParamByName('path').value:=ExtractFileName(OpenDialog1.Filename);

Parameters.ParamByName('id').value:=label3.caption;

execSQL;

end;

produre TFrm2.BitBtn4Click(Send: TObject);

var

Word:Variant;

begin

if fileExists(Edt2.text) then

begin

Word := CreateOleObject('Word.Application');

Word.Documents.Add(Edt2.text);

if not (copy(caption,length(caption)-1,1) = '*') then caption:=caption+'*';

Word.visible:=true;

end

else

begin

Showmessage(' Файл '+Edt2.text+' не найден.'+#10+#13+'Проверьте правильность названия файла и его наличие в указанной папке.');