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

📄 untschoolset.pas

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

interface

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

type
  TfrmSchoolSet = class(TfrmBaseMDEdit)
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label4: TLabel;
    adsDetailiAutoID: TAutoIncField;
    adsDetailSchoolID: TIntegerField;
    adsDetailClassYear: TStringField;
    adsDetailName: TStringField;
  private
    { Private declarations }
  protected
    procedure CheckAvoild; override;
    procedure DoBeforePost; override;
    procedure AfterFormShow; override;
  public
    { Public declarations }
  end;

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

implementation

uses untGlobalFun, untDM;

function SetSchool(ADataSet: TADODataSet; AOpMode: TOperatorMode): Boolean;
begin
  with TfrmSchoolSet.Create(Application) do
    try
      DataSet := ADataSet;
      Title := '学校资料';
      OpMode := AOpMode;
      ContinueAppend := true;
      Result := ShowModal=mrOK;
    finally
      Free;
    end;
end;

{$R *.dfm}

{ TfrmSchoolSet }

procedure TfrmSchoolSet.AfterFormShow;
var
  ID: Integer;
begin
  inherited;
  with adsDetail do begin
    if Active then Active := false;
    Connection := DataSet.Connection;
    if DataSet.FieldByName('iAutoID').IsNull then ID := -1
    else ID := DataSet.FieldByName('iAutoID').AsInteger;
    CommandText := ' select * from tClass '
                  +' where SchoolID='+IntToStr(ID);
    Active := true;
  end;
end;

procedure TfrmSchoolSet.CheckAvoild;
var
  strSQL: string;
begin
  inherited;
  if OpMode = omNew then begin
    strSQL := 'select count(*) from tSchool '
      +' where Name='+QuotedStr(Trim(DBEdit1.Text));
    if GetDBValue(DataSet.Connection, strSQL) > 0 then
    begin
      if DBEdit1.CanFocus then DBEdit1.SetFocus;
      raise Exception.Create('学校名称重复,请重输!');
    end;
  end;
end;

procedure TfrmSchoolSet.DoBeforePost;
var
  ABookStr: TBookmarkStr;
  ID: Integer;
begin
  inherited;
  with adsDetail do begin
    if State in [dsInsert, dsEdit] then Post;
    DisableControls;
    ABookStr := Bookmark;
    First;
    if OpMode=omNew then
      ID := GetMaxID(DataSet.Connection, 'tSchool', 'iAutoID')
    else
      ID := DataSet.FieldByName('iAutoID').Value;
    while not Eof do begin
      Edit;
      if adsDetailSchoolID.Value <> ID then
        adsDetailSchoolID.Value := ID;
      Post;
      Next;
    end;
    EnableControls;
  end;
end;

end.

⌨️ 快捷键说明

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