Сдам Сам

ПОЛЕЗНОЕ


КАТЕГОРИИ







Исходный текс программного продукта





unit Unit1;// Главная форма, отображения таблицы студента

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, StdCtrls, ComCtrls, Menus, Buttons, ExtCtrls,

DBCtrls, Mask, sSkinManager, sSpeedButton, ToolWin, sToolBar, sMaskEdit,

sCustomComboEdit,OleServer,WordXP,jpeg,DB, ADODB, Registry, ComObj, sTooledit,

ExcelXP;

type

TForm1 = class(TForm)

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

N9: TMenuItem;

N10: TMenuItem;

StatusBar1: TStatusBar;

Timer1: TTimer;

N11: TMenuItem;

N13: TMenuItem;

FontDialog1: TFontDialog;

N14: TMenuItem;

PopupMenu1: TPopupMenu;

N15: TMenuItem;

N16: TMenuItem;

N17: TMenuItem;

asdasd1: TMenuItem;

N20: TMenuItem;

sSkinManager1: TsSkinManager;

sToolBar1: TsToolBar;

sSpeedButton1: TsSpeedButton;

sSpeedButton2: TsSpeedButton;

sSpeedButton3: TsSpeedButton;

sSpeedButton4: TsSpeedButton;

sSpeedButton5: TsSpeedButton;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

sSpeedButton6: TsSpeedButton;

DBGrid1: TDBGrid;

Word1: TMenuItem;

Label1: TLabel;

Edit1: TEdit;

Label2: TLabel;

N21: TMenuItem;

N22: TMenuItem;

N23: TMenuItem;

N24: TMenuItem;

N25: TMenuItem;

N26: TMenuItem;

N27: TMenuItem;

N28: TMenuItem;

N29: TMenuItem;

N30: TMenuItem;

N31: TMenuItem;

BitBtn5: TBitBtn;

N12: TMenuItem;

sSpeedButton7: TsSpeedButton;

sSpeedButton8: TsSpeedButton;

sSpeedButton9: TsSpeedButton;

N18: TMenuItem;

sSpeedButton10: TsSpeedButton;

ExcelApplication1: TExcelApplication;

Excel1: TMenuItem;

sSkinManager2: TsSkinManager;

Edit2: TEdit;

N19: TMenuItem;

N32: TMenuItem;

N33: TMenuItem;

procedure sSpeedButton1Click(Sender: TObject);

procedure sSpeedButton2Click(Sender: TObject);

procedure sSpeedButton3Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

procedure Edit1Change(Sender: TObject);

procedure Edit1DblClick(Sender: TObject);

procedure N22Click(Sender: TObject);

procedure N23Click(Sender: TObject);

procedure N24Click(Sender: TObject);

procedure N25Click(Sender: TObject);

procedure N26Click(Sender: TObject);

procedure N27Click(Sender: TObject);

procedure N28Click(Sender: TObject);

procedure N29Click(Sender: TObject);

procedure N30Click(Sender: TObject);

