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

Код формы «Преподаватель»

unit Unit4;

interface

uses

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

Dialogs, StdCtrls, ExtCtrls, Grids, IdBaseComponent, IdComponent,

IdTCPConnection, IdTCPClient, IdTelnet;

type

TForm4 = class(TForm)

Label1: TLabel;

ComboBox1: TComboBox;

StringGrid1: TStringGrid;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

ComboBox3: TComboBox;

ComboBox4: TComboBox;

ComboBox5: TComboBox;

ComboBox6: TComboBox;

StringGrid3: TStringGrid;

Label2: TLabel;

ComboBox2: TComboBox;

StringGrid2: TStringGrid;

Bevel12: TBevel;

Bevel13: TBevel;

Bevel14: TBevel;

Bevel15: TBevel;

Bevel16: TBevel;

Bevel17: TBevel;

Bevel18: TBevel;

Bevel19: TBevel;

Bevel20: TBevel;

Bevel23: TBevel;

Label20: TLabel;

Label21: TLabel;

Label22: TLabel;

Label23: TLabel;

Label24: TLabel;

Label25: TLabel;

Label26: TLabel;

Label27: TLabel;

Label28: TLabel;

StringGrid4: TStringGrid;

Label37: TLabel;

StaticText1: TStaticText;

Label7: TLabel;

Label8: TLabel;

ListBox1: TListBox;

procedure FormCreate(Sender: TObject);

procedure FormActivate(Sender: TObject);

procedure ComboBox1Change(Sender: TObject);

procedure ComboBox2Change(Sender: TObject);

procedure ComboBox3Change(Sender: TObject);

procedure ComboBox4Change(Sender: TObject);

procedure ComboBox5Change(Sender: TObject);

procedure ComboBox6Change(Sender: TObject);

procedure zapstr4(sender:tobject);

private

{ Private declarations }

public

st1, st2,st3,gs1, s2,s1,c1: string;

sem, sub1,sub2,gr1, gr2, ey1,pr1,tp1 : integer;

{ Public declarations }

end;

var

Form4: TForm4;

implementation

uses Unit5, Unit3, Unit1;

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);

begin

form4.left:=0; form4.top:=0;

form4.width:=screen.width;

form4.height:=screen.height-55;

stringgrid1.left:=1;

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

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

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

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

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

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

stringgrid1.colcount:=3;

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

stringgrid1.cells[1,0]:='Фамилия Имя Отчество';

stringgrid1.cells[2,0]:='№ зк';

stringgrid1.colwidths[0]:=27;

stringgrid1.colwidths[1]:=180;

stringgrid1.colwidths[2]:=0;

stringgrid2.RowCount:=2;

stringgrid2.ColCount :=10;

stringgrid2.rowheights[0]:=18;

stringgrid2.rowheights[1]:=18;

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.ColWidths[0]:=27;

stringgrid2.ColWidths[1]:=200;

stringgrid2.ColWidths[2]:=50;

stringgrid2.ColWidths[3]:=75;

stringgrid2.ColWidths[4]:=90;

stringgrid2.ColWidths[5]:=55;

stringgrid2.ColWidths[6]:=65;

stringgrid2.ColWidths[7]:=55;

stringgrid2.ColWidths[8]:=0;

stringgrid2.ColWidths[9]:=0;

stringgrid3.fixedcols:=0;

stringgrid3.fixedrows:=0;

stringgrid3.colcount:=10;

stringgrid3.colwidths[0]:=19;

stringgrid3.colwidths[1]:=156;

stringgrid3.colwidths[2]:=43;

stringgrid3.colwidths[3]:=31;

stringgrid3.colwidths[4]:=30;

stringgrid3.colwidths[5]:=30;

stringgrid3.colwidths[6]:=58;

stringgrid3.colwidths[7]:=37;

stringgrid3.colwidths[8]:=40;

stringgrid3.colwidths[9]:=63;

stringgrid4.RowCount:=2;

stringgrid4.colcount:=16;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

stringgrid4.colwidths[0]:=15;

stringgrid4.colwidths[1]:=50;

stringgrid4.colwidths[2]:=200;

stringgrid4.colwidths[3]:=60;

stringgrid4.colwidths[4]:=100;

stringgrid4.colwidths[5]:=100;

stringgrid4.colwidths[6]:=60;

stringgrid4.colwidths[7]:=55;

stringgrid4.colwidths[8]:=45;

stringgrid4.colwidths[9]:=64;

stringgrid4.colwidths[10]:=44;

stringgrid4.colwidths[11]:=44;

stringgrid4.colwidths[12]:=44;

stringgrid4.colwidths[14]:=0;

stringgrid4.colwidths[15]:=0;

end;

procedure TForm4.FormActivate(Sender: TObject);

Var T1,T2,T3: Word;

Begin

