<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-control" content="max-age=1700">
<meta name="viewport" content="user-scalable=no, width=device-width">
<meta name="MobileOptimized" content="320">
<meta name="author" content="kesion.com">
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="Kesion.APPCode" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.Course" %>
<script runat="server" type="text/C#">
	dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
	private static dynamic __info = new System.Dynamic.ExpandoObject();   //初始化当前页信息
	bool isLoadPage = true;  //定义页面是否加载
    public string title = string.Empty;
    public string days = "0";
    public string showdata = string.Empty;
    public string AgreeMent = string.Empty;
    public DataRow drs = null;
	protected void Page_Load(object sender, EventArgs e)
	{
       showdata= getuse();
	}
	 public static string GetInfo(string RangeType, string LimitType, string LimitClassIDs)
       {

            #region 使用条件
            string str = string.Empty;
            string sql = string.Empty;
			if (RangeType == "0")//内容
			{
				switch (LimitType)
				{
					case "2":
						StringBuilder sb = new StringBuilder();
						if (!string.IsNullOrEmpty(LimitClassIDs))
						{
                            sb.Append("<span>");
							string[] ids = LimitClassIDs.Split(',');
							foreach (string s in ids)
							{
								sb.Append(MyCache.GetCacheClass(Utils.StrToInt(s), 1) + "&nbsp;");
							}
                            sb.Append("</span>");
						}
						str = sb.ToString();
						break;
				}

			}
			if (RangeType == "1")//考试
			{
				switch (LimitType)
				{
					case "2":
						if (!string.IsNullOrEmpty(LimitClassIDs))
						{
							using (DataTable dt = DataFactory.GetDataTable("select top 600 classid,classname from KS_SjClass Where classId in(" + Utils.FilterIDs(LimitClassIDs) + ")"))
							{
								if (dt.Rows.Count > 0)
								{
									foreach (DataRow dr in dt.Rows)
									{

										//str += string.Format("<span class='nav_name'><a href='{0}' target='_blank'>", BaseFun.GetRewriteUrl("examlist", Utils.StrToInt(dr["classid"].ToString()))) + dr[1].ToString() + "</a></span>";

                                        str += string.Format("<span><a href='{0}' target='_blank'>", "javascript:void(0)") + dr[1].ToString() + "</a></span>";
									}
								}
							}
						}
					
						break;
					case "3":
						if (!string.IsNullOrEmpty(LimitClassIDs))
						{
							using (DataTable dt = DataFactory.GetDataTable("select top 600 title,id from KS_SJ where verify=1 and id in(" + Utils.FilterIDs(LimitClassIDs) + ")"))
							{
								if (dt.Rows.Count > 0)
								{
									foreach (DataRow dr in dt.Rows)
									{
										str += string.Format("<span><a href=\"{0}\" target=\"_blank\">", BaseFun.GetRewriteUrl("examview", Utils.StrToInt(dr["id"].ToString()))) + dr["title"].ToString() + " </a></span>";
									}
								}
							}
						}
			
						break;
				}
			}
            if (RangeType == "2")//课程
            {
                switch (LimitType)
                {
                    case "2":
                        if (!string.IsNullOrEmpty(LimitClassIDs))
                        {
                            using (DataTable dt = DataFactory.GetDataTable("select top 600 classid,classname from KS_CosClass Where Type=0 and classId in(" + Utils.FilterIDs(LimitClassIDs) + ")"))
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    foreach (DataRow dr in dt.Rows)
                                    {
                                       
                                        str += string.Format("<span><a href='{0}' target='_blank'>",BaseFun.GetRewriteUrl("courselist",Utils.StrToInt(dr["classid"].ToString())) ) + dr[1].ToString() + "</a></span>";
                                    }
                                }
                            }
                        }
                     
                        break;
                    case "3":
						if (!string.IsNullOrEmpty(LimitClassIDs))
                        {
							using (DataTable dt = DataFactory.GetDataTable("select top 600 name,CourseID from KS_Course where IsOff=1 and CourseID in(" + Utils.FilterIDs(LimitClassIDs) + ")"))
                            {
                                if (dt.Rows.Count > 0)
                                {
                                    foreach (DataRow dr in dt.Rows)
                                    {
                                        str += string.Format("<span><a href=\"{0}\" target=\"_blank\">",BaseFun.GetRewriteUrl("courseview",Utils.StrToInt(dr["courseid"].ToString()))) + dr["name"].ToString() + " </a></span>";
                                    }
                                }
                            }
                        }
                   

                        break;


                }

            }
         
			//else if (RangeType == "0")
			//{
			//	str = @" <p><span class=""used_info_tj""></span></p><ul><span>无限制</span></ul>";

			//}



            return str;


            #endregion
        }
     public static string GetShiYong(string limit, int contenttf, int examtf, int coursetf, string examclassids, string contentclassids, string cosclassids, string examids, string cosids)
     {
         #region 使用条件
         string str = string.Empty;
         string sql = string.Empty;

         if (Utils.StrToInt(limit) == 0)
         {
             switch (contenttf)
             {
                 case 1:
                     str += "<div class=\"f-l w-80 lh-30\">文章模块拥有所有免费查看权限</div><div class=\"clear\"></div>";
                     break;
                 case 2:
                     str += "<div class=\"f-l w-80 lh-30\">部分文章栏目下拥有免费查看权限</div><div class=\"f-l lac\">" + GetInfo("0", contenttf.ToString(), contentclassids) + "</div><div class=\"clear\"></div>";
                     break;
             }
             switch (examtf)
             {
                 case 1:
                     str += "<div class=\"f-l w-80 lh-30\">考试模块拥有所有免费做题权限</div><div class=\"clear\"></div>";
               
                     break;
                 case 2:
                     str += "<div class=\"f-l w-80 lh-30\">部分考试栏目下拥有免费做题权限</div><div class=\"f-l lac\">" + GetInfo("1", examtf.ToString(), examclassids) + "</div><div class=\"clear\"></div>";
                  
                     break;
                 case 3:
                     str += "<div class=\"f-l w-80 lh-30\">指定试卷免费</div><div class=\"f-l lac\">" + GetInfo("1", examtf.ToString(), examids) + "</div><div class=\"clear\"></div>";
              
                     break;
             }
             switch (coursetf)
             {
                 case 1:
                     str += "<div class=\"f-l w-80 lh-30\">课程模块拥有所有免费观看权限</div><div class=\"clear\"></div>";
       
                     break;
                 case 2:
                     str += "<div class=\"f-l w-80 lh-30\">部分课程栏目下拥有免费观看权限</div><div class=\"f-l lac\">" + GetInfo("2", coursetf.ToString(), cosclassids) + "</div><div class=\"clear\"></div>";
                  
                     break;
                 case 3:
                     str += "<div class=\"f-l w-80 lh-30\">指定课程免费</div><div class=\"f-l lac\">" + GetInfo("2", coursetf.ToString(), cosids) + "</div><div class=\"clear\"></div>";
              
                     break;
             }

         }
         else if (limit == "1")
         {
             str = @" <p><span class=""used_info_tj"">可以查看本站的所有收费项目</span></p>";
         }

         return str;
         #endregion
     }
     public string getuse()
     {
         string result = string.Empty;
         int packid = Utils.StrToInt(KSCMS.S("packid"));
         using (DataTable dt = DataFactory.GetDataTable("select top 1 * from KS_UserFeePackages where id=" + packid + ""))
         {
             if (dt.Rows.Count > 0)
             {
                  drs = dt.Rows[0];
                 days = drs["days"].ToString();
                 title = drs["title"].ToString();
                 if (Utils.StrToInt(drs["limit"].ToString())==0)
                 {
                   result=GetShiYong(drs["limit"].ToString(), Utils.StrToInt(drs["contenttf"].ToString()), Utils.StrToInt(drs["examtf"].ToString()), Utils.StrToInt(drs["coursetf"].ToString()), drs["examclassids"].ToString(), drs["contentclassids"].ToString(), drs["cosclassids"].ToString(), drs["examids"].ToString(), drs["cosids"].ToString());
                 }
                 
             }
         }
       
         return result;
     }
     public string GetUserInfo(int feeid)
     {
        string userinfo= DataFactory.GetOnlyValue("select top 1 userinfo from KS_UserFeeSell where id=" + feeid);
         if(userinfo=="0"){
             userinfo = string.Empty;
         }
         return userinfo.ToString();
     }
     public string getVal(string t)
     {
         string s = "";
         if (drs != null)
         {
             s = drs[t].ToString();
         }
         return s;
     }
     public string getroupname(int groupid)
     {
         string groupname = DataFactory.GetOnlyValue("select top 1 groupname from KS_UserGroup where groupid=" + groupid + "");
         if (groupname == "0")
         {
             groupname = "保持不变";
         }
         return groupname;
     }