procedure N31Click(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure BitBtn5Click(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key: Char);

procedure DBGrid1DblClick(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure sSpeedButton5Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure sSpeedButton6Click(Sender: TObject);

procedure sSpeedButton10Click(Sender: TObject);

procedure Edit2Change(Sender: TObject);

procedure sSpeedButton4Click(Sender: TObject);

procedure N14Click(Sender: TObject);

procedure N20Click(Sender: TObject);

procedure sSpeedButton7Click(Sender: TObject);

procedure sSpeedButton8Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Edit2KeyPress(Sender: TObject; var Key: Char);

procedure Edit2DblClick(Sender: TObject);

procedure N33Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

seting:text; //для сохранения настроек в файл

a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,b1,b2,b3:Longint; //служат для сохранения ширины столбцов всех DBGrid

implementation

uses Unit2, Unit3, Unit5, Unit6, Unit7, Unit8, Unit9, Unit10,

Unit11, Unit4, Unit12, Unit13, Unit14;

{$R *.dfm}

function IsWordInstalled: Boolean;

var

Reg: TRegistry;

begin

Reg := TRegistry.Create;

try

Reg.RootKey := HKEY_CLASSES_ROOT;

Result := Reg.KeyExists('Word.Application');

finally

reg.Free;

end;

end;

procedure TForm1.sSpeedButton1Click(Sender: TObject); //Отображения таблицы куратор

begin

Form4.Show;

Form4.Visible:=true;

Form1.Enabled:=False;

end;

procedure TForm1.sSpeedButton2Click(Sender: TObject); //отображения формы комната

begin

Form12.Show;

Form12.Visible:=true;

Form1.Enabled:=False;

end;

procedure TForm1.sSpeedButton3Click(Sender: TObject); //отображения формы группы

begin

Form13.Show;

Form13.Visible:=true;

Form1.Enabled:=False;



end;

procedure TForm1.BitBtn1Click(Sender: TObject); //отображения формы для добавления записи в таблицу студенты

begin

Form3.Show;

Form3.Visible:=true;

Form3.BitBtn1.Visible:=True;

Form3.BitBtn3.Visible:=False;

Form3.sDateEdit1.Date:=(Date);

Form1.Enabled:=False;

end;

procedure TForm1.BitBtn2Click(Sender: TObject);//отображения формы для изменения записи в таблицу студенты

begin

with Form3 do

begin

Edit1.Text:=DataModule2.ADOTable1.FieldValues['FIO_Stud'];

Edit2.Text:=DataModule2.ADOTable1.FieldValues['Raion'];

Edit3.Text:=DataModule2.ADOTable1.FieldValues['Gorod'];

Edit4.Text:=DataModule2.ADOTable1.FieldValues['Adres'];

Edit5.Text:=DataModule2.ADOTable1.FieldValues['Telefon'];

Edit6.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sot'];

sDBLookupComboBox1.KeyValue:=DataModule2.ADOTable1.FieldValues['Gruppa'];

DBEdit1.Text:=DataModule2.ADOTable1.FieldValues['Kurator']; sDBLookupComboBox3.KeyValue:=DataModule2.ADOTable1.FieldValues['Komnata'];

sDateEdit1.Date:=DataModule2.ADOTable1.FieldValues['Data_Zaselenia'];

sDateEdit2.Date:=DataModule2.ADOTable1.FieldValues['Data_roj'];

Edit7.Text:=DataModule2.ADOTable1.FieldValues['FIO_Rod'];

Edit8.Text:=DataModule2.ADOTable1.FieldValues['Telefon_Rod'];

Edit9.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sotov'];

Memo1.Text:=DataModule2.ADOTable1.FieldValues['Primechanie'];

Label14.Caption:=DataModule2.ADOTable1.FieldValues['Kod'];

Form3.Show;

Form3.Visible:=true;

Form3.BitBtn1.Visible:=False;

Form3.BitBtn3.Visible:=True;

Form1.Enabled:=False;

end;

end;

procedure TForm1.BitBtn3Click(Sender: TObject); //удаления записи

var

f:string;

begin

F:=DataModule2.ADOTable1.FieldValues['FIO_Stud'];

if MessageDlg

('Вы действительно хотите удалить '+f+'',mtConfirmation,[mbYes,mbNo],0)= idYes

then

DataModule2.ADOTable1.Delete;

If DBGrid1.Columns.Items[0].Field.Text='' then begin

BitBtn2.Enabled:=False;

BitBtn3.Enabled:=False;

end

else

begin

BitBtn3.Enabled:=True;

BitBtn2.Enabled:=True;

end;

end;

procedure TForm1.BitBtn4Click(Sender: TObject);//выход из программы

begin

if Application.MessageBox('Вы действительно хотите выйти?','Внимание!!!',

mb_YesNo+mb_Iconquestion)=idYes

then

Form8.Close;

rewrite(seting);

Writeln(seting,Form1.DBGrid1.Columns.Items[1].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[2].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[3].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[4].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[5].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[6].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[7].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[8].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[9].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[10].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[11].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[12].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[1].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[2].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[3].Width);

CloseFile(seting);

end;

procedure TForm1.FormActivate(Sender: TObject);//проверка записей на наличие

begin

If DBGrid1.Columns.Items[0].Field.Text='' then begin

BitBtn2.Enabled:=False;

BitBtn3.Enabled:=False;

end

else

begin

BitBtn3.Enabled:=True;

BitBtn2.Enabled:=True;

end;

end;

procedure TForm1.Timer1Timer(Sender: TObject); //отображения время и даты

begin

StatusBar1.Panels[1].Text:=TimeToStr(time);

StatusBar1.Panels[2].Text:=DateToStr(Date);

end;

procedure TForm1.Edit1Change(Sender: TObject); //поиск

begin

DataModule2.ADOTable1.Locate('FIO_Stud',Edit1.Text,[loPartialKey]);

end;

procedure TForm1.Edit1DblClick(Sender: TObject); //очистка поля

begin

Edit1.Clear;

end;

procedure TForm1.N22Click(Sender: TObject); //сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Komnata';

end;

procedure TForm1.N23Click(Sender: TObject); //сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='FIO_Stud';

end;

procedure TForm1.N24Click(Sender: TObject); //сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Raion';

end;

procedure TForm1.N25Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Gorod';

end;

procedure TForm1.N26Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Adres';

end;

procedure TForm1.N27Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Telefon';

end;

procedure TForm1.N28Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Telefon_sot';

end;

procedure TForm1.N29Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Gruppa';

end;

procedure TForm1.N30Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Kurator';

end;

procedure TForm1.N31Click(Sender: TObject);//сортировка

begin

DataModule2.ADOTable1.IndexFieldNames:='Data_Zaselenia';

end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); //выход из программы

begin

Form8.Close;

rewrite(seting);

Writeln(seting,Form1.DBGrid1.Columns.Items[1].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[2].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[3].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[4].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[5].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[6].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[7].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[8].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[9].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[10].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[11].Width);

Writeln(seting,Form1.DBGrid1.Columns.Items[12].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[1].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[2].Width);

Writeln(seting,Form4.DBGrid1.Columns.Items[3].Width);

CloseFile(seting);

end;

procedure TForm1.BitBtn5Click(Sender: TObject); //переход к личным данным

begin

if Edit1.Text='' then

begin

ShowMessage('Введите запись в поле поиска по ФИО студента');

end

else

begin

if Edit1.Text=DataModule2.ADOTable1.FieldValues['FIO_Stud'] then

begin

Form6.Caption:='Личные данные '+DataModule2.ADOTable1.FieldValues['FIO_Stud'];

with Form6 do

begin

Edit1.Text:=DataModule2.ADOTable1.FieldValues['FIO_Stud'];

Edit2.Text:=DataModule2.ADOTable1.FieldValues['Raion'];

Edit3.Text:=DataModule2.ADOTable1.FieldValues['Gorod'];

Edit4.Text:=DataModule2.ADOTable1.FieldValues['Adres'];

Edit5.Text:=DataModule2.ADOTable1.FieldValues['Telefon'];

Edit6.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sot']; sDBLookupComboBox1.KeyValue:=DataModule2.ADOTable1.FieldValues['Gruppa']; sDBLookupComboBox2.KeyValue:=DataModule2.ADOTable1.FieldValues['Kurator']; sDBLookupComboBox3.KeyValue:=DataModule2.ADOTable1.FieldValues['Komnata'];

sDateEdit1.Date:=DataModule2.ADOTable1.FieldValues['Data_Zaselenia'];

Edit7.Text:=DataModule2.ADOTable1.FieldValues['FIO_Rod'];

Edit8.Text:=DataModule2.ADOTable1.FieldValues['Telefon_Rod'];

Edit9.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sotov'];

sDateEdit2.Date:=DataModule2.ADOTable1.FieldValues['Data_roj'];

Memo1.Text:=DataModule2.ADOTable1.FieldValues['Primechanie'];

Form6.Show;

Form6.Visible:=true;

Form1.Enabled:=False;

end;

end

else

begin

ShowMessage('Запись не найдена');

Edit1.Clear;

end;

end;

end;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); //запрет ввода

begin

if key=#13 then BitBtn5.Click;

end;

procedure TForm1.DBGrid1DblClick(Sender: TObject); //переход к личным данным

begin

with Form6 do

begin

Edit1.Text:=DataModule2.ADOTable1.FieldValues['FIO_Stud'];

Edit2.Text:=DataModule2.ADOTable1.FieldValues['Raion'];

Edit3.Text:=DataModule2.ADOTable1.FieldValues['Gorod'];

Edit4.Text:=DataModule2.ADOTable1.FieldValues['Adres'];

Edit5.Text:=DataModule2.ADOTable1.FieldValues['Telefon'];

Edit6.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sot']; sDBLookupComboBox1.KeyValue:=DataModule2.ADOTable1.FieldValues['Gruppa']; sDBLookupComboBox2.KeyValue:=DataModule2.ADOTable1.FieldValues['Kurator'];

sDBLookupComboBox3.KeyValue:=DataModule2.ADOTable1.FieldValues['Komnata'];

sDateEdit1.Date:=DataModule2.ADOTable1.FieldValues['Data_Zaselenia'];

Edit7.Text:=DataModule2.ADOTable1.FieldValues['FIO_Rod'];

Edit8.Text:=DataModule2.ADOTable1.FieldValues['Telefon_Rod'];

Edit9.Text:=DataModule2.ADOTable1.FieldValues['Telefon_sotov'];

sDateEdit2.Date:=DataModule2.ADOTable1.FieldValues['Data_roj'];

Memo1.Text:=DataModule2.ADOTable1.FieldValues['Primechanie'];

Form6.Show;

