protected void cmdExport_Click(object sender, EventArgs e) { string uploadPath = ""; try { string assurName = lbAssur.SelectedItem.Text.ToString(); //List<C_TempExpData> groupsSante = C_TempExpData.GetExpData(assurName); ExcelPackage pack = BLExperience.ExportExperienceForAssureur(assurName); uploadPath = Path.Combine(Request.PhysicalApplicationPath, C.uploadFolder); uploadPath = Path.Combine(uploadPath, User.Identity.Name + "_" + assurName + "_Experience.xlsx"); pack.SaveAs(new FileInfo(uploadPath)); UICommon.DownloadFile(this.Page, uploadPath); } catch (Exception ex) { if (ex.Message != "Thread was being aborted.") { log.Error(ex.Message); } var myCustomValidator = new CustomValidator(); myCustomValidator.IsValid = false; myCustomValidator.ErrorMessage = ex.Message; Page.Validators.Add(myCustomValidator); } }
protected void cmdRecreate_Click(object sender, EventArgs e) { try { //BLGroupsAndGaranties.RecreateGroupsGarantiesSanteFromPresta(); BLExperience.RecreateExperienceFromPresta(); } catch (Exception ex) { log.Error(ex.Message); var myCustomValidator = new CustomValidator(); myCustomValidator.IsValid = false; myCustomValidator.ErrorMessage = ex.Message; Page.Validators.Add(myCustomValidator); } }
protected void Page_Load(object sender, EventArgs e) { try { cmdImport.Attributes.Add("onclick", "jQuery('#" + uploadExcel.ClientID + "').click();return false;"); if (!IsPostBack) { rptExp.DataBind(); } else { //Handle the Delete Event if (Request.Form["cmdDelete"] != null) { } //Handle the import of groups & guarantees if (uploadExcel.PostedFile != null) { if (uploadExcel.PostedFile.FileName.Length > 0) { //Import Garanties string excelFile = Path.GetFileName(uploadExcel.PostedFile.FileName); string excelDirectory = Path.Combine(Request.PhysicalApplicationPath, C.excelFolder); string fullUploadPath = Path.Combine(excelDirectory, excelFile); uploadExcel.PostedFile.SaveAs(fullUploadPath); string assurId = lbAssur.SelectedItem.Value.ToString(); string assurName = lbAssur.SelectedItem.Text.ToString(); int iAssurId = -1; if (int.TryParse(assurId, out iAssurId)) { if (iAssurId == -1) { return; } BLExperience.ImportExperienceForAssureur(assurName, fullUploadPath, true); //refresh the tree lbAssur.DataBind(); if (ItemExists(assurName)) { SelectItem(assurName); rptExp.DataBind(); } else { if (lbAssur.Items.Count > 0) { SelectItem(lbAssur.Items[0].Text); rptExp.DataBind(); } else { rptExp.DataBind(); } } } } } } } catch (Exception ex) { UICommon.HandlePageError(ex, this.Page, "GestionExperience::Page_Load"); } }