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

📄 untjudgestdset.pas

📁 简要说明:对医院幼儿心理情况做的一个调查,统计系统.
💻 PAS
字号:
unit untJudgeStdSet;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, untBaseMDEdit, DB, ADODB, StdCtrls, Buttons, ExtCtrls, Grids,
  DBGrids, jpeg, DBCtrls, Mask, untGlobalVar, fcButton, fcImgBtn;

type
  TfrmJudgeStdSet = class(TfrmBaseMDEdit)
    Label1: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    DBEdit1: TDBEdit;
    DBLookupComboBox1: TDBLookupComboBox;
    adsDetailiAutoID: TAutoIncField;
    adsDetailJSID: TIntegerField;
    adsDetailMeasureCode: TStringField;
    adsDetailItemCode: TStringField;
    adsDetailSex: TIntegerField;
    adsDetailAvgValue: TBCDField;
    adsDetailSDValue: TBCDField;
    DBComboBox1: TDBComboBox;
    adsMeasure: TADODataSet;
    dsMeasure: TDataSource;
    adsMeasurecode: TStringField;
    adsMeasurename: TStringField;
    adsMeasureItem: TADODataSet;
    adsMeasureItemcode: TStringField;
    adsMeasureItemMeasurecode: TStringField;
    adsMeasureItemName: TStringField;
    adsDetailItemName: TStringField;
    adsLookUpMeasureItem: TADODataSet;
    adsLookUpMeasureItemcode: TStringField;
    adsLookUpMeasureItemName: TStringField;
    adsLookUpMeasureItemMeasurecode: TStringField;
    procedure DBComboBox1Exit(Sender: TObject);
    procedure DBLookupComboBox1CloseUp(Sender: TObject);
    procedure adsDetailSexGetText(Sender: TField; var Text: String;
      DisplayText: Boolean);
    procedure adsDetailSexSetText(Sender: TField; const Text: String);
    procedure adsDetailBeforeInsert(DataSet: TDataSet);
    procedure adsMeasureAfterScroll(DataSet: TDataSet);
    procedure adsDetailNewRecord(DataSet: TDataSet);
  private
    { Private declarations }
  protected
    procedure CheckAvoild; override;
    procedure DoBeforePost; override;
    procedure AfterFormShow; override;
    procedure InitComponents; override;
  public
    { Public declarations }
  end;

function SetJudgeStd(ADataSet: TADODataSet; AOpMode: TOperatorMode): Boolean;

implementation

uses untGlobalFun, untDM;

function SetJudgeStd(ADataSet: TADODataSet; AOpMode: TOperatorMode): Boolean;
begin
  with TfrmJudgeStdSet.Create(Application) do
    try
      DataSet := ADataSet;
      Title := '判断标准';
      OpMode := AOpMode;
      ContinueAppend := true;
      Result := ShowModal=mrOK;
    finally
      Free;
    end;
end;

{$R *.dfm}

{ TfrmQuestionSet }

procedure TfrmJudgeStdSet.AfterFormShow;
var
  JSID: Integer;
begin
  inherited;
  if OpMode = omNew then
    JSID := -1
  else
    JSID := DataSet.FieldByName('iAutoID').AsInteger;
  with adsDetail do begin
    if Active then Active := false;
    Connection := DataSet.Connection;
    CommandText := 'select * from tJudgeStd_Mx where JSID='+IntToStr(JSID);
    Active := true;
  end;
end;

procedure TfrmJudgeStdSet.CheckAvoild;
var
  i: Integer;
  bm: TBookmark;
begin
  inherited;
  with adsDetail do begin
    if IsEmpty then
      raise Exception.Create('无任何判断明细资料,不能保存!');

    bm := GetBookmark;
    DisableControls;
    first;

    while not Eof do begin
      for i:=0 to FieldCount-1 do begin
        if Fields[i].Visible and Fields[i].IsNull then
        begin
          EnableControls;
          Fields[i].FocusControl;
          raise Exception.Create('数据输入不完整,请输入'+Fields[i].DisplayLabel);
        end;
      end;
      Next;
    end;
    GotoBookmark(bm);
    EnableControls;
  end;
