Пример #1
0
        /// <summary>
        /// 绑卡
        /// </summary>
        /// <param name="brid">病人ID</param>
        /// <param name="brxm">病人姓名</param>
        /// <param name="sfzh">身份证号</param>
        /// <param name="bklx">绑卡类型</param>
        /// <param name="lxdh">联系电话</param>
        /// <param name="brlx">病人类别 1-门诊  2-住院</param>
        /// <param name="msg">成功、错误或异常信息</param>
        /// <returns>0-成功  大于0-失败   小于0-异常</returns>
        public int DB_BindCard(string brid, string brxm, string sfzh, string bklx, string lxdh, string brlx, out string msg)
        {
            msg = "";

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

            int ret = -1;

            try
            {
                DateTime _bksj;
                if (!DB_Sysdate(out _bksj))
                {
                    msg = "读取系统时间出错";
                    ret = 5;
                    return(ret);
                }

                bool _flag = false;

                string findText = _builder.GetBingCardSql(brid, sfzh, brxm, bklx, brlx, out _flag, out msg);
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, findText);

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

                dr = DbHelperOra.ExecuteReader(findText, connection);

                if (dr.HasRows)
                {
                    if (dr.Read())
                    {
                        string _lxdh = !dr.IsDBNull(0) ? dr.GetString(0).ToUpper() : "";

                        if (_lxdh.Equals(lxdh) && !_lxdh.Equals(""))
                        {
                            msg = "成功绑定";
                            ret = 0;
                        }
                        else if (!_lxdh.Equals(lxdh) && !_lxdh.Equals(""))
                        {
                            msg = "绑定失败,电话号码不匹配";
                            ret = 2;
                        }
                        else if (_lxdh.Equals(""))
                        {
                            msg = "绑定失败,联系号码未登记";
                            ret = 4;
                        }
                        else
                        {
                            msg = "绑定失败,该卡已被绑定";
                            ret = 3;
                        }
                    }
                    else
                    {
                        msg = "绑卡失败";
                        ret = 4;
                    }
                }
                else
                {
                    msg = "绑卡失败,失败原因没有找到记录";
                }

                if (null != dr)
                {
                    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();
            }
        }