Form6.Visible:=true;

Form1.Enabled:=False;

end;

end;

procedure TForm1.N4Click(Sender: TObject); //отображения формы о программе

begin

Form11.Show;

Form11.Visible:=true;

Form1.Enabled:=False;

end;

procedure TForm1.sSpeedButton5Click(Sender: TObject); //передает в Word данные из таблицы

var

MsWord : Variant;

i:integer;

begin

If DBGrid1.Columns.Items[0].Field.Text='' then begin

ShowMessage('Необходима хотябы одна запись');

end

else

begin

if IsWordInstalled = false

then

begin

MessageDlg('Не установлен Microsoft Word'+#13+'установка решит этупроблемму',mtWarning,[mbok],0);

exit;

end;

MSWord := CreateOLEObject('Word.Application');

MsWord.Visible := true;

MsWord.documents.add;

MsWord.ActiveDocument.PageSetup.Orientation := 1;

MsWord.Selection.Font.Bold := 1;

MsWord.Selection.Font.Size := 14;

MsWord.Selection.ParagraphFormat.Alignment := 1;

MsWord.selection.TypeText('Список студентов в общежитие на '+DateToStr(Date)+'');

MsWord.Selection.Font.Bold := 0;

MsWord.Selection.Font.Size := 12;

MsWord.Selection.Tables.add(MsWord.selection.Range,1,15,EmptyParam);

MsWord.Selection.Tables.Item(1).Columns.Item(1).Width:=DBGrid1.Columns.Items[1].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(2).Width:=DBGrid1.Columns.Items[2].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(3).Width:=DBGrid1.Columns.Items[3].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(4).Width:=DBGrid1.Columns.Items[4].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(5).Width:=DBGrid1.Columns.Items[5].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(6).Width:=DBGrid1.Columns.Items[6].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(7).Width:=DBGrid1.Columns.Items[7].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(8).Width:=DBGrid1.Columns.Items[8].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(9).Width:=DBGrid1.Columns.Items[9].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(10).Width:=DBGrid1.Columns.Items[10].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(11).Width:=DBGrid1.Columns.Items[11].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(12).Width:=DBGrid1.Columns.Items[12].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(13).Width:=DBGrid1.Columns.Items[2].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(14).Width:=DBGrid1.Columns.Items[7].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(15).Width:=DBGrid1.Columns.Items[8].Width;

MsWord.Selection.Tables.Item(1).Cell(1,1).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Комната');

MsWord.Selection.Tables.Item(1).Cell(1,2).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('ФИО студента');

MsWord.Selection.Tables.Item(1).Cell(1,3).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('День рождения');

MsWord.Selection.Tables.Item(1).Cell(1,4).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Район');

MsWord.Selection.Tables.Item(1).Cell(1,5).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Город (село)');

MsWord.Selection.Tables.Item(1).Cell(1,6).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Адрес');

MsWord.Selection.Tables.Item(1).Cell(1,7).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Телефон');

MsWord.Selection.Tables.Item(1).Cell(1,8).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Сотовый');

MsWord.Selection.Tables.Item(1).Cell(1,9).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Группа');

MsWord.Selection.Tables.Item(1).Cell(1,10).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Куратор');

MsWord.Selection.Tables.Item(1).Cell(1,11).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Дата заселения');

MsWord.Selection.Tables.Item(1).Cell(1,12).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Примечание');

MsWord.Selection.Tables.Item(1).Cell(1,13).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('ФИО родителей');

MsWord.Selection.Tables.Item(1).Cell(1,14).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Телефон');

MsWord.Selection.Tables.Item(1).Cell(1,15).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Сотовый');

i:=2;

DBGrid1.SelectedRows.Clear;

with DBGrid1.Datasource.DataSet do

begin

First;

DisableControls;

try

while not EOF do

begin

DBGrid1.SelectedRows.CurrentRowSelected := True;

MsWord.Selection.Tables.Item(1).Rows.Add(EmptyParam);

MsWord.Selection.Tables.Item(1).Cell(i,1).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[1].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,2).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[2].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,3).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[3].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,4).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[4].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,5).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[5].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,6).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[6].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,7).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[7].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,8).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[8].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,9).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[9].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,10).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[10].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,11).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[11].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,12).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[12].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,13).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[13].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,14).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[14].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,15).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[15].Field.AsString);

inc(i);

Next;

end;

finally

EnableControls;

end;

end;

end;

end;

procedure TForm1.N5Click(Sender: TObject); //отображения справки

begin

winhelp(Form1.Handle,'Readme\help.hlp',HELP_CONTEXT,1);

end;

procedure TForm1.sSpeedButton6Click(Sender: TObject); //отображения формы ввода пароля

begin

if BitBtn1.Visible=True then begin

ShowMessage('Вы уже в режиме редактирования');

end

else

begin

Form5.Label1.Visible:=True;

Form5.Visible:=True;

Form5.Panel1.Visible:=False;

Form5.Edit1.SetFocus;

Form1.Enabled:=False;

end;

end;

procedure TForm1.sSpeedButton10Click(Sender: TObject); //передает в Excel данные из таблицы

var XL: Variant;

i,j,n:integer;

begin

If DBGrid1.Columns.Items[0].Field.Text='' then begin

ShowMessage('Необходима хотябы одна запись');

end

else

begin

try

XL:=CreateOleObject('Excel.Application');

XL.Visible:=true;

except

Exception.Create('Error');

end;

XL.WorkBooks.Add;

XL.WorkBooks[1].WorkSheets[1].Name :='Студент';

XL.WorkBooks[1].WorkSheets[1].Cells[3,1]:='Комната';

XL.WorkBooks[1].WorkSheets[1].Cells[3,2]:='ФИО студента';

XL.WorkBooks[1].WorkSheets[1].Cells[3,3]:='Дата рождения';

XL.WorkBooks[1].WorkSheets[1].Cells[3,4]:='Район';

XL.WorkBooks[1].WorkSheets[1].Cells[3,5]:='Город';

XL.WorkBooks[1].WorkSheets[1].Cells[3,6]:='Адрес';

XL.WorkBooks[1].WorkSheets[1].Cells[3,7]:='Телефон';

XL.WorkBooks[1].WorkSheets[1].Cells[3,8]:='Телефон сотовый';

XL.WorkBooks[1].WorkSheets[1].Cells[3,9]:='Группа';

XL.WorkBooks[1].WorkSheets[1].Cells[3,10]:='Куратор';

XL.WorkBooks[1].WorkSheets[1].Cells[3,11]:='Дата заселения';

XL.WorkBooks[1].WorkSheets[1].Cells[3,12]:='Примечание';

XL.WorkBooks[1].WorkSheets[1].Cells[3,13]:='ФИО родителей';

XL.WorkBooks[1].WorkSheets[1].Cells[3,14]:='Телефон';

