/// <summary>
        /// 获取对象DataTable
        /// </summary>
        /// <param name="tSysUserProxy">对象</param>
        /// <param name="iIndex">起始页码</param>
        /// <param name="iCount">每页数目</param>
        /// <returns>返回结果</returns>
        public DataTable SelectByTable(TSysUserProxyVo tSysUserProxy, int iIndex, int iCount)
        {
            string strSQL = " select * from T_SYS_USER_PROXY {0} ";

            strSQL = String.Format(strSQL, BuildWhereStatement(tSysUserProxy));
            return(SqlHelper.ExecuteDataTable(BuildPagerExpress(strSQL, iIndex, iCount)));
        }
    public static string EditData(string strID, string strUSER_ID, string strProxyID)
    {
        bool isSuccess = true;

        new TSysUserProxyLogic().Delete(strID);

        TSysUserProxyVo objProxyDel = new TSysUserProxyVo();

        objProxyDel.USER_ID = strUSER_ID;
        new TSysUserProxyLogic().Delete(objProxyDel);

        TSysUserProxyVo objProxy = new TSysUserProxyVo();

        objProxy.ID            = GetSerialNumber("t_sys_user_proxy_id");
        objProxy.USER_ID       = strUSER_ID;
        objProxy.PROXY_USER_ID = strProxyID;

        isSuccess = new TSysUserProxyLogic().Create(objProxy);

        if (isSuccess)
        {
            new PageBase().WriteLog("编辑代理", "", new UserLogInfo().UserInfo.USER_NAME + "编辑代理" + objProxy.ID);
            return("1");
        }
        else
        {
            return("0");
        }
    }
    //获取代理信息
    private string getProxyList()
    {
        string strSortname  = Request.Params["sortname"];
        string strSortorder = Request.Params["sortorder"];
        //当前页面
        int intPageIndex = Convert.ToInt32(Request.Params["page"]);
        //每页记录数
        int intPageSize = Convert.ToInt32(Request.Params["pagesize"]);

        if (strSortname == null || strSortname.Length < 0)
        {
            strSortname = TSysUserProxyVo.ID_FIELD;
        }

        TSysUserProxyVo objProxy = new TSysUserProxyVo();

        if (strIsAdmin.Length == 0)
        {
            objProxy.USER_ID = LogInfo.UserInfo.ID;
        }
        objProxy.SORT_FIELD = strSortname;
        objProxy.SORT_TYPE  = strSortorder;

        int       intTotalCount = new TSysUserProxyLogic().GetSelectResultCount(objProxy);
        DataTable dt            = new TSysUserProxyLogic().SelectByTable(objProxy, intPageIndex, intPageSize);

        string strJson = CreateToJson(dt, intTotalCount);

        return(strJson);
    }
        /// <summary>
        /// 对象编辑
        /// </summary>
        /// <param name="tSysUserProxy_UpdateSet">UpdateSet用户对象</param>
        /// <param name="tSysUserProxy_UpdateWhere">UpdateWhere用户对象</param>
        /// <returns>是否成功</returns>
        public bool Edit(TSysUserProxyVo tSysUserProxy_UpdateSet, TSysUserProxyVo tSysUserProxy_UpdateWhere)
        {
            string strSQL = SqlHelper.BuildUpdateExpress(tSysUserProxy_UpdateSet, TSysUserProxyVo.T_SYS_USER_PROXY_TABLE);

            strSQL += this.BuildWhereStatement(tSysUserProxy_UpdateWhere);
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSQL) > 0 ? true : false);
        }
        /// <summary>
        /// 对象编辑
        /// </summary>
        /// <param name="tSysUserProxy">用户对象</param>
        /// <returns>是否成功</returns>
        public bool Edit(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = SqlHelper.BuildUpdateExpress(tSysUserProxy, TSysUserProxyVo.T_SYS_USER_PROXY_TABLE);

            strSQL += string.Format(" where ID='{0}' ", tSysUserProxy.ID);
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSQL) > 0 ? true : false);
        }
        /// <summary>
        /// 对象删除
        /// </summary>
        /// <param name="Id">ID</param>
        /// <returns>是否成功</returns>
        public bool Delete(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = "delete from T_SYS_USER_PROXY ";

            strSQL += this.BuildWhereStatement(tSysUserProxy);

            return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSQL) > 0 ? true : false);
        }
    public static string getProxyOfUser(string strUserID)
    {
        TSysUserProxyVo objProxyWhere = new TSysUserProxyVo();

        objProxyWhere.USER_ID = strUserID;
        TSysUserProxyVo objProxy = new TSysUserProxyLogic().Details(objProxyWhere);
        TSysUserVo      objUser  = new TSysUserLogic().Details(objProxy.PROXY_USER_ID);

        return(objProxy.PROXY_USER_ID + "|" + objUser.REAL_NAME);
    }
    public static string SaveData(string strUserID, string strProxyID)
    {
        bool isSuccess = true;

        TSysUserProxyVo objProxy = new TSysUserProxyVo();

        TSysUserProxyVo objProxyWhere = new TSysUserProxyVo();

        objProxyWhere.USER_ID = strUserID;
        List <TSysUserProxyVo> lst = new TSysUserProxyLogic().SelectByObject(objProxyWhere, 0, 0);

        if (lst.Count > 0)
        {
            objProxy.ID            = lst[0].ID;
            objProxy.USER_ID       = strUserID;
            objProxy.PROXY_USER_ID = strProxyID;

            isSuccess = new TSysUserProxyLogic().Edit(objProxy);
            if (isSuccess)
            {
                new PageBase().WriteLog("编辑代理设置", "", new UserLogInfo().UserInfo.USER_NAME + "编辑代理设置" + objProxy.ID);
            }
        }
        else
        {
            objProxy.ID            = GetSerialNumber("t_sys_user_proxy_id");
            objProxy.USER_ID       = strUserID;
            objProxy.PROXY_USER_ID = strProxyID;

            isSuccess = new TSysUserProxyLogic().Create(objProxy);
            if (isSuccess)
            {
                new PageBase().WriteLog("添加代理设置", "", new UserLogInfo().UserInfo.USER_NAME + "添加代理设置" + objProxy.ID);
            }
        }

        if (isSuccess)
        {
            return("1");
        }
        else
        {
            return("0");
        }
    }
        /// <summary>
        /// 根据对象构造条件语句
        /// </summary>
        /// <param name="tSysUserProxy"></param>
        /// <returns></returns>
        public string BuildWhereStatement(TSysUserProxyVo tSysUserProxy)
        {
            StringBuilder strWhereStatement = new StringBuilder(" Where 1=1 ");

            if (null != tSysUserProxy)
            {
                //编号
                if (!String.IsNullOrEmpty(tSysUserProxy.ID.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND ID = '{0}'", tSysUserProxy.ID.ToString()));
                }
                //用户编号
                if (!String.IsNullOrEmpty(tSysUserProxy.USER_ID.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND USER_ID = '{0}'", tSysUserProxy.USER_ID.ToString()));
                }
                //被代理人ID
                if (!String.IsNullOrEmpty(tSysUserProxy.PROXY_USER_ID.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND PROXY_USER_ID = '{0}'", tSysUserProxy.PROXY_USER_ID.ToString()));
                }
                //备注
                if (!String.IsNullOrEmpty(tSysUserProxy.REMARK.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND REMARK = '{0}'", tSysUserProxy.REMARK.ToString()));
                }
                //备注1
                if (!String.IsNullOrEmpty(tSysUserProxy.REMARK1.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND REMARK1 = '{0}'", tSysUserProxy.REMARK1.ToString()));
                }
                //备注2
                if (!String.IsNullOrEmpty(tSysUserProxy.REMARK2.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND REMARK2 = '{0}'", tSysUserProxy.REMARK2.ToString()));
                }
                //备注3
                if (!String.IsNullOrEmpty(tSysUserProxy.REMARK3.ToString().Trim()))
                {
                    strWhereStatement.Append(string.Format(" AND REMARK3 = '{0}'", tSysUserProxy.REMARK3.ToString()));
                }
            }
            return(strWhereStatement.ToString());
        }
 /// <summary>
 /// 对象编辑
 /// </summary>
 /// <param name="tSysUserProxy">用户对象</param>
 /// <returns>是否成功</returns>
 public bool Edit(TSysUserProxyVo tSysUserProxy)
 {
     return(access.Edit(tSysUserProxy));
 }
 /// <summary>
 /// 对象编辑
 /// </summary>
 /// <param name="tSysUserProxy_UpdateSet">UpdateSet用户对象</param>
 /// <param name="tSysUserProxy_UpdateWhere">UpdateWhere用户对象</param>
 /// <returns>是否成功</returns>
 public bool Edit(TSysUserProxyVo tSysUserProxy_UpdateSet, TSysUserProxyVo tSysUserProxy_UpdateWhere)
 {
     return(access.Edit(tSysUserProxy_UpdateSet, tSysUserProxy_UpdateWhere));
 }
        /// <summary>
        /// 根据对象获取全部数据,用Table承载
        ///  数据量较小时使用【不推荐】
        /// </summary>
        /// <param name="tSysUserProxy"></param>
        /// <returns></returns>
        public DataTable SelectByTable(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = "select * from T_SYS_USER_PROXY " + this.BuildWhereStatement(tSysUserProxy);

            return(SqlHelper.ExecuteDataTable(strSQL));
        }
 /// <summary>
 /// 对象删除
 /// </summary>
 /// <param name="Id">ID</param>
 /// <returns>是否成功</returns>
 public bool Delete(TSysUserProxyVo tSysUserProxy)
 {
     return(access.Delete(tSysUserProxy));
 }
        /// <summary>
        /// 获取对象List
        /// </summary>
        /// <param name="tSysUserProxy">对象</param>
        /// <param name="iIndex">起始页码</param>
        /// <param name="iCount">每页数目</param>
        /// <returns>返回结果</returns>
        public List <TSysUserProxyVo> SelectByObject(TSysUserProxyVo tSysUserProxy, int iIndex, int iCount)
        {
            string strSQL = String.Format("select * from  T_SYS_USER_PROXY " + this.BuildWhereStatement(tSysUserProxy));

            return(SqlHelper.ExecuteObjectList(tSysUserProxy, BuildPagerExpress(strSQL, iIndex, iCount)));
        }
        /// <summary>
        /// 对象明细
        /// </summary>
        /// <param name="tSysUserProxy">对象条件</param>
        /// <returns>对象</returns>
        public TSysUserProxyVo Details(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = String.Format("select * from  T_SYS_USER_PROXY " + this.BuildWhereStatement(tSysUserProxy));

            return(SqlHelper.ExecuteObject(new TSysUserProxyVo(), strSQL));
        }
 /// <summary>
 /// 获取对象List
 /// </summary>
 /// <param name="tSysUserProxy">对象</param>
 /// <param name="iIndex">起始页码</param>
 /// <param name="iCount">每页数目</param>
 /// <returns>返回结果</returns>
 public List <TSysUserProxyVo> SelectByObject(TSysUserProxyVo tSysUserProxy, int iIndex, int iCount)
 {
     return(access.SelectByObject(tSysUserProxy, iIndex, iCount));
 }
 public TSysUserProxyLogic(TSysUserProxyVo _tSysUserProxy)
 {
     tSysUserProxy = _tSysUserProxy;
     access        = new TSysUserProxyAccess();
 }
 /// <summary>
 /// 获得查询结果总行数,用于分页
 /// </summary>
 /// <param name="tSysUserProxy">对象</param>
 /// <returns>返回行数</returns>
 public int GetSelectResultCount(TSysUserProxyVo tSysUserProxy)
 {
     return(access.GetSelectResultCount(tSysUserProxy));
 }
 /// <summary>
 /// 对象添加
 /// </summary>
 /// <param name="sysRole">对象</param>
 /// <returns>是否成功</returns>
 public bool Create(TSysUserProxyVo tSysUserProxy)
 {
     return(access.Create(tSysUserProxy));
 }
        /// <summary>
        /// 对象添加
        /// </summary>
        /// <param name="tSysUserProxy">对象</param>
        /// <returns>是否成功</returns>
        public bool Create(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = SqlHelper.BuildInsertExpress(tSysUserProxy, TSysUserProxyVo.T_SYS_USER_PROXY_TABLE);

            return(SqlHelper.ExecuteNonQuery(CommandType.Text, strSQL) > 0 ? true : false);
        }
 /// <summary>
 /// 根据对象获取全部数据,用Table承载
 ///  数据量较小时使用【不推荐】
 /// </summary>
 /// <param name="tSysUserProxy"></param>
 /// <returns></returns>
 public DataTable SelectByTable(TSysUserProxyVo tSysUserProxy)
 {
     return(access.SelectByTable(tSysUserProxy));
 }
 /// <summary>
 /// 获取对象DataTable
 /// </summary>
 /// <param name="tSysUserProxy">对象</param>
 /// <param name="iIndex">起始页码</param>
 /// <param name="iCount">每页数目</param>
 /// <returns>返回结果</returns>
 public DataTable SelectByTable(TSysUserProxyVo tSysUserProxy, int iIndex, int iCount)
 {
     return(access.SelectByTable(tSysUserProxy, iIndex, iCount));
 }
        /// <summary>
        /// 获得查询结果总行数,用于分页
        /// </summary>
        /// <param name="tSysUserProxy">对象</param>
        /// <returns>返回行数</returns>
        public int GetSelectResultCount(TSysUserProxyVo tSysUserProxy)
        {
            string strSQL = "select Count(*) from T_SYS_USER_PROXY " + this.BuildWhereStatement(tSysUserProxy);

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(strSQL)));
        }
 /// <summary>
 /// 根据对象特征获取单一对象
 /// </summary>
 /// <param name="tSysUserProxy">对象</param>
 /// <returns></returns>
 public TSysUserProxyVo SelectByObject(TSysUserProxyVo tSysUserProxy)
 {
     return(access.SelectByObject(tSysUserProxy));
 }
 /// <summary>
 /// 对象明细
 /// </summary>
 /// <param name="tSysUserProxy">对象条件</param>
 /// <returns>对象</returns>
 public TSysUserProxyVo Details(TSysUserProxyVo tSysUserProxy)
 {
     return(access.Details(tSysUserProxy));
 }