<%@ Page Title="" Language="C#"  MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Admin_UserImport" CodeBehind="KS.UserImport.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
      <div id="manage_top" class="toptitle menu_top_fixed">
      	 <ul class="titleTab">
            <li><a href="KS.UserAdd.Aspx">新增用户</a></li>
            <li class="curr"><a href="KS.UserImport.Aspx">外部数据源批量导入</a></li>
          </ul>  
      </div>
      <div class="menu_top_fixed_height"></div>   
      <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>

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

              <div class="myTitle">第一步 请选择数据源</div>
              <table width="96%" align="center" border="0" cellpadding="0" cellspacing="0" 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="7" Selected="true" >外部CSV数据源</asp:ListItem>
                          </asp:DropDownList>
                        <br />
                      
                      </td>
                  </tr>
                  <tr>
                      <td class="lefttd" style="text-align: right;padding-top:35px;" valign="top">
                          <strong>选择csv文件：</strong></td>
                      <td class="righttd" text-align: left">
                         
                          <div id="excelstr" style="display: none;">
                              <table>
                                  <tr>
                                      <td width="120" style="padding-top:12px;">
                                       <%=Kesion.APPCode.UploadAPI.EchoUpload("uploadexcelfile",this.ConnStr.ClientID) %>
                                      </td>
                                      <td width="120">
                                       <input type="button" class="button" onclick="SelectFiles('<%=this.ConnStr.ClientID%>',0);" value="选择CSV文件" />
                                      </td>
                                      <td> <a href="/admin/user/用户导入示例.csv">下载导入示例</a></td>
                                  </tr>
                              </table>
                              <asp:TextBox ID="ConnStr" runat="server" style="color:#ccc;border:1px solid #ccc" Width="450px">/DBPath/数据库.mdb</asp:TextBox>
                             
                               
                          </div>
                          <br />
                          <div style="display:none">
                          <asp:Button ID="TextButton" runat="server" Text="测试数据源" CssClass="mt20 button button_on" CausesValidation="False" UseSubmitBehavior="False" />
                           </div>
                      </td>
                  </tr>
                  <tbody id="showtable">
                      <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">
                              <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 button_on" 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 />
              <asp:Button ID="Button2" CssClass="button" runat="server" Text="确定导入" OnClick="Button2_Click" />
          </asp:Panel>

      </div>


    <script type="text/javascript">

        function loadTable() {
            jQuery("#showtable").show();
            jQuery.get('KS.UserImport.aspx', { 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.UserImport.aspx', { 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('/DBPath/test.xls');
                break;
            case 6:
                $("#excelstr").hide();

                jQuery('#<%=this.ConnStr.ClientID %>').val('Data Source=完整数据库路径+名称;Provider=Microsoft.JET.OLEDB.4.0;');
                break;
            case 7:
                $("#excelstr").show();

                jQuery('#<%=this.ConnStr.ClientID %>').val('/DBPath/test.csv');
                    break;
            }
        }

        changeconnstr();


    </script>


</asp:Content>