XL.WorkBooks[1].WorkSheets[1].Cells[3,15]:='Телефон сотовый';

Inc(i);

DataModule2.ADOTable1.Open;//открытие таблицы

DataModule2.ADOTable1.First;// регистр(маркер) в начале таблицы

while not DataModule2.ADOTable1.Eof do

Begin XL.WorkBooks[1].WorkSheets[1].Cells[i+3,1]:=DBGrid1.Columns.Items[1].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,2]:=DBGrid1.Columns.Items[2].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,3]:=DBGrid1.Columns.Items[3].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,4]:=DBGrid1.Columns.Items[4].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,5]:=DBGrid1.Columns.Items[5].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,6]:=DBGrid1.Columns.Items[6].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,7]:=DBGrid1.Columns.Items[7].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,8]:=DBGrid1.Columns.Items[8].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,9]:=DBGrid1.Columns.Items[9].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,10]:=DBGrid1.Columns.Items[10].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,11]:=DBGrid1.Columns.Items[11].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,12]:=DBGrid1.Columns.Items[12].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,13]:=DBGrid1.Columns.Items[13].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,14]:=DBGrid1.Columns.Items[14].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,15]:=DBGrid1.Columns.Items[15].Field.Text;

Inc(i);

DataModule2.ADOTable1.Next; //переход на следующую запись таблицы

End;

DataModule2.ADOTable1.close;//закрытие таблицы XL.WorkBooks[1].WorkSheets[1].Columns[1].ColumnWidth:=DBGrid1.Columns.Items[1].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[2].ColumnWidth:=DBGrid1.Columns.Items[2].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[3].ColumnWidth:=DBGrid1.Columns.Items[3].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[4].ColumnWidth:=DBGrid1.Columns.Items[4].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[5].ColumnWidth:=DBGrid1.Columns.Items[5].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[6].ColumnWidth:=DBGrid1.Columns.Items[6].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[7].ColumnWidth:=DBGrid1.Columns.Items[7].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[8].ColumnWidth:=DBGrid1.Columns.Items[8].Width/2.5; XL.WorkBooks[1].WorkSheets[1].Columns[9].ColumnWidth:=DBGrid1.Columns.Items[9].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[10].ColumnWidth:=DBGrid1.Columns.Items[10].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[11].ColumnWidth:=DBGrid1.Columns.Items[11].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[12].ColumnWidth:=DBGrid1.Columns.Items[12].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[13].ColumnWidth:=DBGrid1.Columns.Items[2].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[14].ColumnWidth:=DBGrid1.Columns.Items[7].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[15].ColumnWidth:=DBGrid1.Columns.Items[8].Width/2.5;

XL.WorkBooks[1].WorkSheets[1].PageSetup.LeftMargin:=1;

XL.WorkBooks[1].WorkSheets[1].PageSetup.RightMargin:=1;

XL.WorkBooks[1].WorkSheets[1].Range['A2:O2'].Merge;

XL.WorkBooks[1].WorkSheets[1].Cells[2,1]:='Таблица студентов';

j:=15+DBGrid1.FieldCount;

n:=1;

XL.WorkBooks[1].WorkSheets[1].Rows[2].HorizontalAlignment:=3;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Bold := True;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Color := clBlack;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Size := 16;

XL.WorkBooks[1].WorkSheets[1].Rows[3].Font.Bold := True;

DataModule2.ADOTable1.Active:=true;

end;

end;

procedure TForm1.Edit2Change(Sender: TObject); //поиск

begin

DataModule2.ADOTable1.Locate('Komnata',Edit2.Text,[loPartialKey]);

end;

procedure TForm1.sSpeedButton4Click(Sender: TObject); //отображения формы поиска

begin

Form14.Show;

Form14.Visible:=True;

Form1.Enabled:=False;

end;

procedure TForm1.N14Click(Sender: TObject); //смена шрифта

begin

FontDialog1.Execute;

DBGrid1.Font:=FontDialog1.Font;

Form4.DBGrid1.Font:=FontDialog1.Font;

Form12.DBGrid1.Font:=FontDialog1.Font;

Form13.DBGrid1.Font:=FontDialog1.Font;

Form14.DBGrid1.Font:=FontDialog1.Font;

end;

procedure TForm1.N20Click(Sender: TObject); //смена шрифта

begin

FontDialog1.Execute;

DBGrid1.TitleFont:=FontDialog1.Font;

Form4.DBGrid1.TitleFont:=FontDialog1.Font;

Form12.DBGrid1.TitleFont:=FontDialog1.Font;

Form13.DBGrid1.TitleFont:=FontDialog1.Font;

Form14.DBGrid1.TitleFont:=FontDialog1.Font;

end;

procedure TForm1.sSpeedButton7Click(Sender: TObject); //отображения формы смены пароля

begin

Form5.Visible:=False;

Form5.Visible:=True;

Form5.Panel1.Visible:=True;

Form5.Edit2.SetFocus;

Form1.Enabled:=False;

end;

procedure TForm1.sSpeedButton8Click(Sender: TObject); //отображения формы блокировки приложения

begin

Form5.Show;

Form5.Edit1.SetFocus;

Form5.Visible:=True;

Form5.BorderIcons:=[];

Form5.Edit1.Clear;

Form5.BitBtn1.DragMode:=dmAutomatic;

Form5.Panel1.Visible:=False;

Form1.Enabled:=False;

end;

procedure TForm1.FormCreate(Sender: TObject); //загрузка и применения настроек

begin

AssignFile(seting,'setings.txt');

Reset(seting);

Readln(seting,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,b1,b2,b3);

DBGrid1.Columns.Items[1].Width:=a1;

DBGrid1.Columns.Items[2].Width:=a2;

DBGrid1.Columns.Items[3].Width:=a3;

DBGrid1.Columns.Items[4].Width:=a4;

DBGrid1.Columns.Items[5].Width:=a5;

DBGrid1.Columns.Items[6].Width:=a6;

DBGrid1.Columns.Items[7].Width:=a7;

DBGrid1.Columns.Items[8].Width:=a8;

DBGrid1.Columns.Items[9].Width:=a9;

DBGrid1.Columns.Items[10].Width:=a10;

DBGrid1.Columns.Items[11].Width:=a11;

DBGrid1.Columns.Items[12].Width:=a12;

end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); //запрет ввода

begin

