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

📄 paydetailunit.pas

📁 学费管理系统,学校使用
💻 PAS
📖 第 1 页 / 共 2 页
字号:
end;

procedure Tpaydetailform.close_bitbtnClick(Sender: TObject);
begin
  self.Close;
end;

procedure Tpaydetailform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  action:=cafree;
  postmessage(handle,wm_user,0,0);
end;

procedure Tpaydetailform.clearcontent;

begin
  ChargeYearID_edit.Text :='';
  ChargeRangeId_edit.Text :='';
  Departmentid_Edit.Text :='';
  Department_ComboBox.ItemIndex:=-1;
  Scholarid_edit.Text :='';
  Scholar_ComboBox.Itemindex:=-1;
  name_Edit.Text :='';
  Length_ComboBox.ItemIndex:=-1;
  ClassCode_Edit.Text :='';
  oper_combobox.ItemIndex:=-1;
  oper_edit.Text :='';
  checkbox1.Checked :=false;
  datetimepicker1.Date:=date;
  datetimepicker2.Date:=date;
end;

procedure Tpaydetailform.FormShow(Sender: TObject);
begin
  clearcontent;
end;

procedure Tpaydetailform.search_bitbtnClick(Sender: TObject);
begin
  if (trim( ChargeYearID_edit.Text )='') and (trim(Departmentid_Edit.Text )='')
    and (trim(Scholarid_edit.Text )='') and (trim(name_Edit.Text )='')
      and (trim(Length_ComboBox.Text )='') and (trim(ClassCode_Edit.Text )='')
        and (trim(ChargeRangeId_edit.text)='') and (trim(oper_edit.Text )='')
          and not  checkbox1.Checked then
  begin
    MessageBox(application.handle,pchar('没有选择查询条件!'),'错误',MB_ICONWARNING+MB_OK);
    list_adoquery.close;
    clearcontent;
    exit;
  end;
  with list_adoquery do
  begin
    close;
    sql.clear;

    sql.Add('select ');
    if trim(oper_edit.Text )<>'' then
    begin
      sql.Add('a.regdate as ''时间'',student.studentname as ''姓名'',');
      sql.add('学费,住宿费,书费,保险费,生活用品费,保证金,合计,票据编号 from ( ');
    end
    else if trim(name_Edit.Text)<>'' then
    begin
      sql.Add('a.regdate as ''时间'',操作员,');
      sql.add('学费,住宿费,书费,保险费,生活用品费,保证金,合计,票据编号 from ( ');
    end
    else if trim(ClassCode_Edit.Text )<>'' then
    begin
      sql.Add('student.studentname as ''姓名'',') ;
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end
    else if trim(Departmentid_Edit.Text )<>'' then
    begin
      sql.Add('student.classcode as ''班级'',');
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end
    else
    begin
      sql.Add(' department.department as ''院系'',');
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end;
    sql.Add('select a.studentid,a.chargerangeid,a.studyyear,a.receive as ''学费'',a.operator,operator.name as ''操作员'',a.regdate,b.receive as ''住宿费'',');
    sql.Add('c.receive as ''书费'',d.receive as ''保险费'',e.receive as ''生活用品费'',f.receive as ''保证金'',billcode as ''票据编号'',');
    sql.Add('(a.receive+b.receive+c.receive+e.receive+f.receive+d.receive) as ''合计'' from(');
    sql.Add('select studentid,chargerangeid,studyyear,receive,operator,regdate,billcode');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=1) as a');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=2) as b on a.studentid=b.studentid and a.chargerangeid=b.chargerangeid and a.regdate=b.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=3) as c on a.studentid=c.studentid and a.chargerangeid=c.chargerangeid and a.regdate=c.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=4) as d on a.studentid=d.studentid and a.chargerangeid=d.chargerangeid and  a.regdate=d.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=5) as e on a.studentid=e.studentid and a.chargerangeid=e.chargerangeid and  a.regdate=e.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=6) as f on a.studentid=f.studentid and a.chargerangeid=f.chargerangeid and  a.regdate=f.regdate');
    sql.Add('left join operator on a.operator=operator.code) as a,student,department where a.studentid=student.id and student.departmentid=department.id');
    if trim( ChargeYearID_edit.Text )<>'' then
      sql.add(' and student.ChargeYearID='+trim( ChargeYearID_edit.Text ));
    if trim( ChargeRangeId_edit.Text )<>'' then
      sql.add(' and a.ChargeRangeId='+trim( ChargeRangeId_edit.Text ));
    if checkbox1.Checked then
    begin
      sql.add(' and a.regdate>='''+datetostr(datetimepicker1.Date)+' 00:00:00'+'''');
      sql.add(' and a.regdate<='''+datetostr(datetimepicker2.Date)+' 23:59:59'+'''');
    end;
    if trim(oper_edit.Text )<>'' then
      sql.Add(' and a.operator='''+trim(oper_edit.Text)+'''');
    if trim(Departmentid_Edit.Text )<>'' then
      sql.add(' and student.departmentid='+trim( Departmentid_Edit.Text ));
    if trim(Scholarid_edit.Text )<>'' then
      sql.add(' and student.Scholarid='+trim( Scholarid_edit.Text ));
    if trim(name_Edit.Text )<>'' then
      sql.add(' and student.studentname='''+trim( name_Edit.Text )+'''');
    if trim(Length_ComboBox.Text )<>'' then
      sql.add(' and student.length='+trim( Length_ComboBox.Text ));
    if trim(ClassCode_Edit.Text )<>'' then
      sql.add(' and student.classcode='''+trim( ClassCode_Edit.Text )+'''');

    if trim(oper_edit.Text )<>'' then   sql.Add('')
    else if trim(name_Edit.Text)<>'' then  sql.Add('')
    else if trim(ClassCode_Edit.Text )<>'' then
      sql.Add(' group by student.studentname ')
    else if trim(Departmentid_Edit.Text )<>'' then
      sql.Add(' group by student.classcode ')
    else  
      sql.Add(' group by department.department ');

    sql.Add('union all');
    if trim(oper_edit.Text )<>'' then
    begin
      sql.Add('select '''+datetimetostr(now)+''' as ''时间'',''合计'' as 姓名,');
      sql.add('sum(学费),sum(住宿费),sum(书费),sum(保险费),sum(生活用品费),sum(保证金),sum(合计),'''' as 票据编号 from ( ');
    end
    else if trim(name_Edit.Text)<>'' then
    begin
      sql.Add('select '''+datetimetostr(now)+''' as ''时间'',''合计'' as 操作员,');
      sql.add('sum(学费),sum(住宿费),sum(书费),sum(保险费),sum(生活用品费),sum(保证金),sum(合计),'''' as 票据编号 from ( ');
    end
    else if trim(ClassCode_Edit.Text )<>'' then
    begin
      sql.Add('select ''合计'' as ''姓名'',') ;
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end
    else if trim(Departmentid_Edit.Text )<>'' then
    begin
      sql.Add('select ''合计'' as ''班级'',');
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end
    else
    begin
      sql.Add('select ''合计'' as ''院系'',');
      sql.add('sum(学费) as 学费,sum(住宿费) as 住宿费,sum(书费) as 书费,sum(保险费) as 保险费,sum(生活用品费) as 生活用品费,sum(保证金) as 保证金,sum(合计) as 合计 from ( ');
    end;
    sql.Add('select a.studentid,a.chargerangeid,a.studyyear,a.receive as ''学费'',a.operator,operator.name as ''操作员'',a.regdate,b.receive as ''住宿费'',');
    sql.Add('c.receive as ''书费'',d.receive as ''保险费'',e.receive as ''生活用品费'',f.receive as ''保证金'',billcode as ''票据编号'',');
    sql.Add('(a.receive+b.receive+c.receive+e.receive+f.receive+d.receive) as ''合计'' from(');
    sql.Add('select studentid,chargerangeid,studyyear,receive,operator,regdate,billcode');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=1) as a');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=2) as b on a.studentid=b.studentid and a.chargerangeid=b.chargerangeid and a.regdate=b.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=3) as c on a.studentid=c.studentid and a.chargerangeid=c.chargerangeid and a.regdate=c.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=4) as d on a.studentid=d.studentid and a.chargerangeid=d.chargerangeid and  a.regdate=d.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=5) as e on a.studentid=e.studentid and a.chargerangeid=e.chargerangeid and a.regdate=e.regdate');
    sql.Add('left join');
    sql.Add('(select studentid,chargerangeid,studyyear,receive,operator,regdate');
    sql.Add('from editreg');
    sql.Add('where chargeitemid=6) as f on a.studentid=f.studentid and a.chargerangeid=f.chargerangeid and  a.regdate=f.regdate');
    sql.Add('left join operator on a.operator=operator.code) as a,student,department where a.studentid=student.id and student.departmentid=department.id');
    if trim( ChargeYearID_edit.Text )<>'' then
      sql.add(' and student.ChargeYearID='+trim( ChargeYearID_edit.Text ));
    if trim( ChargeRangeId_edit.Text )<>'' then
      sql.add(' and a.ChargeRangeId='+trim( ChargeRangeId_edit.Text ));
    if checkbox1.Checked then
    begin
      sql.add(' and a.regdate>='''+datetostr(datetimepicker1.Date)+' 00:00:00'+'''');
      sql.add(' and a.regdate<='''+datetostr(datetimepicker2.Date)+' 23:59:59'+'''');
    end;
    if trim(oper_edit.Text )<>'' then
      sql.Add(' and a.operator='''+trim(oper_edit.Text)+'''');
    if trim(Departmentid_Edit.Text )<>'' then
      sql.add(' and student.departmentid='+trim( Departmentid_Edit.Text ));
    if trim(Scholarid_edit.Text )<>'' then
      sql.add(' and student.Scholarid='+trim( Scholarid_edit.Text ));
    if trim(name_Edit.Text )<>'' then
      sql.add(' and student.studentname='''+trim( name_Edit.Text )+'''');
    if trim(Length_ComboBox.Text )<>'' then
      sql.add(' and student.length='+trim( Length_ComboBox.Text ));
    if trim(ClassCode_Edit.Text )<>'' then
      sql.add(' and student.classcode='''+trim( ClassCode_Edit.Text )+'''');
   // memo1.Lines.Text :=sql.Text;
    { TODO : 需减去退费金额 }
    open;
  end;
end;

procedure Tpaydetailform.ChargeRangeId_editKeyPress(Sender: TObject;
  var Key: Char);
begin
  if not (key in['0'..'9','.',#8,#13]) then key:=#0;  
end;

procedure Tpaydetailform.ChargeYearID_editKeyPress(Sender: TObject;
  var Key: Char);
begin
  if not (key in['0'..'9','.',#8,#13]) then key:=#0;
end;

procedure Tpaydetailform.output_bitbtnClick(Sender: TObject);
begin
  ExportToExc(list_adoquery);
end;

procedure Tpaydetailform.ClassCode_EditChange(Sender: TObject);
var i:Integer;
begin
  name_Edit.Items.Clear;
  if trim(classcode_edit.Text )='' then exit;
  with oper_adoquery do
  begin
    close;
    sql.Clear;
    sql.Add('select distinct(studentname) as studentn from student where  classcode=:classcode');
    Parameters.ParamByName('classcode').Value :=trim(classcode_edit.Text );
    open;
    name_Edit.Items.Add(' ');
    if not isempty then
    begin

      for i := 0 to RecordCount-1 do
      begin
        name_Edit.Items.Add(fieldbyname('studentn').AsString) ;
        Next;
      end;
    end;
  end;

end;

end.

⌨️ 快捷键说明

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