Курсовые работы / ПРИС П _21
.pdf//wdDoc.Close;
//Закрываем MS Word.
//wdApp.Quit;
end;
procedure TOOtbor.DBGrid1TitleClick(Column: TColumn); var
i:integer;
clr:TColor; begin
s:=' ASC'; clr:=clHighlight;
if RadioButton2.Checked then begin
s:=' DESC'; clr:=clAqua; end;
for i:=0 to DBGrid1.Columns.Count-1 do DBGrid1.Columns.Items[i].Title.Color:=clBtnFace; DBGrid1.Columns.Items[Column.Index].Title.Color:=clr;
DM.OtborQuery1.Sort:=DBGrid1.Columns.Items[Column.index].FieldN
ame+s;
end;
procedure TOOtbor.Edit1Change(Sender: TObject); |
// поиск по |
первому критерию |
|
var i:integer; |
|
begin |
|
if ComboBox1.ItemIndex=-1 then ComboBox1.ItemIndex:=0;
s1:=DBGrid1.Columns.Items[ComboBox1.ItemIndex].FieldName;
DM.OtborQuery1.SQL.Clear;
DM.OtborQuery1.SQL.Add('Select * from z_Fond'+' WHERE '+s1+' LIKE "'+Edit1.Text+'%"');
DM.OtborQuery1.Close;
DM.OtborQuery1.Open;
end; |
|
procedure TOOtbor.Edit2Change(Sender: TObject); |
// поиск по |
второму критерию begin
if ComboBox2.ItemIndex=-1 then ComboBox2.ItemIndex:=0;
s2:=DBGrid1.Columns.Items[ComboBox2.ItemIndex].FieldName; DM.OtborQuery1.SQL.Add('and '+s2+' LIKE "'+Edit2.Text+'%"'); DM.OtborQuery1.Close;
DM.OtborQuery1.Open;
end;
procedure TOOtbor.Button3Click(Sender: TObject); // добавить begin
DM.OtborQuery2.SQL.Clear; DM.OtborQuery2.SQL.Add('SELECT * from z_Fond2;'); DM.OtborQuery2.ExecSQL; DM.OtborQuery2.Active:=false; DM.OtborQuery2.Active:=true; DBGrid2.DataSource.DataSet.Append;
DBGrid2.DataSource.DataSet.FieldByName('f_udk2').Value:=DBGrid1.
DataSource.DataSet.FieldByName('f_udk').Value;
DBGrid2.DataSource.DataSet.FieldByName('f_vid2').AsString:=DBGrid 1.DataSource.DataSet.FieldByName('f_vid').AsString;
DBGrid2.DataSource.DataSet.FieldByName('f_nazvanie2').AsString:=D
BGrid1.DataSource.DataSet.FieldByName('f_nazvanie').AsString;
DBGrid2.DataSource.DataSet.FieldByName('f_avtor2').AsString:=DBGr id1.DataSource.DataSet.FieldByName('f_avtor').AsString;
DBGrid2.DataSource.DataSet.FieldByName('f_god2').AsString:=DBGrid 1.DataSource.DataSet.FieldByName('f_god').AsString;
DBGrid2.DataSource.DataSet.FieldByName('f_kolvo2').AsString:=DBGr id1.DataSource.DataSet.FieldByName('f_kolvo').AsString; DBGrid2.DataSource.DataSet.Post; DBGrid2.DataSource.DataSet.Refresh;
DBGrid2.DataSource.DataSet.Close;
DBGrid2.DataSource.DataSet.Open;
end;
procedure TOOtbor.Button5Click(Sender: TObject); // очистить begin
DM.OtborQuery2.Close;
DM.OtborQuery2.SQL.Clear; DM.OtborQuery2.SQL.Add('Delete from z_Fond2;'); DM.OtborQuery2.ExecSQL;
end;
procedure TOOtbor.Button4Click(Sender: TObject); // удаление begin
DBGrid2.DataSource.DataSet.Delete;
end;
procedure TOOtbor.FormClose(Sender: TObject; var Action: TCloseAction);
begin DM.OtborQuery2.Close;
DM.OtborQuery2.SQL.Clear; DM.OtborQuery2.SQL.Add('Delete from z_Fond2;'); DM.OtborQuery2.ExecSQL;
end;
procedure TOOtbor.Button2Click(Sender: TObject); const
wdAlignParagraphCenter = 1; wdAlignParagraphLeft = 0; wdAlignParagraphRight = 2;
wdLineStyleSingle = 1; var
wdApp, wdDoc, wdRng, wdTable : Variant; i, j, Res : Integer;
D : TDateTime; Bm : TBookMark; Sd : TSaveDialog;
begin //{
Sd := SaveDialog1; //SaveDialog1 уже должен быть на форме.
//Если начальная папка диалога не задана, то в качестве начальной берём ту папку,
//в которой расположен исполняемый файл нашей программы.
if Sd.InitialDir = '' then Sd.InitialDir := ExtractFilePath( ParamStr(0) );
//Запуск диалога сохранения файла. if not Sd.Execute then Exit;
//Если файл с заданным именем существует, то запускаем диалог с пользователем.
if FileExists(Sd.FileName) then begin
Res := MessageBox(0, 'Файл с заданным именем уже существует. Перезаписать?'
,'Внимание!', MB_YESNO + MB_ICONQUESTION + MB_APPLMODAL);
if Res <> IDYES then Exit; end;
//Попытка запустить MS Word. try
wdApp := CreateOleObject('Word.Application'); except
MessageBox(0, 'Не удалось запустить MS Word. Действие отменено.'
,'Внимание!', MB_OK + MB_ICONERROR + MB_APPLMODAL);
Exit;
end;
//Делаем видимым окно MS Word. На постоянной основе или на время отладки.
wdApp.Visible := True;
//Создаём новый документ. wdDoc := wdApp.Documents.Add;
//На случай, если очень много данных и wdApp.Visible := True - тогда
//для ускорения работы отключаем перерисовку окна MS Word. wdApp.ScreenUpdating := False;
try
52
wdRng := wdDoc.Content; //Диапазон, охватывающий всё содержимое документа.
//Параграф 1. Заголовок отчёта.
//Заголовок отчёта и перевод строки. wdRng.InsertAfter('Отчёт'#13#10); wdRng.InsertAfter('Список литературы'#13#10); //Выравнивание по центру.
wdRng.ParagraphFormat.Alignment := wdAlignParagraphCenter;
//Параметры шрифта.
wdRng.Font.Name := 'Times New Roman'; wdRng.Font.Bold := True; wdRng.Font.Size := 14;
//Параграф 2. Общие сведения.
//Формируем диапазон нового параграфа непосредственно за текущим диапазоном.
wdRng.Start := wdRng.End; wdRng.InsertAfter(#13#10); D := Now;
wdRng.InsertAfter('Дата: ' + FormatDateTime('dd.mm.yyyy', D) +
#13#10);
wdRng.InsertAfter('Время: ' + FormatDateTime('hh:nn:ss', D) +
#13#10);
//Сброс параметров параграфа. wdRng.ParagraphFormat.Reset;
//Выравнивание по левому краю. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft;
//Отступ слева на 2 сантиметра. Размер отступа задаётся в типографских
//единицах - в пунктах. 1 пункт = 0.035 сантиметра.
//При записи в поле LeftIndent, отступ отсчитывается от левого поля на странице.
//wdRng.ParagraphFormat.LeftIndent := 2 / 0.035;
//Параметры шрифта.
wdRng.Font.Reset; //Сброс параметров шрифта. wdRng.Font.Size := 12;
wdRng.Font.Bold := True;
//Параграф 3. Заголовок таблицы.
wdRng.Start := wdRng.End; wdRng.InsertAfter(#13#10);
wdRng.InsertAfter('Таблица 1 - Список литературы.'#13#10); wdRng.ParagraphFormat.Reset;
wdRng.Font.Reset; wdRng.Font.Size := 12; wdRng.Font.Bold := False;
//Параграф 4. Таблица.
if not DM.OtborQuery2.Active then DM.OtborQuery2.Open;
wdRng.Start := wdRng.End;
//Добавляем таблицу MS Word. Пока создаём таблицу с двумя строками.
wdTable := wdDoc.Tables.Add(wdRng.Characters.Last, 2, DM.OtborQuery2.Fields.Count-1);
//Параметры линий таблицы. wdTable.Borders.InsideLineStyle := wdLineStyleSingle; wdTable.Borders.OutsideLineStyle := wdLineStyleSingle;
//Сброс параметров параграфа. wdRng.ParagraphFormat.Reset;
//Выравнивание всей таблицы - по левому краю. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft;
//Оформление шапки.
wdRng := wdTable.Rows.Item(1).Range; //Диапазон первой строки. wdRng.ParagraphFormat.Alignment := wdAlignParagraphCenter; wdRng.Font.Size := 10;
wdRng.Font.Bold := True;
//Оформление первой строки данных - это вторая строка в таблице.
//При добавлении следующих строк, их оформление будет копироваться с этой строки.
wdRng := wdTable.Rows.Item(2).Range; //Диапазон второй строки. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft; wdRng.Font.Size := 10;
wdRng.Font.Bold := False;
//Записываем шапку таблицы.
//wdTable.Cell(1,1).Range.Text := '№ п/п';
{wdTable.Cell(1,2).Range.Text := 'УДК'; wdTable.Cell(1,3).Range.Text := 'Вид'; wdTable.Cell(1,4).Range.Text := 'Название'; wdTable.Cell(1,5).Range.Text := 'Автор'; wdTable.Cell(1,6).Range.Text := 'Год'; wdTable.Cell(1,7).Range.Text := 'Количество'; } wdTable.Cell(1,1).Range.Text := 'УДК'; wdTable.Cell(1,2).Range.Text := 'Вид'; wdTable.Cell(1,3).Range.Text := 'Название'; wdTable.Cell(1,4).Range.Text := 'Автор'; wdTable.Cell(1,5).Range.Text := 'Год'; wdTable.Cell(1,6).Range.Text := 'Количество'; //Записываем данные таблицы.
DM.OtborQuery2.DisableControls; Bm := DM.OtborQuery2.GetBookMark; DM.OtborQuery2.First;
i := 1; //Текущая строка в таблице MS Word. while not DM.OtborQuery2.Eof do begin
Inc(i);
//Если требуется, добавляем новую строку в конец таблицы. if i > 2 then wdTable.Rows.Add;
//Записываем данные в строку таблицы MS Word. for j := 0 to DM.OtborQuery2.Fields.Count - 2 do
wdTable.Cell(i, j + 1).Range.Text := DM.OtborQuery2.Fields[j].AsString;
DM.OtborQuery2.Next;
end;
DM.OtborQuery2.GotoBookMark(Bm);
DM.OtborQuery2.EnableControls;
finally
//Включение перерисовки окна MS Word. В случае, если wdApp.Visible := True.
wdApp.ScreenUpdating := True; end;
wdApp.DisplayAlerts := False; //Отключаем режим показа предупреждений.
try
wdDoc.SaveAs(FileName:=Sd.FileName); //Запись документа в файл.
finally
wdApp.DisplayAlerts := True; //Включаем режим показа предупреждений.
end;
//Закрываем документ.
//wdDoc.Close;
//Закрываем MS Word.
//wdApp.Quit;
end;
end.
Листинг Б.12 – Sost_fond
unit Sost_fond; |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, |
interface |
Forms, Dialogs, ExtCtrls, DB, ADODB, StdCtrls, ComCtrls, Grids, |
uses |
DBGrids, OleServer, COMObj, ActiveX, WordXP, ExcelXP; |
|
53 |
type
TSSost_fond = class(TForm) Label1: TLabel;
DateTimePicker1: TDateTimePicker; Button1: TButton;
DBGrid1: TDBGrid; GroupBox1: TGroupBox; RadioButton1: TRadioButton; RadioButton2: TRadioButton; GroupBox2: TGroupBox; Label2: TLabel; ComboBox1: TComboBox; Label3: TLabel;
Edit1: TEdit; Button2: TButton; Button3: TButton;
SaveDialog1: TSaveDialog; WordDocument1: TWordDocument; WordApplication1: TWordApplication; WordFont1: TWordFont; WordLetterContent1: TWordLetterContent;
WordParagraphFormat1: TWordParagraphFormat; ExcelOLEObject1: TExcelOLEObject; ExcelWorkbook1: TExcelWorkbook; ExcelWorksheet1: TExcelWorksheet; ExcelApplication1: TExcelApplication;
procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure DBGrid1TitleClick(Column: TColumn); procedure Edit1Change(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction); private
{Private declarations } public
{Public declarations } end;
var
SSost_fond: TSSost_fond; s:string;
implementation
{$R *.dfm}
uses Data_modul;
procedure TSSost_fond.FormCreate(Sender: TObject); var i:integer;
begin DM.ADOConnection1.Connected:=true; DM.Sost_fondQuery1.SQL.Clear;
DM.Sost_fondQuery1.SQL.Add('select * from z_Fondik;'); for i:=0 to DBGrid1.Columns.Count-1 do
ComboBox1.Items.Add(DBGrid1.Columns.Items[i].Title.Caption); DM.Sost_fondQuery1.Open;
DateTimePicker1.Date:=now;
DBGrid1.Visible:=false;
ComboBox1.Enabled:=false;
Edit1.Enabled:=false;
// SSost_fond.color:=$F14F56; end;
procedure TSSost_fond.Button1Click(Sender: TObject); begin
DBGrid1.Visible:=true; DM.Sost_fondQuery1.SQL.Clear;
DM.Sost_fondQuery1.SQL.Add('select * from z_Fondik;'); DM.Sost_fondQuery1.Open;
ComboBox1.Enabled:=true;
Edit1.Enabled:=true;
end;
procedure TSSost_fond.DBGrid1TitleClick(Column: TColumn); var
i:integer;
clr:TColor; begin
s:=' ASC'; clr:=clHighlight;
if RadioButton2.Checked then begin
s:=' DESC'; clr:=clAqua; end;
for i:=0 to DBGrid1.Columns.Count-1 do DBGrid1.Columns.Items[i].Title.Color:=clBtnFace; DBGrid1.Columns.Items[Column.Index].Title.Color:=clr;
DM.Sost_fondQuery1.Sort:=DBGrid1.Columns.Items[Column.index].Fie ldName+s;
end;
procedure TSSost_fond.Edit1Change(Sender: TObject); begin
if ComboBox1.ItemIndex=-1 then ComboBox1.ItemIndex:=0;
s:=DBGrid1.Columns.Items[ComboBox1.ItemIndex].FieldName; DM.Sost_fondQuery1.SQL.Clear; DM.Sost_fondQuery1.SQL.Add('Select * from z_Fondik'+' WHERE '+s+' LIKE "'+Edit1.Text+'%"');
DM.Sost_fondQuery1.Close;
DM.Sost_fondQuery1.Open; end;
procedure TSSost_fond.Button2Click(Sender: TObject); const
wdAlignParagraphCenter = 1; wdAlignParagraphLeft = 0; wdAlignParagraphRight = 2;
wdLineStyleSingle = 1; var
wdApp, wdDoc, wdRng, wdTable : Variant; i, j, Res : Integer;
D : TDateTime; Bm : TBookMark; Sd : TSaveDialog;
begin //{
Sd := SaveDialog1; //SaveDialog1 уже должен быть на форме.
//Если начальная папка диалога не задана, то в качестве начальной берём ту папку,
//в которой расположен исполняемый файл нашей программы.
if Sd.InitialDir = '' then Sd.InitialDir := ExtractFilePath( ParamStr(0) );
//Запуск диалога сохранения файла. if not Sd.Execute then Exit;
//Если файл с заданным именем существует, то запускаем диалог с пользователем.
if FileExists(Sd.FileName) then begin
Res := MessageBox(0, 'Файл с заданным именем уже существует. Перезаписать?'
,'Внимание!', MB_YESNO + MB_ICONQUESTION + MB_APPLMODAL);
if Res <> IDYES then Exit; end;
//Попытка запустить MS Word. try
wdApp := CreateOleObject('Word.Application'); except
MessageBox(0, 'Не удалось запустить MS Word. Действие отменено.'
,'Внимание!', MB_OK + MB_ICONERROR + MB_APPLMODAL);
Exit;
end;
//Делаем видимым окно MS Word. На постоянной основе или на время отладки.
wdApp.Visible := True;
//Создаём новый документ. wdDoc := wdApp.Documents.Add;
//На случай, если очень много данных и wdApp.Visible := True - тогда
54
//для ускорения работы отключаем перерисовку окна MS Word. wdApp.ScreenUpdating := False;
try
wdRng := wdDoc.Content; //Диапазон, охватывающий всё содержимое документа.
//Параграф 1. Заголовок отчёта.
//Заголовок отчёта и перевод строки. wdRng.InsertAfter('Отчёт'#13#10);
D := Now;
wdRng.InsertAfter('Состояние книжного фонда на
'+FormatDateTime('dd.mm.yyyy', D) + #13#10);
//Выравнивание по центру. wdRng.ParagraphFormat.Alignment := wdAlignParagraphCenter;
//Параметры шрифта.
wdRng.Font.Name := 'Times New Roman'; wdRng.Font.Bold := True; wdRng.Font.Size := 14;
//Параграф 2. Общие сведения.
//Формируем диапазон нового параграфа непосредственно за текущим диапазоном.
wdRng.Start := wdRng.End;
//wdRng.InsertAfter(#13#10); D := Now;
//wdRng.InsertAfter('Дата: ' + FormatDateTime('dd.mm.yyyy', D) +
#13#10);
wdRng.InsertAfter('Время: ' + FormatDateTime('hh:nn:ss', D) +
#13#10);
//wdRng.InsertAfter(#13#10);
//Сброс параметров параграфа. wdRng.ParagraphFormat.Reset;
//Выравнивание по левому краю. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft;
//Отступ слева на 2 сантиметра. Размер отступа задаётся в типографских
//единицах - в пунктах. 1 пункт = 0.035 сантиметра.
//При записи в поле LeftIndent, отступ отсчитывается от левого поля на странице.
//wdRng.ParagraphFormat.LeftIndent := 2 / 0.035;
//Параметры шрифта.
wdRng.Font.Reset; //Сброс параметров шрифта. wdRng.Font.Size := 12;
wdRng.Font.Bold := True;
//Параграф 3. Заголовок таблицы.
wdRng.Start := wdRng.End; wdRng.InsertAfter(#13#10);
wdRng.InsertAfter('Таблица 1 - Состояние фонда на '+
FormatDateTime('dd.mm.yyyy', D) + #13#10); wdRng.ParagraphFormat.Reset; wdRng.Font.Reset;
wdRng.Font.Size := 12; wdRng.Font.Bold := False;
//Параграф 4. Таблица.
if not DM.Sost_fondQuery1.Active then DM.Sost_fondQuery1.Open;
wdRng.Start := wdRng.End;
//Добавляем таблицу MS Word. Пока создаём таблицу с двумя строками.
wdTable := wdDoc.Tables.Add(wdRng.Characters.Last, 2, DM.Sost_fondQuery1.Fields.Count);
//Параметры линий таблицы. wdTable.Borders.InsideLineStyle := wdLineStyleSingle; wdTable.Borders.OutsideLineStyle := wdLineStyleSingle; //Сброс параметров параграфа. wdRng.ParagraphFormat.Reset;
//Выравнивание всей таблицы - по левому краю. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft;
//Оформление шапки.
wdRng := wdTable.Rows.Item(1).Range; //Диапазон первой строки. wdRng.ParagraphFormat.Alignment := wdAlignParagraphCenter;
55
wdRng.Font.Size := 10; wdRng.Font.Bold := True;
//Оформление первой строки данных - это вторая строка в таблице.
//При добавлении следующих строк, их оформление будет копироваться с этой строки.
wdRng := wdTable.Rows.Item(2).Range; //Диапазон второй строки. wdRng.ParagraphFormat.Alignment := wdAlignParagraphLeft; wdRng.Font.Size := 10;
wdRng.Font.Bold := False;
//Записываем шапку таблицы.
//wdTable.Cell(1,1).Range.Text := '№ п/п';
{wdTable.Cell(1,2).Range.Text := 'УДК'; wdTable.Cell(1,3).Range.Text := 'Вид'; wdTable.Cell(1,4).Range.Text := 'Название'; wdTable.Cell(1,5).Range.Text := 'Автор'; wdTable.Cell(1,6).Range.Text := 'Год'; wdTable.Cell(1,7).Range.Text := 'Количество'; } wdTable.Cell(1,1).Range.Text := 'УДК'; wdTable.Cell(1,2).Range.Text := 'Вид'; wdTable.Cell(1,3).Range.Text := 'Название'; wdTable.Cell(1,4).Range.Text := 'Автор'; wdTable.Cell(1,5).Range.Text := 'Год'; wdTable.Cell(1,6).Range.Text := 'Количество'; //Записываем данные таблицы.
DM.Sost_fondQuery1.DisableControls;
Bm := DM.Sost_fondQuery1.GetBookMark; DM.Sost_fondQuery1.First;
i := 1; //Текущая строка в таблице MS Word. while not DM.Sost_fondQuery1.Eof do begin
Inc(i);
//Если требуется, добавляем новую строку в конец таблицы. if i > 2 then wdTable.Rows.Add;
//Записываем данные в строку таблицы MS Word.
for j := 0 to DM.Sost_fondQuery1.Fields.Count - 1 do wdTable.Cell(i, j + 1).Range.Text :=
DM.Sost_fondQuery1.Fields[j].AsString; DM.Sost_fondQuery1.Next;
end; DM.Sost_fondQuery1.GotoBookMark(Bm); DM.Sost_fondQuery1.EnableControls;
finally
//Включение перерисовки окна MS Word. В случае, если wdApp.Visible := True.
wdApp.ScreenUpdating := True; end;
wdApp.DisplayAlerts := False; //Отключаем режим показа предупреждений.
try
wdDoc.SaveAs(FileName:=Sd.FileName); //Запись документа в файл.
finally
wdApp.DisplayAlerts := True; //Включаем режим показа предупреждений.
end;
//Закрываем документ.
//wdDoc.Close;
//Закрываем MS Word.
//wdApp.Quit;
end;
procedure TSSost_fond.Button3Click(Sender: TObject); var i,j,index: Integer;
ExcelApp,sheet, exRng: Variant; ClassID: TCLSID;
Rez : HRESULT; begin
Rez := CLSIDFromProgID(PWideChar(WideString('Excel.Application')), ClassID);
if Rez <> S_OK then begin
MessageDlg('Excel не установлен!',mtERROR,[mbok],0);
Exit;
end;
ExcelApp := CreateOleObject('Excel.Application'); ExcelApp.Visible := true; ExcelApp.WorkBooks.Add(-4167);
ExcelApp.WorkBooks[1].WorkSheets[1].name := 'Состояние фонда'; sheet:=ExcelApp.WorkBooks[1].WorkSheets['Состояние фонда'];
Sheet.Cells[1,1]:='Состояние фонда на ';
Sheet.Cells[1,2]:=DateTimePicker1.DateTime;
// Sheet.Cells[1, 1].Resize[1,2].Merge; объединение Sheet.Cells[3,1]:='УДК';
Sheet.Cells[3,2]:='Вид'; Sheet.Cells[3,3]:='Название'; Sheet.Cells[3,4]:='Автор'; Sheet.Cells[3,5]:='Год'; Sheet.Cells[3,6]:='Количество'; index:=4; DBGrid1.DataSource.DataSet.First;
for i:=3 to DBGrid1.DataSource.DataSet.RecordCount+2 do begin
for j:=1 to DBGrid1.FieldCount do sheet.cells[index,j]:=DBGrid1.fields[j-1].asstring; inc(index);
ExcelApp.Columns.AutoFit;
// exSheet := ExBook.WorkSheets[1];
exRng := sheet.Range[sheet.Cells[3,1], sheet.Cells[DBGrid1.DataSource.DataSet.RecordCount+3, DBGrid1.FieldCount]];
exRng.Borders[xlEdgeTop].LineStyle := xlContinuous; exRng.Borders[xlEdgeTop].Weight := xlMedium; exRng.Borders[xlEdgeBottom].LineStyle := xlContinuous; exRng.Borders[xlEdgeBottom].Weight := xlMedium; exRng.Borders[xlEdgeLeft].LineStyle := xlContinuous; exRng.Borders[xlEdgeLeft].Weight := xlMedium; exRng.Borders[xlEdgeRight].LineStyle := xlContinuous; exRng.Borders[xlEdgeRight].Weight := xlMedium;
//Обрамление ячеек внутри диапазона. exRng.Borders[xlInsideHorizontal].LineStyle := xlContinuous; exRng.Borders[xlInsideHorizontal].Weight := xlThin; exRng.Borders[xlInsideVertical].LineStyle := xlContinuous; exRng.Borders[xlInsideVertical].Weight := xlThin;
sheet.Cells[3, 1].Font.Bold:=true; // жирность sheet.Cells[3, 2].Font.Bold:=true;
sheet.Cells[3, 3].Font.Bold:=true; sheet.Cells[3, 4].Font.Bold:=true; sheet.Cells[3, 5].Font.Bold:=true;
sheet.Cells[3, 6].Font.Bold:=true;
sheet.Cells[3, 1].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 1].Borders[xlEdgeBottom].Weight := xlMedium; sheet.Cells[3, 2].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 2].Borders[xlEdgeBottom].Weight := xlMedium; sheet.Cells[3, 3].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 3].Borders[xlEdgeBottom].Weight := xlMedium; sheet.Cells[3, 4].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 4].Borders[xlEdgeBottom].Weight := xlMedium; sheet.Cells[3, 5].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 5].Borders[xlEdgeBottom].Weight := xlMedium;
sheet.Cells[3, 6].Borders[xlEdgeBottom].LineStyle := xlContinuous; sheet.Cells[3, 6].Borders[xlEdgeBottom].Weight := xlMedium;
sheet.Cells[3, 1].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 1].Borders[xlEdgeLeft].Weight := xlMedium; sheet.Cells[3, 2].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 2].Borders[xlEdgeLeft].Weight := xlMedium; sheet.Cells[3, 3].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 3].Borders[xlEdgeLeft].Weight := xlMedium; sheet.Cells[3, 4].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 4].Borders[xlEdgeLeft].Weight := xlMedium; sheet.Cells[3, 5].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 5].Borders[xlEdgeLeft].Weight := xlMedium;
sheet.Cells[3, 6].Borders[xlEdgeLeft].LineStyle := xlContinuous; sheet.Cells[3, 6].Borders[xlEdgeLeft].Weight := xlMedium;
// exRng.Columns.AutoFit; DBGrid1.DataSource.DataSet.Next;
end;
end;
procedure TSSost_fond.FormClose(Sender: TObject; var Action: TCloseAction);
begin DBGrid1.Visible:=false; ComboBox1.Enabled:=false; Edit1.Enabled:=false;
end;
end.
Листинг Б.13 – Parol
unit Parol; |
procedure DBLookupComboBox1CloseUp(Sender: TObject); |
|
|||||
|
private |
|
|
|
|
|
|
interface |
{ Private declarations } |
|
|
|
|||
|
public |
|
|
|
|
|
|
uses |
{ Public declarations } |
|
|
|
|||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, |
end; |
|
|
|
|
|
|
Forms, |
|
|
|
|
|
|
|
Dialogs, StdCtrls, DBCtrls, Mask, jpeg, ExtCtrls, iniFiles; |
var |
|
|
|
|
|
|
|
PParol: TPParol; |
|
|
|
|
||
type |
pass:boolean; |
|
|
|
|
||
TPParol = class(TForm) |
pwd:string; |
//верный пароль |
|
|
|
||
Button1: TButton; |
flag:boolean; // признак существования формы |
|
|
||||
Button2: TButton; |
posetitel:string; |
// переменная в |
которой будем запоминать |
||||
DBLookupComboBox1: TDBLookupComboBox; |
посетителей |
|
|
|
|
|
|
Label3: TLabel; |
|
|
|
|
|
|
|
Label4: TLabel; |
implementation |
|
|
|
|
||
Edit1: TEdit; |
|
|
|
|
|
|
|
DBEdit1: TDBEdit; |
{$R *.dfm} |
|
|
|
|
|
|
DBEdit2: TDBEdit; |
|
|
|
|
|
|
|
Image1: TImage; |
uses |
Fond,Chitatel,Vidacha,Zakaz, |
Oplata, |
Zadolgniki, |
|||
OpenDialog1: TOpenDialog; |
Nevip_zakaz,Dolgniki,Otbor,Sost_fond, |
|
|
|
|||
procedure FormClose(Sender: TObject; var Action: TCloseAction); |
Data_modul,Smena_parol, Main_menu; |
|
|
|
|||
procedure FormCreate(Sender: TObject); |
|
|
|
|
|
|
|
procedure Button1Click(Sender: TObject); |
procedure |
|
TPParol.FormClose(Sender: |
TObject; |
var |
Action: |
|
procedure Button2Click(Sender: TObject); |
TCloseAction); |
|
|
|
|
||
|
56 |
|
|
|
|
|
|
begin
if not pass then form1.Close; end;
procedure TPParol.FormCreate(Sender: TObject); var
DBPath:widestring;
F:TIniFile; buttonSelected : Integer;
begin
If FileExists(GetCurrentDir+'\biblio.mdb') then begin
MessageDlg('Связь c БД установлена.',mtInformation, [mbOk], 0);
F:=TiniFile.Create(ExtractFilePath(Application.ExeName)+'Options.ini');
DBPath:=GetCurrentDir+'\'; F.WriteString('Section_DBPath','Path',DBPath); F.Free;
end else begin
buttonSelected:=MessageDlg('Связь с БД отсутствует. Установить?
',mtError, mbOKCancel, 0);
F:=TiniFile.Create(ExtractFilePath(Application.ExeName)+'Options.ini'); if OpenDialog1.Execute then
begin DBPath:=ExtractFilePath(OpenDialog1.FileName); F.WriteString('Section_DBPath','Path',DBPath);
if buttonSelected = mrOK then begin
DM.ADOConnection1.Close;
DM.ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLE DB.4.0;Data Source='+DBPath+'biblio.mdb;Persist Security Info=False';
DM.ADOConnection1.Open;
DM.ParolQuery1.SQL.Clear; DM.ParolQuery1.SQL.Add('SELECT Parol.*FROM Parol;'); DM.ParolQuery1.Open;
end;
F.Free;
end;
if buttonSelected = mrCancel then begin
DM.ADOConnection1.Connected:=false;
Application.Terminate;
end;
end;
end;
Листинг Б.14 – Smena_parol
unit Smena_parol;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, DBCtrls, jpeg, ExtCtrls;
type
TSSmena_parol = class(TForm) Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
DBLookupComboBox1: TDBLookupComboBox; BitBtn2: TBitBtn;
BitBtn1: TBitBtn; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit;
procedure TPParol.Button1Click(Sender: TObject); begin
if posetitel<>'' then
if pwd<>Trim(Edit1.Text) then
MessageDlg('Неверный пароль!',mtError, [mbOK], 0) else
begin flag:=false;
if not flag then begin
Form1:=TForm1.Create(self);
Form1.Label4.Caption:=DBLookupComboBox1.Text;
flag:=true;
end;
Form1.Show;
PParol.Hide;
DM.ParolQuery1.SQL.Clear;
DM.ParolQuery1.Close; end
else MessageDlg('Укажите пользователя', mtWarning, [mbOK], 0); end;
procedure TPParol.Button2Click(Sender: TObject); begin
PParol.Close;
Form1.Close;
end;
procedure TPParol.DBLookupComboBox1CloseUp(Sender: TObject); begin
posetitel:=DBLookupComboBox1.Text; if posetitel<>'' then
begin Edit1.SetFocus;
DM.ParolQuery1.Close;
DM.ParolQuery1.SQL.Clear; DM.ParolQuery1.SQL.Add('SELECT Parol.*' +' FROM Parol'
+' WHERE Parol.par_id='+IntToStr(DBLookupComboBox1.KeyValue)+';');
DM.ParolQuery1.Open; pwd:=DM.ParolQuery1.FieldByName('par_parol').AsString; DM.ParolQuery1.SQL.Clear; DM.ParolQuery1.SQL.Add('SELECT Parol.*FROM Parol;'); DM.ParolQuery1.Open;
end;
end;
end.
procedure BitBtn1Click(Sender: TObject);
procedure DBLookupComboBox1CloseUp(Sender: TObject); procedure BitBtn2Click(Sender: TObject);
procedure FormShow(Sender: TObject); private
{Private declarations } public
{Public declarations } end;
var
SSmena_parol: TSSmena_parol; posetitel,pwd:string;
implementation
{$R *.dfm}
uses Data_modul, Main_menu;
procedure TSSmena_parol.BitBtn1Click(Sender: TObject); begin
57
if posetitel<>'' then |
|
|
|
Form1.N16.Enabled:=true; |
// состояние фонда |
|
|
if pwd<>Trim(Edit1.Text) then |
|
|
|
Form1.N14.Enabled:=true; |
// отбор литературы |
|
|
MessageDlg('Неверный пароль',mtError,[mbOk],0) |
|
|
Form1.N13.Enabled:=true; |
// задолжники |
|
||
else |
|
|
|
Form1.N12.Enabled:=true; |
// невыполненные заказы |
||
begin |
|
|
|
Form1.N11.Enabled:=true; |
// должники |
|
|
if Edit2.text=Edit3.Text then |
|
|
|
Form1.N1.Enabled:=true; |
// файл |
|
|
begin |
|
|
|
Form1.N3.Enabled:=true; |
// справочники |
|
|
DM.Smena_parolQuery1.SQL.Clear; |
|
|
Form1.N17.Enabled:=true; |
// сервис |
|
||
DM.Smena_parolQuery1.SQL.Add('Update |
Parol |
set |
Form1.N19.Visible:=true; // смена пароля |
|
|||
par_parol="'+Edit3.Text+'" |
|
|
where |
Form1.N21.Visible:=true; // резервное копирование |
|||
par_id='+IntToStr(DBLookupComboBox1.KeyValue)+';'); |
|
Form1.N22.Enabled:=true; |
// справка |
|
|||
DM.Smena_parolQuery1.ExecSQL; |
|
|
Form3.GroupBox1.Enabled:=true; // читатели |
|
|||
Form1:=TForm1.Create(self); |
|
|
Form3.DBNavigator1.Enabled:=true; // читатели |
|
|||
Form1.Show; |
|
|
|
Form16.GroupBox1.Enabled:=true; // заказы |
|
||
if posetitel='ГОСТЬ' then |
|
|
|
Form16.DBNavigator1.Enabled:=true; // заказы |
|
||
begin |
|
|
|
Form2.GroupBox1.Enabled:=true; // фонд |
|
||
{Form1.N10.Visible:=false; // отчеты |
|
|
Form2.DBNavigator1.Enabled:=true; // фонд |
|
|||
Form1.N16.Enabled:=false; |
// состояние фонда |
|
|
Form5.GroupBox1.Enabled:=true; // выдача |
|
||
Form1.N14.Enabled:=false; |
// отбор литературы |
|
|
Form5.DBNavigator1.Enabled:=true; // выдача |
|
||
Form1.N13.Enabled:=false; |
// задолжники |
|
|
Form6.GroupBox1.Enabled:=true; // штрафы |
|
||
Form1.N12.Enabled:=false; |
// невыполненные заказы |
|
Form6.DBNavigator1.Enabled:=true; // штрафы |
} |
|||
Form1.N11.Enabled:=false; |
// должники |
|
|
end; |
|
|
|
Form1.N1.Enabled:=true; |
// файл |
|
|
SSmena_parol.Hide; |
|
|
|
Form1.N3.Enabled:=true; |
// справочники |
|
|
DM.Smena_parolQuery1.SQL.Clear; |
|
||
Form1.N17.Enabled:=true; |
// сервис |
|
|
DM.Smena_parolQuery1.Close; |
|
||
Form1.N19.Visible:=false; // смена пароля |
|
|
end |
|
|
|
|
Form1.N21.Visible:=false; // резервное копирование |
|
else |
|
|
|
||
Form1.N22.Enabled:=true; |
// справка |
|
|
MessageDlg('Неверное дублирование пароля',mtError,[mbOk],0); |
|||
Form3.GroupBox1.Enabled:=false; // читатели |
|
|
end |
|
|
|
|
Form3.DBNavigator1.Enabled:=false; // читатели |
|
|
else |
|
|
|
|
Form16.GroupBox1.Enabled:=false; // заказы |
|
|
MessageDlg('Укажите пользователя',mtWarning,[mbOk],0); |
||||
Form16.DBNavigator1.Enabled:=false; // заказы |
|
|
end; |
|
|
|
|
Form2.GroupBox1.Enabled:=false; // фонд |
|
|
|
|
|
|
|
Form2.DBNavigator1.Enabled:=false; // фонд |
|
|
|
|
|
|
|
Form5.GroupBox1.Enabled:=false; // выдача |
|
|
procedure |
TSSmena_parol.DBLookupComboBox1CloseUp(Sender: |
|||
Form5.DBNavigator1.Enabled:=false; // выдача |
|
|
TObject); |
|
|
|
|
Form6.GroupBox1.Enabled:=false; // штрафы |
|
|
begin |
|
|
|
|
Form6.DBNavigator1.Enabled:=false; // штрафы |
} |
|
posetitel:=DBLookupComboBox1.Text; |
|
|||
end; |
|
|
|
if posetitel <> '' then |
|
|
|
if posetitel='БИБЛИОТЕКАРЬ' then |
|
|
begin |
|
|
|
|
begin |
|
|
|
Edit1.SetFocus; |
|
|
|
{ Form1.N10.Visible:=true; |
// отчеты |
|
|
DM.Smena_parolQuery1.Close; |
|
||
Form1.N16.Enabled:=true; |
// состояние фонда |
|
|
DM.Smena_parolQuery1.SQL.Clear; |
|
||
Form1.N14.Enabled:=true; |
// отбор литературы |
|
|
DM.Smena_parolQuery1.SQL.Add('select * from |
Parol where |
||
Form1.N13.Enabled:=true; |
// задолжники |
|
|
par_id='+inttostr(DBLookupComboBox1.KeyValue)+';'); |
|||
Form1.N12.Enabled:=false; |
// невыполненные заказы |
|
DM.Smena_parolQuery1.Open; |
|
|||
Form1.N11.Enabled:=false; |
// должники |
|
|
pwd:= DM.Smena_parolQuery1.fieldByName('par_parol').AsString; |
|||
Form1.N1.Enabled:=true; |
// файл |
|
|
DM.Smena_parolQuery1.SQL.Clear; |
|
||
Form1.N3.Enabled:=true; |
// справочники |
|
|
DM.Smena_parolQuery1.SQL.Add('select * from Parol;'); |
|||
Form1.N17.Enabled:=true; |
// сервис |
|
|
DM.Smena_parolQuery1.Open; |
|
||
Form1.N19.Visible:=true; // смена пароля |
|
|
end; |
|
|
|
|
Form1.N21.Visible:=true; // резервное копирование |
|
end; |
|
|
|
||
Form1.N22.Enabled:=true; |
// справка |
|
|
|
|
|
|
Form3.GroupBox1.Enabled:=true; // читатели |
|
|
procedure TSSmena_parol.BitBtn2Click(Sender: TObject); |
||||
Form3.DBNavigator1.Enabled:=true; // читатели |
|
|
begin |
|
|
|
|
Form16.GroupBox1.Enabled:=true; // заказы |
|
|
SSmena_parol.Close; |
|
|
||
Form16.DBNavigator1.Enabled:=true; // заказы |
|
|
end; |
|
|
|
|
Form2.GroupBox1.Enabled:=true; // фонд |
|
|
|
|
|
|
|
Form2.DBNavigator1.Enabled:=true; // фонд |
|
|
procedure TSSmena_parol.FormShow(Sender: TObject); |
|
|||
Form5.GroupBox1.Enabled:=true; // выдача |
|
|
begin |
|
|
|
|
Form5.DBNavigator1.Enabled:=true; // выдача |
|
|
DM.Smena_parolQuery1.SQL.Clear; |
|
|||
Form6.GroupBox1.Enabled:=true; // штрафы |
|
|
DM.Smena_parolQuery1.SQL.Add('select * from Parol'); |
||||
Form6.DBNavigator1.Enabled:=true; // штрафы |
} |
|
DM.Smena_parolQuery1.Open; |
|
|
||
end; |
|
|
|
end; |
|
|
|
if posetitel='АДМИНИСТРАТОР' then |
|
|
|
|
|
|
|
begin |
|
|
|
end. |
|
|
|
{ Form1.N10.Visible:=true; |
// отчеты |
|
|
|
|
|
|
58