public void inseir(responsavelDTO dto) { bd.Conectar(); string comando = "INSERT INTO tb_responsavel(nome_responsavel," + "tel_residencial, tel_celular, tel_opcional, nome_opcional)" + " VALUES ('" + dto.Nome_responsavel + "','" + dto.Tel_residencial + "','" + dto.Tel_celular + "','" + dto.Tel_opcional + "','" + dto.Nome_opcional + "')"; bd.ExecutarComandoSQL(comando); }
public DataTable buscaResp(responsavelDTO dto) { SqlCommand cmd = new SqlCommand("pa_pesquisaResponsavel", con.conectarBD()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@nome", SqlDbType.VarChar).Value = dto.nome; SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable resp = new DataTable(); da.Fill(resp); con.desconectarBD(); return(resp); }
public ActionResult confirma(FormCollection frm) { responsavelDTO dto = new responsavelDTO(); responsavelBLL bll = new responsavelBLL(); dto.codResp = frm["txtCod"]; dto.nome = frm["txtNome"]; dto.end = frm["txtEnd"]; dto.bairro = frm["txtBairro"]; dto.cidade = frm["txtCid"]; dto.uf = frm["txtUf"]; bll.inserirResp(dto); return(View()); }
public ActionResult resultado(FormCollection frm) { responsavelDTO dto = new responsavelDTO(); responsavelBLL bll = new responsavelBLL(); GridView dgv = new GridView(); dto.nome = frm["txtNome"]; dgv.DataSource = bll.buscaResp(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()); }
public void inserirResp(responsavelDTO dto) { // SqlCommand cmd = new SqlCommand("insert into tbResponsavel values(@cod,@nome,@end,@bairro, @cid,@uf)", con.conectarBD()); SqlCommand cmd = new SqlCommand(); cmd.Connection = con.conectarBD(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "pa_inserirResponsavel"; cmd.Parameters.Add("@cod", SqlDbType.VarChar).Value = dto.codResp; cmd.Parameters.Add("@nome", SqlDbType.VarChar).Value = dto.nome; cmd.Parameters.Add("@end", SqlDbType.VarChar).Value = dto.end; cmd.Parameters.Add("@bairro", SqlDbType.VarChar).Value = dto.bairro; cmd.Parameters.Add("@cid", SqlDbType.VarChar).Value = dto.cidade; cmd.Parameters.Add("@uf", SqlDbType.VarChar).Value = dto.uf; cmd.ExecuteNonQuery(); con.desconectarBD(); }