If not (Key in ['а'..'я','А'..'Я','0'..'9','.',',','-',#8]) then key:=#0;

end;

procedure TForm1.Edit2DblClick(Sender: TObject); //отчистка поля

begin

Edit1.Clear;

end;

procedure TForm1.N33Click(Sender: TObject);

begin

if not DirectoryExists(ExtractFilePath(Application.ExeName)+'Rezerv') then

MkDir(ExtractFilePath(Application.ExeName)+'Rezerv');

CopyFile(PChar(ExtractFilePath(Application.ExeName)+'БГПК.mdb'), PChar(ExtractFilePath(Application.ExeName)+'Rezerv\Base_'+DateToStr(Now)+'.mdb'), True);

ShowMessage('Резев успешно сохранен');

end;

end.

unit Unit2;

interface

uses

SysUtils, Classes, DB, ADODB, Menus;

type

TDataModule2 = class(TDataModule)

ADOConnection1: TADOConnection;

ADOTable1: TADOTable;

DataSource1: TDataSource;

ADOCommand1: TADOCommand;

ADOQuery1: TADOQuery;

DataSource2: TDataSource;

ADOTable2: TADOTable;

ADOTable3: TADOTable;

ADOTable4: TADOTable;

DataSource3: TDataSource;

DataSource4: TDataSource;

ADOQuery2: TADOQuery;

ADOQuery3: TADOQuery;

DataSource5: TDataSource;

private

{ Private declarations }

public

{ Public declarations }

end;

var

DataModule2: TDataModule2;

implementation

uses Unit1, Unit3, Unit5, Unit6, Unit7, Unit8, Unit9;

{$R *.dfm}

end.

unit Unit3;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons, ComCtrls, ExtCtrls, DBCtrls,

sDBLookupComboBox, Mask, sMaskEdit, sCustomComboEdit, sTooledit;

type

TForm3 = class(TForm)

Edit1: TEdit;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

Label7: TLabel;

Label9: TLabel;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

sDateEdit1: TsDateEdit;

sDBLookupComboBox1: TsDBLookupComboBox;

sDBLookupComboBox3: TsDBLookupComboBox;

Label1: TLabel;

Label8: TLabel;

Label10: TLabel;

Edit5: TEdit;

Edit6: TEdit;

Edit7: TEdit;

Edit8: TEdit;

Edit9: TEdit;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Label14: TLabel;

Label15: TLabel;

Memo1: TMemo;

Label16: TLabel;

sDateEdit2: TsDateEdit;

DBEdit1: TDBEdit;

procedure BitBtn3Click(Sender: TObject);// сохраняет изменения записи в таблицу студент

procedure FormClose(Sender: TObject; var Action: TCloseAction);//закрывает форму3

procedure BitBtn2Click(Sender: TObject);// возврат к предидущей форме

procedure BitBtn1Click(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key: Char);

procedure Edit8KeyPress(Sender: TObject; var Key: Char);

procedure Edit5KeyPress(Sender: TObject; var Key: Char);

procedure Edit6KeyPress(Sender: TObject; var Key: Char);

procedure Edit9KeyPress(Sender: TObject; var Key: Char);

procedure Edit7KeyPress(Sender: TObject; var Key: Char);

procedure Edit2KeyPress(Sender: TObject; var Key: Char);

procedure Edit3KeyPress(Sender: TObject; var Key: Char);

procedure Edit4KeyPress(Sender: TObject; var Key: Char);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form3: TForm3;

i:integer;

implementation

uses Unit2, Unit1, Unit5, Unit6, Unit7, Unit8, Unit9, Unit10, DateUtils;

{$R *.dfm}

procedure TForm3.BitBtn3Click(Sender: TObject);// сохраняет изменения записи в таблицу студент

var

a,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15:string;

begin

a1:=Edit1.Text;

a2:=Edit2.Text;

a3:=Edit3.Text;

a4:=Edit4.Text;

a5:=Edit5.Text;

a6:=Edit6.Text;

a7:=sDBLookupComboBox1.Text;

a8:=DBEdit1.Text;

a9:=sDBLookupComboBox3.Text;

a10:=DateToStr(sDateEdit1.Date);

a11:=Edit7.Text;

a12:=Edit8.Text;

a13:=Edit9.Text;

a14:=DateToStr(sDateEdit2.Date);

a15:=Memo1.Text;

a:=Label14.Caption;

DataModule2.ADOTable1.Active:=false;

DataModule2.ADOCommand1.CommandText:='update Student set FIO_stud='+'"'+a1+'"'+',Raion='+'"'+a2+'"'+',Gorod='+'"'+a3+'"'+',adres='+'"'+a4+'"'+',Telefon='+'"'+a5+'"'+',Telefon_sot='+'"'+a6+'"'+',Gruppa='+'"'+a7+'"'+',Kurator='+'"'+a8+'"'+',Komnata='+'"'+a9+'"'+',Data_zaselenia='+'"'+a10+'"'+',FIO_Rod='+'"'+a11+'"'+',Telefon_Rod='+'"'+a12+'"'+',Telefon_sotov='+'"'+a13+'"'+',Data_roj='+'"'+a14+'"'+',Primechanie='+'"'+a15+'"'+' where kod='+'"'+a+'"';

DataModule2.ADOCommand1.Execute;

DataModule2.ADOTable1.Active:=true;

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

Edit4.Clear;

Edit5.Clear;

Edit6.Clear;

Edit7.Clear;

Edit8.Clear;

Edit9.Clear;

Form3.Memo1.Clear;

Form3.Close;

form1.Enabled:=True;

end;

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);

//Закрывает форму

begin

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

Edit4.Clear;

Edit5.Clear;

Edit6.Clear;

Edit7.Clear;

Edit8.Clear;

Edit9.Clear;

Form3.Memo1.Clear;

Form1.Show;

Form1.Edit1.SetFocus;

Form1.Enabled:=True;

end;

procedure TForm3.BitBtn2Click(Sender: TObject);

// возврат к предидущей форме

begin

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

Edit4.Clear;

Edit5.Clear;

Edit6.Clear;

Edit7.Clear;

Edit8.Clear;

Edit9.Clear;

Form3.Memo1.Clear;

Form3.Close;

Form1.Show;

Form1.Edit1.SetFocus;

form1.Enabled:=True;

end;

procedure TForm3.BitBtn1Click(Sender: TObject);

var q:integer;

begin

DataModule2.ADOQuery1.SQL.Text:='Select * From Student';

DataModule2.ADOQuery1.Open;

DataModule2.ADOQuery1.First;

if (Edit1.Text='') or

(Edit2.Text='') or

(sDateEdit2.Text='') or

(Edit3.Text='') or

(Edit4.Text='') or

(Edit7.Text='') or

(sDBLookupComboBox1.Text='') or

(DBEdit1.Text='') or

(sDBLookupComboBox3.Text='') or

(sDateEdit1.Text='') then BEGIN

MessageBox(Handle, 'Заполните все поля', 'Information', MB_OK) ;

exit;

end;

for q:=1 to DataModule2.ADOQuery1.RecordCount-1 do

begin

if (Edit1.Text=DataModule2.ADOQuery1.FieldByName('FIO_Stud').Value) and

(sDateEdit1.Date=DataModule2.ADOQuery1.FieldByName('Data_roj').Value) and

(Edit2.Text=DataModule2.ADOQuery1.FieldByName('Raion').Value) and

(Edit3.Text=DataModule2.ADOQuery1.FieldByName('Gorod').Value) and

(Edit4.Text=DataModule2.ADOQuery1.FieldByName('Adres').Value) and

(Edit5.Text=DataModule2.ADOQuery1.FieldByName('Telefon').Value) and

(Edit6.Text=DataModule2.ADOQuery1.FieldByName('Telefon_sot').Value) and (sDBLookupComboBox1.Text=DataModule2.ADOQuery1.FieldByName('Gruppa').Value) and

(DBEdit1.Text=DataModule2.ADOQuery1.FieldByName('Kurator').Value) and (sDBLookupComboBox3.Text=DataModule2.ADOQuery1.FieldByName('Komnata').Value) and (sDateEdit1.Date=DataModule2.ADOQuery1.FieldByName('Data_Zaselenia').Value) and

(Edit7.Text=DataModule2.ADOQuery1.FieldByName('FIO_Rod').Value) and

(Edit8.Text=DataModule2.ADOQuery1.FieldByName('Telefon_Rod').Value) and (Edit9.Text=DataModule2.ADOQuery1.FieldByName('Telefon_sotov').Value) then

begin

MessageBox(Handle, 'Такая запись существует', 'Information', MB_OK);

exit;

end else

begin

DataModule2.ADOQuery1.Next;

end;

end;

for i:=1 to 99999999 do

if DataModule2.ADOTable1.Locate('Kod',i,[])=false then break;

DataModule2.ADOTable1.Active:=False;

DataModule2.ADOQuery1.Insert;

DataModule2.ADOQuery1.FieldByName('FIO_Stud').Value:=Edit1.Text;

DataModule2.ADOQuery1.FieldByName('Data_roj').Value:=DateToStr(sDateEdit2.Date);

DataModule2.ADOQuery1.FieldByName('Raion').Value:=Edit2.Text;

DataModule2.ADOQuery1.FieldByName('Gorod').Value:=Edit3.Text;

DataModule2.ADOQuery1.FieldByName('Adres').Value:=Edit4.Text;

DataModule2.ADOQuery1.FieldByName('Telefon').Value:=Edit5.Text;

DataModule2.ADOQuery1.FieldByName('Telefon_sot').Value:=Edit6.Text;

DataModule2.ADOQuery1.FieldByName('Gruppa').Value:=sDBLookupComboBox1.Text;

DataModule2.ADOQuery1.FieldByName('Kurator').Value:=DBEdit1.Text;

DataModule2.ADOQuery1.FieldByName('Komnata').Value:=sDBLookupComboBox3.Text;

DataModule2.ADOQuery1.FieldByName('Data_Zaselenia').Value:=DateToStr(sDateEdit1.Date);

DataModule2.ADOQuery1.FieldByName('FIO_Rod').Value:=Edit7.Text;

DataModule2.ADOQuery1.FieldByName('Telefon_Rod').Value:=Edit8.Text;

DataModule2.ADOQuery1.FieldByName('Telefon_sotov').Value:=Edit9.Text;

DataModule2.ADOQuery1.FieldByName('Primechanie').Value:=Memo1.Text;

DataModule2.ADOQuery1.FieldByName('Kod').Value:=i;

DataModule2.ADOQuery1.Post;

DataModule2.ADOTable1.Active:=true;

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

Edit4.Clear;

Edit5.Clear;

Edit6.Clear;

Edit7.Clear;

Edit8.Clear;

Edit9.Clear;

Form3.Memo1.Clear;

Form1.BitBtn3.Enabled:=True;

Form1.BitBtn2.Enabled:=True;

form1.Enabled:=True;

Close;

//добовляет записи в таблицу студенты

var s1,s2,s3,s4,s5,s6,s7,s8:string;

begin

s1:=edit1.Text;

s2:=edit2.Text;

s3:=edit3.Text;

s4:=edit4.Text;

s5:=ComboBox1.Text;

s6:=ComboBox3.Text;

s7:=ComboBox2.Text;

s8:=Edit5.Text;

DateToStr(DateTimePicker1.Date);

DataModule2.ADOTable1.Active:=false;

DataModule2.ADOCommand1.CommandText:='insert into Student values('+''''+s1+''''+','+''''+s2+''''+','+''''+s3+''''+','+''''+s4+''''+','+''''+s5+''''+','+''''+s6+''''+','+''''+s7+''''+','+''''+DateToStr(DateTimePicker1.Date)+''''+')';