end;

procedure TfrmJudgeStdSet.DoBeforePost;
var
  MaxID: Integer;
begin
  inherited;
  with adsDetail do begin
    if State in [dsInsert, dsEdit] then Post;
    DisableControls;
    First;
    if OpMode = omNew then
      MaxID := GetMaxID(DataSet.Connection, 'tJudgeStd','iAutoID')
    else
      MaxID := DataSet.fieldbyName('iAutoID').AsInteger;
    while not Eof do begin
      Edit;
      if adsDetailJSID.Value <> MaxID then
        adsDetailJSID.Value := MaxID;
      Post;
      Next;
    end;
    EnableControls;
  end;
end;

procedure TfrmJudgeStdSet.InitComponents;
var
  i: Integer;
begin
  inherited;
  with adsMeasure do begin
    if Active then Active := false;
    Active := true;
  end;
  with adsMeasureItem do begin
    if Active then Active := false;
    Active := true;
  end;
  with adsLookUpMeasureItem do begin
    if Active then Active := false;
    Active := true;
  end;
  for i:=0 to grdDetail.Columns.Count - 1 do begin
    if grdDetail.Columns[i].FieldName = 'Sex' then begin
      grdDetail.Columns[i].PickList.Clear;
      grdDetail.Columns[i].PickList.Add('男');
      grdDetail.Columns[i].PickList.Add('女');
    end;
  end;
end;

procedure TfrmJudgeStdSet.DBComboBox1Exit(Sender: TObject);
var
  iType: Integer;
begin
  inherited;
  if dsMaster.DataSet.FieldByName('iType').IsNull then Exit;
  iType := dsMaster.DataSet.FieldByName('iType').Value;
  {adsDetailSDValue.Visible := iType = 0;
  adsDetailAgeBegin.Visible := DataSet['iType'] = 0; 
  adsDetailAgeEnd.Visible := DataSet['iType'] = 0; }
  if iType = 0 then
    adsDetail.FieldByName('AvgValue').DisplayLabel := '均值'
  else
    adsDetail.FieldByName('AvgValue').DisplayLabel := '上限'; 
end;

procedure TfrmJudgeStdSet.DBLookupComboBox1CloseUp(Sender: TObject);
begin
  inherited;
  if VarIsNull(DBLookupComboBox1.KeyValue) then Exit;
  if DBLookupComboBox1.KeyValue <> DataSet['MeasureCode'] then
    with adsDetail do begin
      while not IsEmpty do
        Delete;
    end;
end;

procedure TfrmJudgeStdSet.adsDetailSexGetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
  inherited;
  if VarIsNull(Sender.Value) then Exit;
  case sender.Value of
    0: Text := '男';
    1: Text := '女';
  end;
end;

procedure TfrmJudgeStdSet.adsDetailSexSetText(Sender: TField;
  const Text: String);
begin
  inherited;
  if Text = '女' then Sender.value := 1
  else Sender.value := 0;
end;

procedure TfrmJudgeStdSet.adsDetailBeforeInsert(DataSet: TDataSet);
begin
  inherited;
  if Self.DataSet.FieldByName('MeasureCode').IsNull then begin
    MsgOK('请先选择对应的量表!');
    if DBLookupComboBox1.CanFocus then DBLookupComboBox1.SetFocus;
    Abort;
  end;
end;

procedure TfrmJudgeStdSet.adsMeasureAfterScroll(DataSet: TDataSet);
begin
  inherited;
  with adsLookUpMeasureItem do begin
    if not Active then Active := true;
    if Filtered then Filtered := false;
    Filter := 'MeasureCode='+QuotedStr(DataSet.fieldbyname('Code').AsString);
    Filtered := true;
  end;
end;

procedure TfrmJudgeStdSet.adsDetailNewRecord(DataSet: TDataSet);
begin
  inherited;
  DataSet['MeasureCode'] := Self.DataSet.fieldbyname('MeasureCode').AsString;
end;

end.

⌨️ 快捷键说明

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