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

📄 joinsoci.~pas

📁 企业端数据申报系统:单位管理模块 单位查询. 业务申报模块 在线数据下载 在线数据上传 在线业务申核 申报业务查询 磁盘数据导出 磁盘数据导入 在线业务模块 在线业务
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
//
//模块名称:参保管理
//编写:陈剑
//日期:2001年11月29日
//参数说明:
//
unit JoinSoci;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, basetreewin, DB, DBTables, ComCtrls, Grids, DBGrids, StdCtrls,
  TFlatComboBoxUnit, Menus, ActnList, ImgList, ExtCtrls, ToolWin,
  TreeViewCP, TFlatButtonUnit, DBCtrls, Mask, ToolEdit, RxLookup,
  TFlatMemoUnit, TFlatMaskEditUnit, Buttons, XPMenu,StrUtils;

type
  TJoinSoci_form = class(Tbasetreewin_form)
    Panel4: TPanel;
    DBGrid2: TDBGrid;
    DBGrid3: TDBGrid;
    DataSource1: TDataSource;
    Query1: TQuery;
    DataSource2: TDataSource;
    Query2: TQuery;
    Exit_but: TAction;
    Singchange: TAction;
    Ret_but: TAction;
    Yes_but: TAction;
    Multchange: TAction;
    ImageList3: TImageList;
    Query1ISCODE: TStringField;
    Query1PSNAME: TStringField;
    Query1CHANTIME: TDateField;
    Query1CHANINFO: TStringField;
    Query3: TQuery;
    Query4: TQuery;
    DataSource3: TDataSource;
    DataSource4: TDataSource;
    Query1STATUS: TStringField;
    Splitter2: TSplitter;
    Panel5: TPanel;
    TB_save: TToolButton;
    TB_cancel: TToolButton;
    TB_exit: TToolButton;
    cancel_but: TAction;
    save_but: TAction;
    Query1chgreason: TStringField;
    Query1statusname: TStringField;
    Query1chgreasonname: TStringField;
    Query1MANID: TFloatField;
    TB_bgcancel: TToolButton;
    Query2iscode: TStringField;
    Query2psname: TStringField;
    Query2agcardno: TStringField;
    Query2upreasonname: TStringField;
    Query2cgdate: TDateField;
    Query2opdate: TDateField;
    Query2notes: TStringField;
    Query2procflg: TStringField;
    ToolBar3: TToolBar;
    ToolButton2: TToolButton;
    FlatComboBox1: TComboBox;
    N1: TMenuItem;
    N2: TMenuItem;
    ToolButton3: TToolButton;
    TB_help: TToolButton;
    Menu_Yewu: TMenuItem;
    Menu_Edit: TMenuItem;
    Menu_System: TMenuItem;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    M_yw: TMenuItem;
    M_search: TMenuItem;
    XPMenu1: TXPMenu;
    M_save: TMenuItem;
    M_cancel: TMenuItem;
    M_bgcancel: TMenuItem;
    bgcancel_but: TAction;
    M_exit: TMenuItem;
    M_help: TMenuItem;
    Panel6: TPanel;
    GroupBox1: TGroupBox;
    Label2: TLabel;
    Label1: TLabel;
    Label3: TLabel;
    E_opcode: TEdit;
    E_opdate: TEdit;
    DBRE_chaninfo: TDBRichEdit;
    Panel7: TPanel;
    Panel8: TPanel;
    GroupBox3: TGroupBox;
    E_totrewage: TEdit;
    Label9: TLabel;
    E_totemployee: TEdit;
    Label8: TLabel;
    GroupBox4: TGroupBox;
    Label10: TLabel;
    E_origin: TEdit;
    Label11: TLabel;
    E_new: TEdit;
    GroupBox2: TGroupBox;
    Query5: TQuery;
    TB_itcode: TToolButton;
    Query2opcode: TStringField;
    Query3code: TStringField;
    Query3name: TStringField;
    help_but: TAction;
    ToolBar5: TToolBar;
    Label12: TLabel;
    E_cond: TEdit;
    Label13: TLabel;
    BB_find: TBitBtn;
    Query1PSSENO: TFloatField;
    Query1CPSENO: TFloatField;
    Query1AGCARDNO: TStringField;
    Query1ORGANID: TIntegerField;
    Query1IFDEL: TStringField;
    Query1REWAGE: TFloatField;
    Query1itcode: TFloatField;
    Query1itcodename: TStringField;
    Table1: TTable;
    Table1ISCODE: TStringField;
    Table1PSNAME: TStringField;
    Table1STATUS: TStringField;
    Table1statusname: TStringField;
    Table1chgreasonname: TStringField;
    Table1CHANTIME: TDateField;
    Table1CHANINFO: TStringField;
    Table1IFDEL: TStringField;
    Table1ORGANID: TIntegerField;
    Table1chgreason: TStringField;
    Table1MANID: TFloatField;
    Table1AGCARDNO: TStringField;
    Table1PSSENO: TFloatField;
    Table1CPSENO: TFloatField;
    Table1REWAGE: TFloatField;
    Table1itcode: TFloatField;
    Table1itcodename: TStringField;
    TB_curcancel: TToolButton;
    curcancel_but: TAction;
    M_curcancel: TMenuItem;
    ToolBar4: TToolBar;
    ToolBar6: TToolBar;
    Label4: TLabel;
    Label5: TLabel;
    BB_search: TBitBtn;
    Label6: TLabel;
    DE_sdate: TDateEdit;
    DE_edate: TDateEdit;
    Query1JOINDATE: TDateField;
    N3: TMenuItem;
    ywwizard_but: TAction;
    TB_ywwizard: TToolButton;
    N4: TMenuItem;
    procedure Exit_butExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure cancel_butExecute(Sender: TObject);
    procedure save_butExecute(Sender: TObject);
    procedure Query1AfterEdit(DataSet: TDataSet);
    procedure N1Click(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure FlatComboBox1Change(Sender: TObject);
    procedure TreeViewCP1Changing(Sender: TObject; Node: TTreeNode;
      var AllowChange: Boolean);
    procedure TreeViewCP1Change(Sender: TObject; Node: TTreeNode);
    procedure bgcancel_butExecute(Sender: TObject);
    procedure Query1chgreasonnameChange(Sender: TField);
    procedure DataSource1DataChange(Sender: TObject; Field: TField);
    procedure Query1REWAGEChange(Sender: TField);
    procedure DBGrid2ColEnter(Sender: TObject);
    procedure DBGrid2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DBGrid2Enter(Sender: TObject);
    procedure Query1chgreasonChange(Sender: TField);
    procedure TB_itcodeClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Query1CHANTIMEChange(Sender: TField);
    procedure Query1itcodeChange(Sender: TField);
    procedure Query1CHANINFOChange(Sender: TField);
    procedure Query1CHANTIMESetText(Sender: TField; const Text: String);
    procedure DBGrid2KeyUp(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure help_butExecute(Sender: TObject);
    procedure BB_findClick(Sender: TObject);
    procedure E_condKeyPress(Sender: TObject; var Key: Char);
    procedure DBGrid3TitleClick(Column: TColumn);
    procedure DBGrid2TitleClick(Column: TColumn);
    procedure curcancel_butExecute(Sender: TObject);
    procedure BB_searchClick(Sender: TObject);
    procedure DE_sdateKeyPress(Sender: TObject; var Key: Char);
    procedure DE_edateKeyPress(Sender: TObject; var Key: Char);
    procedure Query1REWAGESetText(Sender: TField; const Text: String);
    procedure ywwizard_butExecute(Sender: TObject);

  private
    statuslist:TStringList;//保存FlatComboBox中文值对应的代码值
    PriorItemIndex:integer;//保存FlatComboBox改变前的项的对应的代码值
    PriorColumn_search,PriorColumn_yw:TColumn;
    IsAsc_search,IsAsc_yw:boolean;
    procedure Sort(column:TColumn;dbgrid:TDBGrid;var PriorColumn:TColumn;var IsAsc:boolean);
    function save():boolean;//变动保存函数
    procedure SetFilter();  //人员过滤过程
    procedure InfoUpdate();
    //function UptypeCando(status,uptype:string):boolean;
    procedure UpreasonFilter(status:string);
  public
    Joindate:String;
    procedure ReOpen(query:TQuery);
    { Public declarations }
  end;

type
  TOrganization=record
  parentid:integer;   //父节点编码
  id:integer;         //机构编码
  name:string;        //机构名称
  disptype:integer;   //显示类型:1-单位  2-部门
  describe:string;    //机构描述
  cpseno:integer;     //单位内码,如是部门则位-1;
  canaccess:boolean;  //当前操作员能否操作该节点,true-能  false-不能
end;

var
  JoinSoci_form: TJoinSoci_form;
  bookmark:TBookmarkStr;
  IsModified,check:boolean;  //修改标志
  MaxRewage,MinRewage:double;

implementation

uses datashare, basedialog,main, basepop,pyitcode, hh, inputjoindate,
  ywwizard,commlist;

{$R *.dfm}

procedure TJoinSoci_form.UpreasonFilter(status:string);
var
  ls_sql:string;
begin
  if (status=null) or (status='') then
    exit;
    
  if status='all' then
  begin
    ls_sql:='select upcode,upname from upreason order by upcode';
  end else
  begin
    ls_sql:='select upcode,upname from upreason ';
    case strtoint(status) of
      0:ls_sql:=ls_sql+' where uptype in ('+chr(39)+'01'+chr(39)+','+chr(39)+'03'+chr(39)+') ';
      1:ls_sql:=ls_sql+' where uptype in ('+chr(39)+'05'+chr(39)+','+chr(39)+'06'+chr(39)+','+chr(39)+'07'+chr(39)+') ';
      2:ls_sql:=ls_sql+' where uptype in ('+chr(39)+'02'+chr(39)+','+chr(39)+'06'+chr(39)+','+chr(39)+'07'+chr(39)+') ';
    else
      ls_sql:='select upcode,upname from upreason ';
    end;
    ls_sql:=ls_sql+' order by upcode';
  end ;

  try
    with query4 do
    begin
      close;
      sql.Clear;
      sql.Add(ls_sql);
      prepare;
      open;
    end;
  except
    on e:exception do
    begin
      application.MessageBox(pchar(e.Message),'恩普软件',MB_OK+MB_IconStop+MB_SystemModal);
      exit;
    end;
  end;
end;

{function TJoinSoci_form.UptypeCando(status,uptype:string):boolean;
begin
  if uptype='' then
  begin
    result:=true;
    exit;
  end;

  if (status='0') and ((uptype='01') or (uptype='03')) then
  begin
    result:=true;
    exit;
  end;

  if (status='1') and ((uptype='05') or (uptype='06') or (uptype='07')) then
  begin
    result:=true;
    exit;
  end;

  if (status='2') and ((uptype='02') or (uptype='06') or (uptype='07')) then
  begin
    result:=true;
    exit;
  end;

  result:=false;
end; }

procedure TJoinSoci_form.ReOpen(query:TQuery);
var
  li_manid:integer;
begin
  if treeviewcp1.Selected=nil then
    exit;
    
  li_manid:=query.fieldbyname('manid').AsInteger;
  query.DisableControls;
  query.Close;
  query.Open;
  query.Locate('manid',li_manid,[loCaseInsensitive]);
  query.EnableControls;
end;

procedure TJoinSoci_form.Sort(column:TColumn;dbgrid:TDBGrid;var PriorColumn:TColumn;var IsAsc:boolean);
var
  ls_sql,ls_oldsql:string;
  li_findindex:integer;
begin
  try
    if (dbgrid.DataSource.DataSet as TQuery).RecordCount=0 then
      exit;

    //ls_oldsql:=query1.SQL.Text;
    ls_oldsql:=(dbgrid.DataSource.DataSet as TQuery).SQL.Text;
    if ls_oldsql='' then
      exit;
    ls_sql:=ls_oldsql;
    li_findindex:=pos('order by',lowercase(ls_sql));
    if li_findindex>0 then
    begin
      ls_sql:=copy(ls_sql,1,li_findindex-1);
    end;

    if PriorColumn=nil then
    begin
      with dbgrid.DataSource.DataSet as TQuery do
      begin
        close;
        sql.Clear;
        //ls_sql:='select a.manid manid,a.iscode,a.psname,a.agcardno,a.psseno psseno,b.totfd,c.name sex,dateformat(a.bdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') bdate,dateformat(a.wkdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') wkdate,dateformat(a.joindate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') joindate,d.name status from {oj psarch a left outer join psacct b on (a.psseno=b.psseno and b.yearno='+ME_yearno.Text+' and b.totfd>0)},sbcode c,sbcode d where a.sex=c.code and c.type='+chr(39)+'sex'+chr(39)+' and a.status=d.code and d.type='+chr(39)+'status'+chr(39)+' and a.psseno>0 and a.organid in ('+treeviewcp1.GenerateOrganIds(treeviewcp1.Selected,main_form.user.operid)+') order by a.'+column.FieldName+' asc';
        ls_sql:=ls_sql+' order by '+column.FieldName+' asc';
        sql.Add(ls_sql);
        prepare;
        open;
      end;
      column.Title.Caption:=column.Title.Caption+' △';
      priorColumn:=column;
      IsAsc:=true;
      exit;
    end;

    if PriorColumn.FieldName=column.FieldName then
    begin
      with dbgrid.DataSource.DataSet as TQuery do
      begin
        close;
        sql.Clear;
        if IsAsc then
        begin
          //ls_sql:='select a.manid manid,a.iscode,a.psname,a.agcardno,a.psseno psseno,b.totfd,c.name sex,dateformat(a.bdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') bdate,dateformat(a.wkdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') wkdate,dateformat(a.joindate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') joindate,d.name status from {oj psarch a left outer join psacct b on (a.psseno=b.psseno and b.yearno='+ME_yearno.Text+' and b.totfd>0)},sbcode c,sbcode d where a.sex=c.code and c.type='+chr(39)+'sex'+chr(39)+' and a.status=d.code and d.type='+chr(39)+'status'+chr(39)+' and a.psseno>0 and a.organid in ('+treeviewcp1.GenerateOrganIds(treeviewcp1.Selected,main_form.user.operid)+') order by a.'+column.FieldName+' desc';
          ls_sql:=ls_sql+' order by '+column.FieldName+' desc';
        end else
          ls_sql:=ls_sql+' order by '+column.FieldName+' asc';
          //ls_sql:='select a.manid manid,a.iscode,a.psname,a.agcardno,a.psseno psseno,b.totfd,c.name sex,dateformat(a.bdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') bdate,dateformat(a.wkdate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') wkdate,dateformat(a.joindate,'+chr(39)+'yyyy-mm-dd'+chr(39)+') joindate,d.name status from {oj psarch a left outer join psacct b on (a.psseno=b.psseno and b.yearno='+ME_yearno.Text+' and b.totfd>0)},sbcode c,sbcode d where a.sex=c.code and c.type='+chr(39)+'sex'+chr(39)+' and a.status=d.code and d.type='+chr(39)+'status'+chr(39)+' and a.psseno>0 and a.organid in ('+treeviewcp1.GenerateOrganIds(treeviewcp1.Selected,main_form.user.operid)+') order by a.'+column.FieldName+' asc';
        sql.Add(ls_sql);
        prepare;
        open;
      end;
      column.Title.Caption:=copy(column.Title.Caption,1,length(column.Title.Caption)-3);
      if IsAsc then
      begin
        column.Title.Caption:=column.Title.Caption+' ▽';
      end else
        column.Title.Caption:=column.Title.Caption+' △';
      priorColumn:=column;
      IsAsc:=not IsAsc;
      exit;
    end else
    begin
      with dbgrid.DataSource.DataSet as TQuery do
      begin
        close;
        sql.Clear;
        ls_sql:=ls_sql+' order by '+column.FieldName+' asc';
        sql.Add(ls_sql);
        prepare;
        open;

⌨️ 快捷键说明

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