DataModule2.ADOCommand1.Execute;

DataModule2.ADOTable1.Active:=true;

Edit1.Clear;

Edit2.Clear;

Edit3.Clear;

ComboBox1.ClearSelection;

Edit4.Clear;

Edit5.Clear;

ComboBox2.ClearSelection;

ComboBox3.ClearSelection;

Form3.Close;

form1.Enabled:=True;}

end;

procedure TForm3.Edit1KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','.',' ',#8]) then key:=#0;

end;

procedure TForm3.Edit8KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['0'..'9','-','+',',','(',')','-',#8]) then key:=#0;

end;

procedure TForm3.Edit5KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['0'..'9','-','+',',','(',')',#8]) then key:=#0;

end;

procedure TForm3.Edit6KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['0'..'9','-','+',',','(',')',#8]) then key:=#0;

end;

procedure TForm3.Edit9KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['0'..'9','-','+',',','(',')',#8]) then key:=#0;

end;

procedure TForm3.Edit7KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','.',' ',#8]) then key:=#0;

end;

procedure TForm3.Edit2KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','-',' ','-',#8]) then key:=#0;

end;

procedure TForm3.Edit3KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','-',' ',#8]) then key:=#0;

end;

procedure TForm3.Edit4KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','0'..'9','.',',','-',' ',#8]) then key:=#0;

end;

end.

unit Unit4;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, Grids, DBGrids, StdCtrls, ComCtrls, Menus, Buttons, ExtCtrls,

DBCtrls, Mask, sSkinManager, sSpeedButton, ToolWin, sToolBar, sMaskEdit,

sCustomComboEdit,XPMan,OleServer,WordXP,jpeg,DB, ADODB, Registry, ComObj, sTooledit,

ExcelXP;

type

TForm4 = class(TForm)

MainMenu1: TMainMenu;

N1: TMenuItem;

N2: TMenuItem;

Word1: TMenuItem;

DBGrid1: TDBGrid;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

Label1: TLabel;

Edit1: TEdit;

N3: TMenuItem;

N4: TMenuItem;

N5: TMenuItem;

N6: TMenuItem;

N7: TMenuItem;

N8: TMenuItem;

ExcelApplication1: TExcelApplication;

PopupMenu1: TPopupMenu;

N9: TMenuItem;

N10: TMenuItem;

N11: TMenuItem;

N12: TMenuItem;

N13: TMenuItem;

N14: TMenuItem;

N15: TMenuItem;

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Edit1Change(Sender: TObject);

procedure Edit1DblClick(Sender: TObject);

procedure N3Click(Sender: TObject);

procedure N4Click(Sender: TObject);

procedure N5Click(Sender: TObject);

procedure N8Click(Sender: TObject);

procedure Word1Click(Sender: TObject);

procedure N6Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key: Char);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form4: TForm4;

implementation

uses Unit2, Unit10, Unit1;

{$R *.dfm}

function IsWordInstalled: Boolean;

var

Reg: TRegistry;

begin

Reg := TRegistry.Create;

try

Reg.RootKey := HKEY_CLASSES_ROOT;

Result := Reg.KeyExists('Word.Application');

finally

reg.Free;

end;

end;

procedure TForm4.BitBtn3Click(Sender: TObject);

var

f:string;

begin

F:=DataModule2.ADOTable4.FieldValues['Kurator'];

if MessageDlg

('Вы действительно хотите удалить '+f+'',mtConfirmation,[mbYes,mbNo],0)= idYes

then

DataModule2.ADOTable4.Delete;

end;

procedure TForm4.BitBtn1Click(Sender: TObject);

begin

Form4.Enabled:=False;;

Form10.Visible:=True;

Form10.BitBtn1.Visible:=True;

Form10.BitBtn3.Visible:=False;

end;

procedure TForm4.BitBtn2Click(Sender: TObject);

begin

with form10 do

begin

Edit1.Text:=DataModule2.ADOTable4.FieldValues['Kurator'];

Edit2.Text:=DataModule2.ADOTable4.FieldValues['Telefon'];

Edit3.Text:=DataModule2.ADOTable4.FieldValues['Adres'];

Label4.Caption:=DataModule2.ADOTable4.FieldValues['Kod'];

end;

Form10.Show;

Form4.Enabled:=False;;

Form10.Visible:=True;

Form10.BitBtn1.Visible:=False;

Form10.BitBtn3.Visible:=True;

end;

procedure TForm4.BitBtn4Click(Sender: TObject);

begin

Edit1.Clear;

Close;

Form1.Show;

Form1.Enabled:=True;

Form1.Edit1.SetFocus;

end;

procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);

begin

Edit1.Clear;

Form1.Show;

Form1.Edit1.SetFocus;

Form1.Enabled:=True;

end;

procedure TForm4.Edit1Change(Sender: TObject);

begin

DataModule2.ADOTable4.Locate('Kurator',Edit1.Text,[loPartialKey]);

end;

procedure TForm4.Edit1DblClick(Sender: TObject);

begin

Edit1.Clear;

end;

procedure TForm4.N3Click(Sender: TObject);

begin

DataModule2.ADOTable4.IndexFieldNames:='Kurator';

end;

procedure TForm4.N4Click(Sender: TObject);

begin

DataModule2.ADOTable4.IndexFieldNames:='telefon';

end;

procedure TForm4.N5Click(Sender: TObject);

begin

DataModule2.ADOTable4.IndexFieldNames:='adres';

end;

procedure TForm4.N8Click(Sender: TObject);

begin

winhelp(Form1.Handle,'Readme\help.hlp',HELP_CONTEXT,1);

end;

procedure TForm4.Word1Click(Sender: TObject);

var

MsWord : Variant;

i:integer;

begin

If DBGrid1.Columns.Items[0].Field.Text='' then begin

ShowMessage('Необходима хотябы одна запись');

end

else

begin

if IsWordInstalled = false

then

begin

MessageDlg('Не установлен Microsoft Word'+#13+'установка решит этупроблемму',mtWarning,[mbok],0);

exit;

end;

MSWord := CreateOLEObject('Word.Application');

MsWord.Visible := true;

MsWord.documents.add;

MsWord.Selection.Tables.add(MsWord.selection.Range,1,3,EmptyParam);

MsWord.Selection.Tables.Item(1).Columns.Item(1).Width:=DBGrid1.Columns.Items[1].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(2).Width:=DBGrid1.Columns.Items[2].Width;

MsWord.Selection.Tables.Item(1).Columns.Item(3).Width:=DBGrid1.Columns.Items[3].Width;

MsWord.Selection.Tables.Item(1).Cell(1,1).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Куратор');

MsWord.Selection.Tables.Item(1).Cell(1,2).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Телефон');

MsWord.Selection.Tables.Item(1).Cell(1,3).Select;

MSWord.Selection.Font.Size := 12;

MsWord.Selection.TypeText('Адрес');

 

i:=2;

DBGrid1.SelectedRows.Clear;

with DBGrid1.Datasource.DataSet do

begin

First;

DisableControls;

try

while not EOF do

begin

DBGrid1.SelectedRows.CurrentRowSelected := True;

MsWord.Selection.Tables.Item(1).Rows.Add(EmptyParam);

MsWord.Selection.Tables.Item(1).Cell(i,1).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[1].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,2).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[2].Field.AsString);

MsWord.Selection.Tables.Item(1).Cell(i,3).Select;

MSWord.Selection.Font.Size := 10;

MSWord.Selection.typetext(DBGrid1.Columns.Items[3].Field.AsString);

inc(i);

Next;

end;

finally

EnableControls;

end;

end;

end;

end;

procedure TForm4.N6Click(Sender: TObject);

var XL: Variant;

i,j,n:integer;

begin

If DBGrid1.Columns.Items[0].Field.Text='' then begin

ShowMessage('Необходима хотябы одна запись');

end

else

begin

try

XL:=CreateOleObject('Excel.Application');

XL.Visible:=true;

except

Exception.Create('Error');

end;

XL.WorkBooks.Add;

XL.WorkBooks[1].WorkSheets[1].Name :='Куратор';

XL.WorkBooks[1].WorkSheets[1].Cells[3,1]:='Куратор';

XL.WorkBooks[1].WorkSheets[1].Cells[3,2]:='Телефон';

XL.WorkBooks[1].WorkSheets[1].Cells[3,3]:='Адрес';

Inc(i);

DataModule2.ADOTable4.Open;//открытие таблицы

DataModule2.ADOTable4.First;// регистр(маркер) в начале таблицы

while not DataModule2.ADOTable4.Eof do

Begin XL.WorkBooks[1].WorkSheets[1].Cells[i+3,1]:=DBGrid1.Columns.Items[1].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,2]:=DBGrid1.Columns.Items[2].Field.Text; XL.WorkBooks[1].WorkSheets[1].Cells[i+3,3]:=DBGrid1.Columns.Items[3].Field.Text;

