public bool IsParteContrariaNovoNome(ParteContraria parteContraria) { FabricaConexao con = new FabricaConexao(); con.AbreConexao(); SqlCommand cmd = new SqlCommand("spIsParteContrariaNovaPeloNome", con.GetConexao()); cmd.Parameters.AddWithValue("@Nome", parteContraria.Nome); cmd.CommandType = CommandType.StoredProcedure; using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count <= 0) { return(true); } else { IdentificaParteContrariaNome(parteContraria); return(false); } } con.FechaConexao(); }
internal List <Cliente> BuscarTodosClientes() { List <Cliente> clientes = new List <Cliente>(); SqlCommand command = new SqlCommand(); command.Connection = conexao; command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM cliente"; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Cliente cliente = new Cliente(); cliente.Id = (Int32)reader["Id"]; cliente.Cpf = (String)reader["cpf"]; cliente.Nome = (String)reader["nome"]; cliente.Nascimento = (DateTime)reader["nascimento"]; clientes.Add(cliente); } FabricaConexao.CloseConnection(conexao); return(clientes); }
public static Telefone BuscarTelefone(Int32 id) { SqlConnection conexao = FabricaConexao.GetConnection(); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao); return(telefoneDAO.buscarTelefone(id)); }
public static List <Atendente> BuscarTodosAtendentes() { SqlConnection conexao = FabricaConexao.GetConnection(); AtendenteDAO atendenteDAO = new AtendenteDAO(conexao); return(atendenteDAO.buscarTodosAtendentes()); }
public static void DeletarCliente(int idAtendente) { SqlConnection conexao = FabricaConexao.GetConnection(); AtendenteDAO atendenteDAO = new AtendenteDAO(conexao); atendenteDAO.deletarAtendente(idAtendente); }
public static void SalvarFilial(Filial filial) { SqlConnection conexao = null; SqlTransaction tx = null; try { conexao = FabricaConexao.GetConnection(); tx = conexao.BeginTransaction(); FilialDAO filialDAO = new FilialDAO(conexao, tx); filialDAO.salvarFilial(filial); filialDAO.salvarFilialBarbearia(filial); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx); telefoneDAO.salvarTelefone(filial.Telefone); filialDAO.salvarFilialTelefone(filial); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } finally { FabricaConexao.CloseConnection(conexao); } }
public static Filial BuscarFilialDoAtendente(Atendente atendente) { SqlConnection conexao = FabricaConexao.GetConnection(); FilialDAO filialDAO = new FilialDAO(conexao); return(filialDAO.buscarFilialDoAtendente(atendente)); }
internal static object BuscarTodosProdutos() { SqlConnection conexao = FabricaConexao.GetConnection(); ProdutoDAO produtoDAO = new ProdutoDAO(conexao); return(produtoDAO.buscarTodosProdutos()); }
private void button2_Click(object sender, EventArgs e) { try { SqlConnection conexao = FabricaConexao.getConexao(); ClientesDAL ClieDAL = new ClientesDAL(); if (cboAssunto.Text.Trim() == string.Empty || cboAssunto.Text.Equals("")) { MessageBox.Show("ESCOLHA UM ASSUNTO!", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ClieDAL.abrirConexao(conexao); string sqlSelect = " select Faleconosco.id, Faleconosco.idcliente, Faleconosco.nome, Faleconosco.email, Faleconosco.telefone, Faleconosco.DataDeEnvio, Faleconosco.respondido, assuntos.assunto, Faleconosco.mensagem from Faleconosco inner join assuntos on assuntos.id_assunto = Faleconosco.assunto where assuntos.assunto = '" + cboAssunto.Text + "'"; dgvFale.DataSource = ClieDAL.retornaDataTable(sqlSelect, conexao); ClieDAL.fecharConexao(conexao); CheckBox1.Checked = false; CheckBox2.Checked = false; mskData.Text = DateTime.Now.ToString(); txtEmail.Clear(); } } catch (Exception) { } }
public static void SalvarProduto(Produto produto) { SqlConnection conexao = FabricaConexao.GetConnection(); ProdutoDAO produtoDAO = new ProdutoDAO(conexao); produtoDAO.salvarProduto(produto); }
public static Produto BuscarProduto(Int32 id) { SqlConnection conexao = FabricaConexao.GetConnection(); ProdutoDAO produtoDAO = new ProdutoDAO(conexao); return(produtoDAO.buscarProduto(id)); }
private void button3_Click(object sender, EventArgs e) { try { SqlConnection conexao = FabricaConexao.getConexao(); ClientesDAL ClieDAL = new ClientesDAL(); if (txtBarras.Text.Trim() == string.Empty || txtBarras.Text.Equals("")) { MessageBox.Show("Digite um Código de Barras", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ClieDAL.abrirConexao(conexao); string sqlSelect = " select IDproduto,CodigoDeBarras,Marca,Nome,ValorUnitario,Quantidade,Categoria,Fornecedor,DataEntrada,DataVencimento from Produtos where CodigoDeBarras ='" + txtBarras.Text + "'"; DgvEstoque.DataSource = ClieDAL.retornaDataTable(sqlSelect, conexao); ClieDAL.fecharConexao(conexao); mskVencimento.Clear(); cboCategoria.Text = " "; } } catch (Exception) { } }
public Double SomaParcelas(Contrato contrato) { FabricaConexao con = new FabricaConexao(); con.AbreConexao(); SqlCommand cmd = new SqlCommand("spSomaParcelas", con.GetConexao()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdContrato", contrato.IdContrato); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count <= 0) { return(0); } else { if (dt.Rows[0][0].ToString() != "") { return(double.Parse(dt.Rows[0][0].ToString())); } else { return(0); } } } con.FechaConexao(); }
public void CadastraProcesso(Cliente cliente, ParteContraria parteContraria, Processo processo, bool novoCliente, bool novaParteContraria) { FabricaConexao con = new FabricaConexao(); con.AbreConexao(); if (novoCliente) { CadastraCliente(cliente); //CADASTROU CLIENTE } if (novaParteContraria) { CadastraParteContraria(parteContraria); //CADASTROU PARTE CONTRARIA } SqlCommand cmd = new SqlCommand("spCadastraProcesso", con.GetConexao()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdCliente", processo.IdCliente); cmd.Parameters.AddWithValue("@IdParteContraria", processo.IdParteContraria); cmd.Parameters.AddWithValue("@NumeroProcesso", processo.NumProcesso); cmd.Parameters.AddWithValue("@Foro", processo.Foro); cmd.Parameters.AddWithValue("@TipoAcao", processo.TipoAcao); cmd.Parameters.AddWithValue("@Area", processo.Area); cmd.Parameters.AddWithValue("@AndamentoProcesso", processo.AndamentoProcesso); cmd.Parameters.AddWithValue("@FoiIndicacao", processo.FoiIndicacao); cmd.Parameters.AddWithValue("@NomeCaptador", processo.NomeCaptador); cmd.Parameters.AddWithValue("@LocalDescobrimento", processo.LocalDescobrimento); cmd.ExecuteNonQuery(); //CADASTROU PROCESSO con.FechaConexao(); }
internal List <Filial> buscarTodasFiliais() { List <Filial> filiais = new List <Filial>(); SqlCommand command = new SqlCommand(); command.Connection = conexao; command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM filial"; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Filial filial = new Filial(); filial.Id = (Int32)reader["Id"]; filial.Cnpj = (String)reader["cnpj"]; filial.Nome = (String)reader["nome"]; filial.Endereco = (String)reader["endereco"]; filiais.Add(filial); } FabricaConexao.CloseConnection(conexao); return(filiais); }
protected void CheckBoxPrimeiro(object sender, EventArgs e) { if (CheckBox1.Checked == true) { CheckBox2.Checked = false; try { SqlConnection conexao = FabricaConexao.getConexao(); ClientesDAL ClieDAL = new ClientesDAL(); if (CheckBox1.Checked) { ClieDAL.abrirConexao(conexao); string sqlSelect = " select id,idcliente,nome,email,telefone,DataDeEnvio,respondido,assunto,mensagem from Faleconosco where respondido ='" + CheckBox1.Text + "'"; dgvFale.DataSource = ClieDAL.retornaDataTable(sqlSelect, conexao); ClieDAL.fecharConexao(conexao); } } catch (Exception) { } } }
internal static void AtualizarFilial(Filial filial) { SqlConnection conexao = null; SqlTransaction tx = null; try { conexao = FabricaConexao.GetConnection(); tx = conexao.BeginTransaction(); FilialDAO filialDAO = new FilialDAO(conexao, tx); filialDAO.atualizarFilial(filial); BarbeariaDAO barbeariaDAO = new BarbeariaDAO(conexao, tx); barbeariaDAO.atualizarBarbeariaDaFilial(filial); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx); telefoneDAO.atualizarTelefoneDaFilial(filial); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } finally { FabricaConexao.CloseConnection(conexao); } }
private void btnPesquisa_Click(object sender, EventArgs e) { try { SqlConnection conexao = FabricaConexao.getConexao(); ClientesDAL ClieDAL = new ClientesDAL(); if (mskData.Text.Trim() == string.Empty || mskData.Text.Equals("")) { MessageBox.Show("DATA INVALIDA!", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { ClieDAL.abrirConexao(conexao); string sqlSelect = " select id,idcliente,nome,email,telefone,DataDeEnvio,respondido,assunto,mensagem from Faleconosco where DataDeEnvio ='" + mskData.Text + "'"; dgvFale.DataSource = ClieDAL.retornaDataTable(sqlSelect, conexao); ClieDAL.fecharConexao(conexao); CheckBox1.Checked = false; CheckBox2.Checked = false; cboAssunto.Text = " "; txtEmail.Clear(); } } catch (Exception) { } }
public static Filial BuscarFilial(Int32 id) { SqlConnection conexao = FabricaConexao.GetConnection(); FilialDAO filialDAO = new FilialDAO(conexao); return(filialDAO.buscarFilial(id)); }
internal static void AtualizarCliente(Cliente cliente) { SqlConnection conexao = null; SqlTransaction tx = null; try { conexao = FabricaConexao.GetConnection(); tx = conexao.BeginTransaction(); ClienteDAO clienteDAO = new ClienteDAO(conexao, tx); clienteDAO.atualizarCliente(cliente); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx); telefoneDAO.atualizarTelefoneDoCliente(cliente); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } finally { FabricaConexao.CloseConnection(conexao); } }
internal static List <Filial> buscarTodasFiliais() { SqlConnection conexao = FabricaConexao.GetConnection(); FilialDAO filialDAO = new FilialDAO(conexao); return(filialDAO.buscarTodasFiliais()); }
public static Servico BuscarServico(Int32 id) { SqlConnection conexao = FabricaConexao.GetConnection(); ServicoDAO servicoDAO = new ServicoDAO(conexao); return(servicoDAO.buscarProduto(id)); }
internal static object obterClientesLike(string nome) { SqlConnection conexao = FabricaConexao.GetConnection(); AtendenteDAO atendenteDAO = new AtendenteDAO(conexao); return(atendenteDAO.buscarAtendentesLike(nome)); }
internal static List <Servico> BuscarTodosServicos() { SqlConnection conexao = FabricaConexao.GetConnection(); ServicoDAO servicoDAO = new ServicoDAO(conexao); return(servicoDAO.buscarTodosServicos()); }
public static void SalvarAtendente(Atendente atendente) { SqlConnection conexao = null; SqlTransaction tx = null; try { conexao = FabricaConexao.GetConnection(); tx = conexao.BeginTransaction(); AtendenteDAO atendenteDAO = new AtendenteDAO(conexao, tx); atendenteDAO.salvarAtendente(atendente); atendenteDAO.salvarAtendenteFilial(atendente); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao, tx); telefoneDAO.salvarTelefone(atendente.Telefone); atendenteDAO.salvarAtendenteTelefone(atendente); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } finally { FabricaConexao.CloseConnection(conexao); } }
internal List <Filial> buscarFiliaisDaBarbearia(Barbearia barbearia) { List <Filial> filiais = new List <Filial>(); SqlCommand command = new SqlCommand(); command.Connection = this.conexao; command.CommandType = CommandType.Text; StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM filial "); sql.Append("INNER JOIN filial_barbearia ON filial.Id = filial_barbearia.id_filial "); sql.Append("WHERE filial_barbearia.id_barbearia = @id"); command.Parameters.AddWithValue("@id", barbearia.Id); command.CommandText = sql.ToString(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Filial filial = new Filial(); filial.Id = (Int32)reader["Id"]; filial.Nome = (String)reader["nome"]; filial.Cnpj = (String)reader["cnpj"]; filial.Endereco = (String)reader["endereco"]; filiais.Add(filial); } FabricaConexao.CloseConnection(conexao); return(filiais); }
public static Telefone BuscarTelefoneDoAtendente(Atendente atendente) { SqlConnection conexao = FabricaConexao.GetConnection(); TelefoneDAO telefoneDAO = new TelefoneDAO(conexao); return(telefoneDAO.buscarTelefoneDoAtendente(atendente)); }
internal List <Filial> buscarFiliaisLike(string filtro) { List <Filial> filiais = new List <Filial>(); SqlCommand command = new SqlCommand(); command.Connection = this.conexao; command.CommandType = CommandType.Text; command.CommandText = "SELECT * FROM filial WHERE nome like @filtro"; command.Parameters.AddWithValue("filtro", "%" + filtro + "%"); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Filial filial = new Filial(); filial.Id = (Int32)reader["Id"]; filial.Nome = (String)reader["nome"]; filial.Cnpj = (String)reader["cnpj"]; filial.Endereco = (String)reader["endereco"]; filiais.Add(filial); } FabricaConexao.CloseConnection(conexao); return(filiais); }
internal static void SalvarPedido(Pedido pedidoAtual) { SqlConnection conexao = null; SqlTransaction tx = null; try { conexao = FabricaConexao.GetConnection(); tx = conexao.BeginTransaction(); PedidoDAO pedidoDAO = new PedidoDAO(conexao, tx); pedidoDAO.salvarPedido(pedidoAtual); foreach (ItemProduto produto in pedidoAtual.ItemProdutos) { pedidoDAO.salvarItemProdutoPedido(produto); } foreach (ItemServico servico in pedidoAtual.ItemServicos) { pedidoDAO.salvarItemServicoPedido(servico); } tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } finally { FabricaConexao.CloseConnection(conexao); } }
public void LocalizaProcesso(Cliente cliente, Processo processo) { //CONTRATO-CONSULTA FabricaConexao con = new FabricaConexao(); con.AbreConexao(); SqlCommand cmd = new SqlCommand("spGetProcessoContrato", con.GetConexao()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IdCliente", cliente.IdCliente); cmd.Parameters.AddWithValue("@IdProcesso", processo.IdProcesso); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count > 0) { processo.IdProcesso = int.Parse(dt.Rows[0][0].ToString()); cliente.IdCliente = int.Parse(dt.Rows[0][1].ToString()); processo.IdCliente = int.Parse(dt.Rows[0][1].ToString()); //PEGA O ID DO CLIENTE PARA CASO DE processo.NumProcesso = dt.Rows[0][2].ToString(); processo.FoiIndicacao = dt.Rows[0][3].ToString(); processo.NomeCaptador = dt.Rows[0][4].ToString(); processo.LocalDescobrimento = dt.Rows[0][5].ToString(); cliente.Nome = dt.Rows[0][6].ToString(); cliente.Cpf = dt.Rows[0][7].ToString(); cliente.Telefone = dt.Rows[0][8].ToString(); } } con.FechaConexao(); }