Chinaunix首页 | 论坛 | 博客
  • 博客访问: 103678680
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类:

2008-04-18 23:10:54

作者:styr  出处:Unix爱好者家园unix-cd.com 

#MENU #COPYRIGHT2002  BY YangRongBo,四川省邮政信息技术局运维部.
#ALL RIGHT RESERVED.
#本版本在省局的脚本上改进而成
#提升查询检索速度,增加按机构号检索输出,支持多机构号检索

#!/bin/ksh
echomain()
{
clear
printf '
  ┌───────────────────────────────────┐
  │          四  川  省  邮  政  储  蓄  帐  户  查  询  系  统          │
  └───────────────────────────────────┘

                                              四 川 省 邮 政 信 息 技 术 局

   ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※'
}

xuanze()  #选择查询活期、定期
{
while :
do
echomain
printf '
  ┌───────────────────────────────────┐
  │                                                                      │
  │           【请选择】                                                 │
  │                                                                      │
  │                   ①    活 期 帐 户 查 询                            │
  │                                                                      │
  │                   ②    定 期 帐 户 查 询                            │
  │                                                                      │
  │                                                  按 0 键退出系统     │
  │                                                                      │
  └───────────────────────────────────┘
  
'
  echo -n "                请选择查询界面   -----------> "
  read
case "$REPLY" in
1)  echoname="【活期查询】" ; databasename="活期数据库名" ; acc_cstm="活期字段名" ; chaxun ;;    #此处屏敝了库名及字段名
2)  echoname="【定期查询】" ; databasename="定期数据库名" ; acc_cstm="定期字段名" ; chaxun ;;    #此处屏敝了库名及字段名
0)  exit 0 ;;
*)  error ;;
esac
done
}

chaxun()
{
acc= ; openinst=
while :
do
clear
printf "
    ┌───────────────────────────────────┐
    │                                                                      │
    │          $echoname                                                │
    │                                                                      │
    │                                                                      │
    │                      用户帐户名称:                                   │
    │                                                                      │
    │                                                  按 0 键返回上层     │
    └───────────────────────────────────┘
                            
"
  [ "$acc" ] && echo "                            用户帐户名称:  $acc" \
|| read acc?"                            用户帐户名称:  "  
  [ $(echo "$acc" | wc -w) -eq 1 ] || { error ; acc= ; continue ; }
  [ "$acc" = "0" ] && return
echo "\n                  用户帐户的开户局机构号:  \c"
read openinst
[ "$openinst" = "0" ] && return
[ "$openinst" ] && { [ "$(echo "$openinst" | sed 's/[0-9 ]//g')" ] && \
{ tput bel ;
printf '
             ┌───────────────────────────┐
             │信息区: 输入错误 ! 请重新输入 !                       │
             │                                                      │
             │    注: 输入开户局号机构号可以显示指定开户局的账号信息│
      │        输入的机构号必须为整数; 指定多个开户机构号时请│
             │        以空格分隔;如不输入直接回车则默认为查询所有机 │
             │        构号下的账号信息; 输入 0 则返回上层           │  
             └───────────────────────────┘' ;
stty -echo ; read ; stty echo ; continue ; }  \
|| { openinst=$(echo "$openinst" | sed 's/^[^0-9][^0-9]*//g;s/  */|/g;s/  $//') ; break ; } ; } || break
done
echo "\n\n                              正在查询,请稍候 !"
##################查询用户帐号,开户机构#####################################
# # #               屏敝掉了数据库查询导出部份  # # #
[ -r mang.txt ] || { tput bel ;
printf '

       ┌───────────────────────────┐
       │ 信息区:   查询文件不存在或不可读 !  按任意键返回 !   │
       └───────────────────────────┘' ;
stty -echo ; read ; stty echo ; return ; }
jieguo="$(egrep "$openinst" mang.txt | sort -bnk2 | \
awk 'length($1)>=18 && $0!~/select/ {printf("%s%20s%12s%18s%s\n"," │",$1,"│",$2,"    │")}')"
[ "$jieguo" ] || { tput bel ;  
printf '

       ┌───────────────────────────┐
       │       信息区:   无此用户账号 !  按任意键返回 !       │
       └───────────────────────────┘' ;
stty -echo ; read ; stty echo ; return ; }
clear
sum=$(($(echo $jieguo | sed 's/│//g' |wc -w)/2))
echo "$jieguo" | sed '$!a\
├───────────────┼───────────┤
;$a\
└───────────────┴───────────┘
' | awk -v acc="$acc" -v sum=$sum 'BEGIN{print "\n   户 名:  "acc"\t\t共搜索到  "sum" 个结果\n\n" \
" ┌───────────────┬───────────┐\n"\
" │   帐        号               │   帐 号 开 户 局     │\n" \
" ├───────────────┼───────────┤"} {print}' | pg -p "按任意键继续"          
stty -echo ; stty echo
}

error()
{
tput bel ;  
printf '       ┌───────────────────────────┐
       │         信息区:   输入错误 !  请重新输入 !           │
       └───────────────────────────┘'
stty -echo ; read ; stty echo
}

############# main ############     #主函数

trap 'echo "\033[0m" ; stty echo ; rm mang.txt mang.sql 2>/dev/null ; exit ' 0 1 2 3 9 15  

echo "\033[1m" ; echomain
printf '
  ┌───────────────────────────────────┐
  │                                                                      │
  │                                                                      │
  │                                                                      │
  │            欢 迎 使 用 四 川 邮 政 储 蓄 帐 户 查 询 系 统           │
  │                                                                      │
  │                                                                      │
  │                                                                      │
  │                                                  按 0 键退出系统     │
  │                                                                      │  
  └───────────────────────────────────┘

                                                      请按任意键继续...'
stty -echo ; read ; stty echo
[ "$REPLY" = "0" ] && exit 0 || xuanze

阅读(389) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~