public void inserirTipo(tipoAnimalDTO dto) { SqlCommand cmd = new SqlCommand("pa_inserirTipo", con.conectarBD()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.VarChar).Value = dto.codTipo; cmd.Parameters.Add("@tipo", SqlDbType.VarChar).Value = dto.tipo; cmd.ExecuteNonQuery(); con.desconectarBD(); }
public ActionResult confirma(FormCollection frm) { tipoAnimalDTO dto = new tipoAnimalDTO(); tipoAnimalBLL bll = new tipoAnimalBLL(); dto.codTipo = frm["txtCod"]; dto.tipo = frm["txtTipo"]; bll.inserirTipo(dto); return(View()); }
public DataTable buscaTipo(tipoAnimalDTO dto) { SqlCommand cmd = new SqlCommand("pa_pesquisaTipo", con.conectarBD()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cod", SqlDbType.VarChar).Value = dto.codTipo; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable tipo = new DataTable(); da.Fill(tipo); con.desconectarBD(); return(tipo); }
public ActionResult resultado(FormCollection frm) { tipoAnimalDTO dto = new tipoAnimalDTO(); tipoAnimalBLL bll = new tipoAnimalBLL(); GridView dgv = new GridView(); dto.codTipo = frm["txtCod"]; dgv.DataSource = bll.buscaTipo(dto); //puxa o metodo de pesquisa e usa o termo inserido pelo usuario dgv.DataBind(); StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); dgv.RenderControl(htw); ViewBag.GridViewString = sw.ToString(); return(View()); }