📄 ucjgl.pas
字号:
'select cxsb_xh from txsb where cxsb_bj = '''+
strbj+''') and ccjb_kc='''+strkc+''' and ccjb_xq='''+strxq+''''+bet;
if (intx=1) and (intb=0) and (intk=0) and (intq=0) then //9
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xibie = '''+strxb+''') and'+bet;
if (intx=1) and (intb=0) and (intk=0) and (intq=1) then //10
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xibie = '''+strxb+''') and ccjb_xq='''+strxq+''' and'+bet;
if (intx=1) and (intb=0) and (intk=1) and (intq=0) then //11
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xibie = '''+strxb+''') and ccjb_kc='''+strkc+''' and'+bet;
if (intx=1) and (intb=1) and (intk=0) and (intq=0) then //12 =4
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_bj = '''+strbj+''') and'+bet;
if (intx=1) and (intb=0) and (intk=1) and (intq=1) then //13
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xibie = '''+
strxb+''') and ccjb_kc='''+strkc+''' and ccjb_xq='''+strxq+''' and'+bet;
if (intx=1) and (intb=1) and (intk=0) and (intq=1) then //14=6
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_bj = '''+strbj+''') and ccjb_xq='''+strxq+''' and'+bet;
if (intx=1) and (intb=1) and (intk=1) and (intq=0) then //15=7
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_bj = '''+strbj+''') and ccjb_kc='''+strkc+''' and'+bet;
if (intx=1) and (intb=1) and (intk=1) and (intq=1) then //16=8
strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_bj = '''+
strbj+''') and ccjb_kc='''+strkc+''' and ccjb_xq='''+strxq+''' and'+bet;
showmessage(strsql);
result:=strsql;
end;
procedure tfmcjgl.getKM();
var
strsql:string;
begin
if combobox4.ItemIndex <1 then begin
strsql:='select ckcb_kc from tkcb';
if combobox3.ItemIndex>0 then
strsql:='select ckcb_kc from tkcb where ckcb_kc in('+
'select ckcb2_kc from tkcb2 where ckcb2_bj in('+
'select cxsb_bj from txsb where cxsb_xibie='''+trimright(combobox3.Text)+'''))';
end
else
strsql:='select ckcb_kc from tkcb where ckcb_kc in('+
'select ckcb2_kc from tkcb2 where ckcb2_bj='''+trimright(combobox4.Text)+''')';
try
// showmessage(strsql);
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
ComboBox5.Clear;
combobox5.Items.Add('所有课程');
while not adoquery1.Eof do
begin
ComboBox5.Items.Add(adoquery1.FieldValues['ckcb_kc']);
adoquery1.Next;
combobox5.ItemIndex := 0;
end;
finally
adoquery1.Close;
end;
end;
function TFmcjgl.gettj():string ;
var
strsql:string;
fw1,fw2:string;
gjz1,gjz2:string;
gx1:string;
begin
if (cbotjy.ItemIndex =0) and (cbotje.ItemIndex =0) then exit;
if cbotjy.ItemIndex <> 0 then begin
if trim(edgjzy.Text)='' then begin
showmessage('条件一的关键字未填写,若不想使用条件一,请将其选为忽略');
exit;
end;
fw1:=cbofwy.Text;
gjz1:=edgjzy.Text;
if cbofwy.ItemIndex =1 then gjz1:='%'+gjz1+'%';
gx1:=cbogxy.Text ;
case cbotjy.ItemIndex of
1:strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xm '+fw1+ ''''+gjz1+''')';
2:strsql:='select * from tcjb where ccjb_xh '+fw1+''''+gjz1+'''';
4:strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_bj '+fw1+''''+gjz1+''')';
3:strsql:='select * from tcjb where ccjb_xh in('+
'select cxsb_xh from txsb where cxsb_xibie '+fw1+''''+gjz1+''')';
end;
if cbotje.ItemIndex<>0 then begin
if trim(edgjze.Text)='' then begin
showmessage('条件二的关键字未填写,若不想使用条件二,请将其选为忽略');
exit;
end;
fw2:=cbofwe.Text;
gjz2:=edgjze.Text;
if cbofwe.ItemIndex =1 then gjz2:='%'+gjz2+'%';
case cbotje.ItemIndex of
1:strsql:=strsql+' '+ gx1+ ' ccjb_kc '+fw2+''''+gjz2+'''';
2:strsql:=strsql+' '+ gx1+' ccjb_xq '+fw2+''''+gjz2+'''';
3:strsql:=strsql+' '+ gx1+' ccjb_cj '+fw2+gjz2;
end;
end;
end
else begin
if cbotje.ItemIndex<>0 then begin
if trim(edgjze.Text)='' then begin
showmessage('条件二的关键字未填写,若不想使用条件二,请将其选为忽略');
exit;
end;
fw2:=cbofwe.Text;
gjz2:=edgjze.Text;
if cbofwe.ItemIndex =1 then gjz2:='%'+gjz2+'%';
case cbotje.ItemIndex of
1:strsql:='select * from tcjb where ccjb_kc '+fw2+''''+gjz2+'''';
2:strsql:='select * from tcjb where ccjb_xq '+fw2+''''+gjz2+'''';
3:strsql:='select * from tcjb where ccjb_cj '+fw2+gjz2;
end;
end;
end;
result:=strsql;
showmessage(strsql);
end;
function TFmcjgl.writeCjToDb():boolean;
var
strsql:string;
strsql2:string;
begin
try
strsql:='select cxsb_xh from txsb where cxsb_xh= '''+ edit1.Text +'''';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
if (ADOQUERy1.Eof and adoquery1.Bof) then begin
//if adoquery1.DataSource.DataSet.RecordCount < 1 then begin
showmessage('输入的学号没找到学生,确认学号是否正确');
result:=false;
exit;
end;
except
end;
try
strsql:='select * from tcjb where ccjb_xh = '''+ edit1.Text +''' and ccjb_kc = '''+ edit4.Text +''' and ccjb_xq = '''+edit5.Text+'''';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
if not (ADOQUERy1.Eof and adoquery1.Bof) then begin
if application.MessageBox('该生这项成绩已经输入,要修改吗?','提示',mb_okcancel)=idok then
begin
strsql2:='select * from tcjb where ccjb_xh = '''+ edit1.Text +''' and ccjb_kc = '''+ edit4.Text +''' ';
strsql:='update tcjb set ccjb_cj= '+ edit3.Text + 'where ccjb_xh = '''+ edit1.Text +''' and ccjb_kc = '''+ edit4.Text +''' and ccjb_xq = '''+edit5.Text+'''';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.sql.add(strsql2);
adoquery1.SQL.Add(strsql);
result:=true;
adoquery1.Open;
end;
end
else begin
strsql:='insert into tcjb values('''+edit1.Text+''','''+edit4.Text+''','''+edit3.Text+''','''+edit5.text+''')';
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
result:=true;
adoquery1.Open;
end;
except
end;
end;
procedure TFmcjgl.getXiBieLista() ;
begin
try
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from txbb order by cxbb_xbbh');
adoquery1.Open;
//dbcxblist.Clear;
//ComboBox1.Clear;
// ComboBox2.Clear;
ComboBox3.Items.Add('所有系别');
while not adoquery1.Eof do
begin
//dbcxblist.Items.Add(adoquery1.FieldValues['cxbb_bbm']);
ComboBox3.Items.Add(adoquery1.FieldValues['cxbb_bbm']);
adoquery1.Next;
end;
combobox1.Items :=combobox3.Items;
//combobox6.Items :=combobox3.Items;
//ComboBox1.ItemIndex:=0;
//combobox4.ItemIndex :=0;
finally
adoquery1.Close;
end;
end;
procedure TFmcjgl.ComboBox1Change(Sender: TObject);
var
strsql:string;
begin
combobox2.Clear;
combobox2.Items.Add('所有班级');
if combobox1.ItemIndex=0 then
strsql:='select * from tbjb'
else
strsql:='select * from tbjb where cbjb_xb='''+ ComboBox1.Text + '''order by cbjb_bjbh';
try
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
//ComboBox1.Clear;
while not adoquery1.Eof do
begin
ComboBox2.Items.Add(adoquery1.FieldValues['cbjb_bjm']);
adoquery1.Next;
combobox2.ItemIndex := 0;
end;
// adotable1.First;
finally
adoquery1.Close;
end;
end;
procedure TFmcjgl.FormShow(Sender: TObject);
begin
//ADOConnection1.Connected:=true;
//adotable1.Active:=true;
//getXiBieLista();
//ComboBox1Change(Sender);
//getKM();
end;
procedure TFmcjgl.ActigetxslbExecute(Sender: TObject);
var
strsql:string;
tmpList:TListItem;
begin
if (combobox1.ItemIndex <1) and (combobox2.ItemIndex <1 ) then begin
if application.MessageBox('未指定系别和班级,将列出所有学生姓名,这可能是非常占用资源的操作,是否终止?','警告',mb_okcancel)=idok then
exit;
end;
lv1.Clear;
if ComboBox1.ItemIndex=0 then begin
if combobox2.ItemIndex=0 then
strsql:='select * from txsb'
else
strsql:='select * from txsb where cxsb_bj = '''+combobox2.Text+'''';
end
else begin
if combobox2.ItemIndex=0 then
strsql:='select * from txsb where cxsb_xibie = '''+combobox1.Text +''''
else
strsql:='select * from txsb where cxsb_xibie = '''+combobox1.Text + ''' and cxsb_bj = '''+combobox2.Text+'''';
end;
try
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
lv1.Items.BeginUpdate ;
while not adoquery1.Eof do
begin
//lv1.Items.Add(adoquery1.FieldValues['cxsb_xm']);
tmpList:=lv1.Items.Add;
tmplist.Caption:= adoquery1.FieldValues['cxsb_xh'];
tmplist.SubItems.Add(adoquery1.FieldValues['cxsb_xm']);
adoquery1.Next;
end;
lv1.Items.EndUpdate;
finally
adoquery1.Close;
end;
end;
procedure TFmcjgl.LV1SelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
begin
try
edit1.Text :=lv1.Selected.Caption;
edit2.Text :=lv1.Selected.SubItems.Text;
except
end;
end;
procedure TFmcjgl.SpeedButton1Click(Sender: TObject);
begin
if memo1.Text ='' then begin
showmessage('对不起不能保存空屁!');
exit;
end;
if savedialog1.Execute then begin
try
memo1.Lines.SaveToFile(savedialog1.FileName);
showmessage('保存成功');
except
end;
end;
end;
procedure TFmcjgl.LV1Editing(Sender: TObject; Item: TListItem;
var AllowEdit: Boolean);
begin
allowedit:=false;
end;
procedure TFmcjgl.ActgetkclbExecute(Sender: TObject);
var
strsql:string;
begin
if (combobox2.ItemIndex=0) and (trim(edit1.Text)='') then begin
showmessage('要获得课程列表,必须先指定班级或填写学号');
exit;
end;
if edit5.Text ='' then begin
showmessage('要获得课程列表,必须先填写学期');
edit5.SetFocus;
exit;
end;
if combobox2.ItemIndex=0 then begin
strsql:='select * from tkcb2 where ckcb2_xq='''+edit5.Text+''' and ckcb2_bj in('+
'select cxsb_bj from txsb where cxsb_xh= '''+edit1.Text+''')';
end
else begin
strsql:='select * from tkcb2 where ckcb2_xq='''+edit5.Text+''' and ckcb2_bj = '''+combobox2.Text+'''';
end;
try
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(strsql);
adoquery1.Open;
// if adoquery1.DataSource.DataSet.Eof and adoquery1.DataSource.DataSet.Bof then begin
// showmessage('没有找到相关课程');
// exit;
// end;
listbox2.Clear;
listbox2.Items.BeginUpdate ;
while not adoquery1.Eof do
begin
listbox2.Items.Add(adoquery1.FieldValues['ckcb2_kc']);
adoquery1.Next;
end;
listbox2.Items.EndUpdate;
finally
adoquery1.Close;
end;
end;
procedure TFmcjgl.BitBtn1Click(Sender: TObject);
begin
if trim(edit5.Text)='' then begin
showmessage('注意,学期未指定');
edit5.SetFocus;
exit;
end;
if trim(edit1.Text)='' then exit;
if trim(edit2.Text)='' then exit;
if trim(edit3.Text)='' then exit;
if trim(edit4.Text)='' then exit;
if trim(edit4.Text)='综合评测' then exit;
if writeCjToDb() then begin
//showmessage('输入成功');
memo1.Lines.Add('输入 '+edit1.Text+' '+edit2.Text+'成功');
memo1.Lines.Add('课程名称: '+edit4.Text+' 课程成绩: '+edit3.Text);
memo1.Lines.Add('学期: '+edit5.Text);
end
else begin
showmessage('输入失败');
memo1.Lines.Add('输入 '+edit1.Text+' '+edit2.Text+' 成绩失败');
memo1.Lines.Add('课程名称: '+edit4.Text+' 学期: '+edit5.Text);
end;
end;
procedure TFmcjgl.BitBtn2Click(Sender: TObject);
begin
edit1.Text :='';
edit2.Text :='';
edit3.Text :='';
edit4.Text :='';
end;
procedure TFmcjgl.ListBox2Click(Sender: TObject);
var
strkc,strxh,strxq,strsql:string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -