Esempio n. 1
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnImport_Click(object sender, EventArgs e)
        {
            string strFilePath = ViewState["FilePath"] as String;

            if (string.IsNullOrEmpty(strFilePath))
            {
                ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Error", "alert('请先上传需要导入的文件!')", true);
                return;
            }
            try
            {
                //导入
                EmployeeCheckInBLL mEmployeeCheckInBLL = new EmployeeCheckInBLL();
                DataTable          dtError             = mEmployeeCheckInBLL.Import(strFilePath);
                this.Bind(1);
                if (dtError.Rows.Count <= 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Success", "alert('导入成功!')", true);
                }
                else
                {
                    //Cache mCache = new Cache(this.UserInfo == null ? this.SystemAdminInfo.Account : this.UserInfo.ADAccount, (this.UserInfo == null ? this.SystemAdminInfo.SiteID : this.UserInfo.SiteID) + "dtError");
                    //mCache.SetCache(dtError);
                    SessionHelper.Set(HttpContext.Current, TypeManager.SESSIONKEY_ImpErrCheckIn, dtError);
                    ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "myScript", "importComplete();", true);
                    ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Success", "alert('部分导入成功,导入失败记录见文件')", true);
                }
            }
            catch (Exception ex)
            {
                var sErr = string.Format("alert(\"导入失败!{0}\")", ex.Message);
                sErr = sErr.Replace("\r\n", "");
                ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "Error", sErr, true);
            }
            finally
            {
                ViewState["FilePath"] = null;
            }
        }