标签:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="new_hosiptalmsysuser_importData.aspx.cs" Inherits="Saleto_new_hosiptalmsysuser_importData" %> <!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 runat="server"> <title> <asp:Literal ID="lblTitle" Text="医院对应代表关联数据导入" runat="server"></asp:Literal></title> <base target="_self" /> <link id="Link1" rel="stylesheet" href="../css/jquery-ui-all.css.aspx" /> <link id="Link2" rel="stylesheet" href="../css/global.css.aspx" /> <script type="text/javascript" src="../js/common/common.js.aspx"></script> <script type="text/javascript" src="../js/common/jquery-ui-all.js.aspx"></script> </head> <body> <form id="form1" runat="server"> <input id="hidMainId" runat="server" type="hidden" /> <div> <table align="center" width="98%" class="query"> <tr> <td class="dialog-header" colspan="2"> <asp:Label ID="lblQueryName" runat="server" Text="医院对应代表关联数据导入"></asp:Label> </td> </tr> <tr> <td> <asp:Label ID="Label7" runat="server" Text="选择导入文件路径:" CssClass="label" ForeColor="Black"></asp:Label> </td> <td style="width: 480px;"> <asp:FileUpload ID="FileUpload1" runat="server" CssClass="file" Width="100%" /> </td> </tr> <tr> <td style="text-align: right; margin-right: 2.5%" colspan="2"> <asp:Button ID="btnImport" runat="server" Text="导 入 " CssClass="button" OnClick="btnImport_Click" /> </td> </tr> <tr> <td colspan="2" style="height: 18px; border-top-width: thin; border-left-width: thin; border-left-color: black; border-bottom-width: thin; border-bottom-color: black; border-top-color: black; border-right-width: thin; border-right-color: black;"> <img id="progress" alt="progress" src="/rektecweb/_imgs/uploading.gif" width="0px" /> </td> </tr> <tr> <td colspan="2" style="height: 320px; text-align: left;"> <div style="width: 100%; height: 320px; overflow: scroll; border: 1px solid; background-color: White;"> <asp:Label ID="lblResult" runat="server" Height="100%" Width="100%"></asp:Label> </div> </td> </tr> </table> </div> </form> </body> </html>
using RekTec.Crm.Biz.Saleto; using RekTec.Crm.Common; using RekTec.Crm.Common.Web; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Saleto_new_hosiptalmsysuser_importData : PageBase { protected void Page_Load(object sender, EventArgs e) { //做导入动作时,将界面的按钮变灰 Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); ButtonOnClientClick(this.btnImport); // hidMainId.Value = Request["id"].ToString(); } void _log(string msg) { if (msg.StartsWith("[Error]")) this.lblResult.Text += "<font color=‘red‘>" + msg + "</font><br>"; else this.lblResult.Text += msg + "<br>"; } /// <summary> /// 导入事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnImport_Click(object sender, EventArgs e) { try { if (this.FileUpload1.HasFile) { string filename = Server.MapPath("../../../rektecweb/upload/") + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + FileUpload1.FileName; //获取文件后缀名 string type = filename.Substring(filename.LastIndexOf(".") + 1); if (type.ToLower() != "xls" && System.IO.Path.GetExtension(filename).ToLower() != ".xlsx") { this.ShowMessage("上传的文件格式不正确"); return; } FileUpload1.SaveAs(filename); Logging log = new Logging(); log.LogUI += new Logging.LogUIEvent(_log); new_hosiptalmsysuser_importCommand cmd = new new_hosiptalmsysuser_importCommand(); cmd.ImportIn(filename, log); } else { this.ShowMessage("请选择要上传的文件"); } } catch (Exception ex) { } } }
这种导入方式不需要在DataMapping.xml中进行配置
标签:
原文地址:http://www.cnblogs.com/hushzhang/p/5266646.html