private void BindDDL() { try { ServiceTypes type = new ServiceTypes(); DataSet ds = type.GetList(" Enabled=1 ORDER BY ServiceType ASC"); ddlServiceTypes.DataTextField = "ServiceType"; ddlServiceTypes.DataValueField = "ServiceType"; ddlServiceTypes.DataSource = ds; ddlServiceTypes.DataBind(); ddlServiceTypes.Items.Insert(0, new ListItem("All", "0")); } catch { } try { ContactRoles roles = new ContactRoles(); DataSet ds = roles.GetList(" Name <> 'Borrower' AND Name <> 'CoBorrower' ORDER BY [Name] ASC"); ddlContactRole.DataValueField = "ContactRoleID"; ddlContactRole.DataTextField = "Name"; ddlContactRole.DataSource = ds; ddlContactRole.DataBind(); } catch { } try { LPWeb.Model.Loans model = new LPWeb.Model.Loans(); Loans loans = new Loans(); model = loans.GetModel(CurrentFileId); if (model == null) { return; } //lbPointFile.Text lbProperty.Text = model.PropertyAddr + " " + model.PropertyCity + " " + model.PropertyState + " " + model.PropertyZip; } catch { } }
protected void btnImport_OnClick(object sender, EventArgs e) { dtErrorInfo.Columns.Add("RowNo"); dtErrorInfo.Columns.Add("BorrowerName"); dtErrorInfo.Columns.Add("ColumnsInfo"); this.BranchId = ddlBranch.SelectedValue.ToString(); this.iLoanOfficer = ddlLoanOfficer.SelectedValue.ToString(); if (ddlLeadSource.SelectedValue != "-1") { this.sLeadSource = ddlLeadSource.SelectedItem.Text; } this.sReferenceCode = tbRefCode.Text; ContactRoles bContactRoles = new ContactRoles(); Roles bRoles = new Roles(); DataSet ds = bContactRoles.GetList("Name = 'Borrower'"); if (ds != null && ds.Tables[0].Rows.Count > 0) { iBrrowerRoleID = Convert.ToInt32(ds.Tables[0].Rows[0]["ContactRoleId"]); } ds = bContactRoles.GetList("Name = 'CoBorrower'"); if (ds != null && ds.Tables[0].Rows.Count > 0) { iCoBrrowerRoleID = Convert.ToInt32(ds.Tables[0].Rows[0]["ContactRoleId"]); } string FilePath = this.FileUpload.FileName; string strUploadUrl = Server.MapPath("./");//此"."可以换成项目文件里的其它文件夹名称 strUploadUrl = strUploadUrl.Replace("Pipeline\\", ""); #region 文件到临时文件夹 string strUploadFolder = @"\UploadFiles\\Temp\\"; // 临时文件夹 string sTempUploadFold = strUploadUrl + strUploadFolder; // this.MapPath("~/UploadFiles/Temp/"); string sFileExt1 = Path.GetExtension(this.FileUpload.FileName).ToLower(); string sTempFileName1 = Guid.NewGuid().ToString() + sFileExt1; // 临时文件路径 string sTempFilePath1 = Path.Combine(sTempUploadFold, sTempFileName1); // "D:\\Test\\" + FilePath;// try { // 文件上传到临时文件夹 this.FileUpload.SaveAs(sTempFilePath1); } catch (Exception ex) { ClientScriptManager clientScriptManager = Page.ClientScript; clientScriptManager.RegisterStartupScript(this.GetType(), "1", "<script language='javascript'>"); clientScriptManager.RegisterStartupScript(this.GetType(), "2", "alert('Failed to upload the file due to insufficient privilege. Please contact your system administrator.');"); clientScriptManager.RegisterStartupScript(this.GetType(), "3", "</script>"); return; } #endregion try { PageCommon commonMgr = new PageCommon(); if (sTempFilePath1.Substring(sTempFilePath1.LastIndexOf(".")).ToLower() == ".xlsx") { dtExcelData = commonMgr.GetTableFromXlsx(sTempFilePath1); } else if (sTempFilePath1.Substring(sTempFilePath1.LastIndexOf(".")).ToLower() == ".xls") { dtExcelData = commonMgr.GetTableFromXls(sTempFilePath1); } else if (sTempFilePath1.Substring(sTempFilePath1.LastIndexOf(".")).ToLower() == ".csv") { dtExcelData = commonMgr.GetTableFromCsv(sTempFilePath1); } int iRow = 2; foreach (DataRow dr in dtExcelData.Rows) { ImportOneRecord(dr, iRow); iRow++; } } catch (Exception ex) { ClientScriptManager clientScriptManager = Page.ClientScript; clientScriptManager.RegisterStartupScript(this.GetType(), "1", "<script language='javascript'>"); clientScriptManager.RegisterStartupScript(this.GetType(), "2", "alert('Import Error. Please make sure row 1 of the file has data.');"); clientScriptManager.RegisterStartupScript(this.GetType(), "3", "</script>"); } finally { if (File.Exists(sTempFilePath1)) { File.Delete(sTempFilePath1); } } if (dtErrorInfo.Rows.Count > 0) { //show Error Info this.aspnetForm.Visible = false; this.divError.Visible = true; gvErrorView.DataSource = dtErrorInfo; gvErrorView.DataBind(); } else { ClientScriptManager clientScriptManager = Page.ClientScript; clientScriptManager.RegisterStartupScript(this.GetType(), "1", "<script language='javascript'>"); clientScriptManager.RegisterStartupScript(this.GetType(), "2", "alert('Import success!');"); clientScriptManager.RegisterStartupScript(this.GetType(), "3", "</script>"); } }