Отчет по курсовой (Курсовая работа - Информационная служба учета времени работы сотрудника), страница 2
Описание файла
Файл "Отчет по курсовой" внутри архива находится в папке "Курсовая работа - Информационная служба учета времени работы сотрудника". Документ из архива "Курсовая работа - Информационная служба учета времени работы сотрудника", который расположен в категории "". Всё это находится в предмете "базы данных" из 6 семестр, которые можно найти в файловом архиве РТУ МИРЭА. Не смотря на прямую связь этого архива с РТУ МИРЭА, его также можно найти и в других разделах. Архив можно найти в разделе "курсовые/домашние работы", в предмете "базы данных (бд)" в общих файлах.
Онлайн просмотр документа "Отчет по курсовой"
Текст 2 страницы из документа "Отчет по курсовой"
ADOStoredProc: TADOStoredProc;
EmployeesID_Boss: TIntegerField;
private
{ Private declarations }
public
Procedure CreateFormList(Name:String);
Procedure ShowAddForm(Name:String; F_Add:boolean);
Procedure DeleteObject(Name:String);
Procedure Sort(NameTable:String; NameField:String);
Procedure ShowFilterForm(Name:String);
Procedure FilterTable(Name:String; Field:String; Value:String);
Procedure ShowStatistic(StatisticEmployee:String; StatisticMonth:TDateTime);
Procedure CreateRandomDocumentsAutomiticly();
end;
type TResultArray = Array [1..5,1..3] of string;
var
DM: TDM;
implementation
uses Unit4, Unit1, Unit5;
{$R *.dfm}
//Процедура обновления всех таблиц
Procedure RequeryAll();
Begin
DM.Employees.Requery();
DM.Departments.Requery();
DM.TimeControl.Requery();
DM.Table_TimeControl.Requery();
End;
//Словарь для заголовков и прочего
Function Slovar(Word:String):String;
Begin
result := 'отсутствует в словаре';
If Word = 'Departments' then result := 'Отделы';
If Word = 'Department' then result := 'Отдел';
If Word = 'Employees' then result := 'Сотрудники';
If Word = 'Employee' then result := 'Сотрудник';
If Word = 'TimeControl' then result := 'Контроль времени';
If Word = 'Name' then result := 'Наименование';
If Word = 'Adress' then result := 'Адрес';
If Word = 'Phone' then result := 'Телефон';
If Word = 'ID_Department' then result := 'Отдел';
If Word = 'ID_Boss' then result := 'Руководитель';
If Word = 'DocumentDate' then result := 'Дата документа';
If Word = 'DocumentNumber' then result := 'Номер документа';
If Word = 'ID_Employee' then result := 'Ответственный';
End;
//Получить массив названия и назначения полей 1- едит; 2-Кобобокс; 3-Таблица; 4-АктивацияДокумента;
Function GetFieldsMas(Word:String): TResultArray;
Begin
result[1,1] := '0';
result[2,1] := '0';
result[3,1] := '0';
result[4,1] := '0';
result[5,1] := '0';
If Word = 'Departments' Then Begin
result[1, 1] := '1';
result[1, 2] := 'Name';
result[2, 1] := '1';
result[2, 2] := 'Adress';
result[3, 1] := '1';
result[3, 2] := 'Phone';
End;
If Word = 'Employees' Then Begin
result[1, 1] := '1';
result[1, 2] := 'Name';
result[2, 1] := '2';
result[2, 2] := 'ID_Department';
result[2, 3] := 'Departments';
result[3, 1] := '2';
result[3, 2] := 'ID_Boss';
result[3, 3] := 'Employees';
End;
If Word = 'TimeControl' Then Begin
result[1, 1] := '1';
result[1, 2] := 'DocumentDate';
result[2, 1] := '1';
result[2, 2] := 'DocumentNumber';
result[3, 1] := '2';
result[3, 2] := 'ID_Employee';
result[3, 3] := 'Employees';
result[4, 1] := '3';
End;
End;
//Процедура заполнения Comboboxa
Procedure FillBox(Box:TComboBox; Table:TADOTable);
Begin
Table.First;
While Not Table.Eof Do Begin
Box.Items.Add(Table.FieldByName('Name').AsString);
Table.Next;
End;
End;
//Процедура установки и заполнения поля ввода для формы
Procedure SetPoleInForm(NameTable: String; TypeField:String; FieldLabel:String; Forma:TForm3; Position:Integer; Value:String; NameForFill:String);
Var
Edit : TEdit;
Combobox : TCombobox;
Metka : TLabel;
TOP : Integer;
Setup : Boolean;
Table : TADOTable;
ValueForCombobox : String;
Begin
TOP := 0;
Setup := False;
If TypeField = '1' Then Begin
Edit := Forma.FindComponent('Edit' + IntToStr(Position)) As TEdit;
Edit.Visible := True;
Edit.Left := 168;
TOP := 19 + (Position - 1) * 27;
Edit.Top := TOP;
Setup := True;
Edit.Text := Value;
End;
If TypeField = '2' Then Begin
Combobox := Forma.FindComponent('Combobox' + IntToStr(Position)) As TCombobox;
Combobox.Visible := True;
Combobox.Left := 168;
TOP := 19 + (Position - 1) * 27;
Combobox.Top := TOP;
Setup := True;
Table := DM.FindComponent(NameForFill) As TADOTable;
FillBox(Combobox, Table);
Combobox.Text := '';
If (Value <> '') And (Table.Locate('ID', Value, [])) Then
Combobox.Text := Table.FieldByName('Name').Asstring;
End;
If TypeField = '3' Then Begin
Forma.Table.Visible := True;
Forma.Table.Top := 19 + (Position - 1) * 27;
Forma.Navigator.Visible := True;
TOP := 140 + (Position - 1) * 27;
Forma.Navigator.Top := TOP;
Forma.Comands.Top := TOP + 50;
Forma.Height := TOP + 150;
If Value <> '' Then Begin
DM.ADOStoredProc.ProcedureName := 'CopyDTable_TimeControlForUpdate';
DM.ADOStoredProc.Parameters.Clear;
DM.ADOStoredProc.Parameters.AddParameter();
DM.ADOStoredProc.Parameters[0].Name := 'ID';
DM.ADOStoredProc.Parameters[0].Value := StrToInt(Value);
DM.ADOStoredProc.ExecProc;
DM.Table_TimeControl.Requery();
End;
End;
If Setup = False then exit;
Metka := Forma.FindComponent('Label'+ IntToStr(Position)) As TLabel;
Metka.Caption := Slovar(FieldLabel) + ' :';
Metka.Visible := True;
Metka.Left := 16;
Metka.Top := 19 + (Position - 1) * 27;
Forma.Comands.Top := TOP + 50;
Forma.Height := TOP + 150;
End;
//Вызываемые процедуры
Procedure TDM.CreateFormList(Name:String);
Var FormList:TForm4;
Begin
FormList := TForm4.Create(application);
FormList.Caption := Slovar(Name);
FormList.P_NameForm := Name;
FormList.List.DataSource := DM.FindComponent('DS_' + Name) as TDataSource;
FormList.Show;
End;
Procedure TDM.ShowAddForm(Name:String; F_Add: boolean);
Var
AddForm : TForm3;
MasField : TResultArray;
i,id : integer;
Text : String;
Table : TADOTable;
Begin
AddForm := TForm3.Create(application);
If F_Add = False Then Begin
Table := DM.FindComponent(Name) AS TADOTable;
AddForm.ID_ForUpdate := Table.FieldByName('ID').AsInteger;
End;
MasField := GetFieldsMas(Name);
For i := 1 to 5 do begin
If F_Add = True Then
SetPoleInForm(Name, MasField[i,1], MasField[i,2], AddForm, i, '', MasField[i,3])
Else Begin
If (MasField[i,1] = '1') or (MasField[i,1] = '2') Then Begin
Table := DM.FindComponent(Name) AS TADOTable;
Text := Table.FieldByName(MasField[i,2]).AsString;
SetPoleInForm(Name, MasField[i,1], MasField[i,2], AddForm, i, Text, MasField[i,3]);
End
Else If (MasField[i,1] = '3') Then Begin
Table := DM.FindComponent(Name) AS TADOTable;
Text := Table.FieldByName('ID').AsString;
SetPoleInForm(Name, MasField[i,1], MasField[i,2], AddForm, i, Text, MasField[i,3]);
End;
End;
End;
AddForm.F_Add := F_Add;
AddForm.P_NameForm := Name;
AddForm.Show;
End;
//Процедура удаления записей
Procedure TDM.DeleteObject(Name: string);
Var
ID : String;
Table : TADOTable;
Begin
Table := DM.FindComponent(Name) AS TADOTable;
ID := Table.FieldByName('ID').AsString;
DM.ADOStoredProc.ProcedureName := 'DeleteElement';
DM.ADOStoredProc.Parameters.Clear;
DM.ADOStoredProc.Parameters.AddParameter();
DM.ADOStoredProc.Parameters[0].Name := 'ID';
DM.ADOStoredProc.Parameters[0].Value := ID;
DM.ADOStoredProc.Parameters.AddParameter();
DM.ADOStoredProc.Parameters[1].Name := 'Name';
DM.ADOStoredProc.Parameters[1].Value := Name;
DM.ADOStoredProc.ExecProc;
RequeryAll();
End;
//Процедура сортировки полей
Procedure TDM.Sort(NameTable: String; NameField: String);
Var
Table : TADOTable;
Begin
Try
Table := DM.FindComponent(NameTable) AS TADOTable;
Table.Sort := NameField;
Except
Showmessage('По данному полю нельзя сортировать!');
End;
End;
//Вывести форму поиска и фильтрации
Procedure TDM.ShowFilterForm(Name: string);
Var
FilterForm : TFilter;
Table : TADOTable;
i : Integer;
Begin
FilterForm := TFilter.Create(application);
FilterForm.Caption := 'Фильтрация и поиск в таблице ' + Slovar(Name);
FilterForm.P_NameForm := Name;
Table := DM.FindComponent(Name) AS TADOTable;
For i:= 0 to Table.Fields.Count - 1 do
If Table.Fields[i].Visible = True Then
FilterForm.Fields.Items.Add(Table.Fields[i].DisplayLabel);
FilterForm.Height := 176;
FilterForm.Show;
End;
//Установить фильтр на таблицу по значению
Procedure TDM.FilterTable(Name: string; Field: string; Value: string);
Var
Table : TADOTable;
I : Integer;
SearchField : String;
Begin
SearchField := '';
Table := DM.FindComponent(Name) AS TADOTable;
For I := 0 to Table.Fields.Count - 1 do
If Table.Fields[i].DisplayLabel = Field Then
SearchField := Table.Fields[i].FieldName;
If SearchField = '' Then Exit;
Table.Filtered := False;
Table.Filter := SearchField + ' like ' + '*' + Value + '* ';
Table.Filtered := True;
End;
Procedure TDM.ShowStatistic(StatisticEmployee:String; StatisticMonth:TDateTime);
Var
i,HourCount, Hours : Integer;
TextQuery, ID : String;
StepDate : TDate;
Begin
HourCount := 0;
If DM.Employees.Locate('Name', StatisticEmployee, []) = False Then Exit;
ID := DM.Employees.FieldByName('ID').AsString;
DM.RunQuery.SQL.Clear;
TextQuery := 'Exec ShowStatistic ' + #39 + ID + #39 + ', ' + #39 + DateToStr(StartOfTheMonth(StatisticMonth)) + #39 + ', ' + #39 + DateToStr(StartOfTheMonth(IncMonth(StatisticMonth))) + #39;
DM.RunQuery.SQL.Add(TextQuery);
DM.RunQuery.Active := True;
DM.RunQuery.ExecSQL;
DM.RunQuery.First;
Form1.Statistic.Series[0].Clear;
Form1.Statistic.LeftAxis.Minimum := 0;
Form1.Statistic.LeftAxis.Maximum := 16;
StepDate := StartOfTheMonth(StatisticMonth);
While StepDate < EndOfTheMonth(StatisticMonth) Do Begin
If DayOf(StepDate) = DM.RunQuery.FieldByName('Day').AsInteger Then begin
Hours := DM.RunQuery.FieldByName('HourCount').AsInteger;
Form1.Statistic.Series[0].add(Hours, IntToStr(DayOf(StepDate)));
HourCount := HourCount + Hours;
DM.RunQuery.Next;
End Else
Form1.Statistic.Series[0].add(0, IntToStr(DayOf(StepDate)));
StepDate := IncDay(StepDate);
End;
Form1.HourCount.Caption := 'Общее количество часов в месяце: ' + IntToStr(HourCount);
End;
Procedure TDM.CreateRandomDocumentsAutomiticly();
Var
i,j,l : integer;
NumDoc : String;
DataPoint : TDateTime;
Begin
DataPoint := StrToDate('01.01.2012');
DM.TimeControl.Last;
l := DM.TimeControl.fieldbyname('id').asinteger;
// while Not DM.TimeControl.Eof do DM.TimeControl.Delete;
for i := 1 to 300 do begin
DM.TimeControl.Append;
DM.TimeControlID_Employee.Value := 18;
DM.TimeControlDocumentDate.Value := DateToStr(DataPoint);
NumDoc := InttoStr(i);
If Length(NumDoc) = 2 then
NumDoc := '0' + NumDoc;
If Length(NumDoc) = 1 then
NumDoc := '00' + NumDoc;
DM.TimeControlDocumentNumber.Value := NumDoc;
DM.TimeControl.Post;
For j := 1 to 5 do begin
DM.Table_TimeControl.Append;
DM.Table_TimeControlID_TimeControl.Value := l+i;
DM.Table_TimeControlID_Employee.Value := 20 + j;
DM.Table_TimeControlInWork.Value := RecodeHour(DataPoint, 7 + Random(3));
DM.Table_TimeControlOutWork.Value := RecodeHour(DataPoint, 17 + Random(3));
DM.Table_TimeControl.Post;
end;
DataPoint := IncDay(DataPoint);
end;
End;
end.
Unit 3. pas
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, ADODB, DB, Menus, DateUtils,
ComCtrls;
type
TForm3 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Ok: TButton;
CloseForm: TButton;
Comands: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Table: TDBGrid;
Label4: TLabel;
Edit4: TEdit;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
Navigator: TPanel;
AddRow: TButton;
DelRow: TButton;