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

📄 stat_frms.pas

📁 证券公司考试系统,三层架构,从题库自动产生试卷,全部主观题
💻 PAS
字号:
unit Stat_Frms;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, jpeg, Grids, DBGrids;

type
  TStat_Frm = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    DanXuan_DBGrid: TDBGrid;
    Panel3: TPanel;
    GroupBox1: TGroupBox;
    Sales_Department_CheckBox: TCheckBox;
    Department_CheckBox: TCheckBox;
    Sales_Department_Edit: TEdit;
    Department_Edit: TEdit;
    GroupBox2: TGroupBox;
    Edit_Exam_Name_CheckBox: TCheckBox;
    Edit_Exam_Name_ComboBox: TComboBox;
    Achievement_CheckBox: TCheckBox;
    Achievement_ComboBox: TComboBox;
    ID_card_CheckBox: TCheckBox;
    ID_card_Edit: TEdit;
    GroupBox3: TGroupBox;
    Image3: TImage;
    Label9: TLabel;
    Label3: TLabel;
    GroupBox4: TGroupBox;
    Name_CheckBox: TCheckBox;
    Employee_Code_CheckBox: TCheckBox;
    Employee_Code_Edit: TEdit;
    Name_Edit: TEdit;
    Function  Select_Employee_Achievement_SQL
              (Edit_Exam_Name_CheckBox,Achievement_CheckBox,ID_card_CheckBox,Sales_Department_CheckBox,
               Department_CheckBox,Name_CheckBox,Employee_Code_CheckBox:TCheckBox):string;
    procedure Label9Click(Sender: TObject);
    procedure Edit_Exam_Name_ComboBoxDropDown(Sender: TObject);
    procedure ID_card_CheckBoxClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Stat_Frm: TStat_Frm;

implementation

uses Background_Main, Background_DataModules;

{$R *.dfm}
Function  TStat_Frm.Select_Employee_Achievement_SQL
 (Edit_Exam_Name_CheckBox,Achievement_CheckBox,ID_card_CheckBox,Sales_Department_CheckBox,
  Department_CheckBox,Name_CheckBox,Employee_Code_CheckBox:TCheckBox):string;
Var
   SQL:string;
   First_Parameter:Boolean;{是否是WHERE后面的第一个参数}
{组合成绩查询字串}
begin
 First_Parameter:=True;{初始化}
 SQl:='Select * from Employee_Achievement_Table'; {基本查询语句}
 
 If Edit_Exam_Name_CheckBox.Checked or Achievement_CheckBox.Checked or
    ID_card_CheckBox.Checked or Sales_Department_CheckBox.Checked or
    Department_CheckBox.Checked or Name_CheckBox.Checked or Employee_Code_CheckBox.Checked
  then
   begin   {起码有一个参数被选中的情况}
    SQl:=SQl+' Where';

    {考试名称}
    If Edit_Exam_Name_CheckBox.Checked
     then
      begin
       SQL:= SQL+ ' (Exam_Name=' + ''''+Edit_Exam_Name_ComboBox.Text+ '''' +')';
       First_Parameter:=False;
      end;

    {成绩}
    If Achievement_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (Achievement>' + Achievement_ComboBox.Text+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(Achievement>' + Achievement_ComboBox.Text + ')';

    {身份证号码}
    If ID_card_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (ID_card=' + '''' + ID_card_Edit.Text + ''''+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(ID_card=' + '''' +ID_card_Edit.Text + ''''+ ')';

    {营业部}
    If Sales_Department_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (Sales_Department=' + '''' + Sales_Department_Edit.Text+  ''''+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(Sales_Department=' + '''' +Sales_Department_Edit.Text + ''''+ ')';

   {业务部门}
    If Department_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (Department=' + '''' + Department_Edit.Text + ''''+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(Department=' + '''' +Department_Edit.Text + '''' +')';

   {员工姓名}
    If Name_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (Name=' + '''' + Name_Edit.Text + ''''+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(Name=' + '''' +Name_Edit.Text + ''''+ ')';

   {员工代码}
    If Employee_Code_CheckBox.Checked then
     If First_Parameter=True
      then
       begin
        SQL:= SQL+ ' (Employee_Code=' + '''' + Employee_Code_Edit.Text + ''''+ ')';
        First_Parameter:=False;
       end
      else SQL:= SQL+ ' and(Employee_Code=' + '''' +Employee_Code_Edit.Text + ''''+ ')';

   end
  else {全部不选的情况};

 SQl:=SQl+' Order by Achievement desc';
 Select_Employee_Achievement_SQL:= SQl;

end;


procedure TStat_Frm.Label9Click(Sender: TObject);
begin
 {showmessage(Select_Employee_Achievement_SQL
 (Edit_Exam_Name_CheckBox,Achievement_CheckBox,ID_card_CheckBox,
  Sales_Department_CheckBox,Department_CheckBox,Name_CheckBox,Employee_Code_CheckBox)) ;  }

 With Background_DataModule do
  begin
   Select_Employee_Achievement_Table.Close;
   Select_Employee_Achievement_Table.SQL.Text:=
    Select_Employee_Achievement_SQL
     (Edit_Exam_Name_CheckBox,Achievement_CheckBox,ID_card_CheckBox,
     Sales_Department_CheckBox,Department_CheckBox,Name_CheckBox,Employee_Code_CheckBox);
   Select_Employee_Achievement_Table.Open;
  end;                              
end;

procedure TStat_Frm.Edit_Exam_Name_ComboBoxDropDown(Sender: TObject);
Var
  FieldName:string;
begin
  FieldName:='Exam_Name';
  Main_Frm.DropDown_Fields_Content_For_ComboBox
  (Edit_Exam_Name_ComboBox,Background_DataModule.Exam_Name_Table,FieldName);
end;

procedure TStat_Frm.ID_card_CheckBoxClick(Sender: TObject);
begin
 If ID_card_CheckBox.Checked
  then
   begin
    Edit_Exam_Name_CheckBox.Enabled:=False;
    Achievement_CheckBox.Enabled:=False;
    Sales_Department_CheckBox.Enabled:=False;
    Department_CheckBox.Enabled:=False;
    Name_CheckBox.Enabled:=False;
    Employee_Code_CheckBox.Enabled:=False;

    Edit_Exam_Name_CheckBox.Checked:=False;
    Achievement_CheckBox.Checked:=False;
    Sales_Department_CheckBox.Checked:=False;
    Department_CheckBox.Checked:=False;
    Name_CheckBox.Checked:=False;
    Employee_Code_CheckBox.Checked:=False;
   end
  else
   begin
    Edit_Exam_Name_CheckBox.Enabled:=True;
    Achievement_CheckBox.Enabled:=True;
    Sales_Department_CheckBox.Enabled:=True;
    Department_CheckBox.Enabled:=True;
    Name_CheckBox.Enabled:=True;
    Employee_Code_CheckBox.Enabled:=True;
   end;
end;

end.

⌨️ 快捷键说明

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