⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 将阅卷机(百事易光电阅卷机)的数据重新处理的程序
💻 PAS
📖 第 1 页 / 共 2 页
字号:
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
classname:=combobox3.Text;
if query4.RecordCount<=84 then
  begin
    frxreport1.PrepareReport;
    frxreport1.ShowPreparedReport;
  end
else
  begin
    frxreport2.PrepareReport;
    frxreport2.ShowPreparedReport;
  end;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
var
i:integer;
begin
if checkbox1.Checked=true then
    begin
        query2.Close;     //testno 在选考试名称时已经确定
        query2.SQL.Clear;
        query2.SQL.Add('select classno from tb_test_class where testno='''+testno+'''');
        query2.Open;
        query2.First;
        for i:=1 to query2.RecordCount do
            begin
               query3.Close;
               query3.SQL.Clear;
               query3.SQL.Add('select classname from tb_class_info where classno='''+query2.Fields[0].Value+'''');
               query3.Open;
               if combobox4.Text<>'分科列表' then
                   begin
                       if (combobox4.Text='政治') or (combobox4.Text='物理') then    // sum_value3为政治或物理
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value3 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value3) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+''' and sum_value3<>0');
                                query5.Open;
                            end;
                       if (combobox4.Text='历史') or (combobox4.Text='化学') then
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value2 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value2) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+''' and sum_value2<>0');
                                query5.Open;
                            end;
                       if (combobox4.Text='地理') or (combobox4.Text='生物') then
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value1 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value1) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+''' and sum_value1<>0');
                                query5.Open;
                            end;

                       classname:=query3.Fields[0].Value;
                       combobox3.Text:=query3.Fields[0].Value;

                       if query4.RecordCount<=84 then
                            begin
                                frxreport1.PrepareReport;
                                frxreport1.PrintOptions.ShowDialog:=false;
                                frxreport1.Print;
                            end
                            else
                                begin
                                    frxreport2.PrepareReport;
                                    frxreport2.PrintOptions.ShowDialog:=false;
                                    frxreport2.Print;
                                end;
                   end
                   else if combobox4.Text='分科列表' then    //打印该科总分
                       begin
                           query4.Close;
                           query4.SQL.Clear;
                           query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value0 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+'''  order by studentno');
                           query4.Open;
                           query5.Close;
                           query5.SQL.Clear;
                           query5.SQL.Add('select avg(sum_value0) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+query3.Fields[0].Value+''' and sum_value0<>0');
                           query5.Open;

                           classname:=query3.Fields[0].Value;
                           combobox3.Text:=query3.Fields[0].Value;

                           if query4.RecordCount<=84 then
                            begin
                                frxreport1.PrepareReport;
                                frxreport1.PrintOptions.ShowDialog:=false;
                                frxreport1.Print;
                            end
                            else
                                begin
                                    frxreport2.PrepareReport;
                                    frxreport2.PrintOptions.ShowDialog:=false;
                                    frxreport2.Print;
                                end;
                       end;
               query2.Next;
            end;
    end
    else //逐班打印
        begin
             if combobox4.Text<>'分科列表' then
                   begin
                       if (combobox4.Text='政治') or (combobox4.Text='物理') then    // sum_value3为政治或物理
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value3 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value3) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+''' and sum_value3<>0');
                                query5.Open;
                            end;
                       if (combobox4.Text='历史') or (combobox4.Text='化学') then
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value2 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value2) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+''' and sum_value2<>0');
                                query5.Open;
                            end;
                       if (combobox4.Text='地理') or (combobox4.Text='生物') then
                            begin
                                query4.Close;
                                query4.SQL.Clear;
                                query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value1 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+'''  order by studentno');
                                query4.Open;
                                query5.Close;
                                query5.SQL.Clear;
                                query5.SQL.Add('select avg(sum_value1) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+''' and sum_value1<>0');
                                query5.Open;
                            end;

                       classname:=combobox3.Text;

                       if query4.RecordCount<=84 then
                            begin
                                frxreport1.PrepareReport;
                                frxreport1.PrintOptions.ShowDialog:=false;
                                frxreport1.Print;
                            end
                            else
                                begin
                                    frxreport2.PrepareReport;
                                    frxreport2.PrintOptions.ShowDialog:=false;
                                    frxreport2.Print;
                                end;
                   end
                   else if combobox4.Text='分科列表' then    //打印该科总分
                       begin
                           query4.Close;
                           query4.SQL.Clear;
                           query4.SQL.Add('select classname as 班别,studentno as 考号,studentname as 姓名,sum_value0 as 分数 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+'''  order by studentno');
                           query4.Open;
                           query5.Close;
                           query5.SQL.Clear;
                           query5.SQL.Add('select avg(sum_value0) as 平均分 from tb_test_stu_detail where testno='''+testno+''' and classname='''+combobox3.Text+''' and sum_value0<>0');
                           query5.Open;

                           classname:=combobox3.Text;

                           if query4.RecordCount<=84 then
                            begin
                                frxreport1.PrepareReport;
                                frxreport1.PrintOptions.ShowDialog:=false;
                                frxreport1.Print;
                            end
                            else
                                begin
                                    frxreport2.PrepareReport;
                                    frxreport2.PrintOptions.ShowDialog:=false;
                                    frxreport2.Print;
                                end;
                       end;
        end;
end;


procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
if query4.State=dsedit then    //query4的requestlive 属性必须为true才能修改数据
query4.Post;
end;

procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
query4.Next;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin    //实现用鼠标滚轮进行翻页的功能,象浏览网页一样
  if  (DBGrid1.Focused)  And  (Msg.message  =  WM_MOUSEWHEEL)  then
       begin  
           if  Msg.wParam  >  0  then  
               SendMessage(DBGrid1.Handle,  WM_KEYDOWN,  VK_UP,  0)  
           else
               SendMessage(DBGrid1.Handle,  WM_KEYDOWN,  VK_DOWN,  0);
           Handled  :=  True;
       end;
end;


procedure TForm1.frxReport1GetValue(const VarName: String;
  var Value: Variant);
begin
if varname='classname' then value:=classname;
end;

procedure TForm1.frxReport2GetValue(const VarName: String;
  var Value: Variant);
begin
if varname='classname' then value:=classname;
end;



end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -