protected void cmdExport_Click(object sender, EventArgs e) { string uploadPath = ""; try { string assurName = lbAssur.SelectedItem.Text.ToString(); List <GroupGarantySante> groupsSante = GroupGarantySante.GetGroupsAndGarantiesForAssureur(assurName); ExcelPackage pack = BLGroupsAndGaranties.ExportGroupsGarantiesSanteForAssureur(assurName); uploadPath = Path.Combine(Request.PhysicalApplicationPath, C.uploadFolder); uploadPath = Path.Combine(uploadPath, User.Identity.Name + "_" + assurName + "_GroupsEtGuarantees.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(); } 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) { lbAssur.SelectedIndex = 0; UpdateTreeView(C.cDEFAULTASSUREUR); } 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 compId = lbCompanies.SelectedItem.Value.ToString(); //int iCompId = -1; string assurId = lbAssur.SelectedItem.Value.ToString(); string assurName = lbAssur.SelectedItem.Text.ToString(); int iAssurId = -1; if (int.TryParse(assurId, out iAssurId)) { if (iAssurId == -1) { assurName = C.cDEFAULTASSUREUR; } BLGroupsAndGaranties.ImportGroupsGarantiesSanteForAssureur(assurName, fullUploadPath, true); //refresh the tree lbAssur.DataBind(); if (ItemExists(assurName)) { SelectItem(assurName); UpdateTreeView(assurName); } else { if (lbAssur.Items.Count > 0) { SelectItem(lbAssur.Items[0].Text); UpdateTreeView(lbAssur.Items[0].Text); } else { tvGaranties.Nodes.Clear(); } } //lbAssur.DataBind(); //string selAssur = Session["SelectedAssureurName"].ToString(); //SelectItem(selAssur); } } } } } catch (Exception ex) { var myCustomValidator = new CustomValidator(); myCustomValidator.IsValid = false; myCustomValidator.ErrorMessage = ex.Message; Page.Validators.Add(myCustomValidator); } }