Учет дипломных работ в среде программирования Delphi 7

Автор работы: Пользователь скрыл имя, 25 Июня 2015 в 15:45, дипломная работа

Краткое описание

Актуальной становится задача проектирования и создания систем хранения и обработки информации с целью сокращения рутинного, малоэффективного человеческого труда. Широкое распространение вычислительной техники в разных сферах предприятия, промышленности, экономики, увеличение специалистов в данной области даёт реальную возможность для решения данной задачи.
В данной дипломной работе разрабатывается базы данных «Учет дипломных работ». Программа предназначена для сотрудников учебного отдела.

Прикрепленные файлы: 1 файл

ПЗ-дипломы.docx

— 975.76 Кб (Скачать документ)

begin

if Column=DBGrid1.Columns[0] then  DM.Dip.IndexName:='ThInd';

if Column=DBGrid1.Columns[1] then  DM.Dip.IndexName:='LNInd';

if Column=DBGrid1.Columns[4] then  DM.Dip.IndexName:='SpecialtyID';

if Column=DBGrid1.Columns[5] then  DM.Dip.IndexName:='GroupID';

if Column=DBGrid1.Columns[6] then  DM.Dip.IndexName:='YRInd';

if Column=DBGrid1.Columns[7] then  DM.Dip.IndexName:='HeadID';

if Column=DBGrid1.Columns[8] then  DM.Dip.IndexName:='RevieverID';

 

 

end;

 

procedure TfmMain.ToolButton5Click(Sender: TObject);

var word:TMSWord;

