public void Atualizar() { try { endereco.Atualizar(); var cmd = @"UPDATE clinica SET id_endereco = @id_endereco, razao_social = @razao_social, nome_fantasia = @nome_fantasia, cnpj = @cnpj, ie = @ie, ddd_tel = @ddd_tel, telefone = @telefone, ddd_cel = @ddd_cel, celular = @celular, email = @email, logo_clinica = @logo_clinica, site = @site" ; Conexao.AbrirConexao(); Conexao.Cmd = new SqlCommand(cmd, Conexao.ConexaoSQL); Conexao.Cmd.Parameters.AddWithValue("id_endereco", endereco.id); Conexao.Cmd.Parameters.AddWithValue("razao_social", razaoSocial); Conexao.Cmd.Parameters.AddWithValue("nome_fantasia", nomeFantasia); Conexao.Cmd.Parameters.AddWithValue("cnpj", cnpj); Conexao.Cmd.Parameters.AddWithValue("ie", ie); Conexao.Cmd.Parameters.AddWithValue("ddd_tel", dddTel); Conexao.Cmd.Parameters.AddWithValue("telefone", telefone); Conexao.Cmd.Parameters.AddWithValue("ddd_cel", dddCel); Conexao.Cmd.Parameters.AddWithValue("celular", celular); Conexao.Cmd.Parameters.AddWithValue("email", email); Conexao.Cmd.Parameters.AddWithValue("site", site); Conexao.Cmd.Parameters.AddWithValue("logo_clinica", logo != null ? ImagemUtil.ImageParaByte(logo) : SqlBinary.Null); Conexao.Cmd.ExecuteNonQuery(); } catch (Exception ex) { Excecao.Mostrar(ex); } finally { Conexao.FecharConexao(); } }
public void Cadastrar() { try { endereco.Cadastrar(); var cmd = @"INSERT INTO clinica (id_endereco, razao_social, nome_fantasia, cnpj, ie, ddd_tel, telefone, ddd_cel, celular, email, logo_clinica, site) OUTPUT inserted.id_clinica VALUES (@id_endereco, @razao_social, @nome_fantasia, @cnpj, @ie, @ddd_tel, @telefone, @ddd_cel, @celular, @email, @logo_clinica, @site)" ; Conexao.AbrirConexao(); Conexao.Cmd = new SqlCommand(cmd, Conexao.ConexaoSQL); Conexao.Cmd.Parameters.AddWithValue("id_endereco", endereco.id); Conexao.Cmd.Parameters.AddWithValue("razao_social", razaoSocial); Conexao.Cmd.Parameters.AddWithValue("nome_fantasia", nomeFantasia); Conexao.Cmd.Parameters.AddWithValue("cnpj", cnpj); Conexao.Cmd.Parameters.AddWithValue("ie", ie); Conexao.Cmd.Parameters.AddWithValue("ddd_tel", dddTel); Conexao.Cmd.Parameters.AddWithValue("telefone", telefone); Conexao.Cmd.Parameters.AddWithValue("ddd_cel", dddCel); Conexao.Cmd.Parameters.AddWithValue("celular", celular); Conexao.Cmd.Parameters.AddWithValue("email", email); Conexao.Cmd.Parameters.AddWithValue("site", site); Conexao.Cmd.Parameters.AddWithValue("logo_clinica", logo != null ? ImagemUtil.ImageParaByte(logo) : SqlBinary.Null); id = (int)Conexao.Cmd.ExecuteScalar(); } catch (Exception ex) { Excecao.Mostrar(ex); } finally { Conexao.FecharConexao(); } }