DecodeDate(Date(),T3,T2,T1);

if Date()>StrtoDate('01.09.'+Inttostr(T3)) then

Begin

sem:=1;

st1:='01.09.'+Inttostr(T3);

st2:='31.12.'+Inttostr(T3);

st3:= inttostr (t3)+'-'+inttostr(t3+1);

end

else

Begin

st1:='01.01.'+Inttostr(T3);

st2:='31.08.'+Inttostr(T3);

st3:= inttostr (t3-1)+'-'+inttostr(t3);

sem:=2;

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)+' unique id_sub'));

DM.IBQuery1.Active:=True;

while DM.IBQuery1.Eof=false do

begin

DM.IBQuery2.Close;

DM.IBQuery2.SQL.Clear;

DM.IBQuery2.SQL.Add('Select * From subject where id_sub='+quotedstr(DM.IBQuery1.FieldByName('Title').AsString));

DM.IBQuery2.Active:=True;

if DM.IBQuery2.Eof=false then combobox1.items.add(DM.IBQuery2.Fieldbyname('title').AsString) ;

DM.IBQuery1.Next;

end;

DM.IBQuery1.Close;

DM.IBQuery1.SQL.Clear;

DM.IBQuery1.SQL.Add('select *from edu_years');

DM.IBQuery1.Active:=true;

while DM.IBQuery1.Eof=false do

begin

ComboBox3.items.add(DM.IBQuery1.FieldByName('name').AsString);

DM.IBQuery1.Next;

end;

if ComboBox3.Items.Count>0 then

begin

ComboBox3.Text:=st3;

zapstr4(sender);

end;

end;

end;

procedure TForm4.ComboBox1Change(Sender: TObject);

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 TForm4.ComboBox2Change(Sender: TObject);

var i : integer;

begin

stringgrid1.rowcount:=2;

stringgrid1.colcount:=3;

for i:=0 to 2 do stringgrid1.cells[i,1]:='';

stringgrid2.rowcount:=2 ;

for i:=0 to 3 do stringgrid2.cells[i,1]:='';

dm.ibquery1.close ;

dm.ibquery1.sql.clear ;

dm.ibquery2.sql.add('select * from grups where name='+quotedstr(combobox2.text));

dm.ibquery2.active:=true;

if dm.ibquery1.eof=false then

begin

gr1:=dm.ibquery1.fieldbyname('id_group').asinteger;

end;

end;

procedure TForm4.ComboBox3Change(Sender: TObject);

begin

combobox4.text:='' ;

combobox4.items.clear;

DM.IBQuery1.close;

DM.IBQuery1.SQL.Clear;

DM.IBQuery1.SQL.ADD('select * from edu_years order by name');

DM.IBQuery1.Active:=true;

if DM.IBQuery1.Locate('Name', combobox3.text,[])=true then

begin

ey1:=DM.IBQuery1.fieldbyname('id_ey').Asinteger;

combobox4.items.add('1');

combobox4.items.add('2');

end;

end;

procedure TForm4.ComboBox4Change(Sender: TObject);

begin

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

if combobox4.itemindex>-1 then

begin

if combobox4.text='1' then

begin

s1:='01.09.'+copy(combobox3.text,1,4);

s2:='31.12.'+copy(combobox3.text,1,4);

end

else

begin

s1:='01.01.'+copy(combobox3.text,6,4);

s2:='31.08'+copy(combobox3.text,6,4);

end;

DM.IBQuery1.close;

DM.IBQuery1.SQL.Clear ;

DM.IBQuery1.SQL.add('select * from schedule_less where date_less>='+quotedstr(s1)+'and date_less<='+quotedstr(s2)+'');

DM.IBQuery1.Active:=true;

while DM.IBQuery1.Eof=false do

begin

combobox5.items.add(DM.IBQuery1.fieldbyname('name').AsString);

DM.IBQuery1.Next;

end;

end;

end;

procedure TForm4.ComboBox5Change(Sender: TObject);

begin

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

DM.IBQuery1.close;

DM.IBQuery1.SQL.clear;

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

DM.IBQuery1.Active:=true;

if DM.IBQuery1.Eof=false then

begin

gr2:=dm.IBQuery1.fieldbyname('id_group').AsInteger;

DM.IBQuery1.close;

DM.IBQuery1.SQL.clear;

DM.IBQuery1.SQL.add('select * from schedule_less where date_less>='+quotedstr(s1)+'and date_less<='+quotedstr(s2)+' id_group='+quotedstr(inttostr(gr2))+'');

DM.IBQuery1.Active:=true;

while DM.IBQuery1.Eof=false do

begin

combobox6.items.add(DM.IBQuery1.fieldbyname('name').asstring);

DM.IBQuery1.next

end;

end;

end;

procedure TForm4.ComboBox6Change(Sender: TObject);

var i: integer;