Inc(i);

DataModule2.ADOTable4.Next; //переход на следующую запись таблицы

End;

DataModule2.ADOTable4.close;//закрытие таблицы

XL.WorkBooks[1].WorkSheets[1].Columns[1].ColumnWidth:=DBGrid1.Columns.Items[1].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[2].ColumnWidth:=DBGrid1.Columns.Items[2].Width/5.5; XL.WorkBooks[1].WorkSheets[1].Columns[3].ColumnWidth:=DBGrid1.Columns.Items[3].Width/5.5;

XL.WorkBooks[1].WorkSheets[1].PageSetup.LeftMargin:=1;

XL.WorkBooks[1].WorkSheets[1].PageSetup.RightMargin:=1;

XL.WorkBooks[1].WorkSheets[1].Range['A2:C2'].Merge;

XL.WorkBooks[1].WorkSheets[1].Cells[2,1]:='Таблица кураторов';

j:=4+DBGrid1.FieldCount;

n:=1;

XL.WorkBooks[1].WorkSheets[1].Rows[2].HorizontalAlignment:=3;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Bold := True;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Color := clBlack;

XL.WorkBooks[1].WorkSheets[1].Rows[2].Font.Size := 16;

XL.WorkBooks[1].WorkSheets[1].Rows[3].Font.Bold := True;

