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

📄 yearratio.pas

📁 主要是介绍DELPHI三层应用以及分布式数据库的应用
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure TFrm_yearratio.btn_editClick(Sender: TObject);
begin

        qyearratio.Edit ;
        //让文本框可以编辑
        UnlockEdit;
        //使一些按钮失效
        DisableBtn;
        btn_save.Enabled :=true;
        btn_cancel.Enabled :=true;

end;


procedure TFrm_yearratio.btn_cancelClick(Sender: TObject);
begin
        qyearratio.Cancel ;

        lockedit;

        enablebtn;
        btn_cancel.Enabled :=false;
        btn_save.Enabled :=false;

end;


procedure TFrm_yearratio.btn_deleteClick(Sender: TObject);
begin
     qyearratio.Delete ;
     qyearratio.ApplyUpdates;
     lockedit;

     enablebtn;
//     btn_cancel.Enabled :=false;
     btn_save.Enabled :=false;

end;
//***************以上是按纽操作。*********************
//***************打开数据集********************
procedure TFrm_yearratio.FormCreate(Sender: TObject);
begin
    lockedit;
    enablebtn;

  //通过quse读出办事处名称列表
  with quse do begin
    if active then close;
    unprepare;
    sql.Clear;
    sql.Add('select 办事处名称 from pub_z_office');
    prepare;
    open;
    if findfirst then begin
    while not eof do begin
      DBComboBox1.Items.Add(fieldbyname('办事处名称').AsString);
      next;
    end;
    end;
  end;

    with qyearratio do begin
    open;
    first;
    end;


end;
procedure TFrm_yearratio.btn_brsClick(Sender: TObject);
begin
    qyearratio.Filtered :=false;
    DBGrid1.DataSource :=dsyearratio;
    qyearratioAfterOpen(qyearratio);
end;

procedure TFrm_yearratio.btn_qryClick(Sender: TObject);
var
  qitem,q1,q2,q3,q4:string;