stt:string;

begin

stringgrid3.RowCount:=1;

for i:=0 to Stringgrid3.ColCount-1 do Stringgrid3.Cells[i,0]:='';

DM.IBQuery1.Close; DM.IBQuery1.SQL.Clear;

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

DM.IBQuery1.Active:=true;

if DM.IBQuery1.Eof=false then

begin

sub2:=DM.IBQuery1.fieldbyname('id_sub').AsInteger ;

DM.IBQuery1.SQL.Clear;

DM.IBQuery1.SQL.Add('select *from protocols where id_ey='+quotedstr(inttostr(ey1))+' and id_sem='+quotedstr(combobox4.text)+ 'and id_group='+quotedstr(inttostr(gr2))+' and id_sub='+quotedstr(inttostr(sub2)));

DM.IBQuery1.Active:=true;

if DM.IBQuery1.Eof=false then

begin

pr1:=DM.IBQuery1.fieldbyname('id_prot').Asinteger;

tp1:=DM.IBQuery1.fieldbyname('type_prot').Asinteger;

if pr1=1 then

begin

label7.caption:='баллы за зачет';

label8.caption:='результат'; end;

if pr1=2

then

begin

label7.caption:='баллы за экзамен';

label8.caption:='Буквенный эквивалент';

end;

DM.IBQuery1.Close;

DM.IBQuery1.SQL.Clear;

DM.IBQuery1.SQL.Add('select * from protocols_body where id_prot='+quotedstr(inttostr(pr1)));

DM.IBQuery1.Active:=true;

ListBox1.Items.Clear;

while DM.IBQuery1.Eof=false do

begin

DM.IBQuery2.close;

DM.IBQuery2.SQL.Clear;

DM.IBQuery2.SQL.Add('select * from students where id_stud='+quotedstr(DM.IBQuery1.fieldbyname('id_stud').AsString));

DM.IBQuery2.Active:=true;

if DM.IBQuery2.Eof=false then

begin

dm.ibquery3.close;

dm.ibquery3.sql.clear;

dm.ibquery3.sql.add('select * from students where id_stud='+quotedstr(dm.ibquery2.fieldbyname('id_stud').asstring));

dm.ibquery3.active:=true;

if dm.ibquery3.eof=false then

begin

ListBox1.items.add(DM.IBQuery3.fieldbyname('LastName').Asstring+''+dm.ibquery3.fieldbyname ('name').asstring+''+DM.IBQuery3.FieldByName('Patronymic').AsString+'#'+DM.IBQuery1.FieldByName('id_stud').AsString+'#'+DM.IBQuery1.fieldbyname('kt1').AsString+'#'+DM.IBQuery1.fieldbyname('kt2').AsString+'#'+DM.IBQuery1.fieldbyname('kt3').AsString+'#'+DM.IBQuery1.fieldbyname('bb').AsString+'#'+DM.IBQuery1.fieldbyname('cb').AsString);

end;

end;

DM.IBQuery1.Next;

end;

listbox1.sorted:=true;

stringgrid3.RowCount:=listbox1.items.count;

for i:=0 to listbox1.items.count-1 do

begin

stt:=listbox1.items[i];

stringgrid3.cells[0,i]:=inttostr(i+1);

