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



<!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 %>
    <style type="text/css">
        #TabCourse td {
            min-width: 30px;
        }
    </style>
   

    <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 sZ = selectid.split("_");
                if (sZ.length == 1) {
                    return;
                }
                else {
                    selectid = sZ[1];
                }

                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($(this).attr("ID"));
                }
            });
        });

        function jsSelect(sID) {
            //alert(bSelect);
            var skytid = $("#drpSkyTID").val();
            if (bSelect == false) {
                //获取那些可以交换
                if ($("#" + sID).html() == "") {
                    $("#" + sID).removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");
                    return;
                }

                bSelect = true;
                lastID = sID;
                $.ajax({
                    type: "POST",
                    url: "autocoursemainajax.aspx",
                    data: "id=3&para=" + sID + "&skytid=" + skytid,
                    success: function (msg) {
                        //alert(msg);
                        var sZ = sID.split("_");
                        //所有子项都让他可以选择
                        $("#" + sZ[0]).children().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");
                console.debug(sClass)
                if (sClass == "tabmanagertrF tabmanagertrC tabmanagertrB") {

                    //交换内容
                    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);

                    var sZ = sID.split("_");
                    //所有子项都让他可以选择
                    $("#" + sZ[0]).children().removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");

                    //提交到数据库

                    $.ajax({
                        type: "POST",
                        url: "autocoursemainajax.aspx",
                        data: "id=4&para=" + lastID + "&para1=" + sID + "&skytid=" + skytid,
                        success: function (msg) {
                            if (msg == "0") {
                                //alert("恭喜您，更换课程成功！");
                            }
                            else {
                                alert("对不起，更换课程失败！");
                            }
                        }
                    });


                }
                else {
                    var sZ = sID.split("_");
                    //所有子项都让他可以选择
                    $("#" + sZ[0]).children().removeClass("tabmanagertrB").removeClass("tabmanagertrC").addClass("tabmanagertrA");
                    sZ = lastID.split("_");
                    $("#" + sZ[0]).children().removeClass("tabmanagertrB").removeClass("tabmanagertrC").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">
                        全校课程表
                    </div>
                </div>
            </div>
            <div class="divTbgF">
            </div>
            <div class="divTNavBG" id="topURL">
                <ul id="topURLul">
                    <li class="divURLed" id="div1">
                        <div>
                            <img src="../style/default/images/mini_icons_046.gif" width="10" height="10" />
                            基本信息
                        </div>
                    </li>
                </ul>
            </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">
                                    <asp:DropDownList ID="drpSkyTID" runat="server" AutoPostBack="True" Enabled="false"
                                        OnSelectedIndexChanged="drpSkyTID_SelectedIndexChanged">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr class="tablisttr">
                                <td class="tablisttitle" width="100">手动排课</td>
                                <td class="tabmanagertr" align="left">如果您想手动排课，请点击想要调整课程安排的课程，则选中的自动变成<font color="#FF0000">红色课程</font>效果。然后可以交换的课程自动变成<font color="#00FF00">绿色课程</font>，点击一个您满意的<font color="#00FF00">绿色课程</font>即可更换。</td>
                            </tr>

                        </table>
                        <div style="margin: 0px;">
                            <div  class="coursedivinfo">
                                <asp:Table ID="TabCourse" runat="server" CssClass="tablist" Width="100%"
                                    CellPadding="0" CellSpacing="1">
                                </asp:Table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <asp:Literal ID="litJavaScript" runat="server"></asp:Literal>

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