<%@ Control Language="C#" %>
<%@ 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" %>
<%@ Import Namespace="Kesion.Components" %>
<script runat="server" type="text/C#">
    dynamic __user = HttpContext.Current.Items["user"];                //初始化用户信息，
    bool isLoadPage = true;  //定义页面是否加载
    bool ispower = false;     //判断用户权限
    public static int RoomID = 0;
    public static int type;
    public static int workID;
    public static string name;
    public static string DefaultFile = string.Empty;
    public static string photourl = string.Empty;
    public static string ClassRoomTitle = string.Empty;
    public DataRow drp = null;
    public DataRow drClass = null;
    public int schoolID = 0;
    protected void Page_Load(object sender, EventArgs e)
    {

        RoomID = Utils.StrToInt(KSCMS.S("RoomID"));
        int tcid = Utils.StrToInt(DataFactory.GetOnlyValue("select TcID from KS_CosTeacher where UserID =" + __user.UserID));
        /*if (__user.GroupID == 3 || Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_CosClassroom where BanzhuRenID =" + new TemporaryVar().UserID + " and RoomID =" + RoomID)) > 0)
        {
            ispower = true;
        }
        else if (Utils.StrToInt(DataFactory.GetOnlyValue("select count(*) from KS_CosClassManage where TaskType = 9 and RoomID =" + RoomID + " and TcID=" + tcid)) != 0)
        {
            ispower = true;
        }
        */
        ispower = true;
        string sql1 = "";

        if (new TemporaryVar().GroupID == 4)
        {
            schoolID = new TemporaryVar().SchoolID;
        }
        if (schoolID == 0)
        {
            schoolID = new TemporaryVar().UserID;
        }
        if (RoomID != 0)
        {
            sql1 = "select top 1 * from KS_CosClassRoom where RoomID=" + RoomID;
            using (DataTable dt = DataFactory.GetDataTable(sql1))
            {
                if (dt.Rows.Count > 0)
                {
                    drClass = dt.Rows[0];
                    ClassRoomTitle = drClass["Title"].ToString();

                }
            }
        }

        if (KSCMS.S("action").Equals("save"))
        {
            SaveChange();
        }
        string DoMethod = KSCMS.S("do");

        switch (DoMethod)
        {
            case "modify":
                initialEdit(Utils.StrToInt(KSCMS.S("WorkID")));
                break;
            case "del":
                deleteSj(KSCMS.S("WorkID"));
                break;
            case "ispublic":
                CommonData.UpdateFieldStatus("KS_CosHomeWork", "verify", "WorkID", Utils.StrToInt(KSCMS.S("WorkID")));
                Msg.Alert("修改成功！", BasicField.GetUserUrl("teacher/TcHomeWork", "roomid-" + RoomID + ""));
                break;
        }

    }
    private void deleteSj(string WorkID)
    {
        if (WorkID == null || WorkID == "0") return;

        WorkID = Utils.FilterIDs(WorkID);
        using (DataTable dt = DataFactory.GetDataTable("select WorkID from KS_CosHomeWork Where WorkID in(" + WorkID + ")"))
        {
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    int id = Utils.StrToInt(dr["WorkID"].ToString());
                    Hashtable ht = new Hashtable();
                    ht.Add("WorkID", id);
                    CommonData.Delete("[KS_CosHomeWork]", ht);
                }
            }
        }
        Msg.Alert("删除成功!", BasicField.GetUserUrl("teacher/TcHomeWork", "roomid-" + RoomID));
        isLoadPage = false;
        return;
    }
    private void initialEdit(int WorkID)
    {
        SqlParam[] param = new SqlParam[1];
        param[0] = new SqlParam("WorkID", WorkID);

        using (DataTable dt = CommonData.GetDataTable("[KS_CosHomeWork]", "*", param))
        {
            if (dt.Rows.Count > 0)
            {
                drp = dt.Rows[0];
            }
        }
    }

    public string GetParam(string Fields)
    {
        string result = string.Empty;
        if (drp != null)
        {
            result = drp[Fields].ToString();
        }
        return result;
    }
    protected void SaveChange()
    {
        Hashtable ht = new Hashtable();
        ht.Add("title", Utils.ChkSQL(KSCMS.S("TxtName")));
        ht.Add("Content", Utils.ChkSQL(KSCMS.S("TxtIntro")));
        ht.Add("Verify", Utils.StrToInt(KSCMS.S("RdbVerify")));//资料状态
        ht.Add("ClassRoomID", RoomID);
        ht.Add("userid", UserManage.GetUserInfo().UserID);//提供者
        DefaultFile = KSCMS.S("DefaultFile");
        ht.Add("FjUrl", DefaultFile);

        #region 指定试卷

        ht.Add("IsExam", Utils.StrToInt(KSCMS.S("RadioButtonList3")));//是否有试卷
        string SJIDs = string.Empty;
        switch (Utils.StrToInt(KSCMS.S("RadioButtonList3")))
        {
            case 2:
                SJIDs = KSCMS.S("LstB1");
                break;
        }
        ht.Add("examPleID", SJIDs);
        ht.Add("IsAuto", Utils.StrToInt(KSCMS.S("RadioButtonList4")));//是否
        if(Utils.StrToInt(KSCMS.S("RadioButtonList3"))==2)
        {
            if(string.IsNullOrEmpty(KSCMS.S("endtime")))
            {
                Msg.Alert("对不起,完成有效时限不能为空!");
                isLoadPage = false;
                return;
            }
        }

        ht.Add("endtime", Utils.StrToDateTime(KSCMS.S("endtime")));//是否

        #endregion
        ht.Add("IsWXNotice", 0);
        if (drClass != null)
        {
            if (KSCMS.S("IsWXNotice") == "1")
            {
                ht.Remove("IsWXNotice");
                ht.Add("IsWXNotice", 1);

                #region 微信通知

                //班级已发布，作业已发布
                if (drClass["verify"].ToString() == "1" && Utils.StrToInt(KSCMS.S("RdbVerify")) == 1)
                {

                    int totlaNum = 0;

                    string tempid = DataFactory.GetOnlyValue("select top 1 mytemplateid from KS_weixineptemplate where userid=" + schoolID + " and orderid=1 and enable=1");

                    if (!string.IsNullOrEmpty(tempid) && tempid != "0")
                    {
                        ShowMain("正在通知学员，请稍后..");
                        using (DataTable dt = DataFactory.GetDataTable("select b.username,b.WeiXinOpenID from KS_CosClassStudent a inner join KS_User b on a.userid=b.userid where a.roomID=" + Utils.StrToInt(drClass["roomid"].ToString()) + ""))
                        {
                            if (dt.Rows.Count > 0)
                            {
                                totlaNum = dt.Rows.Count;
                                int i = 1;
                                foreach (DataRow dr in dt.Rows)
                                {
                                    if (!string.IsNullOrEmpty(dr["WeiXinOpenID"].ToString()))
                                    {
                                        string Data = string.Format(@"
                                      ""data"":{{
                                                       ""first"": {{
                                                           ""value"":""[作业通知]"",
                                                           ""color"":""#173177""
                                                       }},
                                                       ""keyword1"":{{
                                                           ""value"":""{0}""
                                                       }},
                                                       ""keyword2"": {{
                                                           ""value"":""{1}""
                                                       }},""keyword3"": {{
                                                           ""value"":""{2}""
                                                       }},
                                                      ""remark"":{{
                                                           ""value"":""{3}""
                                                       }}
                                               }}
                                           ", drClass["title"].ToString(), Utils.ChkSQL(KSCMS.S("TxtName")), KSCMS.S("endtime"), KSCMS.S("TxtIntro"));
                                        Kesion.Weixin.ks_weixin.SendEpWeixinTemplateMsg(tempid, dr["WeiXinOpenID"].ToString(), Data,schoolID);
                                        InnerJS(totlaNum, i);
                                        i++;
                                    }
                                }
                            }
                        }
                    }

                }
                #endregion
            }
        }

        if (KSCMS.S("do").Equals("add"))
        {
            ht.Add("adddate", DateTime.Now);
            CommonData.Insert("KS_CosHomeWork", ht);
            Msg.Alert("恭喜,作业添加成功!", BasicField.GetUserUrl("teacher/TcHomeWork", "roomid-" + RoomID));
            isLoadPage = false;
            return;
        }
        else
        {
            workID = Utils.StrToInt(KSCMS.S("workID"));
            CommonData.Update("KS_CosHomeWork", ht, " where  WorkID= " + workID);
            Msg.Alert("恭喜,作业修改成功!", BasicField.GetUserUrl("teacher/TcHomeWork", "roomid-" + RoomID));
            isLoadPage = false;
            return;
        }
    }
    private static void ShowMain(string tips)
    {
        #region 显示主体
        string str = string.Format(@"
                    <!DOCTYPE html><html>
                    <head>
<link href='/admin/images/style.CSS' rel='stylesheet' type='text/css' />
                    </head>
                  <body scroll=no bgcolor='transparent'>
                   <div id='manage_top' class='toptitle menu_top_fixed'>{0}</div><div class=""menu_top_fixed_height""></div> 
", tips);


        str += @"<div><div class=""content-area""> ";
        str += @"<table id=""BarShowArea"" width=""400"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1"">
				    <tr>
				    <td bgcolor=000000>
				     <table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""1"">
				    <tr>
				    <td bgcolor=ffffff height=9 style=""text-align:left""><img src=""../../sysimg/default/bar.gif"" width=0 height=10 id=img2 name=img2 align=absmiddle></td></tr></table>
				    <td bgcolor=ffffff height=9><span width=0 height=16 id=Span1 name=img2 align=absmiddle bgcolor='#000000'></span></td></tr></table>
				    </td></tr></table>
				    <table width=""550"" border=""0"" align=""center"" cellspacing=""1"" cellpadding=""1""><tr>
				    <td align=center> <span id=txt2 name=txt2 style=""font-size:9pt"">0</span><span id=txt4 style=""font-size:9pt"">%</span></td></tr>
				    <tr><td align=center><span id=txt3 name=txt3 style=""font-size:9pt"">0</span></td></tr>
				    </table>
    			 </div>
    		 

           </body>
         </htmL>
              ";
        KSCMS.W(str);
        #endregion
    }
    private static void InnerJS(int NowNum, int TotalNum)
    {
        #region 显示进度

        KSCMS.W("<script>");
        KSCMS.W(string.Format(@"img2.width={0};", ((double)NowNum / TotalNum) * 400));
        KSCMS.W(string.Format(@"txt2.innerHTML=""通知进度:{0}"";", (((double)NowNum / TotalNum) * 100).ToString("f2")));
        KSCMS.W(string.Format(@"txt3.innerHTML=""总共需要通知 <font color=red><b>{0}</b></font> 位学员,<font color=red><b>在此过程中请勿刷新此页面！！！</b></font> 系统正在通知第 <font color=red><b>{1}</b></font> 位学员"";", TotalNum, NowNum));
        KSCMS.W("<"+"/script>");
        KSCMS.Flush();
        #endregion
    }

</script>
<script>
	function showwatermarkarea() {
		var checkrad = jQuery("#RadioButtonList3 :radio[checked]").val();
		if (checkrad == "2") {
			jQuery("#watermark0").css("display", "none");
			jQuery("#watermark2").css("display", "");
		} else if (checkrad == "1") {
			jQuery("#watermark0").css("display", "");
			jQuery("#watermark2").css("display", "none");
		}
		else {
			jQuery("#watermark0").css("display", "none");
			jQuery("#watermark2").css("display", "none");
		}
	}
	jQuery(document).ready(function () {
		showwatermarkarea();

	});
	function searchSJ() {
		var key = jQuery("#TxtSJKey").val();
		if (key == '') {
			KesionJS.Alert("请输入试卷关键字！", "jQuery('#TxtSJKey').focus()");
			return false;
		} else {
			puburl = "/plus/course/CourseAjax.ashx?action=getsearchsj&inputer=<%=new TemporaryVar().UserName%>&key=" + escape(key);

			jQuery.ajax({
				url: puburl, success: function (d) {
					jQuery("#LstB2").empty();
					jQuery("#LstB2").html(d);
				}
			});
		}
	}
	//var k = 0;
	var dest = document.getElementById('LstB1');
	function addUser() {
		var src = document.getElementById('LstB2');
		var dest = document.getElementById('LstB1');
		k = dest.options.length;
		for (var i = 0; i < src.options.length; i++) {
			
			if (src.options[i].selected) {
				
					var exist = false;
					for (var j = 0; j < dest.options.length; j++) {
						if (dest.options[j].value == src.options[i].value) {
							exist = true;
							break;
						}
					}
					if (!exist) {
						//if (k >= 1)
						//{
						//	alert("对不起，只能添加一份试卷");
						//	return;
						//}
						var opt = document.createElement('OPTION');
						opt.value = src.options[i].value;
						opt.text = src.options[i].text;
						opt.selected = true;
						dest.options.add(opt);
						k++;
					}
				}
			}
		
	}
	function delUser() {
		var dest = document.getElementById('LstB1');

		for (var i = dest.options.length - 1; i >= 0; i--) {
			if (dest.options[i].selected) {
				dest.options[i] = null;
				//	k--;
			}
		}
	}

</script>
<%
    if (!isLoadPage) return;
if (!KSCMS.S("do").Equals("modify") && !KSCMS.S("do").Equals("add"))
	{
%>
 <form name="myform" action="<%=BasicField.GetUserUrl("teacher/TcHomeWork") %>" method="post" id="Form1" >
  <div class="t_tybox">
            <div class="tytitle"><h4>作业管理</h4>
                <%if(ispower){ %>
                <a href="<%=BasicField.GetUserUrl("teacher/TcHomeWork","do-add,roomid-"+RoomID.ToString()) %>" class="addbtn">+添加作业</a>
               <%} %>
           	<a onclick="" href="<%=BasicField.GetUserUrl("teacher/TcClassRoom") %>" class="addbtn">返回</a>
            </div>
            <div class="clear blank10"></div>
			<div class="part_now" style="padding-left:20px">当前班级：<%=ClassRoomTitle %></div>
			<div class="clear blank10"></div>
          
            <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
              <tr align="center" class="title">             
				 <td width="6%">选择</td>
                 <td width="6%">状态</td>
                 <td width="20%">作业名称</td> 
				  <td width="40%">试卷信息</td>
                 <td width="12%">添加时间</td>
				   <td width="8%">附件</td>
                 <td width="10%">操作</td>
              </tr>  
        <%
				 int recordcount, pagecount;
					 int CurrPage = new BasicField().GetCurrPage;
					 int PageSize = 10;
					 string sqlParam = "KS_CosHomeWork a where a.userID=" + UserManage.GetUserInfo().UserID + "";
            if (RoomID != 0)
            {
                sqlParam += " and ClassRoomID=" + RoomID;
            }
			using (DataTable dt = DataFactory.GetPage("a.*", sqlParam, "WorkID", "order by  a.adddate desc", CurrPage, PageSize, out recordcount, out pagecount))
			{
				if (dt.Rows.Count > 0)
				{
					int i = (CurrPage - 1) * PageSize + 1;

					foreach (DataRow dr in dt.Rows)
					{
						KSCMS.W("<TR class=\"tdbg sort bar\"> <td class=\"splittd\" align=\"center\"><input class=\"checkbtn\" type=\"checkbox\" name=\"WorkID\" value=\"" + dr["workid"].ToString() + "\" /></td>" +
                            "<td class=\"Ctd\" align=\"center\">" + (ispower ? (" <a href=\"" + BasicField.GetUserUrl("teacher/TcHomeWork", "do-IsPublic,workid-" + dr["workid"].ToString() + ",roomid-" + RoomID.ToString()) + "\" >" + (Utils.StrToInt(dr["verify"]) == 1 ? "发布" : "未发布") + "</a>") : (Utils.StrToInt(dr["verify"]) == 1 ? "发布" : "未发布")) + "</td>" +
		"<td class=\"tag_left lefticon\"> <font class=\"fonths\">" + dr["title"].ToString() + "</font></td>" +
			"<td class=\"tag_left lefticon\">" );
						if (!string.IsNullOrEmpty(dr["examPleID"].ToString()))
			{
				using (DataTable dts = DataFactory.GetDataTable("select title,id,testhits from KS_sj where id in(" + dr["examPleID"].ToString() + ")"))
				{
					if(dts.Rows.Count>0)
					{
						foreach(DataRow drs in dts.Rows)
						{
							KSCMS.W("<div style='margin-top:7px'>"+
                                "<span>" + (ispower ? ("<a target='_blank' href=\"" + BasicField.GetRewriteUrl("examview", Utils.StrToInt(drs["id"].ToString())) + "\">" + drs["title"].ToString() + "</a>") : drs["title"].ToString()) + "</span>" +
								"<span>（"+drs["testhits"].ToString()+"人参与）</span>");
                            if (ispower)
                            {
                                KSCMS.W("<span style='float:right'><a  href=\"" + BasicField.GetUserUrl("teacher/TcHWSjScore", "sjid-" + drs["id"].ToString()) + " \" >批改</a></span>");
                            }
                            KSCMS.W("</div>");
						}
					}
				}
            }
                        KSCMS.W("</td>" +
                        "<td width=\"160\">" + Convert.ToDateTime(dr["adddate"].ToString()).ToString("yyyy-MM-dd") + "</td>" +
                        "<td align=\"center\" width=\"160\"><div class=\"gl_btn one_width\"><span class=\"span\"><a title=\"下载\" target='_blank'  href=\"" + dr["fjurl"].ToString() + "\">" + (string.IsNullOrEmpty(dr["fjurl"].ToString()) ? "" : "<i class=\"iconfont\" style=\"font-size:24px;display:block\">&#xe604;</i>下载") + " </a></span></div></td>");
                        if (ispower)
                        {
                            KSCMS.W("<td><div class=\"gl_btn\">" +
                                    "<span class=\"span4\" style=\"width:50%\"><a title=\"编辑\" class=\"edit\" href=\"" + BasicField.GetUserUrl("teacher/tchomework", "do-modify,WorkID-" + dr["WorkID"].ToString() + ",roomid-" + RoomID + "") + "\"> <i class=\"icon iconfont icon-xiazai48\"></i>编辑</a></span>" +
                                    "<span class=\"span5\" style=\"width:50%\"><a onclick=\"return(confirm(确定删除该作业吗?));\" title=\"删除\" class=\"delete\" href=\"" + BasicField.GetUserUrl("teacher/tchomework", "do-del,WorkID-" + dr["WorkID"].ToString()) + ",roomid-" + RoomID + "\"><i class=\"iconfont icon-lajitong-copy\"></i>删除</a></span></div></td>");
                        }
                        else
                        {
                            KSCMS.W("<td class=\"splittd\" align=\"center\">无操作权限</td>");
                        }
                        KSCMS.W("</div>");
                        i++;
                    }
                }
				else
				{
					KSCMS.W("<tr class=\"tdbg\"><td class=\"Ctd\" style=\"text-align:center\" colspan=\"10\" ><div class=\"empty\">暂未添加任何作业</div></td> </tr> ");
				}
			}
			 %>
           </table>
       <%if(ispower){ %> 
     <div class="cz_btn" style="margin-top:10px">
		  <input type="hidden" value="<%=RoomID %>" name="RoomID" />
		 <input type="hidden" value="del" name="do" />
        <span><input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);"/>全选</span>
        <span><input type="submit" class="button" value="批量删除" onclick="return (CheckIds('del'));"></span>
     </div>
      <%} %>
      <div class="clear"></div>
            <div class="fy_box" >
			 <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
         %>
            </div>
            <div class="clearfix"></div>
		</div>
	 	</form>
	 	   
        <div >
        <script type="text/javascript">
            showtips(' <span><strong>操作说明：</strong><br />未发布代表前台是看不到</span>的。');
		</script>
		</div>
	<%}else{ %>
		<script src="/ks_inc/DatePicker/WdatePicker.js"></script>
		  <form name="myform" action="<%=BasicField.GetUserUrl("teacher/TcHomeWork","do-"+KSCMS.S("do")) %>" method="post" id="myform" >
	   <div class="t_tybox">
         <div class="ty_title">添加作业</div>
         <div class="tips" style="padding:10px 0px; font-size:14px">
        <span style="margin-left:20px">班级名称：<%=ClassRoomTitle %></span></div>
		<input name="action" type="text" value="save" style="display:none" />
		<input name="roomid" type="text" value="<%=RoomID %>" style="display:none" />
		<input name="workid" type="text" value="<%=KSCMS.S("workid") %>" style="display:none" />
	 <input name="coursetype" type="text" value="<%=type.ToString() %>" id="coursetype" style="display:none" />
         <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" class="border"> 
			<tr>
				<td align="right" class="lefttd" height="30" width="120"><strong>作业名称：</strong></td>
				<td class="tag_left"><input name="TxtName" type="text" value="<%=string.IsNullOrEmpty(GetParam("title"))? Utils.GetDate()+"作业":GetParam("title") %>" id="TxtName" class="textbox" style="width:300px;" />
					<font color=red >*</font>
				</td>
			</tr>
		 <tr>
			<td align="right" class="lefttd" height="30" ><strong>上传作业附件：</strong></td>
			<td class="tag_left">
			  <input id="DefaultFile" name="DefaultFile"  style="width:300px;float:left" Class="textbox" type="text" value="<%=GetParam("FjUrl") %>" >
			      <%=Kesion.APPCode.UploadAPI.EchoUpload("courseZLFile","DefaultFile") %> 上传PDF格式文件支持在线图文浏览    
			</td>
		 </tr>
		  <tr>
				<td align="right" class="lefttd" height="30" ><strong>是否绑定试卷：</strong></td>
				<td class="tag_left">
					<table id="RadioButtonList3" onclick="showwatermarkarea()" border="0" style="height:24px;">
		<tr>
			<td class="bo-min"><input id="RadioButtonList3_0"  class="radiobtn" type="radio" name="RadioButtonList3" value="0" <%=Utils.StrToInt(GetParam("IsExam"))==0?"checked":"" %> />无</td>
			<td class="bo-min"><input id="RadioButtonList3_1" class="radiobtn" style="margin-left:10px" type="radio" name="RadioButtonList3" value="2" <%=GetParam("IsExam")=="2"?"checked":"" %> />指定试卷ID</td>
		</tr>
	</table>
				</td>
			</tr>
			<tbody id="watermark0" runat="server" style="display: none">
				<tr>
					<td align="right" class="lefttd"><strong>试卷栏目：</strong></td>
					<td class="righttd">
					<select size="4" name="ListSjClass" multiple="multiple" id="ListSjClass" style="height:300px;width:150px;float:left;height:200px !important; background:#fff"></select>

						<a class="textarea_min" href="javascript:zoomtextarea(-5,'ListSjClass');"></a>
						<a class="textarea_max" href="javascript:zoomtextarea(5,'ListSjClass');"></a>

					</td>
				</tr>
			</tbody>
			 <tbody id="watermark2"  style="display:none" >
            <tr>
            <td align="right" class="lefttd" height="30"></td>
            <td class="tag_left" valign="top">
			 <div class="clear blank10"></div>
         	 <table border=0>
			 	<tr>
				
					<td><span style="float:left; line-height:40px">搜索试卷：</span><input name="TxtSJKey" type="text" id="TxtSJKey" class="textbox" style="width:160px;" style="float:left;" />
		<input type="button" value="搜索" class="button" onclick="searchSJ()" class="button" style="margin-left: 10px; border-radius: 5px; border: 1px solid #dce2e4;" />
<span class="tips">自己发布的试卷</span>
				    <div class="clear"></div>
				   </td>
			   </tr>
			 </table>  
            <table border=0>
             <tr>
	            <td style="width:300px">
				<span style="text-align:left; display:block;height:30px; line-height:30px;">指定试卷id：</span>
				<div class="clear"></div>
             <select size="4" name="LstB2" multiple="multiple" id="LstB2" style="height:300px;width:200px;float: left; height: 200px !important; background: #fff">
	</select>
	</td>
                  <td><p><input type="button" value=" > " onclick="addUser()" class="button" /></p>
					<br />
			 		<p><input type="button" value=" < " onclick="delUser()" class="button" /></p>
                  </td>
	            <td>
               <span style="text-align:left; display:block;height:30px; line-height:30px; padding-left:15px;">指定试卷如下：</span>
               <div class="clear"></div>
              <select size="4" name="LstB1" multiple="multiple" id="LstB1" style="height:300px;width:200px;float: left; height: 200px !important; background: #fff">
							<%
	  if (!string.IsNullOrEmpty(GetParam("examPleID")))
	  {
		  StringBuilder sb = new StringBuilder();
		  string sql2 = "select ID,Title from KS_SJ where id in(" + GetParam("examPleID") + ")";
		  using (DataTable dt2 = DataFactory.GetDataTable(sql2))
		  {
			  if (dt2.Rows.Count > 0)
			  {
				  foreach (DataRow dr2 in dt2.Rows)
				  {
					  sb.AppendFormat("<option value=\"{1}\" selected>{0}</option>", dr2["title"].ToString(), dr2["id"].ToString());
				  }
			  }
		  }
		  KSCMS.W(sb.ToString());
	  }
		   
		    %>
	</select>
				</td>
             </tr>
			

            </table>
            </td>
            </tr>
			  <tr>
				<td align="right" class="lefttd" height="30" ><strong>是否自动批阅：</strong></td>
				<td class="tag_left">
					<table id="Table1" border="0" style="height:24px;">
		<tr>
			<td><input id="Radio1" type="radio" name="RadioButtonList4" value="0" <%=Utils.StrToInt(GetParam("IsAuto"))==0?"checked":"" %> /><label for="RadioButtonList4_0">手动批阅</label></td>
			<td><input id="Radio2" type="radio" name="RadioButtonList4" value="1" <%=GetParam("IsAuto")=="1"?"checked":"" %> /><label for="RadioButtonList4_1">系统自动批阅</label></td>
		</tr>
	</table>
				</td>
			</tr>
			<tr>
			 <td align="right" class="lefttd" height="30" style="width: 102px"><strong>做题截止时间：</strong></td>
			 <td class="tag_left">
			  <input name="EndTime" type="text" id="EndTime" value="<%=GetParam("endtime") %>" class="textbox  Wdate" onclick="WdatePicker({dateFmt:&#39;yyyy-MM-dd HH:mm:ss&#39;,minDate:&#39;%y-%M-%d&#39;});" /> 
			 </td>
			</tr>

           </tbody>
		 <tr>
			 <td align="right" class="lefttd" height="30" ><strong>作业内容：</strong></td>
			 <td class="tag_left"><textarea name="TxtIntro" rows="2" cols="20" id="TxtIntro" style="height:200px;width:90%;"><%=GetParam("Content") %></textarea>
			    <%Kesion.APPCode.EditorAPI.EchoHead(); %>
				<% Kesion.APPCode.EditorAPI.EchoEditor("editor", "TxtIntro", "Basic",0,false,true,true,false);%>
			 </td>
		 </tr>
		<tr>
			 <td align="right" class="lefttd" height="30" style="width: 102px"><strong>发布状态：</strong></td>
			 <td class="tag_left">
				 <table id="RdbVerify" border="0" style="height:24px;width:190px;">
		<tr>
			<td class="bo-min"><input id="RdbVerify_0" type="radio" class="radiobtn" name="RdbVerify" value="1" <%=GetParam("verify")=="1"?"checked":"" %> />发布</td>
			<td class="bo-min"><input id="RdbVerify_1" type="radio"  class="radiobtn" name="RdbVerify" value="0" <%=Utils.StrToInt(GetParam("verify"))==0?"checked":"" %> />未发布</td>
		</tr>
	</table>
			 </td>
		 </tr>
         <%if (DataFactory.GetOnlyValue("select top 1 verify from ks_weixinuser where userid=" + schoolID + "")=="1") { %>
             <tr>
			 <td align="right" class="lefttd" height="30" style="width: 102px"><strong>是否微信提醒：</strong></td>
			 <td class="tag_left">
				 <table id="IsWXNotice" border="0" style="height:24px;width:190px;">
		<tr>
            <td class="bo-min"><input id="IsWXNotice_1" type="radio"  class="radiobtn" name="IsWXNotice" value="0" <%=Utils.StrToInt(GetParam("IsWXNotice")) == 0 ? "checked" : "" %> />否</td>
			<td class="bo-min"><input id="IsWXNotice_0" type="radio" class="radiobtn" name="IsWXNotice" value="1" <%=GetParam("IsWXNotice") == "1" ? "checked" : "" %> />是</td>
		</tr>
	</table>
			 </td>
		 </tr>
             <%} %>

       </table>
       <div class="clear blank10"></div>
       <div class="cz_btn nofloat" style="padding-left:162px;">
         <span><input type="submit" name="Button2" value="确定保存" onclick="return (CheckForm());" id="Button2" class="button" /></span>
           <span><input type="button" class="button" onclick="window.history.go(-1);"value=" 返 回 "></span>
       </div>
		</div>
		</form>
		<script>
			function CheckForm() {
				if (jQuery('#TxtName').val() == '') {
					KesionJS.Alert('作业名称必须输入!', "jQuery('#TxtName').focus()");
					return false;
                }

                var IsExam = jQuery("#RadioButtonList3 :radio[checked]").val();
                if (IsExam == '2') {
                    if (jQuery('#EndTime').val() == '') {
					KesionJS.Alert('对不起,完成有效时限不能为空!', "jQuery('#EndTime').focus()");
					return false;
                }
                }
                return true;
			}
	</script>
	<%} %>