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

📄 f_sel_person.pas

📁 用Delphi 开发的一个 户籍管理系统
💻 PAS
字号:
unit f_sel_person;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, RzButton, Mask, RzEdit, DBCtrls, RzDBCmbo, RzLabel,
  ComCtrls, ToolWin, SUIToolBar, 
  cxEdit, DB, cxDBData, cxCheckBox, ADODB,
  cxGridLevel, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxClasses, cxControls, cxGridCustomView, cxGrid, ActnList, 
  RzDBGrid, RzCmboBx, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage;

type
  Tfm_sel_person = class(TForm)
    suiToolBar1: TsuiToolBar;
    btn_4: TToolButton;
    RzLabel39: TRzLabel;
    cbb_field: TRzDBLookupComboBox;
    btn_3: TToolButton;
    actlst_hjgl: TActionList;
    act_find: TAction;
    act_search: TAction;
    act_showall: TAction;
    act_exit: TAction;
    ds_person: TDataSource;
    ds_fieldshow: TDataSource;
    dst_person: TADODataSet;
    strngfld__peopleCode: TWideStringField;
    strngfld__peopleName: TWideStringField;
    strngfld__peopleOldName: TWideStringField;
    strngfld__peopleSexName: TStringField;
    dtmfld__peopleBirthday: TDateTimeField;
    strngfld__peopleIDCard: TWideStringField;
    strngfld__peopledoorNumber: TWideStringField;
    strngfld__peopleHouseMaster: TWideStringField;
    strngfld__peoplerelationName: TWideStringField;
    strngfld__peoplemarriageName: TWideStringField;
    strngfld__peopleregTypeName: TWideStringField;
    strngfld__peopleGroupName: TWideStringField;
    dtmfld__peopleQfDate: TDateTimeField;
    strngfld__peoplerecordStatusName: TWideStringField;
    strngfld__peopleEduDegreeName: TWideStringField;
    strngfld__peopleBloodTypeName: TStringField;
    strngfld__peopleNationlityName: TStringField;
    strngfld__peopleHealthName: TWideStringField;
    strngfld__peopleReligionName: TWideStringField;
    strngfld__peopleEscuageName: TWideStringField;
    strngfld__peoplePolityName: TWideStringField;
    intgrfld__peopleregType: TIntegerField;
    strngfld__peoplerelation: TWideStringField;
    strngfld__peopleOrgan: TWideStringField;
    intgrfld__peopleRecordStatus: TIntegerField;
    dtmfld__peopleRecordDate: TDateTimeField;
    intgrfld__peopleEduDegree: TIntegerField;
    strngfld__peopleBirthAddress: TWideStringField;
    intgrfld__peopleSex: TIntegerField;
    intgrfld__peopleStature: TIntegerField;
    intgrfld__peopleBloodType: TIntegerField;
    intgrfld__peopleNationlity: TIntegerField;
    intgrfld__peopleHealth: TIntegerField;
    strngfld__peopleDwellingPlace: TWideStringField;
    strngfld__peopleTelephone: TWideStringField;
    strngfld__peopleOtherDwellingPlace: TWideStringField;
    intgrfld__peopleReligion: TIntegerField;
    intgrfld__peopleMarriage: TIntegerField;
    intgrfld__peopleEscuage: TIntegerField;
    strngfld__peopleWork: TWideStringField;
    strngfld__peopleService: TWideStringField;
    intgrfld__peoplePolity: TIntegerField;
    mfld__peopleRemark: TMemoField;
    blnfld__peopleLownessDefend: TBooleanField;
    blnfld__peopleArmyCorps: TBooleanField;
    blbfld__peoplePic: TBlobField;
    strngfld__peopleDoorRecordLocus: TWideStringField;
    strngfld__peopleNativePlace: TWideStringField;
    dtmfld__peopleIngoingDate: TDateTimeField;
    strngfld__peopleOriginalDwellingPlace: TWideStringField;
    intgrfld__peopleIngoingType: TIntegerField;
    fld__peopleIngoingTypeName: TStringField;
    strngfld__peopleIngoingCause: TWideStringField;
    dtmfld__peopleExceedDate: TDateTimeField;
    strngfld__peopleExceedAddress: TWideStringField;
    intgrfld__peopleExceedType: TIntegerField;
    fld__peopleExceedTypeName: TStringField;
    strngfld__peopleExceedCause: TWideStringField;
    blnfld__peopleDeath: TBooleanField;
    blnfld__peopleLogout: TBooleanField;
    dtmfld__peopleDeathDate: TDateTimeField;
    strngfld__peopleDeathCause: TWideStringField;
    dtmfld__peopleLogoutDate: TDateTimeField;
    strngfld__peopleLogoutCause: TWideStringField;
    intgrfld__peopleID: TIntegerField;
    blnfld__peopleisbmp: TBooleanField;
    grd_person: TcxGrid;
    tv_person: TcxGridDBTableView;
    lv_person: TcxGridLevel;
    lmn__personCode: TcxGridDBColumn;
    lmn__personName: TcxGridDBColumn;
    lmn__personOldName: TcxGridDBColumn;
    lmn__personSexName: TcxGridDBColumn;
    lmn__personBirthday: TcxGridDBColumn;
    lmn__personIDCard: TcxGridDBColumn;
    lmn__persondoorNumber: TcxGridDBColumn;
    lmn__personHouseMaster: TcxGridDBColumn;
    lmn__personrelationName: TcxGridDBColumn;
    lmn__personmarriageName: TcxGridDBColumn;
    lmn__personregTypeName: TcxGridDBColumn;
    lmn__personGroupName: TcxGridDBColumn;
    lmn__personQfDate: TcxGridDBColumn;
    lmn__personrecordStatusName: TcxGridDBColumn;
    lmn__personEduDegreeName: TcxGridDBColumn;
    lmn__personBloodTypeName: TcxGridDBColumn;
    lmn__personNationlityName: TcxGridDBColumn;
    lmn__personHealthName: TcxGridDBColumn;
    lmn__personReligionName: TcxGridDBColumn;
    lmn__personEscuageName: TcxGridDBColumn;
    lmn__personPolityName: TcxGridDBColumn;
    lmn__personregType: TcxGridDBColumn;
    lmn__personrelation: TcxGridDBColumn;
    lmn__personOrgan: TcxGridDBColumn;
    lmn__personRecordStatus: TcxGridDBColumn;
    lmn__personRecordDate: TcxGridDBColumn;
    lmn__personEduDegree: TcxGridDBColumn;
    lmn__personBirthAddress: TcxGridDBColumn;
    lmn__personSex: TcxGridDBColumn;
    lmn__personStature: TcxGridDBColumn;
    lmn__personBloodType: TcxGridDBColumn;
    lmn__personNationlity: TcxGridDBColumn;
    lmn__personHealth: TcxGridDBColumn;
    lmn__personDwellingPlace: TcxGridDBColumn;
    lmn__personTelephone: TcxGridDBColumn;
    lmn__personOtherDwellingPlace: TcxGridDBColumn;
    lmn__personReligion: TcxGridDBColumn;
    lmn__personMarriage: TcxGridDBColumn;
    lmn__personEscuage: TcxGridDBColumn;
    lmn__personWork: TcxGridDBColumn;
    lmn__personService: TcxGridDBColumn;
    lmn__personPolity: TcxGridDBColumn;
    lmn__personRemark: TcxGridDBColumn;
    lmn__personLownessDefend: TcxGridDBColumn;
    lmn__personArmyCorps: TcxGridDBColumn;
    lmn__personPic: TcxGridDBColumn;
    lmn__personDoorRecordLocus: TcxGridDBColumn;
    lmn__personNativePlace: TcxGridDBColumn;
    lmn__personIngoingDate: TcxGridDBColumn;
    lmn__personOriginalDwellingPlace: TcxGridDBColumn;
    lmn__personIngoingType: TcxGridDBColumn;
    lmn__personIngoingTypeName: TcxGridDBColumn;
    lmn__personIngoingCause: TcxGridDBColumn;
    lmn__personExceedDate: TcxGridDBColumn;
    lmn__personExceedAddress: TcxGridDBColumn;
    lmn__personExceedType: TcxGridDBColumn;
    lmn__personExceedTypeName: TcxGridDBColumn;
    lmn__personExceedCause: TcxGridDBColumn;
    lmn__personDeath: TcxGridDBColumn;
    lmn__personLogout: TcxGridDBColumn;
    lmn__personDeathDate: TcxGridDBColumn;
    lmn__personDeathCause: TcxGridDBColumn;
    lmn__personLogoutDate: TcxGridDBColumn;
    lmn__personLogoutCause: TcxGridDBColumn;
    lmn__personID: TcxGridDBColumn;
    lmn__personisbmp: TcxGridDBColumn;
    act_OK: TAction;
    cbb_condition: TRzComboBox;
    edt_condition: TRzEdit;
    btn_find: TRzBitBtn;
    btn_search: TRzBitBtn;
    btn_showall: TRzBitBtn;
    btn_OK: TRzBitBtn;
    btn_exit: TRzBitBtn;
    procedure act_findExecute(Sender: TObject);
    procedure act_searchExecute(Sender: TObject);
    procedure act_showallExecute(Sender: TObject);
    procedure act_exitExecute(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure act_OKExecute(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    function isAttribute(TypeName: string): Boolean;
  end;

var
  fm_sel_person: Tfm_sel_person;

implementation

uses F_RDB;
{$R *.dfm}

function Tfm_sel_person.isAttribute(TypeName: string): Boolean;
begin
  Result := True;
  if RDB.dst_tmp.Active then
    RDB.dst_tmp.Active := False;
  RDB.dst_tmp.CommandText := 'select id from  Sys_attribute where type=''' +
    TypeName + '''';
  RDB.dst_tmp.Open;
  if RDB.dst_tmp.RecordCount <= 0 then
    Result := False;
end;

procedure Tfm_sel_person.act_findExecute(Sender: TObject);
var
  tab, ID: string;
begin
  tab := ds_FieldShow.DataSet.FieldByName('field').AsString;
  if not isAttribute(tab) then
  begin
    dst_person.Locate(tab, Trim(edt_condition.Text), [loCaseInsensitive,
      loPartialKey]);
    Exit;
  end;
  if RDB.dst_tmp.Active then
    RDB.dst_tmp.Active := False;
  RDB.dst_tmp.CommandText := 'select id from  Sys_attribute where type=''' +
    tab + ''' and Name=''' + Trim(edt_condition.Text) + '''';
  RDB.dst_tmp.Open;
  if RDB.dst_tmp.RecordCount <= 0 then
    Exit;
  RDB.dst_tmp.First;
  ID := RDB.dst_tmp.FieldByName('ID').AsString;
  dst_person.Locate(tab, id, [loCaseInsensitive, loPartialKey]);
end;

procedure Tfm_sel_person.act_searchExecute(Sender: TObject);
var
  Sql, tab, ID, condition, Text: string;
begin
  Text := edt_condition.Text;
  case cbb_condition.ItemIndex of
    0:
      begin
        condition := ' like ';
        Text := ' %' + text + '% ';
      end;
    1:
      begin
        condition := ' not like ';
        Text := ' %' + text + '% ';
      end;
    2: condition := ' = ';
    3: condition := ' > ';
    4: condition := ' < ';
    5: condition := ' <> ';
    6: condition := ' <= ';
    7: condition := ' >= ';
  end;
  tab := ds_FieldShow.DataSet.FieldByName('field').AsString;
  if not isAttribute(tab) then
  begin
    Sql := 'select * from info_people where ' + tab + condition + '''' +
      Trim(Text) + '''';
    dst_person.Active := False;
    dst_person.CommandText := Sql;
    dst_person.Open;
    Exit;
  end;
  if RDB.dst_tmp.Active then
    RDB.dst_tmp.Active := False;
  sql := 'select id from  Sys_attribute where type=''' +
    tab + ''' and Name= ' + condition + '''' + Trim(Text) + '''';
  RDB.dst_tmp.CommandText := Sql;
  RDB.dst_tmp.Open;
  if RDB.dst_tmp.RecordCount <= 0 then
    exit;
  RDB.dst_tmp.First;
  ID := RDB.dst_tmp.FieldByName('ID').AsString;
  Sql := 'select * from info_people where ' + tab + ' = ' + ID + '';
  dst_person.Active := False;
  dst_person.CommandText := Sql;
  dst_person.Open;
end;

procedure Tfm_sel_person.act_showallExecute(Sender: TObject);
var
  tab: string;
begin
  tab := 'select * from info_people';
  dst_person.Active := False;
  dst_person.CommandText := tab;
  dst_person.Active := true;
end;

procedure Tfm_sel_person.act_exitExecute(Sender: TObject);
begin
  ModalResult := mrCancel;
end;

procedure Tfm_sel_person.FormDestroy(Sender: TObject);
begin
  ModalResult := mrCancel;
  dst_person.Active := False;
end;

procedure Tfm_sel_person.act_OKExecute(Sender: TObject);
begin
  dst_person.Post;
  ModalResult := mrOk;
end;

procedure Tfm_sel_person.FormShow(Sender: TObject);
begin
  RDB.sql.SQL.Clear;
  RDB.sql.SQL.Add('Update info_people set isbmp=false');
  RDB.sql.ExecSQL;
  act_showall.Execute;
end;

end.

⌨️ 快捷键说明

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