示例#1
0
        /// <summary>
        /// 添加常用联系人
        /// </summary>
        /// <param name="info">用户信息</param>
        /// <param name="linkInfo">常用联系人信息</param>
        /// <returns>0-成功  大于0-失败   小于0-异常</returns>
        public int DB_AddContacts(UserInfo info, out UserInfo linkInfo, out string msg)
        {
            msg      = "";
            linkInfo = new UserInfo();
            int    ret       = -1;
            string linkmanid = "";

            OracleConnection connection = new OracleConnection(WebConfigParameter.ConnectionHisString);

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

            try
            {
                bool _flag = false;
                ret = DB_GetLinkmanid(info.openid, out linkmanid, out msg);
                if (ret != 0)
                {
                    ret = 03;
                    msg = "获取联系人ID失败!";
                    return(ret);
                }

                string insertText = _builder.GetAddContactsSql(info.openid, info.label, info.name, info.phone,
                                                               info.idcardno, info.address, linkmanid, out _flag, out msg);
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, insertText);

                if (!_flag)
                {
                    ret = 10;
                    return(ret);
                }
                ArrayList listSql = new ArrayList();
                listSql.Add(insertText);

                DbHelperOra.ExecuteSqlTran(listSql, connection);

                linkInfo.label     = info.label;
                linkInfo.name      = info.name;
                linkInfo.linkmanid = linkmanid;

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