begin

  word:=TMSWord.Create;

  if not word.Open then

  begin

    Error('Íå  ìîãó îòêðûòü msWord');

    exit;

  end;

  word.New;                            //íîâûé äîêóìåíò

  word.InsertCenterText(caption+#13);    //âñòàâèòü çàãîëîâîê äîêóìåíòà

  DataSetToWordTable(dbGrid1,DM.dsDip.DataSet,word,true);   //âñòàâèòü òàáëèöó

  word.Show;           //ïîêàçàòü Word

  word.Free;           //Îñâîáîäèòü ïàìÿòü

end;

 

 

 

procedure TfmMain.Edit1Change(Sender: TObject);

begin

DM.Dip.IndexName:='ThInd';

DM.Dip.FindNearest([Edit1.Text]);

end;

 

procedure TfmMain.Edit2Change(Sender: TObject);

begin

DM.Dip.IndexName:='LNInd';

DM.Dip.FindNearest([Edit2.Text]);

end;

 

procedure TfmMain.CheckBox1Click(Sender: TObject);

var Filter: string;

begin

  Filter := '';

 

  if (CheckBox1.Checked) and (DBlcbSp.KeyValue<>Null) then

  begin

    if Filter <> '' then  Filter := Filter + ' and ';

    Filter := Filter +'(SpecialtyID = ' + IntToStr(DBlcbSp.KeyValue) + ')';

  end;

 

  if (CheckBox2.Checked) and (DBlcbHd.KeyValue<>Null) then

  begin

    if Filter <> '' then  Filter := Filter + ' and ';

    Filter :=Filter + '(HeadID = ' + IntToStr(DBlcbHd.KeyValue) + ')';

  end;

 

  if (CheckBox3.Checked) and (DBlcbGr.KeyValue<>Null) then

  begin

    if Filter <> '' then  Filter := Filter + ' and ';

    Filter :=Filter + '(GroupID = ' + IntToStr(DBlcbGr.KeyValue) + ')';

  end;

 

  if (CheckBox4.Checked) and (Edit3.Text<>'') then begin

    if Filter <> '' then

      Filter := Filter + ' and ';

    Filter := Filter + '(YearOfRelease = ' + Edit3.Text + ')';

    end;

 

  if Filter <> '' then

  begin

    DM.Dip.Filter := Filter;

    DM.Dip.Filtered := True;

  end

  else  DM.Dip.Filtered := False;

 

if not(CheckBox2.Checked) then DBlcbHd.KeyValue:=Null;

if not(CheckBox1.Checked) then DBlcbSp.KeyValue:=Null;

if not(CheckBox3.Checked) then DBlcbGr.KeyValue:=Null;

if not(CheckBox4.Checked) then   Edit3.Text:='';

end;

 

procedure TfmMain.CopyFileWithProgressBar1(Source, Destination: string);

var

  FromF, ToF: file of byte;

  Buffer: array[0..65536] of char;

  NumRead: integer;

  FileLength: longint;

begin

  AssignFile(FromF, Source);

  reset(FromF);

  AssignFile(ToF, Destination);

  rewrite(ToF);

  FileLength := FileSize(FromF);

  with ProgressBar1 do

  begin

    Min := 0;

    Max := FileLength;

    while FileLength > 0 do

    begin

      BlockRead(FromF, Buffer[0], SizeOf(Buffer), NumRead);

      FileLength := FileLength - NumRead;

      BlockWrite(ToF, Buffer[0], NumRead);

      Position := Position + NumRead;

    end;

    CloseFile(FromF);

    CloseFile(ToF);

  end;

end;

 

procedure TfmMain.ToolButton3Click(Sender: TObject);

   var f:TextFile;

begin

   CopyFileWithProgressBar1('Data\Dip.DB', 'backup_bases\Dip.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Gr.DB', 'backup_bases\Gr.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Hd.DB', 'backup_bases\Hd.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Rev.DB', 'backup_bases\Rev.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Sp.DB', 'backup_bases\Sp.DB');

   ProgressBar1.Position:=0;

   AssignFile(f,'backup_bases\data.dat');

   Rewrite(f);

   WriteLn(f,DateToStr(Date));

   WriteLn(f,TimeToStr(Time));

   CloseFile(f);

   ShowMessage('Ðåçåðâíàÿ  êîïèÿ ñîçäàíà óñïåøíî!');

end;

 

procedure TfmMain.ToolButton4Click(Sender: TObject);

var f:TextFile;

    Date:String;

    Time:String;

begin

   AssignFile(f,'backup_bases\data.dat');

   Reset(f);

   ReadLn(f,Date);

   ReadLn(f,Time);

   CloseFile(f);

   if messagedlg('Âû  äåéñòâèòåëüíî õîòèòå âîññòàíîâèòü  ðåçåðâíóþ êîïèþ, ñîçäàííóþ '+Date+' '+Time+'?', mtConfirmation,[mbyes,mbNo],0)=mrYes then

   begin

      CopyFileWithProgressBar1('backup_bases\Dip.DB','Data\Dip.DB');

      ProgressBar1.Position:=0;

      CopyFileWithProgressBar1('backup_bases\Gr.DB','Data\Gr.DB');

      ProgressBar1.Position:=0;

      CopyFileWithProgressBar1('backup_bases\Hd.db','Data\Hd.db');

      ProgressBar1.Position:=0;

      CopyFileWithProgressBar1('backup_bases\Rev.db','Data\Rev.db');

      ProgressBar1.Position:=0;

      CopyFileWithProgressBar1('backup_bases\Sp.db','Data\Sp.db');

      ProgressBar1.Position:=0;

      ShowMessage('Ðåçåðâíàÿ  êîïèÿ çàãðóæåíà óñïåøíî!');

      {DataModule2.Query1.Close;

      DataModule2.Query1.SQL.Clear;

      DataModule2.Query1.SQL.Add('select * from ''main.db'' order by '+Label9.Caption);

      DataModule2.Query1.Open;

      DataModule2.Query2.Close;

      DataModule2.Query2.SQL.Clear;

      DataModule2.Query2.SQL.Add('select * from ''org.db''');

      DataModule2.Query2.Open;

      DataModule2.Query3.Close;

      DataModule2.Query3.SQL.Clear;

      DataModule2.Query3.SQL.Add('select * from ''works.db''');

      DataModule2.Query3.Open;

      DataModule2.Query4.Close;

      DataModule2.Query4.SQL.Clear;

      DataModule2.Query4.SQL.Add('select * from ''workers.db''');

      DataModule2.Query4.Open;}

   end;

end;

 

procedure TfmMain.N11Click(Sender: TObject);

begin

  Application.Terminate;

end;

 

procedure TfmMain.SpeedButton2Click(Sender: TObject);

   var f:TextFile;

begin

   CopyFileWithProgressBar1('Data\Dip.DB', 'backup_bases\Dip.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Gr.DB', 'backup_bases\Gr.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Hd.DB', 'backup_bases\Hd.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Rev.DB', 'backup_bases\Rev.DB');

   ProgressBar1.Position:=0;

   CopyFileWithProgressBar1('Data\Sp.DB', 'backup_bases\Sp.DB');

   ProgressBar1.Position:=0;

   AssignFile(f,'backup_bases\data.dat');

   Rewrite(f);

   WriteLn(f,DateToStr(Date));

   WriteLn(f,TimeToStr(Time));

   CloseFile(f);

   ShowMessage('Ðåçåðâíàÿ  êîïèÿ ñîçäàíà óñïåøíî!');

end;

 

procedure TfmMain.SpeedButton3Click(Sender: TObject);

var word:TMSWord;

begin

  word:=TMSWord.Create;

  if not word.Open then

  begin

    Error('Íå  ìîãó îòêðûòü msWord');

    exit;

  end;

  word.New;                            //íîâûé äîêóìåíò

  word.InsertCenterText(caption+#13);    //âñòàâèòü çàãîëîâîê äîêóìåíòà

  DataSetToWordTable(dbGrid1,DM.dsDip.DataSet,word,true);   //âñòàâèòü òàáëèöó

  word.Show;           //ïîêàçàòü Word

  word.Free;           //Îñâîáîäèòü ïàìÿòü

end;

 

end.

 

 

unit Unit2;

 

interface

 

uses

  SysUtils, Classes, DB, DBTables;

 

type

  TDM = class(TDataModule)

    dsDip: TDataSource;

    dsSp: TDataSource;

    dsGr: TDataSource;

    dsHd: TDataSource;

    dsRev: TDataSource;

    Dip: TTable;

    Sp: TTable;

    Gr: TTable;

    Hd: TTable;

    Rev: TTable;

    DipID: TAutoIncField;

    DipTheme: TStringField;

    DipLastName: TStringField;

    DipName: TStringField;

    DipMiddleName: TStringField;

    DipSpecialtyID: TIntegerField;

    DipGroupID: TIntegerField;

    DipYearOfRelease: TIntegerField;

    DipHeadID: TIntegerField;

    DipRevieverID: TIntegerField;

    DipPractice: TStringField;

    SpID: TAutoIncField;

    SpSpecialty: TStringField;

    SpCipher: TStringField;

    GrID: TAutoIncField;

    GrGroup: TStringField;

    HdID: TAutoIncField;

    HdHead: TStringField;

    HdLastName: TStringField;

    HdName: TStringField;

    HdMiddleName: TStringField;

    HdPost: TStringField;

    HdPlaseOfWork: TStringField;

    RevID: TAutoIncField;

    RevReviewer: TStringField;

    RevLastName: TStringField;

    RevName: TStringField;

    RevMiddleName: TStringField;

    RevPost: TStringField;

    RevPlaseOfWork: TStringField;

    DipCipher: TStringField;

    DipGroup: TStringField;

    DipHead: TStringField;

    Database1: TDatabase;

    DipReviewer: TStringField;

    procedure DataModuleCreate(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  DM: TDM;

implementation

{$R *.dfm}

procedure TDM.DataModuleCreate(Sender: TObject);

begin

  if not Session.IsAlias('alDiplom') then begin

    Session.ConfigMode := cmAll;

    Session.AddStandardAlias('alDiplom', ExtractFilePath(ParamStr(0))+'Data', 'PARADOX');

    end;

  Database1.Open;

  Dip.Open;

  Sp.Open;

  Gr.Open;

  Hd.Open;

  Rev.Open;

end;

 

end. 
unit Unit3;

 

interface

 

uses

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

  Dialogs, DBCtrls, StdCtrls, Mask, unit2,unit4,unit5,unit6,unit7,db, Buttons;

 

type

  TfmDip = class(TForm)

    DBEdit1: TDBEdit;

    DBEdit2: TDBEdit;

    DBEdit3: TDBEdit;

    DBEdit4: TDBEdit;

    DBLookupComboBox1: TDBLookupComboBox;

    DBLookupComboBox2: TDBLookupComboBox;

    DBEdit5: TDBEdit;

    DBLookupComboBox4: TDBLookupComboBox;

    DBLookupComboBox5: TDBLookupComboBox;

    Label1: TLabel;

    Label2: TLabel;

    Label3: TLabel;

    Label4: TLabel;

    Label5: TLabel;

    Label6: TLabel;

    Label7: TLabel;

    Label8: TLabel;

    Label9: TLabel;

    Label10: TLabel;

    Label11: TLabel;

    SpeedButton1: TSpeedButton;

    SpeedButton2: TSpeedButton;

    DBComboBox1: TDBComboBox;

    SpeedButton3: TSpeedButton;

    SpeedButton4: TSpeedButton;

    SpeedButton5: TSpeedButton;

    SpeedButton6: TSpeedButton;

    SpeedButton7: TSpeedButton;

    procedure SpeedButton1Click(Sender: TObject);

    procedure SpeedButton2Click(Sender: TObject);

    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);

    procedure Button1Click(Sender: TObject);

    procedure SpeedButton3Click(Sender: TObject);

    procedure SpeedButton4Click(Sender: TObject);

    procedure SpeedButton5Click(Sender: TObject);

    procedure SpeedButton6Click(Sender: TObject);

    procedure SpeedButton7Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  fmDip: TfmDip;

 

implementation

 

{$R *.dfm}

 

procedure TfmDip.SpeedButton3Click(Sender: TObject);

begin

if DM.Dip.State in [dsInsert, dsEdit] then DM.Dip.Post;

DM.Dip.Append;

end;

 

procedure TfmDip.SpeedButton1Click(Sender: TObject);

begin

 

if DM.Dip.State in [dsInsert, dsEdit] then DM.Dip.Post;

 

if DM.Database1.InTransaction then DM.Database1.Commit;

 

close;

 

end;

 

procedure TfmDip.SpeedButton2Click(Sender: TObject);

begin

  if (DM.Dip.State=dsInsert) or  (DM.Dip.State=dsEdit) then DM.Dip.Cancel;

end;

 

procedure TfmDip.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin

  if (DM.Dip.State=dsInsert) or  (DM.Dip.State=dsEdit) then DM.Dip.Cancel;

  if DM.Database1.InTransaction then DM.Database1.Rollback;

  DM.Dip.Refresh;

end;

 

procedure TfmDip.Button1Click(Sender: TObject);

begin

if DM.Dip.State in [dsInsert, dsEdit] then DM.Dip.Post;

DM.Dip.Insert;

end;

 

 

 

procedure TfmDip.SpeedButton4Click(Sender: TObject);

begin

if fmSp.ShowModal =mrOk then

begin

if not(DM.Dip.State in [dsInsert, dsEdit]) then DM.Dip.Edit;

DM.DipSpecialtyID.Value:=DM.SpID.Value;

end;

end;

 

procedure TfmDip.SpeedButton5Click(Sender: TObject);

begin

if fmHd.ShowModal =mrOk then

begin

if not(DM.Dip.State in [dsInsert, dsEdit]) then DM.Dip.Edit;

DM.DipHeadID.Value:=DM.HdID.Value;

end;

end;

 

procedure TfmDip.SpeedButton6Click(Sender: TObject);

begin

if fmRev.ShowModal=mrOk then

begin

if not(DM.Dip.State in [dsInsert, dsEdit]) then DM.Dip.Edit;

DM.DipRevieverID.Value:=DM.RevID.Value;

end;

end;

 

procedure TfmDip.SpeedButton7Click(Sender: TObject);

begin

if fmGr.ShowModal=mrOk then

begin

if not(DM.Dip.State in [dsInsert, dsEdit]) then DM.Dip.Edit;

DM.DipGroupID.Value:=DM.GrID.Value;

end;

end;

 

end. 
unit Unit4;

 

interface

 

uses

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

  Dialogs, unit2, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, Buttons;

 

type

  TfmSp = class(TForm)

    DBGrid1: TDBGrid;

    DBNavigator1: TDBNavigator;

    BitBtn1: TBitBtn;

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  fmSp: TfmSp;

 

implementation

uses msWord,rusdlg,sg2word;

{$R *.dfm}

 

end. 
unit Unit5;

 

interface

 

uses

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

  Dialogs, unit2, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, Buttons;

 

type

  TfmGr = class(TForm)

    DBGrid1: TDBGrid;

    DBNavigator1: TDBNavigator;

    BitBtn1: TBitBtn;

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  fmGr: TfmGr;

 

implementation

 

{$R *.dfm}

 

end. 
unit Unit6;

 

interface

uses

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

  Dialogs,unit2, Grids, DBGrids, ExtCtrls, DBCtrls, StdCtrls, Buttons;

type

  TfmHd = class(TForm)

    DBGrid1: TDBGrid;

    DBNavigator1: TDBNavigator;

    BitBtn1: TBitBtn;

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

    procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  fmHd: TfmHd;

implementation

{$R *.dfm}

procedure TfmHd.DBGrid1KeyPress(Sender: TObject; var Key: Char);

begin

DBGrid1.DataSource.DataSet.FieldByName('Head').Value:=vartostr(DBGrid1.DataSource.DataSet.FieldByName('LastName').Value)+' '+

     copy(vartostr(DBGrid1.DataSource.DataSet.FieldByName('Name').Value),1,1)+'.'+

     copy(vartostr(DBGrid1.DataSource.DataSet.FieldByName('MiddleName').Value),1,1)+'.';

end;

 

procedure TfmHd.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);

begin

DBGrid1.DataSource.DataSet.FieldByName('LastName').FocusControl;

end;

end. 
unit Unit7;

interface

uses

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

  Dialogs, unit2, ExtCtrls, DBCtrls, Grids, DBGrids, StdCtrls, Buttons;

type

  TfmRev = class(TForm)

    DBNavigator1: TDBNavigator;

    DBGrid1: TDBGrid;

    BitBtn1: TBitBtn;

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

    procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);

  private

    { Private declarations }

  public

    { Public declarations }

  end;

var

  fmRev: TfmRev;

implementation

 

{$R *.dfm}

procedure TfmRev.DBGrid1KeyPress(Sender: TObject; var Key: Char);

begin

DBGrid1.DataSource.DataSet.FieldByName('Reviewer').Value:=vartostr(DBGrid1.DataSource.DataSet.FieldByName('LastName').Value)+' '+

     copy(vartostr(DBGrid1.DataSource.DataSet.FieldByName('Name').Value),1,1)+'.'+

     copy(vartostr(DBGrid1.DataSource.DataSet.FieldByName('MiddleName').Value),1,1)+'.';

 

end;

procedure TfmRev.DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);

begin

DBGrid1.DataSource.DataSet.FieldByName('LastName').FocusControl;

end;

end. 
Приложение 2

 

Приложение 3


Информация о работе Учет дипломных работ в среде программирования Delphi 7