unit txset;

interface

uses Sysutils, DB, DBTables, uss, auxiapi, txsetsub;

procedure TRANPROC_T1100(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T1101(inComm: TTinComm;var outComm: TToutComm);

procedure TRANPROC_T0901(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0902(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0903(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0904(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0905(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0801(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0802(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0803(inComm: TTinComm;var outComm: TToutComm);
procedure TRANPROC_T0804(inComm: TTinComm;var outComm: TToutComm);

implementation

uses
   i_SYSCJNL1,
   i_SYSCJNL2,
   i_SYSPABCP,
   i_SYSPALVL,
   i_SYSPASCT,
   i_SYSPASCV,
   i_SYSPATEL,
   i_SYSPATRX,
   i_SYSPAZON,
   i_SYSSJNL1,
   i_SYSSJNL2,
   i_ebss;

procedure TRANPROC_T1100(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   nthpasct: _SYSPASCT;
   DataSet: TDataSet;
   tin: record
          TZONE, TBRNO, TTELLER, TPASSWORD: Int64;
        end;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号# 柜员号# 密码  }
      nthpatel := _SYSPATEL.Create;
      nthpasct := _SYSPASCT.Create;

      tin.TZONE     := StrToInt(inComm.TIFIELD00);
      tin.TBRNO     := StrToInt(inComm.TIFIELD01);
      tin.TTELLER   := StrToInt(inComm.TIFIELD02);
      tin.TPASSWORD := StrToInt(inComm.TIFIELD03);

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName,
                       'ZONENO = ' + IntToStr(tin.TZONE) + ' and ' +
                       'BRCHNO = ' + IntToStr(tin.TBRNO) + ' and ' +
                       'TELLNO = ' + IntToStr(tin.TTELLER));
      If Not DataSet.IsEmpty then
      begin
         If (tin.TZONE = 0)and(tin.TBrno = 0)and(tin.TTELLER = 0) then
         begin
            outComm.TOOVERID  := SOSYSTEMTELLER;
            outComm.TOSTATEMENT := SOSTATSYSTEMTELLER;
//         end else If tin.TBRNO <> DataSet.FieldByName('BRNO').AsString then
//         begin
//            outComm.TOOVERID  := ROWRONGTELLER;
//            outComm.TOSTATEMENT := ROSTATWRONGTELLER;
         end else If DataSet.FieldByName('STATUS').AsInteger = DBSYS_TELLER_DELETE then
         begin
            outComm.TOOVERID  := RONOTFOUNDBRNO;
            outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
         end else if tin.TPASSWORD <> DataSet.FieldByName('PSW').AsInteger then
         begin
            outComm.TOOVERID  := ROWRONGPASSWD;
            outComm.TOSTATEMENT := ROSTATWRONGPASSWD;
         end else if DataSet.FieldByName('STATUS').AsInteger <> DBSYS_TELLER_LOGOUT then
         begin
            outComm.TOOVERID  := ROALEADYLOGON;
            outComm.TOSTATEMENT := ROSTATALEADYLOGON;
         end else begin
            nthpatel.setSTATUSvalue(txSessionName, txDatabaseName, IntToStr(DBSYS_TELLER_LOGON),
                       'ZONENO = ' + IntToStr(tin.TZONE) + ' and ' +
                       'BRCHNO = ' + IntToStr(tin.TBRNO) + ' and ' +
                       'TELLNO = ' + IntToStr(tin.TTELLER));

            outComm.TOFIELD00 := DataSet.FieldByName('TELLNO').AsString;
            outComm.TOFIELD01 := DataSet.FieldByName('BRCHNO').AsString;
            outComm.TOFIELD02 := IntToStr(DBSYS_TELLER_LOGON);
            outComm.TOFIELD03 := DataSet.FieldByName('SLEVEL').AsString;
            outComm.TOFIELD04 := 'ONLINE';
            outComm.TOFIELD05 := DataSet.FieldByName('ZONENO').AsString;
         end;
      end else begin
         outComm.TOOVERID  := RONOTFOUNDTEL;
         outComm.TOSTATEMENT := ROSTATNOTFOUNDTEL;
      end;
      DataSet.Close;

      DataSet := nthpasct.getAllRows(txSessionName, txDatabaseName);;
      If Not DataSet.IsEmpty then
      begin
         outComm.TOFIELD06 := DataSet.FieldByName('WORKDATE').AsString;
      end else begin
         outComm.TOFIELD06 := '1795-10-21';
      end;
      DataSet.Close;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
      nthpasct.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T1101(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   nthpasct: _SYSPASCT;
   DataSet: TDataSet;
   tin: record
          TZONE, TBRNO, TTELLER: Int64;
        end;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号# 柜员号  }
      nthpatel := _SYSPATEL.Create;
      nthpasct := _SYSPASCT.Create;

      tin.TZONE     := StrToInt(inComm.TIFIELD00);
      tin.TBRNO     := StrToInt(inComm.TIFIELD01);
      tin.TTELLER   := StrToInt(inComm.TIFIELD02);

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      If (tin.TZONE = StrToInt(inComm.TIZONENO))and(tin.TBRNO = StrToInt(inComm.TIBRANCH))and(tin.TTELLER = StrToInt(inComm.TITELLER))and
         (Not((tin.TZONE = 0)and(tin.TBRNO = 0)and(tin.TTELLER = 0))) // 非系统用户
      then
      begin
         DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName,
                            'ZONENO = ' + IntToStr(tin.TZONE) + ' and ' +
                            'BRCHNO = ' + IntToStr(tin.TBRNO) + ' and ' +
                            'TELLNO = ' + IntToStr(tin.TTELLER));
         If Not DataSet.IsEmpty then
         begin
//            If tin.TBRNO <> DataSet.FieldByName('BRCHNO').AsString then
//            begin
//               outComm.TOOVERID  := ROWRONGTELLER;
//               outComm.TOSTATEMENT := ROSTATWRONGTELLER;
{            end else }
            If DataSet.FieldByName('STATUS').AsInteger <> DBSYS_TELLER_LOGON then
            begin
               outComm.TOOVERID  := ROALEADYLOGOUT;
               outComm.TOSTATEMENT := ROSTATALEADYLOGOUT;
            end else begin
               nthpatel.setSTATUSvalue(txSessionName, txDatabaseName, IntToStr(DBSYS_TELLER_LOGOUT),
                            'ZONENO = ' + IntToStr(tin.TZONE) + ' and ' +
                            'BRCHNO = ' + IntToStr(tin.TBRNO) + ' and ' +
                            'TELLNO = ' + IntToStr(tin.TTELLER));
               outComm.TOFIELD00 := DataSet.FieldByName('TELLNO').AsString;
               outComm.TOFIELD01 := DataSet.FieldByName('BRCHNO').AsString;
               outComm.TOFIELD02 := IntToStr(DBSYS_TELLER_LOGOUT);
               outComm.TOFIELD03 := DataSet.FieldByName('SLEVEL').AsString;
               outComm.TOFIELD04 := 'OFFLINE';
               outComm.TOFIELD05 := DataSet.FieldByName('ZONENO').AsString;
            end;
         end else begin
            outComm.TOOVERID  := RONOTFOUNDTEL;
            outComm.TOSTATEMENT := ROSTATNOTFOUNDTEL;
         end;
         DataSet.Close;

         DataSet := nthpasct.getAllRows(txSessionName, txDatabaseName);;
         If Not DataSet.IsEmpty then
         begin
            outComm.TOFIELD05 := DataSet.FieldByName('WORKDATE').AsString;
         end else begin
            outComm.TOFIELD05 := '1795-10-21';
         end;
         DataSet.Close;
      end else begin
         outComm.TOOVERID  := SONOTCURTEL;
         outComm.TOSTATEMENT := SOSTATNOTCURTEL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
      nthpasct.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0904(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   DataSet: TDataSet;
   tin: record
           TBRNO: String
        end;
   ROW_COUNT, COL_COUNT: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpatel := _SYSPATEL.Create;

      tin.TBRNO     := inComm.TIFIELD00;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

// //   DataSet := nthpatel.getAllRows('BRNO = '''+tin.TBRNO+'''');
      DataSet := nthpatel.openSQL(txSessionName, txDatabaseName,
                                  Format('Select ZONENO, TELLNO, BRCHNO, NAME, IDCODE, STATUS, SLEVEL, SIGNDATE, EXPIREDATE, NOTE '+
                                         'From syspatel Where ZONENO = %s and BRCHNO = %s ', [inComm.TIZONENO, inComm.TIBRANCH])
                                  );
      If Not DataSet.IsEmpty then
      begin
// //      outComm.TOFIELD00 := PackTable(DataSet);
         outComm.TOFIELD00 := PackTable(DataSet,
                                        VarArrayOf(['地区号','柜员号','所属网点','姓名','身份证号','状态','级别','启用日期','停用日期','备注']),
                                        VarArrayOf(['48','48','80','64','160','48','32','80','80','180'])
                                        );
      end else begin
         outComm.TOOVERID  := RONOTFOUNDBRNO;
         outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
      end;
      DataSet.Close;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0905(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   DataSet: TDataSet;
   tin: record
          TZONENO, TBRNO: String
        end;
   ROW_COUNT, COL_COUNT: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpatel := _SYSPATEL.Create;

      tin.TZONENO   := inComm.TIFIELD00;
      tin.TBRNO     := inComm.TIFIELD01;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      If (tin.TZONENO = '全部')and(tin.TBRNO = '全部') then
      begin
        DataSet := nthpatel.openSQL(txSessionName, txDatabaseName,
                      'Select ZONENO, TELLNO, BRCHNO, NAME, IDCODE, STATUS, SLEVEL, SIGNDATE, EXPIREDATE, NOTE '+
                      'From syspatel'
                                  );
      end else If (tin.TZONENO = '全部')and(tin.TBRNO <> '全部') then
      begin
        DataSet := nthpatel.openSQL(txSessionName, txDatabaseName,
                      Format('Select ZONENO, TELLNO, BRCHNO, NAME, IDCODE, STATUS, SLEVEL, SIGNDATE, EXPIREDATE, NOTE '+
                             'From syspatel Where BRCHNO = %s ', [inComm.TIBRANCH])
                                  );
      end else If (tin.TZONENO <> '全部')and(tin.TBRNO = '全部') then
      begin
        DataSet := nthpatel.openSQL(txSessionName, txDatabaseName,
                      Format('Select ZONENO, TELLNO, BRCHNO, NAME, IDCODE, STATUS, SLEVEL, SIGNDATE, EXPIREDATE, NOTE '+
                             'From syspatel Where ZONENO = %s ', [inComm.TIZONENO])
                                  );
      end else begin
        DataSet := nthpatel.openSQL(txSessionName, txDatabaseName,
                                  Format('Select ZONENO, TELLNO, BRCHNO, NAME, IDCODE, STATUS, SLEVEL, SIGNDATE, EXPIREDATE, NOTE '+
                                         'From syspatel Where ZONENO = %s and BRCHNO = %s ', [inComm.TIZONENO, inComm.TIBRANCH])
                                  );
      end;

      If Not DataSet.IsEmpty then
      begin
         outComm.TOFIELD00 := PackTable(DataSet,
                                        VarArrayOf(['地区号','柜员号','所属网点','姓名','身份证号','状态','级别','启用日期','停用日期','备注']),
                                        VarArrayOf(['48','48','80','64','160','48','32','80','80','180'])
                                        );
      end else begin
         outComm.TOOVERID  := RONOTFOUNDBRNO;
         outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
      end;
      DataSet.Close;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0803(inComm: TTinComm;var outComm: TToutComm);
var
   nthpabcp: _SYSPABCP;
   DataSet: TDataSet;
   tin: record
           TZONENO, TBRNO: String
        end;
   ROW_COUNT, COL_COUNT: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpabcp := _SYSPABCP.Create;

      tin.TZONENO   := inComm.TIFIELD00;
//      tin.TBRNO     := inComm.TIFIELD01;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      DataSet := nthpabcp.openSQL(txSessionName, txDatabaseName,
                   Format('Select ZONENO, BRCHNO, BNAME, SNAME, KINK, STATUS, ADDR, TELE, FAX, CEO, IDCODE, MTELE, NOTE '+
                          'From syspabcp Where ZONENO = %s', [tin.TZONENO])
                          );

      If Not DataSet.IsEmpty then
      begin
// //      outComm.TOFIELD00 := PackTable(DataSet);
         outComm.TOFIELD00 := PackTable(DataSet,
                                        VarArrayOf(['地区号','网点号','网点名称','网点简称','种类','状态','地址','电话','传真','负责人','身份证号','手机/电话','备注']),
                                        VarArrayOf(['48','48','120','80','32','32','180','120','120','64','160','120','180'])
                                        );
      end else begin
         outComm.TOOVERID  := RONOTFOUNDBRNO;
         outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
      end;
      DataSet.Close;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpabcp.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0801(inComm: TTinComm;var outComm: TToutComm);
var
   nthpabcp: _SYSPABCP;
   nthpasnc: _SYSPASCV;
   nthpatrx: _SYSPATRX;
   nthpatel: _SYSPATEL;
   nthpazon: _SYSPAZON;
   DataSet: TDataSet;
   tin: record
           TBRNO: String
        end;
   ROW_COUNT, COL_COUNT: Integer;
   newBrno: String;
   x: Integer;
   txDataSet: TDataSet;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpabcp := _SYSPABCP.Create;
      nthpasnc := _SYSPASCV.Create;
      nthpatrx := _SYSPATRX.Create;
      nthpatel := _SYSPATEL.Create;
      nthpazon := _SYSPAZON.Create;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      try
         x := Trunc(nthpasnc.getAPPSQNOvalue(txSessionName, txDatabaseName, 'APPCODE = ''00''') + 1);
         newBrno := FormatInt(x, 4);
         nthpasnc.setAPPSQNOvalue(txSessionName, txDatabaseName, newBrno, 'APPCODE = ''00''');

         nthpazon.Insert(txSessionName, txDatabaseName,
                         VarArrayOf([0, newBrno, 0, 0, '''自动地区''']));


         nthpabcp.Insert(txSessionName, txDatabaseName,
                         VarArrayOf([0,
                                     newBrno,
                                ''''+inComm.TIFIELD00+'''',
                                ''''+inComm.TIFIELD01+'''',
                                     0,
                                     0,
                                ''''+inComm.TIFIELD02+'''',
                                ''''+inComm.TIFIELD03+'''',
                                ''''+inComm.TIFIELD04+'''',
                                     ''''+inComm.TIFIELD05+'''',
                                     ''''+inComm.TIFIELD07+'''',
                                     ''''+inComm.TIFIELD06+'''',
                                     ''''+inComm.TIFIELD08+''''
                                    ])
                         );

         outComm.TOFIELD00 := newBrno;
         outComm.TOFIELD01 := inComm.TITRXD;
         outComm.TOFIELD02 := nthpatrx.getSCRIPTvalue(txSessionName, txDatabaseName, 'CODE='''+inComm.TITRXD+'''');
         outComm.TOFIELD03 := inComm.TITRXSQNO;
         outComm.TOFIELD04 := inComm.TISYSDATE;

         outComm.TOFIELD05 := nthpatel.getNAMEvalue(txSessionName, txDatabaseName, 'TELLNO='''+inComm.TITELLER+'''');
         outComm.TOFIELD06 := nthpabcp.getBNAMEvalue(txSessionName, txDatabaseName, 'BRCHNO='''+inComm.TIBRANCH+'''');
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpazon.Free;
      nthpatrx.Free;
      nthpatel.Free;
      nthpasnc.Free;
      nthpabcp.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0802(inComm: TTinComm;var outComm: TToutComm);
var
   nthpabcp: _SYSPABCP;
   nthpatel: _SYSPATEL;
   nthpazon: _SYSPAZON;
   DataSet: TDataSet;
   newBrno: String;
   x: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpabcp := _SYSPABCP.Create;
      nthpatel := _SYSPATEL.Create;
      nthpazon := _SYSPAZON.Create;

      outComm.TOOVERID    := SONORMAL;
      outComm.TOSTATEMENT   := SOSTATNORMAL;

      try
        If inComm.TIRANK = '4' then
        begin
          nthpazon.setSTATUSvalue(txSessionName, txDatabaseName,
                      '2', 'ZONENO='''+inComm.TIFIELD00+''' and BRCHNO='''+inComm.TIFIELD01+'''');
          nthpabcp.setSTATUSvalue(txSessionName, txDatabaseName,
                      '2', 'ZONENO='''+inComm.TIFIELD00+''' and BRCHNO='''+inComm.TIFIELD01+'''');
          nthpatel.setSTATUSvalue(txSessionName, txDatabaseName,
                      '2', 'ZONENO='''+inComm.TIFIELD00+''' and BRCHNO='''+inComm.TIFIELD01+'''');
        end else begin
          outComm.TOOVERID  := ROLOWRIGHTTEL;
          outComm.TOSTATEMENT := ROSTATLOWRIGHTTEL;
        end;
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpazon.Free;
      nthpabcp.Free;
      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0804(inComm: TTinComm;var outComm: TToutComm);
var
   nthpasnc: _SYSPASCV;
   nthpatel: _SYSPATEL;
   nthpatrx: _SYSPATRX;
   nthpabcp: _SYSPABCP;
   DataSet: TDataSet;
   newTeller: String;
   x: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpasnc := _SYSPASCV.Create;
      nthpatel := _SYSPATEL.Create;
      nthpatrx := _SYSPATRX.Create;
      nthpabcp := _SYSPABCP.Create;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      try
        DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName, 'ZONENO = ' + inComm.TIFIELD05 + ' and BRCHNO = '+inComm.TIFIELD00+' and SLEVEL = 3');
        If DataSet.IsEmpty then
        begin
           DataSet := nthpabcp.getAllRows(txSessionName, txDatabaseName, 'ZONENO = ' + inComm.TIFIELD05 + ' and BRCHNO = '+inComm.TIFIELD00);
           If Not DataSet.IsEmpty then
           begin
              x := Trunc(nthpasnc.getAPPSQNOvalue(txSessionName, txDatabaseName, 'APPCODE = ''01''') + 1);
              newTeller := FormatInt(x, 4);
              nthpasnc.setAPPSQNOvalue(txSessionName, txDatabaseName, newTeller, 'APPCODE = ''01''');

              nthpatel.Insert(txSessionName, txDatabaseName,
                              VarArrayOf([     newTeller,
                                               3,
                                               inComm.TIFIELD05,
                                               inComm.TIFIELD00,
                                          ''''+inComm.TIFIELD01+'''',
                                          ''''+inComm.TIFIELD03+'''',
                                               0,
                                               inComm.TIFIELD02,
                                            '''9999-12-31''',
                                            '''9999-12-31''',
                                          ''''+inComm.TIFIELD04+''''
                                         ])
                              );

              outComm.TOFIELD00 := newTeller;
              outComm.TOFIELD01 := inComm.TITRXD;
              outComm.TOFIELD02 := nthpatrx.getSCRIPTvalue(txSessionName, txDatabaseName, 'CODE='''+inComm.TITRXD+'''');
              outComm.TOFIELD03 := inComm.TITRXSQNO;
              outComm.TOFIELD04 := inComm.TISYSDATE;

              outComm.TOFIELD05 := nthpatel.getNAMEvalue(txSessionName, txDatabaseName, 'TELLNO='''+inComm.TITELLER+'''');
              outComm.TOFIELD06 := nthpabcp.getBNAMEvalue(txSessionName, txDatabaseName, 'BRCHNO='''+inComm.TIBRANCH+'''');

              outComm.TOFIELD07 := nthpabcp.getSNAMEvalue(txSessionName, txDatabaseName, 'BRCHNO='''+inComm.TIFIELD00+'''');
              outComm.TOFIELD08 := inComm.TIFIELD00;
           end else begin
              outComm.TOOVERID  := RONOTFOUNDBRNO;
              outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
           end;
        end else begin
           outComm.TOOVERID  := SOEXISTADMINTEL;
           outComm.TOSTATEMENT := SOSTATEXISTADMINTEL;
        end;
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpabcp.Free;
      nthpatrx.Free;
      nthpasnc.Free;
      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0901(inComm: TTinComm;var outComm: TToutComm);
var
   nthpasnc: _SYSPASCV;
   nthpatel: _SYSPATEL;
   nthpatrx: _SYSPATRX;
   nthpabcp: _SYSPABCP;
   DataSet: TDataSet;
   newTeller: String;
   x: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpasnc := _SYSPASCV.Create;
      nthpatel := _SYSPATEL.Create;
      nthpatrx := _SYSPATRX.Create;
      nthpabcp := _SYSPABCP.Create;

      outComm.TOOVERID    := SOTRANSFER;
      outComm.TOSTATEMENT   := SOSTATTRANSFER;

      try
//        DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName, 'ZONENO = ' + inComm.TIFIELD05 + ' and BRCHNO = '+inComm.TIFIELD00+' and SLEVEL = 3');
//        If DataSet.IsEmpty then
//        begin
           DataSet := nthpabcp.getAllRows(txSessionName, txDatabaseName, 'ZONENO = ' + inComm.TIZONENO + ' and BRCHNO = '+inComm.TIBRANCH);
           If Not DataSet.IsEmpty then
           begin
              x := Trunc(nthpasnc.getAPPSQNOvalue(txSessionName, txDatabaseName, 'APPCODE = ''01''') + 1);
              newTeller := FormatInt(x, 4);
              nthpasnc.setAPPSQNOvalue(txSessionName, txDatabaseName, newTeller, 'APPCODE = ''01''');

              nthpatel.Insert(txSessionName, txDatabaseName,
                              VarArrayOf([     newTeller,
                                               1,
                                               inComm.TIZONENO,
                                               inComm.TIBRANCH,
                                          ''''+inComm.TIFIELD00+'''',
                                          ''''+inComm.TIFIELD02+'''',
                                               0,
                                               inComm.TIFIELD01,
                                            '''9999-12-31''',
                                            '''9999-12-31''',
                                          ''''+inComm.TIFIELD03+''''
                                         ])
                              );

              outComm.TOFIELD00 := newTeller;
              outComm.TOFIELD01 := inComm.TITRXD;
              outComm.TOFIELD02 := nthpatrx.getSCRIPTvalue(txSessionName, txDatabaseName, 'CODE='''+inComm.TITRXD+'''');
              outComm.TOFIELD03 := inComm.TITRXSQNO;
              outComm.TOFIELD04 := inComm.TISYSDATE;

              outComm.TOFIELD05 := nthpatel.getNAMEvalue(txSessionName, txDatabaseName, 'TELLNO='''+inComm.TITELLER+'''');
              outComm.TOFIELD06 := nthpabcp.getBNAMEvalue(txSessionName, txDatabaseName, 'BRCHNO='''+inComm.TIBRANCH+'''');

              outComm.TOFIELD07 := nthpabcp.getSNAMEvalue(txSessionName, txDatabaseName, 'BRCHNO='''+inComm.TIBRANCH+'''');
              outComm.TOFIELD08 := inComm.TIBRANCH;
           end else begin
              outComm.TOOVERID  := RONOTFOUNDBRNO;
              outComm.TOSTATEMENT := ROSTATNOTFOUNDBRNO;
           end;
//        end else begin
//           outComm.TOOVERID  := SOEXISTADMINTEL;
//           outComm.TOSTATEMENT := SOSTATEXISTADMINTEL;
//        end;
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpabcp.Free;
      nthpatrx.Free;
      nthpasnc.Free;
      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0902(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   DataSet: TDataSet;
   newBrno: String;
   x: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpatel := _SYSPATEL.Create;

      outComm.TOOVERID    := SONORMAL;
      outComm.TOSTATEMENT   := SOSTATNORMAL;

      try
        DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName,
                                       'TELLNO='+inComm.TIFIELD00+' and BRCHNO='+inCOmm.TIBRANCH+' and ZONENO=' +inCOmm.TIZONENO
                                       );
        If Not DataSet.IsEmpty then
        begin
           If inComm.TIRANK = '3' then
           begin
             nthpatel.setSTATUSvalue(txSessionName, txDatabaseName,
                                     '2', 'TELLNO='+inComm.TIFIELD00+' and BRCHNO='+inCOmm.TIBRANCH+' and ZONENO=' +inCOmm.TIZONENO
                                     );
           end else begin
             outComm.TOOVERID  := ROLOWRIGHTTEL;
             outComm.TOSTATEMENT := ROSTATLOWRIGHTTEL;
           end;
        end else begin
           outComm.TOOVERID  := ROWRONGTELLER;
           outComm.TOSTATEMENT := ROSTATWRONGTELLER;
        end;
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

procedure TRANPROC_T0903(inComm: TTinComm;var outComm: TToutComm);
var
   nthpatel: _SYSPATEL;
   DataSet: TDataSet;
   newBrno: String;
   x: Integer;
   txDatabase: TDatabase;
   txSession: TSession;
   txDatabaseName, txSessionName: String;
begin
   openDatabase(txSession, txDatabase, txSessionName, txDatabaseName);

   TransactionStart(txDatabase);
   try
{ IN = 网点号  }
      nthpatel := _SYSPATEL.Create;

      outComm.TOOVERID    := SONORMAL;
      outComm.TOSTATEMENT   := SOSTATNORMAL;

      try
        DataSet := nthpatel.getAllRows(txSessionName, txDatabaseName,
                                       'TELLNO='+inComm.TITELLER+' and BRCHNO='+inComm.TIBRANCH+' and ZONENO=' +inCOmm.TIZONENO
                                       );
        If Not DataSet.IsEmpty then
        begin
           nthpatel.setPSWvalue(txSessionName, txDatabaseName,
                                inComm.TIFIELD00,
                                'TELLNO='+inComm.TITELLER+' and BRCHNO='+inComm.TIBRANCH+' and ZONENO=' +inCOmm.TIZONENO
                                );
        end else begin
           outComm.TOOVERID  := ROWRONGTELLER;
           outComm.TOSTATEMENT := ROSTATWRONGTELLER;
        end;
      except
         outComm.TOOVERID  := SOABNORMAL;
         outComm.TOSTATEMENT := SOSTATABNORMAL;
      end;

      LOG_APP(txSessionName, txDatabaseName, inComm, outComm);

      nthpatel.Free;
   except
      TransactionRollBack(txDatabase);
      closeDatabase(txSession, txDatabase);
      outComm.TOOVERID  := ROABNORMAL;
      outComm.TOSTATEMENT := ROSTATABNORMAL;
      Exit;
   end;
   TransactionCommit(txDatabase);
   closeDatabase(txSession, txDatabase);
{ OUT = 可用标志# 情况说明# 柜员号# 网点号# 柜员状态# 柜员级别  }
end;

end.
