Пример #1
0
        /// <summary>
        ///  删除常用联系人
        /// </summary>
        /// <param name="openid">用户标识</param>
        /// <param name="linkmanid">联系人ID</param>
        /// <param name="info">用户信息</param>
        /// <returns>0-成功  大于0-失败   小于0-异常</returns>
        public int DB_DeleteFavoriteContactsStrr(string openid, string linkmanid, out UserInfo info, out string msg)
        {
            msg  = "";
            info = new UserInfo();
            int ret = -1;

            OracleConnection connection = new OracleConnection(WebConfigParameter.ConnectionHisString);

            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }
            OracleDataReader dr = null;

            OracleCommand cmd = new OracleCommand();

            cmd.Connection = connection;
            OracleTransaction tx = connection.BeginTransaction();

            cmd.Transaction = tx;

            try
            {
                bool _flag = false;

                string querySql = _builder.GetLinkManNameSql(openid, linkmanid, out _flag, out msg);
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, querySql);
                cmd.CommandText = querySql;
                dr = cmd.ExecuteReader();


                if (dr.Read())
                {
                    info.linkmanid = !dr.IsDBNull(0) ? dr.GetString(0).ToUpper() : "";
                    info.name      = !dr.IsDBNull(1) ? dr.GetString(1).ToUpper() : "";
                }
                else
                {
                    msg = "无该联系人信息";
                    ret = 03;
                    dr.Close();
                    tx.Commit();
                    return(ret);
                }

                string deletText = _builder.GetDeleteFavoriteContactsSql(openid, linkmanid, out _flag, out msg);
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, deletText);

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

                cmd.CommandText = deletText;
                ret             = cmd.ExecuteNonQuery();
                if (ret == 1)
                {
                    ret = 0;
                }
                else
                {
                    ret = 09;
                    msg = "删除常用联系人异常!";
                    tx.Rollback();
                }

                dr.Close();
                tx.Commit();
                return(ret);
            }
            catch (Exception ex)
            {
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                msg = GetExceptionInfo(ex);
                tx.Rollback();
                ret = -1;
                return(ret);
            }
            finally
            {
                if (null != dr)
                {
                    dr.Close();
                }
                if (null != connection && ConnectionState.Open == connection.State)
                {
                    connection.Close();
                }
            }
        }