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

📄 xygz_js_pas.pas

📁 不错啊
💻 PAS
📖 第 1 页 / 共 2 页
字号:
   adq6.SQL.Add('select a.*,b.lbbl from ksryb a,kslb b where a.kslb=b.lbname and a.ksname='+#39+ks+#39);
   adq6.Prepared;
   adq6.Open;
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('insert into xyjsb(nf,yf,ks,htry,zsry,fpbl) values(:nf,:yf,:ks,:htry,:zsry,:fpbl)');
   adq5.Parameters.ParamByName('nf').Value :=nf;
   adq5.Parameters.ParamByName('yf').Value :=yf;
   adq5.Parameters.ParamByName('ks').Value :=ks;
   adq5.Parameters.ParamByName('htry').Value :=adq6.FieldValues['kshtry'] ;
   adq5.Parameters.ParamByName('zsry').Value :=adq6.FieldValues['kszsry'] ;
   adq5.Parameters.ParamByName('fpbl').Value :=adq6.FieldValues['lbbl'] ;
   adq5.ExecSQL ;
   //录入正式与合同的分配比率
   adq6.Close;
   adq6.SQL.Clear;
   adq6.SQL.Add('select * from system_rybl');
   adq6.Prepared;
   adq6.Open;
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set zsbl='+inttostr(adq6.FieldValues ['fpbl'])+' where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
   adq6.Next;
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set htbl='+inttostr(adq6.FieldValues ['fpbl'])+' where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
   //录入科室的收入合计及支出合计
   adq6.Close;
   adq6.SQL.Clear;
   adq6.SQL.Add('select sum(num) as num from fyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39+' and mark=1');
   adq6.Prepared;
   adq6.Open;
   if adq6.FieldValues ['num']>0 then
   begin
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set srhj='+floattostr(adq6.FieldValues ['num'])+' where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
   end;
   adq6.Close;
   adq6.SQL.Clear;
   adq6.SQL.Add('select sum(num) as num from fyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39+' and mark=0');
   adq6.Prepared;
   adq6.Open;
   if adq6.FieldValues ['num']>0 then
   begin
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set zchj='+floattostr(adq6.FieldValues ['num'])+' where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
   end;
   //求分段前的平均值
   adq5.Close;
   adq6.Close;
   adq6.SQL.Clear;
   adq6.SQL.Add('select * from xyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq6.Prepared;
   adq6.Open;
   if adq6.FieldValues['srhj'] >0 then
     a_calc:=((adq6.FieldValues['srhj']-adq6.FieldValues['zchj'])*adq6.FieldValues['fpbl']/100)/(adq6.FieldValues['zsry']+adq6.FieldValues['htry'])
   else
     a_calc:=0;
   //计算分段平均值
   a_test:=true;
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('select ksd,jsd,bl from gz_fdb group by ksd,jsd,bl order by ksd');
   adq5.Open;
   b_calc:=0;
   while a_test do
   begin
      if a_calc<=adq5.FieldValues['jsd'] then
      begin
        if a_calc=0 then
        begin
          a_test:=false;
          b_calc:=0;
        end
        else
        begin
        a_calc:=a_calc-adq5.FieldValues['ksd'];
        a_test:=false;
        b_calc:=b_calc+a_calc*adq5.FieldValues ['bl']/100;
        end;
      end
      else
      begin
       if adq5.FieldValues['jsd']=adq5.FieldValues['ksd'] then
       begin
         a_test:=false;
         a_calc:=a_calc-adq5.FieldValues['jsd'];
         b_calc:=b_calc+a_calc*adq5.FieldValues ['bl']/100;
       end
       else
        b_calc:=b_calc+(adq5.FieldValues['jsd']-adq5.FieldValues['ksd'])*adq5.FieldValues ['bl']/100;
      end;
      adq5.Next;
   end;
   //当前分段平均值已经算完 b_calc中存放
   //一次性的写入表中
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set fdpjz='+floattostr(b_calc)+' where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
   adq5.Close;
   adq5.SQL.Clear;
   adq5.SQL.Add('update xyjsb set zsje=fdpjz*zsbl/100,htje=fdpjz*htbl/100,kskfpje=fdpjz*htbl/100*htry+fdpjz*zsbl/100*zsry where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
   adq5.ExecSQL;
 end;
end;

procedure Txygz_js.sj_lr(nf,yf:integer;ks:string;js_mark:boolean);
var
  i:integer;
begin
  //首先查找当前所要计算的数据是不是已经存在了,如果存在看是不是js_mark为真
  //如果为真则删除当前条件 的数据,并重新计算,否则显示当前的数据
  if not js_mark then
  begin
   if trim(ks)='全部' then
   //if listbox1.ItemIndex =0 then
   begin 
      main_dm.adq4.Close;
      main_dm.adq4.SQL.clear;
      main_dm.adq4.SQL.Add('select * from xyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf='+combobox2.Items[combobox2.itemindex]);
      main_dm.adq4.Prepared;
      main_dm.adq4.Open;
      if main_dm.adq4.RecordCount >0 then
      begin
        exit;
        listbox1.SetFocus;
      end;
   end
   else
   begin

      main_dm.adq4.Close;
      main_dm.adq4.SQL.clear;
      main_dm.adq4.SQL.Add('select * from xyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
      main_dm.adq4.Prepared;
      main_dm.adq4.Open;
      if main_dm.adq4.Recordset.RecordCount >0 then
      begin
        exit;
        listbox1.SetFocus;
      end;
   end;
  end
  else
  begin
  //如果标志为真,则删除符合条件的数据
  if ks='全部' then
  begin
    main_dm.adq4.Close;
    main_dm.adq4.SQL.Clear;
    main_dm.adq4.SQL.Add('delete from xyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf));
    main_dm.adq4.ExecSQL;
  end
  else
  begin
    main_dm.adq4.Close;
    main_dm.adq4.SQL.Clear;
    main_dm.adq4.SQL.Add('delete from xyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' and ks='+#39+ks+#39);
    main_dm.adq4.ExecSQL;
  end;
  end;
  if ks='全部' then
  begin
  //计算本年度,本月份内的所有科室的费用
    main_dm.adq4.Close;
    main_dm.adq4.SQL.clear;
    main_dm.adq4.SQL.Add('select ks from fyjsb where nf='+inttostr(nf)+' and yf='+inttostr(yf)+' group by ks');
    main_dm.adq4.Prepared;
    main_dm.adq4.Open;
   for i:=0 to main_dm.adq4.RecordCount -1 do
   begin
     sj_data_post(nf,yf,main_dm.adq4.FieldValues ['ks']);
     main_dm.adq4.Next;
   end;
  end
  else
  begin
  //计算本年度,本月份内的指定科室的费用
    sj_data_post(nf,yf,ks);
  end;
end;



procedure Txygz_js.ToolButton3Click(Sender: TObject);
var
  a_str:string;
begin
  inherited;
  a_str:='全部';
  if listbox1.ItemIndex <>0 then
    sj_lr(strtoint(combobox1.Items[combobox1.ItemIndex]),strtoint(combobox2.Items[combobox2.ItemIndex]),listbox1.Items[listbox1.itemindex],true)
  else
   sj_lr(strtoint(combobox1.Items[combobox1.ItemIndex]),strtoint(combobox2.Items[combobox2.ItemIndex]),a_str,true);
  ref_screen;
end;

procedure Txygz_js.ToolButton2Click(Sender: TObject);
var
  a_str:string;
begin
  inherited;
  a_str:='全部';
  if listbox1.ItemIndex <>0 then
    sj_lr(strtoint(combobox1.Items[combobox1.ItemIndex]),strtoint(combobox2.Items[combobox2.ItemIndex]),listbox1.Items[listbox1.itemindex],false)
  else
    sj_lr(strtoint(combobox1.Items[combobox1.ItemIndex]),strtoint(combobox2.Items[combobox2.ItemIndex]),a_str,false);
  ref_screen;
end;

procedure Txygz_js.ToolButton4Click(Sender: TObject);
begin
  inherited;
  qrdbtext1.DataSet :=main_dm.adq3;
  qrdbtext1.DataField :='年份';
  qrdbtext2.DataSet :=main_dm.adq3;
  qrdbtext2.DataField :='月份';
  qrlabel6.Caption :=datetimetostr(now);
  //select nf as 年份,yf as 月份,ks as 科室,srhj as 收入合计,
//zchj as 支出合计,zsje as 正式人员效益,htje as 合同人员效益,
//kskfpje as 科室效益总额,(htry+zsry) as 人员合计');
  quickrep1.DataSet :=main_dm.adq3;
  qrdbtext3.DataSet :=main_dm.adq3;
  qrdbtext3.DataField :='科室';
  qrdbtext4.DataSet :=main_dm.adq3;
  qrdbtext4.DataField :='收入合计';
  qrdbtext5.DataSet :=main_dm.adq3;
  qrdbtext5.DataField :='支出合计';
  qrdbtext6.DataSet :=main_dm.adq3;
  qrdbtext6.DataField :='分配比率';
  qrdbtext7.DataSet :=main_dm.adq3;
  qrdbtext7.DataField :='人员合计';
  qrdbtext8.DataSet :=main_dm.adq3;
  qrdbtext8.DataField :='正式人员效益';
  qrdbtext9.DataSet :=main_dm.adq3;
  qrdbtext9.DataField :='合同人员效益';
  qrdbtext10.DataSet :=main_dm.adq3;
  qrdbtext10.DataField :='科室效益总额';
  quickrep1.PreviewModal ;
end;

end.

⌨️ 快捷键说明

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