<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="viewclassadmincourse.aspx.cs" Inherits="Us.Web.admin.autocourse.viewclassadmincourse" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>班级课程表</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8,chrome=1" />
    <asp:Literal ID="litregscript" runat="server" Text=""></asp:Literal><link href="../style/default/style.css" rel="stylesheet" type="text/css" />
<%=ImportScriptStr %>

   
    <script language="javascript" type="text/javascript">
        var bSelect = false;
        var lastID;
        
        $(document).ready(function() {
            $("#TabCourse tr td").click(function() {
                var selectid = $(this).attr("id");
                var s1 = selectid.substring(0, 1);
                var s2 = selectid.substring(1, 2);
                if (s1 == "0" || s2 == "0") {

                }
                else {
                    var myclass = "tabmanagertrB";
                    if ($(this).attr("class") == myclass) {
                        $(this).removeClass("tabmanagertrB").addClass("tabmanagertrA");
                        //$(this).html("");
                    }
                    else {
                        $(this).removeClass("tabmanagertrA").addClass("tabmanagertrB");
                        //$(this).html("不排");
                    }
                    //jsSelect();
                    jsSelect($(this).attr("ID"));

                }
            });
        });


        function jsSelect(sID) {

            var skytid = $("#drpSkyTID").val();
            var sClassID = $("#txtSkyCID").val();
            var urlData = "";
            if (bSelect == false) {

                if ($("#" + sID).html() == "") {
                    $("#" + sID).removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");
                    return;
                }

                bSelect = true;
                lastID = sID;

                urlData = "id=5&para=" + sClassID + "_" + sID + "&skytid=" + skytid;
                //alert(urlData);
                $.ajax({
                    type: "POST",
                    url: "autocoursemainajax.aspx",
                    data: urlData,
                    success: function(msg) {
                        //alert(msg);
                        var sZ = sID.split("_");
                        //alert(sID);
                        //所有子项都让他可以选择
                        $("#TabCourse tr td[class=tabmanagertrA]").removeClass("tabmanagertrB").removeClass("tabmanagertrA").addClass("tabmanagertrC");
                        //这些是不能更换的
                        $(msg).removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");
                        //这个是选中的
                        $("#" + sID).removeClass("tabmanagertrA").removeClass("tabmanagertrC").addClass("tabmanagertrB");
                        //这个是标题
                        $("#" + sZ[0] + "_00").removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");
                    }
                });
            }
            else {
                bSelect = false;
            }

            //选择了
            if (bSelect == false) {
                var sClass = $("#" + sID).attr("class");
                //alert(sClass);
                if (sClass == "tabmanagertrC tabmanagertrB") {

                    

                   
                    //提交到数据库
                    urlData = "id=6&para=" + sClassID+"_"+lastID + "&para1=" + sID + "&skytid=" + skytid;
                    //alert(urlData);
                    $.ajax({
                        type: "POST",
                        url: "autocoursemainajax.aspx",
                        data: urlData,
                        success: function(msg) {
                            if (msg == "0") {
                                //alert("恭喜您，更换课程成功！");
                                //交换内容
                                var sValue = $("#" + lastID).html();
                                $("#" + lastID).html($("#" + sID).html());
                                $("#" + sID).html(sValue);

                                //交换数据
                                sValue = $("#" + lastID).attr("title");
                                $("#" + lastID).attr("title", $("#" + sID).attr("title"));
                                $("#" + sID).attr("title", sValue);
                            }
                            else {
                                alert("对不起，更换课程失败！");
                            }
                        }
                    });

                    //所有子项都让他可以选择
                    $("#TabCourse tr td[class=tabmanagertrB]").removeClass("tabmanagertrB").removeClass("tabmanagertrC").removeClass("tabmanagertrA").addClass("tabmanagertrA");
                    $("#TabCourse tr td[class=tabmanagertrC]").removeClass("tabmanagertrB").removeClass("tabmanagertrC").removeClass("tabmanagertrA").addClass("tabmanagertrA");
                    $("#TabCourse tr td[class=tabmanagertrC tabmanagertrB]").removeClass("tabmanagertrB").removeClass("tabmanagertrC").removeClass("tabmanagertrA").addClass("tabmanagertrA");
                }
                else {
                    var sZ = sID.split("_");
                    //所有子项都让他可以选择
                    $("#TabCourse tr td[class=tabmanagertrB]").removeClass("tabmanagertrB").removeClass("tabmanagertrC").removeClass("tabmanagertrA").addClass("tabmanagertrA");
                    $("#TabCourse tr td[class=tabmanagertrC]").removeClass("tabmanagertrB").removeClass("tabmanagertrC").removeClass("tabmanagertrA").addClass("tabmanagertrA");

                }
            }

        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    
    
    <div id="tbMain">
        <div class="divTbg">
            <div class="divTbgL">
            </div>
            <div class="divTbgInfo">
                <div class="divTbgTitle">
                    <asp:Literal ID="litTitle" runat="server"></asp:Literal>课程表</div>
            </div>
        </div>
        <div class="divTbgF">
        </div>
        
        <div id="mypanel">
            <div class="divInfoContext">
                <div class="divInfo">
                    <div class="divInfoblack">
                        <div class="divInfoTopList">
                            <div class="listLeft">
                                <div class="navtitle">
                                    班级课程表</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="divInfo">
                    <table width="100%" border="0" cellpadding="0" cellspacing="1" class="tablist" id="mainlist">
                        <tr class="tablisttr">
                            <td width="100" class="tablisttitle">
                                选择学期                            </td>
                            <td class="tabmanagertr" align="left" style="width:40%">
                                <asp:DropDownList ID="drpSkyTID" runat="server" AutoPostBack="True" 
                                    onselectedindexchanged="drpSkyTID_SelectedIndexChanged">                                </asp:DropDownList>
                                <span style="display:none"><asp:TextBox runat="server" ID="txtSkyCID"></asp:TextBox></span>                                </td>
                                <td width="100" class="tablisttitle">
                                 
                                导出数据</td>
                            
                            <td class="tabmanagertr" align="left" style="width:40%">
                                <p id="searchSubmit">
                                <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="导出数据" 
                                        CssClass="SkyButtonFocus" Width="82px" />                                </p>                            </td>
                        </tr>
                        <tr class="tablisttr">
                          <td class="tablisttitle">手动排课</td>
                          <td colspan="3" align="left" class="tabmanagertr" style="width:40%">如果您想手动排课，请点击想要调整课程安排的课程，则选中的自动变成<font color="#FF0000">红色课程</font>效果。然后可以交换的课程自动变成<font color="#00FF00">绿色课程</font>，点击一个您满意的<font color="#00FF00">绿色课程</font>即可更换。</td>
                        </tr>
                        <tr class="tablisttr">
                            <td colspan="4">
                                <div style="margin:5px;">
                                <div  class="coursedivinfo1">
                                    <asp:Table ID="TabCourse" runat="server" CssClass="tablist" Width="100%" 
                                        CellPadding="0" CellSpacing="1"></asp:Table>
                                </div>   </div></td>
                        </tr>
                    </table>
              </div>
            </div>
        </div>
    </div>

    </form>
</body>
</html>
