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



<!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" />
    <%=ImportScriptStr %>
    <asp:Literal ID="litregscript" runat="server" Text=""></asp:Literal><link href="../style/default/style.css" rel="stylesheet" type="text/css" />
    
   
    <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=1&para=" + sID + "&skytid=" + skytid,
                    success: function (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");
                if (sClass == "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=2&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");

                }
            }

        }

        function AutoSave() {
            var info;
            info = "您是要把临时的排课信息更新到正式课程表中吗？请注意该操作是不可逆的，一旦保存，本学期的排课信息将全部更新！";
            var bstate = confirm(info);
            return bstate;
        }
    </script>

    <style type="text/css">
#TabCourse td {
	min-width:30px;
}
</style>



</head>
<body onload="win_onLoad();">
    <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" style="width: 90%">
                                    <asp:DropDownList ID="drpSkyTID" runat="server" AutoPostBack="True"
                                        OnSelectedIndexChanged="drpSkyTID_SelectedIndexChanged">
                                    </asp:DropDownList>
                                    发布按钮在页面底部，请点击滚动条</td>
                            </tr>
                            
                        </table><div style="margin: 0px;">
                                        <div style="width: 100%; height: 500px; overflow: auto;">
                                            <asp:Table ID="TabCourse" runat="server" CssClass="tablist"
                                                CellPadding="0" CellSpacing="1">
                                            </asp:Table>
                                        </div>
                                    </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="divSave">
            <asp:Button ID="btnSubmit" runat="server" Text="正式发布(S)" CssClass="SkyButtonFocus"
                OnClick="btnSubmit_Click" AccessKey="S" CommandName="save"></asp:Button>
        </div>
         <asp:Literal ID="litJavaScript" runat="server"></asp:Literal>

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