<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.Components" %>
<script runat="server" type="text/C#">
    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
    private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
    bool isLoadPage = true;  //定义页面是否加载
    string sqlParam = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckUserLogin.Run();
    }

</script>
<script>

    function add(id) {
        window.open("index.aspx?c=user&a=course&f=MyCourseFList&id=" + id, "面授课程查看", "height=500,width=700");
    }
</script>

<%
    if (!isLoadPage) return;
%>

<div class="r_tybox t_tybox nomar clearfix">
    <div class="r_title tytitle  pd0">
        <div class="tabs" style="float:left">
            <ul>
                <li  class="puton"><a href="<%=BasicField.GetUserUrl("basic/BargainList")%>">砍价列表</a></li>
                <li><a href="<%=BasicField.GetUserUrl("basic/MyBargain")%>">我的砍价</a></li>
            </ul>
        </div>
    </div>
      <div class="top-sort clearfix">
        <div class="top-sort-tab lf">
            <ul>
               
            </ul>
        </div>
        <div class="top-sort-option rf">
            <a href='<%=BasicField.GetUserUrl("basic/bargainlist") %>'>所有课程</a>
            <a href='<%=BasicField.GetUserUrl("basic/bargainlist","type-0") %>'>点播课程</a>
            <a href='<%=BasicField.GetUserUrl("basic/bargainlist","type-1") %>'>面授课程</a>
             <a href='<%=BasicField.GetUserUrl("basic/bargainlist","type-2") %>'>直播课程</a>
        </div>
    </div>
    <div class="myCourse">
        <ul id="mainCourse">
            <%
                if (!string.IsNullOrEmpty(KSCMS.S("type")))
                {
                    sqlParam += " AND CourseType=" + KSCMS.S("type");
                }
                int recordcount, pagecount;
                int CurrPage = new BasicField().GetCurrPage;
                int PageSize = 10;
                Kesion.HtmlTags.CommonFunc.InitBlogNav(UserManage.GetUserInfo().UserID, (new TemporaryVar()).UserName);
                using (DataTable dt = DataFactory.GetPage("name,courseid,price,money,coursetype,photourl", " KS_CosBargain WHERE isopen=1"+sqlParam, "ID", "ORDER BY ID DESC", CurrPage, PageSize, out recordcount, out pagecount))
                {
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            string cosname = dr["name"].ToString();  //课程名
                            string courseid = dr["courseid"].ToString();
                            string costype = dr["coursetype"].ToString() == "0" ? "点播课程" : dr["coursetype"].ToString() == "1" ? "面授课程" : "直播课程";  //课程类型
                            decimal price = Utils.StrToDecimal(dr["price"].ToString());             //课程原价
                            decimal money = Utils.StrToDecimal(dr["money"].ToString());             //砍价活动价格
                            string url = MyCache.GetCacheConfig(5) + "/" + (dr["coursetype"].ToString() == "1" ? "face" : "course") + "/" + courseid;
                            StringBuilder sb = new StringBuilder();
                            sb.AppendFormat("<li>");
                            sb.AppendFormat("<div class='image'> <img src='"+dr["photourl"].ToString()+"' onerror='this.src = '/sysimg/nopic.gif'' alt=''></div>");
                            sb.AppendFormat("<div class='name'><a  title='前台页'>{0}</a></div> ", cosname);
                            sb.AppendFormat("<div class='info'><span>{0}</span></div>", costype);
                            sb.AppendFormat("<div class='button'><a target='_blank' href='"+url+"'>去砍价</a></div>");
                            sb.AppendFormat("<div class='link'>原课程价格：￥" + Kesion.APPCode.Public.ReturnShopPrice(price) + "，最低价格￥" + Kesion.APPCode.Public.ReturnShopPrice(money) + "</div></li>");

                            KSCMS.W(sb.ToString());
                        }
                    }
                    else
                    {
                        KSCMS.W("<div class=\"empty\">当前暂无砍价课程</div><style>.cz_btn{display:none;}</style>");
                    }
                }
            %>
        </ul>

    </div>
    <div class="cz_btn">
        <%
            #region 分页
            string PageStr = "[KS:PageStr2]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
        %>
    </div>
</div>
