<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Config" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<script runat="server" type="text/C#">

    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
    bool isLoadPage = true;  //定义页面是否加载
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!string.IsNullOrEmpty(KSCMS.S("userface")))
        {
            isLoadPage = false;
            DataFactoryUser.ExecuteNonQuery("update KS_User set userface='" + KSCMS.S("userface") + "' where userid=" + __user.UserID);
            return;
        }

    }


</script>
<div class="t_tybox nomar">
    <div class="r_title tytitle pd0">
        <h4 class="ty-none">上传头像设置</h4>
        <div class="tabs ">	

            <ul class="clearfix">
                <%if (__user.GroupID==4) { %>
                    <li><a href="<%=BasicField.GetUserUrl("teacher/teacher") %>">我的资料</a></li>
                    <%}
                      else if (__user.GroupID == 3){ %>
                    <li><a href="<%=BasicField.GetUserUrl("School/UserEnterprise") %>">基本资料</a></li>
                    <%}else { %>
                     <li><a href="<%=BasicField.GetUserUrl("basic/editinfo") %>">修改我的资料</a></li>
                     <%} %>
                    <li class='puton'><a href="<%=BasicField.GetUserUrl("basic/userface") %>">上传头像</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("basic/editpass") %>">修改密码</a></li>
                    <% if (__user.GroupID==3) {%>
                    <li ><a href="<%=BasicField.GetUserUrl("school/userepintroduce") %>">机构介绍</a></li>
                    <li ><a href="<%=BasicField.GetUserUrl("school/userepbank") %>">银行账户</a></li>
                    <% } 
                    %>
                    <li ><a href="<%=BasicField.GetUserUrl("basic/editquestion") %>">修改安全问题</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("basic/mobilebind") %>">第三方绑定</a></li>
                    <li><a href="<%=BasicField.GetUserUrl("Shop/MyAddress") %>">收货人地址</a></li>
            </ul>
        </div>
    </div>
    <%
        string thumbarr = string.Empty;
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("~/config/uploadsetting.config"));
        XmlNode  xn = doc.SelectSingleNode("//uploadsetting/item[@module='userface']");
        if (xn != null)
        {
            thumbarr = xn.SelectSingleNode("@thumbarr").InnerText;
        }
        string[] arr=null;
        if (!string.IsNullOrEmpty(thumbarr))
        {
            arr = thumbarr.Split(',');
        }
        int userId = __user.UserID;


    %>
    <div class="r_padbox">
  
        <table  cellspacing="1" cellpadding="3" class="border" width="100%" align="center" border="0">
            <tr>
                <td colspan="10" style="height:60px;">
                 <input type="hidden" name="userface" id="userface" />
                 <%=Kesion.APPCode.UploadAPI.EchoUpload("userface","userface") %></td>
            </tr>
            <!--<tr>
                <td colspan="10" style="height:60px;">自动生成头像</td>
            </tr>-->
            <tr>
            <%
                
             if (arr!=null){
              foreach (string a in arr)
               {
                   if (a.IndexOf("x") != -1)
                   {
               %>
                <td style="height:<%=Utils.StrToInt(a.Split('x')[1])+80 %>px" valign="top">
                 <div class="ar_r_t"><div class="ar_l_t"><div class="ar_r_b"><div class="ar_l_b">
                 <img userface="<%=a %>" onerror="this.src='/sysimg/avatar.jpg';" src="/UploadFiles/avatar/<%=userId %>_<%=a %>.jpg?rnd=<%=Guid.NewGuid() %>" oldsrc="/UploadFiles/avatar/<%=userId %>_<%=a %>.jpg?rnd=<%=Guid.NewGuid() %>" width="<%=a.Split('x')[0] %>"  height="<%=a.Split('x')[1] %>"/>
                </div></div></div></div>
                    <div style="clear:both;line-height:22px; font-size:12px;padding-left:0;" class="tips">尺寸：<%=a %>
                        <br />文件名：<%=userId.ToString()+"_"+a+".jpg" %>
                    </div>
               </td>
                <% 
                   } 
               } 
               }%>
            
            </tr>
            <tr style="clear:both">
                 <td colspan="10" style="border-bottom:0px">
                     原图:<br />
                 <div class="ar_r_t"><div class="ar_l_t"><div class="ar_r_b"><div class="ar_l_b">
                 <img userface="<%=userId %>" onerror="this.src='/sysimg/avatar.jpg';" src="/UploadFiles/avatar/<%=userId %>.jpg?rnd=<%=Guid.NewGuid() %>" oldsrc="/UploadFiles/avatar/<%=userId %>.jpg?rnd=<%=Guid.NewGuid() %>" style="cursor:pointer;max-height:280px;max-width:280px" title="点击查看原图" onclick="window.open($(this).attr('src'));"/>
                </div></div></div></div>
                    <div class="tips" style="padding-left:0;">
                        文件名：<%=userId.ToString()+".jpg" %>
                    </div>
               </td>
             </tr>
        </table>
         
    </div>
</div>
<script>
   $("#upframe").css('height','65px')

</script>