</script>
<script src="/Template3G/newstyle01/phone_ui/phonesize.js"></script> 
<link href="/Template3G/newstyle01/phone_ui/style.css" rel="stylesheet" type="text/css">
<style>
body{ background:#fff;}
.pagetable{border: 1px solid #eee;}
.pagetable .p-t-title strong{font-size: 1.2em;font-weight: normal;}
.pagetable .p-t-title{ background:#f8f8f8;}
.pagetable>tbody>tr>td{padding:0.6em 0.5em; border-bottom:1px solid #eee;}
.pagetable .p-t-l{ width:30%; border-right:1px solid #eee; text-align:right;}
.line{text-decoration: underline;}
.lh-30{ color:#999;}
.lac{ margin-top:0.5em;}
.lac span a{color: #03A9F4;}
.line input{  border:0px; background:none;border-bottom:2px solid #000; }
</style>
<%
    if (!isLoadPage) return;
%>

<div class="ro_5 tan-box ">
	<%--<img src="{$GetTemplateDir}/images/close.png" class="guan">--%>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="pagetable">
		<tr class="p-t-title"><td colspan="2" align="center"><strong><%=title %></strong></td></tr>
		<tr><td class="p-t-l">期限：</td><td class="p-t-r"><%=days %>天<%=KSCMS.S("feeid")=="0"?Utils.StrToInt(drs["GiveVIPDay"].ToString())==0?"":"(赠送VIP:"+Utils.StrToInt(drs["GiveVIPDay"].ToString())+"天)":"" %></td></tr>
		<tr>
			<td class="p-t-l">营销卡权限：</td>
			<td class="p-t-r">
				<%=showdata %>
				<%--<div>
					<div class="f-l w-80 lh-30">免费课程（6门）</div>
					<div class="f-l lac">
						<span>网页设计</span>
						<span>编译原理</span>
						<span>计算机组成原理</span>
						<span>应用数学</span>
						<span>计算机一级</span>
						<span>普通话</span>
					</div>
					<div class="clear"></div>
				</div>
				<div class="mp_20 md_10">
					<div class="f-l w-80 lh-30">免费试卷（2份）</div>
					<div class="f-l lac">
						<span>编译原理A卷</span>
						<span>应用数学B卷</span>
					</div>
					<div class="clear"></div>
				</div>--%>
			</td>
		</tr>
		<tr class="p-t-title">
			<td colspan="2" align="center">用户组权限</td>
		</tr>
		<tr>
			<td class="p-t-l">使用升级：</td>
			<td class="p-t-r">
				<span><%=getroupname(Utils.StrToInt( getVal("UpGroup"))) %></span>
			</td>
		</tr>
		<tr>
			<td class="p-t-l">到期降级：</td>
			<td class="p-t-r">
				<span><%=getroupname(Utils.StrToInt(getVal("DownGroup"))) %></span>
			</td>
		</tr>
		<tr>
			<td class="p-t-l">营销卡介绍：</td>
			<td class="p-t-r"><%=getVal("Descript") %></td>
		</tr>
		<tr>
			<td colspan="2"><div class="contractBox"><%=Utils.StrToInt(getVal("IsIdentity"))==1?GetUserInfo(Utils.StrToInt(KSCMS.S("feeid"))):"" %></div></td>
		</tr>
	</table>
</div>
