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

📄 input_sr_pas.pas

📁 不错啊
💻 PAS
字号:
unit input_sr_pas;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, pub_frm_pas, Grids, DBGrids, StdCtrls, ImgList, ComCtrls,
  ToolWin, ExtCtrls, DBCtrls,DateUtils, ppClass, daDataView,
  daQueryDataView, daADO, ppModule, daDataModule, ppBands, ppCache, ppComm,
  ppRelatv, ppProd, ppReport;

type
  Tinput_sr = class(Tpub_frm)
    ToolButton3: TToolButton;
    ToolButton5: TToolButton;
    Panel3: TPanel;
    ComboBox1: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    ComboBox2: TComboBox;
    Label3: TLabel;
    ComboBox3: TComboBox;
    Label4: TLabel;
    Label5: TLabel;
    Edit1: TEdit;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    DBGrid1: TDBGrid;
    Panel8: TPanel;
    Label6: TLabel;
    Edit2: TEdit;
    Label7: TLabel;
    Edit3: TEdit;
    Label8: TLabel;
    Edit4: TEdit;
    Label9: TLabel;
    Edit5: TEdit;
    Label10: TLabel;
    Edit6: TEdit;
    ComboBox4: TComboBox;
    Label11: TLabel;
    ToolButton2: TToolButton;
    ToolButton4: TToolButton;
    ppReport1: TppReport;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand1: TppDetailBand;
    ppFooterBand1: TppFooterBand;
    daDataModule1: TdaDataModule;
    daADOQueryDataView1: TdaADOQueryDataView;
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ComboBox1Change(Sender: TObject);
    procedure ref_screen;
    procedure ComboBox4KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox1KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox2KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox3KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox4Change(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  input_sr: Tinput_sr;

implementation
  uses
    main_dm_pas,ks_sr_cx_pas,ks_zc_cx_pas;
  var
    main_dm:Tmain_dm;
    sjb:string;
{$R *.dfm}

procedure Tinput_sr.ref_screen ;
begin
  if combobox1.ItemIndex >-1 then
    if combobox2.ItemIndex >-1 then
      if combobox3.ItemIndex >-1 then
      begin
         main_dm.adq2.Close;
         main_dm.adq2.SQL.Clear;
         main_dm.adq2.SQL.Add('select nf as 年份,yf as 月份,ks as 科室,mark as 标记,num as 金额,xmmc as 项目名称,id as 编号');
         main_dm.adq2.SQL.Add('from fyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
         main_dm.adq2.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
         main_dm.adq2.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39);
         main_dm.adq2.Prepared;
         main_dm.adq2.Open;
         main_dm.DataSource1.DataSet :=main_dm.adq2 ;
         dbgrid1.DataSource :=main_dm.DataSource1 ;
         //科室分配比率
         main_dm.adq3.Close;
         main_dm.adq3.SQL.Clear;
         main_dm.adq3.SQL.Add('select b.lbbl from ksryb a,kslb b where a.kslb=b.lbname and a.ksname='+#39+combobox3.Items[combobox3.itemindex]+#39);
         main_dm.adq3.Prepared;
         main_dm.adq3.Open;
         if not varisnull(main_dm.adq3.FieldValues['lbbl']) then
         edit2.Text :=inttostr(main_dm.adq3.FieldValues['lbbl']);
         //科室正式人员
         main_dm.adq3.Close;
         main_dm.adq3.SQL.Clear;
         main_dm.adq3.SQL.Add('select kszsry as ry from ksryb a where a.ksname='+#39+combobox3.Items[combobox3.itemindex]+#39);
         main_dm.adq3.Prepared;
         main_dm.adq3.Open;
         if not varisnull(main_dm.adq3.FieldValues['ry']) then
         edit3.Text :=inttostr(main_dm.adq3.FieldValues['ry']);
         //科室合同人员
         main_dm.adq3.Close;
         main_dm.adq3.SQL.Clear;
         main_dm.adq3.SQL.Add('select kshtry as ry from ksryb a where a.ksname='+#39+combobox3.Items[combobox3.itemindex]+#39);
         main_dm.adq3.Prepared;
         main_dm.adq3.Open;
         if not varisnull(main_dm.adq3.FieldValues['ry']) then
         edit4.Text :=inttostr(main_dm.adq3.FieldValues['ry']);
         //科室当前收入合计
         main_dm.adq3.Close;
         main_dm.adq3.SQL.Clear;
         main_dm.adq3.SQL.Add('select sum(num) as num');
         main_dm.adq3.SQL.Add('from fyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
         main_dm.adq3.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
         main_dm.adq3.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39+' and mark=1');
         main_dm.adq3.Prepared;
         main_dm.adq3.Open;
         if not varisnull(main_dm.adq3.FieldValues['num']) then
         edit5.Text :=floattostr(main_dm.adq3.FieldValues['num']);
         //科室支出合计
         main_dm.adq3.Close;
         main_dm.adq3.SQL.Clear;
         main_dm.adq3.SQL.Add('select sum(num) as num');
         main_dm.adq3.SQL.Add('from fyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
         main_dm.adq3.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
         main_dm.adq3.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39+' and mark=0');
         main_dm.adq3.Prepared;
         main_dm.adq3.Open;
         dbgrid1.Columns[2].Width :=100; 
         if not varisnull(main_dm.adq3.FieldValues['num']) then
         edit6.Text :=floattostr(main_dm.adq3.FieldValues['num']);
      end;
end;

procedure Tinput_sr.FormCreate(Sender: TObject);
var
  i:integer;
begin
  inherited;
  sjb:='';
  for i:=0 to self.ComponentCount-1 do
    if self.Components[i] is Tedit then
      (self.Components[i] as Tedit).Clear;
  main_dm:=Tmain_dm.Create(self);
  main_dm.gz.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(application.ExeName)+'gzgl.mdb;Persist Security Info=False';
  with main_dm do
  begin
    adq1.Close;
    adq1.SQL.clear;
    adq1.SQL.Add('SELECT nf from system_jzq group by nf');
    adq1.Prepared;
    adq1.Open;
    combobox1.Items.Clear;
    for i:=0 to adq1.RecordCount -1 do
      begin
        combobox1.Items.Add(inttostr(adq1.FieldValues ['nf']));
        adq1.Next;
        if strtoint(combobox1.Items[i])=yearof(now) then
          combobox1.ItemIndex :=i;
      end;
    combobox2.ItemIndex :=monthof(now)-1;
    adq1.Close;
    adq1.SQL.clear;
    adq1.SQL.Add('SELECT ksname from ksryb group by ksname order by ksname');
    adq1.Prepared;
    adq1.Open;
    combobox3.Items.Clear;
    for i:=0 to adq1.RecordCount -1 do
    begin
      combobox3.Items.Add(adq1.FieldValues ['ksname']);
      adq1.Next;
    end;
    combobox3.ItemIndex :=-1;
    if self.Name ='input_sr_sr' then
    begin
      adq4.Close;
      adq4.sql.Clear;
      adq4.SQL.Add('select name from system_sr group by name order by name');
      adq4.Prepared;
      adq4.Open;
      sjb:='system_sr';
    end
    else
    begin
      adq4.Close;
      adq4.sql.Clear;
      adq4.SQL.Add('select name from system_zc group by name order by name');
      adq4.Prepared;
      adq4.Open;
      sjb:='system_zc';
    end;
    combobox4.Clear;
    combobox4.items.Clear;
    for i:=0 to adq4.RecordCount-1 do
    begin
      combobox4.Items.Add(adq4.FieldValues['name']);
      adq4.Next;
    end;
    combobox4.ItemIndex :=-1;
  end;
end;

procedure Tinput_sr.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  main_dm.Free;
end;

procedure Tinput_sr.ComboBox1Change(Sender: TObject);
begin
  inherited;
  ref_screen ;
end;

procedure Tinput_sr.ComboBox4KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=VK_return then
  if combobox4.ItemIndex >-1 then
    begin
      edit1.Clear;
      edit1.SetFocus;
      //如果系统内已经存在相应的数据,则进行显示
      main_dm.adq4.Close;
      main_dm.adq4.SQL.clear;
      main_dm.adq4.SQL.Add('select num');
      main_dm.adq4.SQL.Add('from fyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
      main_dm.adq4.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
      main_dm.adq4.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39);
      if sjb='system_zc' then
        main_dm.adq4.SQL.Add(' and mark=0 ')
      else
        main_dm.adq4.SQL.Add(' and mark=1 ');
      main_dm.adq4.SQL.Add(' and xmmc='+#39+combobox4.Items[combobox4.itemindex]+#39);
      main_dm.adq4.Prepared;
      main_dm.adq4.Open;
      if main_dm.adq4.RecordCount >0 then
      begin
        edit1.Text :=inttostr(main_dm.adq4.FieldValues['num']);
      end
      else
        edit1.Text :='0';
      edit1.SelectAll ;
    end;
end;

procedure Tinput_sr.Edit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=VK_return then
  if combobox3.ItemIndex >-1 then
  if combobox4.ItemIndex >-1 then 
  begin
  //进行数据的保存
    main_dm.adq4.Close;
    main_dm.adq4.SQL.clear;
    main_dm.adq4.SQL.Add('select num');
    main_dm.adq4.SQL.Add('from fyjsb where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
    main_dm.adq4.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
    main_dm.adq4.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39);
    if sjb='system_zc' then
      main_dm.adq4.SQL.Add(' and mark=0 ')
    else
      main_dm.adq4.SQL.Add(' and mark=1 ');
    main_dm.adq4.SQL.Add(' and xmmc='+#39+combobox4.Items[combobox4.itemindex]+#39);
    main_dm.adq4.Prepared;
    main_dm.adq4.Open;
    if main_dm.adq4.RecordCount >0 then
    begin
      //如果已经录入了数据
      main_dm.adq4.Close;
      main_dm.adq4.SQL.clear;
      main_dm.adq4.SQL.Add('update fyjsb set num='+edit1.Text);
      main_dm.adq4.SQL.Add(' where nf='+combobox1.Items[combobox1.itemindex]+' and yf=' );
      main_dm.adq4.SQL.Add(combobox2.Items[combobox2.itemindex]+' and ks=');
      main_dm.adq4.SQL.Add(#39+combobox3.Items[combobox3.itemindex]+#39);
      if sjb='system_zc' then
        main_dm.adq4.SQL.Add(' and mark=0 ')
      else
        main_dm.adq4.SQL.Add(' and mark=1 ');
      main_dm.adq4.SQL.Add(' and xmmc='+#39+combobox4.Items[combobox4.itemindex]+#39);
      main_dm.adq4.ExecSQL ;
    end
    else
    begin
      //如果还没有录入数据
      main_dm.adq4.Close;
      main_dm.adq4.SQL.Clear;
      main_dm.adq4.SQL.Add('insert into fyjsb(nf,yf,ks,mark,num,xmmc,kszsry,kshtry,fybl) values(');
      main_dm.adq4.SQL.Add(':nf,:yf,:ks,:mark,:num,:xmmc,:kszsry,:kshtry,:fybl)');
      main_dm.adq4.Parameters.ParamByName('nf').Value :=combobox1.Items[combobox1.itemindex];
      main_dm.adq4.Parameters.ParamByName('yf').Value :=combobox2.Items[combobox2.itemindex];
      main_dm.adq4.Parameters.ParamByName('ks').Value :=combobox3.Items[combobox3.itemindex];
      if sjb='system_zc' then
      main_dm.adq4.Parameters.ParamByName('mark').Value :=0
      else
      main_dm.adq4.Parameters.ParamByName('mark').Value :=1;
      main_dm.adq4.Parameters.ParamByName('num').Value :=strtofloat(edit1.text);
      main_dm.adq4.Parameters.ParamByName('xmmc').Value :=combobox4.Items[combobox4.itemindex];
      main_dm.adq4.Parameters.ParamByName('kszsry').Value :=strtoint(edit3.Text );
      main_dm.adq4.Parameters.ParamByName('kshtry').Value :=strtoint(edit4.Text );
      main_dm.adq4.Parameters.ParamByName('fybl').Value :=strtoint(edit2.Text );
      main_dm.adq4.ExecSQL ;
    end;
    ref_screen ;
  //
    if combobox4.ItemIndex >=combobox4.Items.Count-1 then
      begin
        combobox4.ItemIndex :=-1;
        label11.Caption :='当前项目:';
        combobox3.SetFocus;
      end
    else
    begin
      combobox4.ItemIndex :=combobox4.ItemIndex+1;
      label11.Caption :='当前项目:'+combobox4.Items[combobox4.itemindex];
      combobox4.SetFocus ;
    end;
  end;
end;

procedure Tinput_sr.ComboBox1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=VK_return then
    combobox2.SetFocus;
end;

procedure Tinput_sr.ComboBox2KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
    if key=VK_return then
    combobox3.SetFocus;

end;

procedure Tinput_sr.ComboBox3KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=VK_return then
    combobox4.SetFocus;
end;

procedure Tinput_sr.ComboBox4Change(Sender: TObject);
begin
  inherited;
  label11.Caption :='当前项目:'+combobox4.Items[combobox4.itemindex];
end;

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

procedure Tinput_sr.ToolButton3Click(Sender: TObject);
var
  abc:integer;
begin
  inherited;
  if dbgrid1.Columns.Count >1 then
  begin
  abc:=application.MessageBox('是否确定删除当前在列表所选定的记录?','提示',1);
  if abc=1 then
  begin
    //进行删除
    main_dm.adq4.Close;
    main_dm.adq4.SQL.Clear;
    main_dm.adq4.SQL.Add('delete from fyjsb where id='+inttostr(dbgrid1.DataSource.DataSet.FieldValues['编号']));
    main_dm.adq4.ExecSQL ;
    application.MessageBox('数据删除完毕!','系统提示',0);
    ref_screen ;
  end;
  end
  else
  begin
    application.MessageBox('没有检查到可以删除的数据!','系统提示',0);
  end;
end;

procedure Tinput_sr.ToolButton2Click(Sender: TObject);
var
  ks_sr_cx:Tks_sr_cx;
begin
  inherited;
  ks_sr_cx:=Tks_sr_cx.Create(input_sr);
  ks_sr_cx.ShowModal ;
  ks_sr_cx.Free;
end;

procedure Tinput_sr.ToolButton4Click(Sender: TObject);
var
  ks_zc_cx:Tks_zc_cx;
begin
  inherited;
  ks_zc_cx:=Tks_zc_cx.Create(input_sr);
  ks_zc_cx.ShowModal ;
  ks_zc_cx.Free;
end;

end.

⌨️ 快捷键说明

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