コード例 #1
0
ファイル: MzBindCardDB.cs プロジェクト: wlxawlx/MyFiles
        /// <summary>
        /// 卡号是否是否有效
        /// </summary>
        /// <param name="brid">病人ID</param>
        /// <param name="bkhm">病人号码</param>
        /// <param name="brlx">病人类型 1:门诊病人 2:住院病人</param>
        /// <param name="msg">返回错误信息</param>
        /// <returns>0:成功  大于0:出错  小于0:异常</returns>
        public int DB_ValidCard(string brid, string bkhm, string brlx, out string msg)
        {
            msg = "";
            int ret = -1;

            OracleConnection connection = new OracleConnection(WebConfigParameter.ConnectionHisString);
            OracleDataReader dr         = null;

            try
            {
                //说明返回值
                // 0:成功,
                // 1:该病人绑卡数据有误
                // 2: 记录已找到,但是没有该病人ID
                // 3: 绑卡记录没找到,确认办卡信息
                string _brid = "";


                bool _flag = false;

                string sqlStr = _builder.GetBridByBkhmSql(bkhm, brid, brlx, out _flag, out msg);
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, sqlStr);

                if (!_flag)
                {
                    ret = 10;
                    return(ret);
                }

                dr = DbHelperOra.ExecuteReader(sqlStr, connection);
                if (dr.HasRows)
                {
                    if (dr.Read())
                    {
                        if (WebConfigParameter.HospitalName() == AppUtils.HOSPITALNAME.WZSDQRMYY ||
                            WebConfigParameter.HospitalName() == AppUtils.HOSPITALNAME.WZSCNXDYRMYY)
                        {
                            _brid = !dr.IsDBNull(0) ? dr.GetString(0) : "";
                        }
                        else
                        {
                            _brid = !dr.IsDBNull(0) ? Convert.ToString(dr.GetInt64(0)) : "";
                        }

                        if (_brid != brid || _brid.Equals(""))
                        {
                            msg = "绑卡信息有误";
                            ret = 13;
                        }
                        else
                        {
                            msg = "成功,该病人绑卡数据有效";
                            ret = 00;
                        }
                    }
                    else
                    {
                        msg = "记录已找到,但是没有该病人ID";
                        ret = 14;
                    }
                }
                else
                {
                    msg = "绑卡记录没找到,确认办卡信息";
                    ret = 15;
                }

                dr.Close();
                return(ret);
            }
            catch (Exception ex)
            {
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);

                msg = GetExceptionInfo(ex);
                ret = -1;
                return(ret);
            }
            finally
            {
                if (null != dr)
                {
                    dr.Close();
                }
                connection.Close();
            }
        }