stringgrid3.cells[1,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[2,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[3,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[4,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[5,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[6,i]:=copy(stt,1,pos('#',stt)-1);

delete(stt,1,pos('#',stt));

stringgrid3.cells[7,i]:=copy(stt,1,pos('#',stt)-1);

if strtointdef(stt,0)>0 then

begin

stringgrid3.Cells[8,i]:=inttostr(strtointdef(stringgrid3.cells[3,i],0)+strtointdef(stringgrid3.cells[4,i],0)+strtointdef(stringgrid3.cells[5,i],0)+strtointdef(stringgrid3.cells[6,i],0)+strtointdef(stringgrid3.cells[7,i],0));

if label7.caption='баллы за зачет' then

begin

if strtointdef(stringgrid3.Cells[8,i],0)>=42 then Stringgrid3.Cells[9,i]:='зачтено' else Stringgrid3.Cells[9,i]:='незачтено'

end;

if label7.caption='Баллы за экзамен' then

begin

if strtointdef(stringgrid3.cells[8,i],0)>=95 then

stringgrid3.cells[9,i]:='A (отлично)'else

if strtointdef(stringgrid3.cells[8,i],0)>=85 then

stringgrid3.cells[9,i]:='B (отлично)'else

if strtointdef(stringgrid3.cells[8,i],0)>=75 then

stringgrid3.cells[9,i]:='C (хорошо)'else

if strtointdef(stringgrid3.cells[8,i],0)>=65 then

stringgrid3.cells[9,i]:='D (хорошо)'else

if strtointdef(stringgrid3.cells[8,i],0)>=55 then

stringgrid3.cells[9,i]:='E (удовлетворительно)'else

if strtointdef(stringgrid3.cells[8,i],0)>=45 then

stringgrid3.cells[9,i]:='F (удовлетворительно)'else

if strtointdef(stringgrid3.cells[8,i],0)>=55 then

stringgrid3.cells[9,i]:='E (удовлетворительно)'else

end;

end;

end;

end;

end;

end;

procedure Tform4.zapstr4(sender:tobject);

var i,cp:integer;

sub_st,gr_st,stud_st,res_st:string;

begin

stringgrid4.rowcount:=2;

for i:=0 to 9 do stringgrid4.cells[i,1]:='';

dm.IBQuery1.Close;

dm.IBQuery1.sql.Clear;

dm.IBQuery1.SQL.Add('select * from ind_protocols where (result='+quotedstr('')+'and (((date_s>='+quotedstr(datetostr(date()))+')and (date_f>='+quotedstr(datetostr(date())) +

'))or((date_s<='+quotedstr(datetostr(date()))+')and(date_d>='+quotedstr(datetostr(date()))+')))');

dm.IBQuery1.Active:=true; I:=0;

while dm.IBQuery1.eof=false do //отбирает из протоколов,те

begin

dm.IBQuery2.close;

dm.IBQuery2.sql.clear;

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

dm.IBQuery2.active:=true;

if dm.IBQuery2.eof=false then

begin

if dm.IBQuery2.FieldByName('id_coll').asstring=form1.c1 then

begin

dm.IBQuery3.close;

dm.IBQuery3.sql.Clear;

dm.IBQuery3.sql.add('select * from subject where id_sub='+quotedstr(dm.IBQuery2.fieldbyname('id_sub').asstring));

dm.IBQuery3.active:=true;

if dm.IBQuery3.eof=false then sub_st:= dm.IBQuery3.fieldbyname('name').asstring else

sub_st:='';

dm.IBQuery3.close;

dm.IBQuery3.sql.Clear;

dm.IBQuery3.sql.add('select * from groups where id_group='+

quotedstr(dm.IBQuery2.fieldbyname('id_group').asstring));

dm.IBQuery3.active:=true;

if dm.IBQuery3.eof=false then gr_st:= dm.IBQuery3.fieldbyname('name').asstring else

gr_st:='';

dm.IBQuery3.close;

dm.IBQuery3.sql.Clear;

dm.IBQuery3.sql.add('select * from students where id_stud='+quotedstr(dm.IBQuery1.fieldbyname('id_stud').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.IBQuery2.fieldbyname('id_man').asstring));

dm.IBQuery4.active:=true;

if dm.IBQuery4.eof=false then stud_st:= dm.IBQuery4.fieldbyname('lastname').asstring+

''+dm.IBQuery4.fieldbyname('name').asstring+

''+dm.IBQuery4.fieldbyname('patronymic').asstring else stud_st:='';

end else stud_st:='';

res_st:='';

dm.IBQuery3.Close;

dm.IBQuery3.sql.Clear;

dm.IBQuery3.sql.Add('select * from ind_protocols where id_stud='+

quotedstr(dm.IBQuery1.fieldbyname('id_stud').asstring)+'and id_prot='+

quotedstr(dm.IBQuery1.fieldbyname('id_prot').asstring));

dm.IBQuery3.active:=true;

if dm.IBQuery3.eof=false then

begin

dm.IBQuery3.Last;

cp:=dm.IBQuery3.RecNo;

if dm.IBQuery3.fieldbyname('result').asinteger=null then

begin

cp:=cp-1;

if cp<>0 then

begin

dm.IBQuery3.Prior;

res_st:=dm.IBQuery3.fieldbyname('result').asstring;

end;

begin

dm.IBQuery4.Close;

dm.IBQuery4.sql.Clear;

dm.IBQuery4.SQL.Add('selelct * from protocols_body where id_prot='+

quotedstr(dm.IBQuery4.fieldbyname('id_prot').asstring)+'and id_stud='+

quotedstr(dm.IBQuery4.fieldbyname('id_stud').asstring));

dm.IBQuery4.Active:=true;

if dm.IBQuery4.eof=false then res_st:=dm.IBQuery3.fieldbyname ('cb').AsString

else res_st:='';

end;

end;

end;

if stud_st>''then

begin

inc(i);

stringgrid4.Rowcount:=I+1;

stringgrid4.cells[0,i]:=inttostr(i);

stringgrid4.cells[1,i]:=stud_st;

stringgrid4.cells[2,i]:=gr_st;

stringgrid4.cells[3,i]:=sub_st;

stringgrid4.cells[4,i]:=res_st;

stringgrid4.cells[5,i]:=inttostr(cp);

end;

end;

end;

dm.IBQuery1.Next;

end;

end;

end.