begin

  q2 :=cbbsc.Text;
  q1 :=cbxm.Text;
  q3 :=cbgh.Text;
  q4 :=cbgw.Text;

  if (q1='') and (q2='') and (q3='')   and (q4='')
  then  application.MessageBox('您还没有设置查询条件呢!','提示',MB_OK)
  else  begin

    if not(cbxm.Text='') then
      begin
      q1:=cbxm.Text;
      q1:=' 姓名='''+q1+''' ';
      end
    else
      q1:='';
    if not(cbbsc.Text='') then
      begin
      q2:=cbbsc.Text;
      q2:=' 办事处名称='''+q2+''' ';
      end
    else
      q2:='';
    if not(cbgh.Text='') then
      begin
      q3:=cbgh.Text;
      q3:=' 工号='''+q3+''' ';
      end
    else
      q3:='';
    if not(cbgw.Text='') then
      begin
      q4:=cbgw.Text;
      q4:=' 岗位='''+q4+''' ';
      end
    else
      q4:='';


     //将条件累加成子句
     if q1<>'' then qitem:=q1 else qitem:='';

     if qitem='' then
         if q2<>'' then qitem:=q2;
     if qitem<>'' then
         if q2<>'' then qitem:=qitem+' and '+q2 ;

     if qitem='' then
         if q3<>'' then qitem:=q3;
     if qitem<>'' then
         if q3<>'' then qitem:=qitem+' and '+q3;

     if qitem='' then
         if q4<>'' then qitem:=q4;
     if qitem<>'' then
         if q4<>'' then qitem:=qitem+' and '+q4;


   //根据条件过滤
    with qyearratio do begin

      filter:=qitem;
      filtered:=true;
      qyearratioAfterOpen(qyearratio);
      if not findfirst then  begin
        application.MessageBox('没有您要的信息!','提示',MB_OK);
        btn_clrClick(btn_clr);
        end ;
    end;

end;

end;

procedure TFrm_yearratio.btn_clrClick(Sender: TObject);
begin
      cbxm.Text :='';
      cbbsc.Text :='';
      cbgh.Text :='';
      cbgw.Text :='';
end;




procedure TFrm_yearratio.DBComboBox1Exit(Sender: TObject);
begin
        //通过办事处 给出姓名列表。
    with quse do begin
      if active then close;
      sql.Clear;
      sql.Add('select * from pub_z_stuff where 办事处名称=:bscname');
      parambyname('bscname').AsString:=qyearratio.fieldbyname('办事处名称').AsString ;
      open;
      DBComboBox2.Items.Clear ;
      while not eof do begin
      DBComboBox2.Items.Add(FieldByName('姓名').AsString);
      next;
      end;
   end;

end;

procedure TFrm_yearratio.TabSheet2Enter(Sender: TObject);
begin
   with quse do begin
    if active then close;
    unprepare;
    sql.Clear;
    sql.Add('select 职位 from std_office_station');
    prepare;
    open;
      cbgw.Items.Clear ;
      while not Eof do begin
      cbgw.Items.Add(FieldByName('职位').AsString);
      Next;
      end;
    end;

   with quse do begin
    if active then close;
    unprepare;
    sql.Clear;
    sql.Add('select 工号,姓名 from pub_z_stuff');
    prepare;
    open;
      cbxm.Items.Clear ;
      cbgh.Items.Clear ;
      while not Eof do begin
      cbxm.Items.Add(FieldByName('姓名').AsString);
      cbgh.Items.Add(FieldByName('工号').AsString);
      Next;
      end;
    end;
  with quse do begin
    if active then close;
    unprepare;
    sql.Clear;
    sql.Add('select 办事处名称 from pub_z_office');
    prepare;
    open;
      cbbsc.Items.Clear ;
      while not Eof do begin
      cbbsc.Items.Add(FieldByName('办事处名称').AsString);
      Next;
      end;
    end;

end;

procedure TFrm_yearratio.qyearratioAfterOpen(DataSet: TDataSet);
var
a1:real;
a2:real;
a3:real;
begin
  a1:=0;
  a2:=0;
  a3:=0;
     while not qyearratio.Eof  do begin

         a1:=a1+qyearratio.fieldbyname('年终奖金权').asfloat;
         a2:=a2+qyearratio.fieldbyname('应扣').asfloat;
         a3:=a3+qyearratio.fieldbyname('其他奖励').asfloat;
         qyearratio.Next ;
     end;
//Edit1.text:=floattostr(a1);
//Edit2.text:=floattostr(a2);
//Edit3.text:=floattostr(a3);

end;

procedure TFrm_yearratio.btn_prtClick(Sender: TObject);
begin
     frp_yearratio:=Tfrp_yearratio.Create(application);
     frp_yearratio.QuickRep1.Preview;
     frp_yearratio.free;
end;

procedure TFrm_yearratio.DBComboBox2Exit(Sender: TObject);
begin
        //通过姓名 给出工号,岗位。
    with quse do begin
      if active then close;
      sql.Clear;
      sql.Add('select * from pub_z_stuff where 姓名=:xm');
      parambyname('xm').AsString:=qyearratio.fieldbyname('姓名').AsString ;
      open;
      qyearratio.FieldByName('工号').AsString:=FieldByName('工号').AsString;
      qyearratio.FieldByName('岗位').AsString:=FieldByName('岗位').AsString;
      first;
      DBComboBox5.Items.Clear ;
      while not eof do begin
      DBComboBox5.Items.Add(FieldByName('工号').AsString);
      next;
      end;
   end;
end;

procedure TFrm_yearratio.DBComboBox5Exit(Sender: TObject);
begin
        //通过姓名 给出工号,岗位。
    with quse do begin
      if active then close;
      sql.Clear;
      sql.Add('select * from pub_z_stuff where 工号=:gh');
      parambyname('gh').AsString:=qyearratio.fieldbyname('工号').AsString ;
      open;
      qyearratio.FieldByName('岗位').AsString:=FieldByName('岗位').AsString;
   end;
end;

procedure TFrm_yearratio.FormDestroy(Sender: TObject);
begin
    Frm_yearratio:=nil;
end;

end.

⌨️ 快捷键说明

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