























Учись благодаря многочисленным ресурсам, которые есть на Docsity
Заработай баллы, помогая другим студентам, или приобретай их по тарифом Премиум
Эта страница недоступна для предварительного просмотра
Не пропусти важные части!
























Содержание
1 Задание на разработку программного комплекса............................................................................ 3 2 ..................................................................................................................................................... 3 Спецификация программного комплекса......................................................................................... 4 4 ..................................................................................................................................................... 5 Структурная диаграмма программного комплекса......................................................................... 5 6 Данные для тестирования.................................................................................................................. 6 7 ..................................................................................................................................................... 8 Инструкция пользователя.................................................................................................................. 6 9 Приложение. Исходные тексты программных модулей................................................................. 8
Задание на разработку программного комплекса
Разработать информационную подсистему отдела кадров. Информация, обрабатываемая в подсистеме, должна храниться в текстовом или типизированном файлах. Данные, которые должны быть отражены в подсистеме: фамилия, месяц и год приема на работу, образование, специальность, пол, отношение к воинской службе, год рождения. Сведения о сотрудниках пополняются по мере приема на работу. В системе должны решаться следующие задачи:
Структурная диаграмма программного комплекса
Схема построения программного средства и основных классов:
Данные для тестирования
Фамилия Дата рождения
Принят на работу
Пол Образование Специальность Отношение к воинской службе Петров 03.12.1956 12.12.2001 муж Высшее Инженер В запасе Иванов 15.01.1990 11.12.2009 муж Среднее Техник В запасе Федорова 30.04.1964 04.11.2004 жен Высшее Бухгалтер Сидоров 24.07.1992 0707.2010 муж Начальное Курьер Призывник
Инструкция пользователя
При запуске программы пользователь попадает но основное окно программы:
Приложение. Исходные тексты программных модулей
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Menus, Grids, DBGrids, DB, DBTables; type TWorker=record FIO: string[100]; StartWork : TDate; Edication : String[100]; Spec : String[100]; sex: byte; Armi: String[100]; BirthDay: TDate; end; type TForm1 = class(TForm) MainMenu1: TMainMenu; File1: TMenuItem; Exit1: TMenuItem; Button1: TButton; Button2: TButton; Button3: TButton; StringGrid1: TStringGrid; Button4: TButton; Button5: TButton; ComboBox1: TComboBox; procedure Exit1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
procedure ReadData(fileName:string; new:bool); procedure Button2Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure TableRowToWorker(index:integer; table:TStringGrid); procedure AddRowToTable(row:TWorker; table:TStringGrid); procedure EditTableRow(row:TWorker; table:TStringGrid); procedure Button5Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure SetBase(); procedure WriteData(fileName:string; table:TStringGrid); procedure Button3Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } Worker:TWorker; Base:String; tableDS:TDataSet; public { Public declarations } end; var Form1: TForm1; implementation uses Unit2, Unit3, DateUtils, Unit4, Unit5, Unit6, Unit7; {$R *.dfm} procedure TForm1.Exit1Click(Sender: TObject); begin Close; end; procedure TForm1.Button1Click(Sender: TObject); begin
table.Cells[4, table.RowCount - 1] := 'муж' else table.Cells[4, table.RowCount - 1] := 'жен'; table.Cells[5, table.RowCount - 1] := row.Armi; table.Cells[6, table.RowCount - 1] := DateToStr(row.BirthDay); table.RowCount := table.RowCount + 1; end; //Вносит изменения в отредактированную строку //row - отредактированные данные типа TWorker //table - таблица, в которую вносятся изменения procedure TForm1.EditTableRow(row:TWorker; table:TStringGrid); var i:integer; begin i := table.Selection.Top; table.Cells[0, i] := row.FIO; table.Cells[1, i] := DateToStr(row.StartWork); table.Cells[2, i] := row.Edication; table.Cells[3, i] := row.Spec; if row.sex = 0 then table.Cells[4, i] := 'муж' else table.Cells[4, i] := 'жен'; table.Cells[5, i] := row.Armi; table.Cells[6, i] := DateToStr(row.BirthDay); end; //Преобразует строку таблицы в TWorker //index - номер строки //table - таблица, в которой находятся данные procedure TForm1.TableRowToWorker(index:integer; table:TStringGrid ); var
i:integer; begin i := index; Worker.FIO := table.Cells[0, i]; Worker.StartWork := StrToDate(table.Cells[1, i]); Worker.Edication := table.Cells[2, i]; Worker.Spec := table.Cells[3, i]; if table.Cells[4, i] = 'муж' then Worker.sex := 0 else Worker.sex := 1; Worker.Armi := table.Cells[5, i]; Worker.BirthDay := StrToDate(table.Cells[6, i]); end; //читает данные из файла в таблицу // fileName - имя файла и путь к нему //new - показывает отрывается существующая база или создается новая procedure TForm1.ReadData(fileName:string; new:bool); var F:File of TWorker; size:integer; begin AssignFile(F,fileName); if new then begin Rewrite(F); end else begin Reset(F); Seek(F,0);
except MessageDlg('При попытки редактирования произошла ошибка',mtError, [mbOK],0); end; end; //Функция удаления строки из TStringGrid //RowNumber - номер строки //Grid - таблица из которой происходит удаление procedure GridDeleteRow(RowNumber: Integer; Grid: TstringGrid); var i: Integer; begin Grid.Row := RowNumber; if (Grid.Row = Grid.RowCount - 1) then { On the last row} Grid.RowCount := Grid.RowCount - 1 else begin { Not the last row} for i := RowNumber to Grid.RowCount - 1 do Grid.Rows[i] := Grid.Rows[i + 1]; Grid.RowCount := Grid.RowCount - 1; end; end; //Удаление строк procedure TForm1.Button5Click(Sender: TObject); var i,n,start:integer; begin n := StringGrid1.Selection.Bottom - StringGrid1.Selection.Top + 1; start:= StringGrid1.Selection.Top;
if StringGrid1.Selection.Bottom < StringGrid1.Selection.Top then start:= StringGrid1.Selection.Bottom; for i := 1 to n do begin GridDeleteRow(start + i - 1, StringGrid1); end; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var res:integer; begin if Base = '' then begin res := MessageDlg('Сохранить записи?',mtInformation,[mbYes, mbNo],0); if res = mrYes then SetBase() else exit; end; WriteData(Base, StringGrid1); end; //запись данных в файл базы //fileName - имя и путь к файлу базы //table - Таблица с данными procedure TForm1.WriteData(fileName:string; table:TStringGrid); var F:File of TWorker; i:integer; begin AssignFile(F,fileName); Reset(F);
end; until Lo > Hi; if Hi > iLo then QuickSort(A, iLo, Hi) ; if Lo < iHi then QuickSort(A, Lo, iHi) ; end; //Выполняет запросы procedure TForm1.Button3Click(Sender: TObject); var i:integer; Workers:array of TWorker; y1,m1,d1,y2,m2,d2:Word; MAge, WAge : real; MStch, WStch : integer; begin if ComboBox1.ItemIndex = 0 then begin SetLength(Workers, StringGrid1.RowCount - 2); DecodeDate(Now,y2,m2,d2); for i := 1 to StringGrid1.RowCount - 2 do begin TableRowToWorker(i,StringGrid1); DecodeDate(Worker.BirthDay,y1,m1,d1); if (abs(y2 - y1) <= 30) and (Worker.sex = 0) then Workers[i-1] := Worker; end; Form4.FillTable(Workers); Form4.ShowModal; end else if ComboBox1.ItemIndex = 1 then begin
DecodeDate(Now,y2,m2,d2); MStch := 0; WStch := 0; for i := 1 to StringGrid1.RowCount - 2 do begin TableRowToWorker(i,StringGrid1); DecodeDate(Worker.BirthDay,y1,m1,d1); if (Worker.sex = 0) then begin MAge := MAge + y2 - y1; MStch := MStch +1; end else begin WAge := WAge + y2 - y1; WStch := WStch +1; end; end; MAge := MAge / MStch; WAge := WAge / WStch; Form5.Label3.Caption := FloatToStrF(MAge,ffGeneral, 8, 2); Form5.Label4.Caption := FloatToStrF(WAge,ffGeneral, 8, 2); Form5.ShowModal; end else if ComboBox1.ItemIndex = 2 then begin SetLength(Workers, StringGrid1.RowCount - 1); DecodeDate(Now,y2,m2,d2); for i := 1 to StringGrid1.RowCount - 2 do begin
begin SetLength(Workers, StringGrid1.RowCount - 2); for i := 1 to StringGrid1.RowCount - 2 do begin TableRowToWorker(i,StringGrid1); Workers[i-1] := Worker; end; Form7.FillKrug(Workers); Form7.ShowModal; end else if ComboBox1.ItemIndex = 5 then begin SetLength(Workers, StringGrid1.RowCount - 2); for i := 1 to StringGrid1.RowCount - 2 do begin TableRowToWorker(i,StringGrid1); Workers[i-1] := Worker; end; Form7.FillStolb(Workers); Form7.ShowModal; end; end; procedure TForm1.FormShow(Sender: TObject); begin StringGrid1.Cells[0,0] := 'Фамилия'; StringGrid1.Cells[1,0] := 'Принят'; StringGrid1.Cells[2,0] := 'Образование'; StringGrid1.Cells[3,0] := 'Специализация'; StringGrid1.Cells[4,0] := 'Пол'; StringGrid1.Cells[5,0] := 'Отн. к службе';
StringGrid1.Cells[6,0] := 'Дата рождения'; end; end. unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) RadioButton1: TRadioButton; RadioButton2: TRadioButton; Edit1: TEdit; Label1: TLabel; Label3: TLabel; Edit3: TEdit; Button1: TButton; Button2: TButton; Button3: TButton; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; procedure RadioButton1Click(Sender: TObject); procedure RadioButton2Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;