protected void Excluir_Click(object sender, EventArgs e) { ApoliceBO apoliceBO = new ApoliceBO(); Page page = HttpContext.Current.Handler as Page; try { apoliceBO.ExcluirApolice(CarregaApoliceExcluir()); ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('Apólice excluida com sucesso');", true); CarregaGridEdropdown(); } catch (Exception ex) { aviso.InnerText = ex.Message; ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + ex.Message + "');", true); } }
protected void Apolice_SelectedIndexChanged(object sender, EventArgs e) { Page page = HttpContext.Current.Handler as Page; try { ApoliceBO apoliceBO = new ApoliceBO(); ApoliceDTO apolice = new ApoliceDTO(); apolice.ID = Convert.ToInt32(ddlApolice.SelectedValue); apolice = apoliceBO.PesquisarApolicePorID(apolice); CarregaCamposAlterar(apolice); } catch (Exception ex) { aviso.InnerText = ex.Message; ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + ex.Message + "');", true); } }
protected void Pesquisar_Click(object sender, EventArgs e) { try { ApoliceBO apoliceBO = new ApoliceBO(); if (txtPesquisarNumeroApolice.Text.Equals(string.Empty)) { gvApolice.DataSource = apoliceBO.PesquisarApoliceTodas(); } else { gvApolice.DataSource = apoliceBO.PesquisarApolice(CarregaApolicePesquisar()); } gvApolice.DataBind(); } catch (Exception ex) { aviso.InnerText = ex.Message; Page page = HttpContext.Current.Handler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + ex.Message + "');", true); } }
private void CarregaGridEdropdown() { try { ApoliceBO apoliceBO = new ApoliceBO(); List <ApoliceDTO> apolices = apoliceBO.PesquisarApoliceTodas(); gvApolice.DataSource = apolices; gvApolice.DataBind(); ddlApolice.DataSource = apolices; ddlApolice.DataValueField = "ID"; ddlApolice.DataTextField = "NumeroApolice"; ddlApolice.DataBind(); ddlApolice.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Selecione a apólice para alterar", "-1")); } catch (Exception ex) { aviso.InnerText = ex.Message; Page page = HttpContext.Current.Handler as Page; ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + ex.Message + "');", true); } }