在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
using System.Data.OleDb; using System.IO;
using java.io;
public partial class Modules_ClassHR_UplRecordList : System.Web.UI.Page { const string ROLEADMIN = "TechClass_ADM" ; --const定义常量字符串 #region Page_Load protected void Page_Load(object sender , EventArgs e) { this .Page.Title=System.Configuration.ConfigurationManager.AppSettings[ "WebSiteTitle" ].ToString(); if (!User.Identity.IsAuthenticated) string v_domin= " " ; string v_domainaccount = " " ; string v_empID = " " ; string systemid = ConfigurationManager.AppSettings[ "SystemID" ].ToString( ); if (!IsPostBack) { if ((Page.User.Identity.AuthenticationType.ToString() == "Negotiate" ) || (Page.User.Identity.AuthenticationType.ToString() == "NTLM" )) { if (Page.User.Identity.Name.IndexOf( '\\' ) < 1) v_domain = Page.User.Identity.Name.Split( '\\' )[0].ToString(); } else { v_empID = Page.User.Identity.Name; } if (v_empID == " " ) if (!Coeno.Main.Roles.IsUserInRole(systemid, v_empID, ROLEADMIN) && !Coeno.Main.Roles.IsUserInRole(systemid, v_empID, TechClass_HR)) txtCurrentEmpID.Text = v_empID; } } #endregion protected void BtnUpload_Click(object sender, EventArgs e) { HttpPostedFile file = uploadFile.PostedFile; { lblMsg.Text= " 请选择一个要上传的文件!" ; lblMsg.ForeColor=System.Drawing.Color.Red; return ; } if (Path.GetExtension(file.FileName) != ".xls" ) { lblMsg.Text= " 请选择一个.xls为后缀的文件" ; lblMsg.ForeColor=System.Drawing.Color.Red; return; } string filename=txtCurrentEmpID.Text+System.DateTime.NowToString( "yyyyMMddHHmmss" )+Path.GetExtension(fileName); string filePath = "~/UploadFiles/HRUplEmpQuery/" + filename; file.SaveAs(Server.MapPath(filePath)); OleDbConnection OleConn = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(filePath) + ";Extended Properties=\"Excel 8.0;IMEX=1;\";" ); { OleDbCommand OleDbCmd = new OleDbCommand( "SELECT * FROM [Sheet1$]", OleConn ); OleDbCommand OleDbCmdc = new OleDbCommand( "SELECT count(*) FROM [Sheet1$]" , OleConn); lblGUID.Text = " " ; dt.Columns.Add( "PeriodID" , typeof(string));//1 DataRow dr; { dr = dt.NewRow(); dr[0] = lblGUID.Text; dr[1] = odr[0].ToString(); dr[2] = odr[1].ToString(); dr[3] = odr[2].ToString(); dr[4] = odr[3].ToString().Substring(0,2); dr[6] = odr[4].ToString(); dt.Rows.Add(dr); } odr.Close(); //修改 if (dt.Rows.Count > 0) { string returnstatus = " " ; int ecode = Coeno.TechClass.ClassHR.RecordInsByExcel(dt); if (ecode == 0) else gvDataBind(lblGUID.Text); if (returnstatus == "1" ) { pnlRecordList.Visible = true ; lblMsg.Text = "共上傳:" + Num + "筆,成功:" + NumOK + "筆,失敗:" + NumErr + "筆" ; } else { pnlRecordList.Visible = false ; lblMsg.Text =returnmsg; } } } catch(Exception ex) { pnlRecordList.Visible = false ; } pnlRecordList.Visible = true ; } protected void gvDataBind(string v_GUID) { gvRecordList.DataSource = null ; DataTable dt = Coeno.TechClass.ClassHR.QueryRecordProcList(lblGUID.Text); if (dt.Rows.Count > 0) { gvRecordList.DataSource = dt; gvRecordList.DataBind(); } }
}
|
请发表评论