Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Kursovaya_rabota_po_VYCh_TEKh_Sleptsova_M_M_ITS...docx
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
639.38 Кб
Скачать

Код формы «Студент»

unit Unit5;

interface

uses

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

Dialogs, StdCtrls, Grids, ExtCtrls;

type

TForm5 = class(TForm)

Bevel2: TBevel;

Label1: TLabel;

Label2: TLabel;

ComboBox1: TComboBox;

StringGrid2: TStringGrid;

Label10: TLabel;

Label7: TLabel;

StringGrid3: TStringGrid;

Label8: TLabel;

StringGrid5: TStringGrid;

Label4: TLabel;

Label5: TLabel;

Label3: TLabel;

Label11: TLabel;

Label12: TLabel;

Label13: TLabel;

Button2: TButton;

Button1: TButton;

Button3: TButton;

ComboBox2: TComboBox;

Label14: TLabel;

procedure FormCreate(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure zapstr3(sender:tobject);

procedure ComboBox1Change(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure FormActivate(Sender: TObject);

private

{ Private declarations }

public

ey_st:string;

sem_t,pr1,sub2,ey2:integer;

{ Public declarations }

end;

var

Form5: TForm5;

implementation

uses Unit1, Unit3;

{$R *.dfm}

procedure TForm5.FormCreate(Sender: TObject);

begin

label5.Caption:='1';

label11.Caption:='1';

label4.Caption:='ey_st';

button1.Enabled:=false;

form5.Font.Name:='Times new roman';

form5.Font.Size:=10;

form5.Top:=0;

form5.left:=0;

form5.width:=screen.Width;

form5.height:=screen.Height;

stringgrid3.RowCount:=6;

stringgrid3.ColCount :=11;

stringgrid3.rowheights[0]:=18;

stringgrid3.rowheights[1]:=18;

stringgrid3.rowheights[2]:=18;

stringgrid3.rowheights[3]:=18;

stringgrid3.rowheights[4]:=18;

stringgrid3.rowheights[5]:=18;

stringgrid3.ColCount :=11;

stringgrid3.ColWidths[0]:=25;

stringgrid3.ColWidths[1]:=246;

stringgrid3.ColWidths[3]:=31;

stringgrid3.ColWidths[4]:=31;

stringgrid3.ColWidths[5]:=31;

stringgrid3.ColWidths[6]:=71;

stringgrid3.ColWidths[7]:=47;

stringgrid3.ColWidths[8]:=37;

stringgrid3.ColWidths[9]:=76;

stringgrid3.ColWidths[10]:=101;

stringgrid3.Cells[0,0]:='№';

stringgrid3.Cells[1,0]:='Ф.И.О.';

stringgrid3.Cells[2,0]:='№ зачетки';

stringgrid3.ColWidths[2]:=0;

stringgrid3.Cells[3,0]:='1 к.т.';

stringgrid3.Cells[4,0]:='2 к.т.';

stringgrid3.Cells[5,0]:='3 к.т.';

stringgrid3.Cells[6,0]:='Рубежный срез';

stringgrid3.Cells[7,0]:='Итоговый балл';

stringgrid3.Cells[8,0]:='Всего';

stringgrid3.Cells[9,0]:='Буквенный элемент';

stringgrid3.Cells[10,0]:=' Оценка';

stringgrid5.RowCount:=2;

stringgrid5.ColCount :=10;

stringgrid5.rowheights[0]:=18;

stringgrid5.rowheights[1]:=18;

stringgrid5.Cells[0,0]:='№';

stringgrid5.Cells[1,0]:='Фамилия И.О. студента';

stringgrid5.Cells[2,0]:=' Группа';

stringgrid5.Cells[3,0]:='Дисциплина';

stringgrid5.Cells[4,0]:='Текущая оценка';

stringgrid5.Cells[5,0]:='Попытка ';

stringgrid5.Cells[6,0]:='Дата сдачи ';

stringgrid5.Cells[7,0]:='Резултат';

stringgrid5.Cells[8,0]:='№ протокола ';

stringgrid5.Cells[9,0]:='№ зач.кн. ';

stringgrid5.ColWidths[0]:=27;

stringgrid5.ColWidths[1]:=200;

stringgrid5.ColWidths[2]:=50;

stringgrid5.ColWidths[3]:=75;

stringgrid5.ColWidths[4]:=90;

stringgrid5.ColWidths[5]:=55;

stringgrid5.ColWidths[6]:=65;

stringgrid5.ColWidths[7]:=55;

stringgrid5.ColWidths[8]:=0;

stringgrid5.ColWidths[9]:=0;

stringgrid2.colcount:=16;

stringgrid2.cells[0,0]:='№';

stringgrid2.cells[1,0]:='Группа';

stringgrid2.cells[2,0]:='Студент';

stringgrid2.cells[3,0]:='Тип';

stringgrid2.cells[4,0]:='Дисцпилина';

stringgrid2.cells[5,0]:='Преподаватель';

stringgrid2.cells[6,0]:='Результат';

stringgrid2.cells[7,0]:='Попыток';

stringgrid2.cells[8,0]:='Подано';

stringgrid2.cells[9,0]:='Разрешано';

stringgrid2.cells[10,0]:='с';

stringgrid2.cells[11,0]:='по';

stringgrid2.cells[12,0]:='Сдано';

stringgrid2.cells[13,0]:='Результат';

stringgrid2.cells[14,0]:='№ з.к.';

stringgrid2.cells[15,0]:='№ протокола';

stringgrid2.colwidths[0]:=15;

stringgrid2.colwidths[1]:=50;

stringgrid2.colwidths[2]:=200;

stringgrid2.colwidths[3]:=60;

stringgrid2.colwidths[4]:=100;

stringgrid2.colwidths[5]:=100;

stringgrid2.colwidths[6]:=60;

stringgrid2.colwidths[7]:=55;

stringgrid2.colwidths[8]:=45;

stringgrid2.colwidths[9]:=64;

stringgrid2.colwidths[10]:=44;

stringgrid2.colwidths[11]:=44;

stringgrid2.colwidths[12]:=44;

stringgrid2.colwidths[14]:=0;

stringgrid2.colwidths[15]:=0;

end;

procedure TForm5.Button3Click(Sender: TObject);

begin

button1.Enabled:=true;

label5.Caption:=inttostr(strtoint(label5.Caption)+1);

if form1.max_sem=strtoint(label5.caption) then button3.Enabled:=false;

if (strtoint(label5.Caption) mod 2)=0 then label11.Caption:=inttostr(strtoint(label5.Caption) div 2)

else label11.caption:=inttostr((strtoint(label5.caption)div 2)+1);

label4.Caption:=

inttostr(strtoint(copy(form1.ey_st,1,4))+strtoint(label11.Caption)-1)+'-'+inttostr(strtoint(copy(form1.ey_st,1,4))+strtoint(label11.Caption));

zapstr3(sender);

end;

procedure TForm5.Button1Click(Sender: TObject);

begin

button3.enabled:=true;

label5.Caption:=inttostr(strtoint(label5.Caption)-1);

if label5.caption='1' then button1.Enabled:=false;

if (strtoint(label5.Caption) mod 2)=0 then label11.Caption:=inttostr(strtoint(label5.Caption) div 2)

else label11.caption:=inttostr((strtoint(label5.caption)div 2)+1);

label4.Caption:=inttostr(strtoint(copy(form1.ey_st,1,4))+strtoint(label11.Caption)-1)+'-'+

inttostr(strtoint(copy(form1.ey_st,1,4))+strtoint(label11.Caption));

zapstr3(sender);

end;

procedure tform5.zapstr3(sender:tobject);

var i,ey2:integer ;

k,e1,z1,s1:integer;

stt1:string;

begin

combobox2.text:='';

dm.ibquery1.close;

dm.ibquery1.sql.clear;

dm.ibquery1.sql.add('select *from edu_years where name='+quotedstr(label4.caption));

dm.ibquery1.active:=true;

if dm.ibquery1.eof=false then

begin

ey2:=dm.ibquery1.fieldbyname('id_ey').asinteger;

if (strtoint(label5.caption)mod 2)=1 then sem_t:=1 else sem_t:=2;

dm.ibquery1.close;

dm.ibquery1.sql.clear;

dm.ibquery1.sql.add('select*from protocols where id_group='+quotedstr(inttostr(form1.gr1))+'and id_ey='+quotedstr(inttostr(ey2))+'and id_sem='+quotedstr(inttostr(sem_t)));

dm.ibquery1.active:=true; e1:=0;z1:=0;

while dm.ibquery1.eof=false do

begin

if dm.ibquery1.fieldbyname ('type_prot').asinteger=3 then k:=1 else k:=8;

pr1:=dm.ibquery1.fieldbyname('id_prot').asinteger;

dm.ibquery2.close;

dm.ibquery2.sql.Clear;

dm.ibquery2.sql.add ('select from protocols_body where id_prot='+quotedstr(inttostr(pr1))+'and id_stud='+quotedstr(form1.c1));

dm.ibquery2.active:=true;

if dm.ibquery2.eof=false then

begin

if ((dm.ibquery2.fieldbyname('result').asinteger>=55) and (form1.brs=1)) or ((dm.ibquery2.fieldbyname('result').asinteger>2) and (form1.brs=0)) then

begin

if dm.ibquery1.fieldbyname('type_prot').asinteger=3 then

begin

inc(e1);

s1:=e1;

end

else

begin

inc(z1);

s1:=z1;

end;

dm.ibquery3. close;

dm.ibquery3.sql.clear;

dm.ibquery3.sql.add('select * from subjects where id_sub='+quotedstr(dm.ibquery1.fieldbyname('id_sub').asstring));

dm.ibquery3.active:=true;

if dm.ibquery3.eof=false then

begin

stringgrid2.cells[k,s1]:=dm.ibquery3.fieldbyname('Name').asstring;

stringgrid2.cells[k+3,s1]:=dm.ibquery1.fieldbyname('date_prot').asstring;

dm.ibquery3.close;

dm.ibquery3.sql.clear;

dm.ibquery3.sql.add('select*from collaborators where id_coll='+quotedstr(dm.ibquery1.fieldbyname('id_coll').asstring));

dm.ibquery3.active:=true;

if dm.ibquery3.Eof=false then

begin

dm.ibquery4.close;

dm.ibquery4.sql.clear;

dm.ibquery4.sql.add('select*from mans where id_man='+quotedstr(dm.ibquery3.fieldbyname('id_man').asstring));

dm.ibquery4.active:=true;

if dm.ibquery4.eof=false then

begin

stringgrid2.cells[k+4,s1]:=dm.ibquery1.fieldbyname('lastname').asstring+''+copy(dm.ibquery4.fieldbyname('name').asstring,1,1)+'.'+

copy(dm.ibquery4.fieldbyname('patronymic').asstring,1,1)+'.';

case form1.brs of

0:begin

if dm.ibquery2.fieldbyname('type_prot').asinteger=1 then stt1:='зачтено)'else

begin

if dm.ibquery2.fieldbyname('result').asinteger>=5 then stt1:='5(отлично)'else

if dm.ibquery2.fieldbyname('result').asinteger>=4 then stt1:='4(охорошо)'else

if dm.ibquery2.fieldbyname('result').asinteger>=3 then stt1:='3(удовлетворительноо)'else

end;

end;

1: begin

if dm.ibquery1.fieldbyname('type_prot').asinteger=1 then stt1:='зачтено'else

begin

if dm.ibquery2.fieldbyname('result').asinteger>=95 then stt1:='А(отлично)'else

if dm.ibquery2.fieldbyname('result').asinteger>=85 then stt1:='B(отлично)'else

if dm.ibquery2.fieldbyname('result').asinteger>=75 then stt1:='C(хорошо)'else

if dm.ibquery2.fieldbyname('result').asinteger>=65 then stt1:='D(хорошо)'else

stt1:='E(удовлетворительно)'

end;

end;

end;

stringgrid2.cells[k+2,s1]:=stt1;

end;

end;

end;

end else

begin

dm.ibquery3. close;

dm.ibquery3.sql.clear;

dm.ibquery3.sql.add('select * from subjects where id_sub='+quotedstr(dm.ibquery1.fieldbyname('id_sub').asstring));

dm.ibquery3.active:=true;

if dm.ibquery3.eof=false then combobox2.items.add(dm.ibquery3.fieldbyname('name').asstring);

end;

dm.ibquery1.next;

end;

end;

end;

end;

{ procedure ComboBox2Change(Sender: TObject);

begin

button2.enabled:=false;

(...)

sub2:=dm.ibquery.fieldbyname('id_sub').asinteger;

button3.enabled:=true;

end; }

procedure TForm5.ComboBox1Change(Sender: TObject);

var sub1:integer;

st1,st2:string;

begin

combobox2.text:=''; combobox2.items.clear;

DM.IBQuery1.close ;

DM.IBQuery1.SQL.clear;

DM.IBQuery1.SQL.add('select * from subject where title='+quotedstr(combobox1.text));

DM.IBQuery1.Active:=true;

if DM.IBQuery1.Eof=false then

begin

sub1:=DM.IBQuery1.fieldByName('id_sub').AsInteger;

DM.IBQuery1.close;

DM.IBQuery1.SQL.clear;

DM.IBQuery1.SQL.add('select *from schedule_less where date_less>='+quotedstr(st1)+'and date_less<='+quotedstr(st2)+'and id_coll='+quotedstr(form1.c1)+'and id_sub='+quotedstr(inttostr(sub1))+'');

DM.IBQuery1.Active:=true;

while DM.IBQuery1.Eof=false do

begin

DM.IBQuery2.close;

DM.IBQuery2.SQL.Clear;

DM.IBQuery2.SQL.Add('select * from groups where id_group='+quotedstr(dm.IBQuery1.FieldByName('id_group').AsString));

DM.IBQuery2.Active:=true;

if DM.IBQuery2.Eof=false then combobox2.items.add(DM.IBQuery2.FieldByname('Name').AsString);

DM.IBQuery1.next;

end;

end;

end;

procedure TForm5.Button2Click(Sender: TObject);

var prot1,k1,k2:integer;

begin

dm.IBQuery1.Close;

dm.IBQuery1.SQL.Clear;

dm.IBQuery1.sql.add('select from protocols where id_seb='+quotedstr(inttostr(sub2))+'and id_group='+quotedstr(inttostr(form1.gr1))+'and id_ey='+quotedstr(inttostr(ey2))+'and id_sem='+quotedstr (inttostr(sem_t)));

dm.IBQuery1.active:=true;

if dm.IBQuery1.eof=false then

begin

prot1:=dm.IBQuery2.fieldbyname('id_prot').asinteger;

dm.IBQuery2.Close;

dm.IBQuery2.SQL.clear;

dm.IBQuery2.SQL.Add('select * from protocols_body where id_prot='+quotedstr(inttostr(prot1))+' and id_stud='+quotedstr(form1.c1));

dm.IBQuery2.active:=true;

if dm.IBQuery2.eof=false then

begin

if ((dm.IBQuery1.FieldByName('type_prot').asinteger=1) and (dm.IBQuery2.fieldbyname('result').asinteger<>1))or

((dm.IBQuery1.fieldbyname('type_prot').asinteger<>1)and(dm.IBQuery2.fieldbyname('result').asinteger<45)) then

begin

dm.IBQuery3.close;

dm.IBQuery3.sql.clear;

dm.IBQuery3.sql.add('select*from ind_protocols where id_prot=' + quotedstr(inttostr(prot1))+'and id_stud='+quotedstr(form1.c1));

dm.IBQuery3.active:=true;

k1:=0; //количетсов попыток

k2:=1; //паво наперес

while dm.IBQuery3.eof=false do

begin

inc(k1);

if (dm.IBQuery3.fieldbyname('result').asinteger=1) and

(dm.IBQuery1.fieldbyname('type_prot').asinteger=1) then k2:=0;

if (dm.IBQuery3.fieldbyname('result').asinteger<55) and

(dm.IBQuery1.fieldbyname('type_prot').asinteger<>1) then k2:=0;

dm.IBQuery3.next;

end;

if (k1<2)and(k2=1) then

begin

dm.IBQuery1.Close;

dm.IBQuery1.SQL.clear;

dm.IBQuery1.SQL.Add('insert into ind_protocls(Id_prot,id_stud,date_d)values('+quotedstr(inttostr(prot1))+','+quotedstr(form1.c1)+','+

quotedstr(datetostr(date()))+')');

dm.IBQuery1.ExecSQL;

end;

end;

end;

end;

end;

procedure TForm5.FormActivate(Sender: TObject);

var st1:string;

begin

form1.ey_st:='2011-2012';

//label14

dm.IBQuery1.Close;

dm.IBQuery1.Close;

dm.IBQuery1.sql.add('select*from ind_protocols where id_stud'+quotedstr(form1.c1)+'and result='+

quotedstr('')+'and date_a<='+quotedstr(datetostr(date()))+'and date_s<='+quotedstr(datetostr(date()))+'and date_f>='+

quotedstr(datetostr(date()))+'order by date_a');

dm.IBQuery1.active:=true;

while dm.IBQuery1.eof=false do

begin

st1:='c '+dm.IBQuery1.fieldbyname('date_s').asstring +'po '+dm.IBQuery1.fieldbyname('date_s').asstring+'необходимо пересдать дисциплину"';

dm.IBQuery2.close;

dm.IBQuery2.sql.Clear;

dm.IBQuery2.SQL.Add('select*from protocols id_prot='+quotedstr( dm.IBQuery1.fieldbyname('id_prot').asstring));

dm.IBQuery2.active:=true;

begin

dm.IBQuery3.close;

dm.IBQuery3.sql.Clear;

dm.IBQuery3.SQL.Add('select*from subjects id_sub='+quotedstr( dm.IBQuery1.fieldbyname('id_sub').asstring));

dm.IBQuery3.active:=true;

if dm.IBQuery3.eof=false then st1:=st1+ dm.IBQuery3.fieldbyname('name').asstring+'"!';

end;

if label14.Caption='' then label14.Caption:=st1 else label14.caption:=label14.Caption+''#10#13''+st1;

dm.IBQuery1.Next;

end;

end;

end.