// присвоение ячейке значения

// XL.WorkBooks[1].WorkSheets[1].Cells[1, 1] := 'AIS_for_KFX';

//XL.Visible := true;

DataModule2.ADOTable4.Active:=true;

end;

end;

procedure TForm4.FormCreate(Sender: TObject);

begin

DBGrid1.Columns.Items[1].Width:=b1;

DBGrid1.Columns.Items[2].Width:=b2;

DBGrid1.Columns.Items[3].Width:=b3;

end;

procedure TForm4.Edit1KeyPress(Sender: TObject; var Key: Char);

begin

If not (Key in ['а'..'я','А'..'Я','.',' ','-',#8]) then key:=#0;

end;

end.

unit Unit5;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, Buttons, Menus, ExtCtrls;

type

TForm5 = class(TForm)

Label1: TLabel;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

Panel1: TPanel;

Edit2: TEdit;

Edit3: TEdit;

Edit4: TEdit;

BitBtn3: TBitBtn;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

BitBtn4: TBitBtn;

Edit1: TEdit;

Label2: TLabel;

Label6: TLabel;

Label7: TLabel;

Label8: TLabel;

procedure BitBtn2Click(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);

procedure BitBtn4Click(Sender: TObject);

procedure Edit1KeyPress(Sender: TObject; var Key: Char);

procedure FormClose(Sender: TObject; var Action: TCloseAction);

procedure Edit2KeyPress(Sender: TObject; var Key: Char);

procedure Edit4KeyPress(Sender: TObject; var Key: Char);

procedure Edit3KeyPress(Sender: TObject; var Key: Char);

private

{ Private declarations }

public

{ Public declarations }

function xortext(text:string):string;

function xortext1(text:string):string;

function xortext2(text:string):string;

Procedure MakePassword;

Function ReadPassword(pwrd:string):string;

end;

var

Form5: TForm5;

parol,Xy:String;

counter : integer;

NoSplash:byte;

implementation

uses Unit1, Unit2, Unit3, Unit6, Unit7, Unit8, Unit10 ,Unit9, DB,

ADODB, Math, Unit4, Unit12, Unit13;

{$R *.dfm}

procedure TForm5.BitBtn2Click(Sender: TObject);

begin

if xortext(Edit1.Text) = ReadPassword(Xy) then begin

if MessageDlg

('Пароль принят ',mtInformation,[mbOK],0)= mrOk then begin

with Form1 do

begin

StatusBar1.Panels[0].Text:='Редактирование';

BitBtn1.Visible:=True;

BitBtn2.Visible:=True;

BitBtn3.Visible:=True;

N15.Visible:=True;

N16.Visible:=True;

N17.Visible:=True;

sSpeedButton7.Enabled:=True;

sSpeedButton8.Enabled:=True;

N8.Enabled:=True;

N9.Enabled:=True;

N10.Enabled:=True;

N6.Enabled:=True;

N13.Enabled:=True;

N33.Enabled:=True;

end;

With Form4 do

begin

BitBtn1.Visible:=True;

BitBtn2.Visible:=True;

BitBtn3.Visible:=True;

N10.Enabled:=True;

N11.Enabled:=True;

N12.Enabled:=True;

N13.Visible:=True;

N14.Visible:=True;

N15.Visible:=True;

end;

With Form12 do

begin

BitBtn1.Visible:=True;

BitBtn2.Visible:=True;

N1.Visible:=True;

N2.Visible:=True;

end;

With Form13 do

begin

BitBtn1.Visible:=True;

BitBtn2.Visible:=True;

BitBtn3.Visible:=True;

N1.Visible:=True;

N2.Visible:=True;

N3.Visible:=True;

end;

DataModule2.ADOTable1.IndexFieldNames:='Komnata';

DataModule2.ADOTable2.IndexFieldNames:='Komnata';

DataModule2.ADOTable3.IndexFieldNames:='Gruppa';

DataModule2.ADOTable4.IndexFieldNames:='Kurator';

Form1.Show;

Form1.Edit1.SetFocus;

Form1.Enabled:=True;

Close;

end;

end

else begin

Edit1.Clear;

while counter<>0 do

begin

MessageDlg

('Пароль введен неверно',mtInformation ,[mbOK],0);

counter:=counter-1;

Label1.Caption:='Осталось попыток ввода: '+IntToStr(counter);

Break;

end;

if counter=0 then begin

ShowMessage('Пароль введен неверно');

end;

end;

end;

function TForm5.xortext(text:string):string;

var key, longkey : string;

i:integer;

toto: char;

begin

key:='0'; //ключ

for i := 0 to (length(Edit1.text) div length(key)) do

longkey := longkey + key;

for i := 1 to length(Edit1.text) do begin

toto := chr((ord(Edit1.text[i]) XOR ord(longkey[i])));

result := result + toto;

end;

end;

Procedure TForm5.MakePassword;

var

F:TextFile;

begin

AssignFile(F,'License.dat');

rewrite(F);

Write(F,Parol);

CloseFile(F);

end;

Function TForm5.ReadPassword(pwrd:string):string;

var F:TextFile;

begin

AssignFile(F,'License.dat');

try

reset(F);

except on EInOutError do begin

MessageDlg

('Не удается найти ключевого файла License.dat Приложение будет завершено',mtWarning ,[mbOK],0);

Application.Terminate;

end;

end;

Read(F,pwrd);

Xy:=pwrd;

Result:=pwrd;

CloseFile(F);

end;

procedure TForm5.BitBtn1Click(Sender: TObject);

begin

Form1.Show;

Form1.Edit1.SetFocus;

Form1.Enabled:=True;

Close;

end;

procedure TForm5.BitBtn3Click(Sender: TObject);

begin

if xortext1(Edit2.Text) = ReadPassword(Xy) then begin









Не нашли то, что искали? Воспользуйтесь поиском гугл на сайте:


©2015- 2018 zdamsam.ru Размещенные материалы защищены законодательством РФ.