<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Course.Admin.Course.KS_CourseImport" CodeBehind="KS.CosImport.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="Server">
    <KS:TopNav ID="TopNav1" Text="点播课程批量导入操作" runat="server" />
    <div class="content-area">
        <style type="text/css">
            .graph {
                width: 450px;
                border: 1px solid #9bdf70;
                height: 25px;
            }

            #bar {
                display: block;
                background: #FFE7F4;
                float: left;
                height: 100%;
                text-align: center;
            }

            #barNum {
                position: absolute;
            }
        </style>

        <script type="text/javascript">

            function loadTable() {
                jQuery("#showtable").show();

                jQuery.get('KS.CosImport.aspx?costype=<%=CosType%>', { rnd: Math.random(), action: 'loadTable', lst: jQuery('#<%=this.LabelDataSource.ClientID %>>option:selected').val(), cstr: jQuery('#<%=this.ConnStr.ClientID %>').val() }, function (s) {
                    jQuery("#tablename").empty().append(s);
                });
            }
            function checkdatasource() {

                jQuery.get('KS.CosImport.aspx?costype=<%=CosType%>', { action: 'CheckDataSource', lst: jQuery('#<%=this.LabelDataSource.ClientID %>>option:selected').val(), cstr: jQuery('#<%=this.ConnStr.ClientID %>').val() }, function (s) {
                    if (s == 'true') {
                        KesionJS.AlertByTime(1, '恭喜，数据源连接测试通过!', 2);
                        loadTable();
                    }
                    else {
                        KesionJS.AlertByTime(2, '连接出错，请检查连接字符串!', 2);
                    }
                    return false;
                });
            }

            function changeconnstr() {
                switch (parseInt(jQuery('#<%=this.LabelDataSource.ClientID %>>option:selected').val())) {
            case 1:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('/DBPath/数据库.mdb');
                break;
            case 2:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('User ID=sa; Password=989066; Initial Catalog=kesionicms; server=(local);');
                break;
            case 3:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('DSN=数据源名;UID=用户名;PWD=密码');
                break;
            case 4:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('Data Source=数据源名;User Id=用户名;Password=密码;Integrated Security=no;');
                break;
            case 5:
                $("#excelstr").show();

                jQuery('#<%=this.ConnStr.ClientID %>').val('/cc.xls');
                break;
            case 6:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('Data Source=完整数据库路径+名称;Provider=Microsoft.JET.OLEDB.4.0;');
                        break;
                }
            }
        </script>
        <div class="tabs_header longTabs">
            <ul class="tabs">
                <li class="active"><a href="KS.CosImport.aspx"><span>导入课程</span></a></li>
                <li><a href="KS.CosAddPeriod.aspx?costype=<%=CosType %>"><span>导入章节时</span></a></li>
                <li><a href="KS.CosDataImport.aspx?costype=<%=CosType %>"><span>导入资料</span></a></li>
            </ul>
        </div>
        <asp:Panel ID="top" runat="server" Width="100%">
            <div class="myTitle">第一步 请选择数据源</div>
            <table width="100%" border="0" cellpadding="1" cellspacing="1" class="CTable no-borderTable">
                <tr style="display:none">
                    <td class="lefttd" style="height: 30px; text-align: right">
                        <strong>数 据 源：</strong></td>
                    <td class="righttd" style="height: 30px; text-align: left">
                        <asp:DropDownList ID="LabelDataSource" runat="server">
                            <asp:ListItem Value="1">外部Access数据源</asp:ListItem>
                            <asp:ListItem Value="2">外部MS SQL数据源</asp:ListItem>
                            <asp:ListItem Value="3">外部ODBC数据源</asp:ListItem>
                            <asp:ListItem Value="4">外部Oracle数据源</asp:ListItem>
                            <asp:ListItem Value="5" Selected="true">外部Excel数据源</asp:ListItem>
                            <asp:ListItem Value="6">外部OLE数据源</asp:ListItem>
                        </asp:DropDownList>

                    </td>
                </tr>
                <tr>
                    <td class="lefttd" style="height: 30px; text-align: right">
                        <strong>连接字符串：</strong></td>
                    <td class="righttd" style="height: 30px; text-align: left">

                        <asp:TextBox ID="ConnStr" runat="server" Height="50px" TextMode="MultiLine" Width="450px">/cc.xls</asp:TextBox>

                        <div id="excelstr">
                            <input type="button" class="button" onclick="SelectFiles('<%=this.ConnStr.ClientID%>    ',0);" value="选择Excel文件" style="vertical-align: middle;" />
                            <div style="display: inline-block; width: 100px; height: 34px; vertical-align: middle;"><%=Kesion.APPCode.UploadAPI.EchoUpload("uploadexcelfile",this.ConnStr.ClientID) %></div>
                            <a href="../../admin/course/课程导入示例文档.xls" style="color: green">课程导入示例文档下载</a>
                        </div>
                        <br />
                        <asp:Button ID="TextButton" runat="server" Text="测试数据源" CssClass="button" CausesValidation="False" UseSubmitBehavior="False" />

                    </td>
                </tr>
                <tbody style="display: none;" id="showtable">
                    <tr>
                        <td class="lefttd" style="height: 30px; text-align: right"><strong>请选择要导入数据表：</strong></td>
                        <td class="righttd" style="height: 30px; text-align: left">
                            <select name="tablename" id="tablename"></select>
                        </td>
                    </tr>
                    <tr>
                        <td class="lefttd" style="height: 30px; text-align: right"></td>
                        <td class="righttd" style="height: 30px; text-align: left">
                            <asp:Button ID="Button1" runat="server" CssClass="button" OnClick="Button1_Click" Text="下一步" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </asp:Panel>



        <asp:Panel ID="list" runat="server" Width="100%">

            <asp:Label ID="Label1" runat="server" Text="Label" />
            <br />
            <div style="padding-left:200px">
            <asp:Button ID="Button2" CssClass="button button_on" runat="server" Text="确定导入" OnClick="Button2_Click" />
            </div>

        </asp:Panel>
    </div>
</asp:Content>

