当前位置: 首页>>代码示例>>C#>>正文


C# Connection.closeConnection方法代码示例

本文整理汇总了C#中Connection.closeConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.closeConnection方法的具体用法?C# Connection.closeConnection怎么用?C# Connection.closeConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.closeConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: buscar

        public List<Mensalista> buscar(String nomeCliente)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Mensalistas m INNER JOIN Clientes c ON m.Id_cliente = c.Id_Cliente WHERE c.Nome like '%"+ nomeCliente +"%'";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Mensalista> listaMensalistas = new List<Mensalista>();

            while (reader.Read())
            {
                Mensalista mensalista = new Mensalista();
                mensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                mensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));

                Cliente cliente = new Cliente();
                cliente.nome = string.Format("{0}", reader[4]);

                mensalista.nome_cliente = cliente.nome;
                mensalista.data_termino = string.Format("{0}", reader[2]);

                listaMensalistas.Add(mensalista);
            }
            con.closeConnection();
            return listaMensalistas;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:31,代码来源:mensalistaDAO.cs

示例2: buscar

        public List<Cliente> buscar(String nome)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Clientes where Nome LIKE '%" + nome + "%'";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Cliente> listaClientes = new List<Cliente>();

            while (reader.Read())
            {
                Cliente cliente = new Cliente();
                cliente.id_cliente = Int32.Parse(string.Format("{0}", reader[0]));
                cliente.nome = string.Format("{0}", reader[1]);
                cliente.cpf = string.Format("{0}", reader[2]);
                cliente.saldo = double.Parse(string.Format("{0}", reader[3]));

                listaClientes.Add(cliente);
            }

            con.closeConnection();
            return listaClientes;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:28,代码来源:ClienteDAO.cs

示例3: buscar

        public List<Carro> buscar(String nome)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Carro where modelo LIKE '%" + nome + "%' OR marca LIKE '%" + nome + "%'";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Carro> listaCarros = new List<Carro>();

            while (reader.Read())
            {
                Carro carro = new Carro();
                carro.id_carro = Int32.Parse(string.Format("{0}", reader[0]));
                carro.modelo = string.Format("{0}", reader[1]);
                carro.marca = string.Format("{0}", reader[2]);
                carro.cor = string.Format("{0}", reader[3]);

                listaCarros.Add(carro);
            }

            con.closeConnection();
            return listaCarros;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:28,代码来源:CarroDAO.cs

示例4: editar

 public Boolean editar(Carro carro)
 {
     Connection con = new Connection();
     con.openConnection();
     SqlCommand command = new SqlCommand();
     String sql = "UPDATE Carro set marca='" + carro.marca + "', modelo ='" + carro.modelo + "',  cor = '" + carro.cor + "' where ID_carro = " + carro.id_carro;
     command.CommandText = sql;
     command.CommandType = CommandType.Text;
     command.Connection = con.getConnection();
     command.ExecuteNonQuery();
     con.closeConnection();
     return true;
 }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:13,代码来源:CarroDAO.cs

示例5: editar

 public Boolean editar(Mensalista mensalista)
 {
     Connection con = new Connection();
     con.openConnection();
     SqlCommand command = new SqlCommand();
     String sql = "UPDATE Mensalistas set Data_termino ='" + mensalista.data_termino +"' where Id_Mensalista = "+mensalista.id_mensalista;
     command.CommandText = sql;
     command.CommandType = CommandType.Text;
     command.Connection = con.getConnection();
     command.ExecuteNonQuery();
     con.closeConnection();
     return true;
 }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:13,代码来源:mensalistaDAO.cs

示例6: deletar

        public Boolean deletar(Ticket ticket)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "DELETE Tickets WHERE ID_ticket = " + ticket.id_ticket;
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            con.closeConnection();

            return true;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:16,代码来源:TicketDAO.cs

示例7: deletar

        public Boolean deletar(Carro carro)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "DELETE Carro WHERE ID_carro = " + carro.id_carro;
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            con.closeConnection();

            return true;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:16,代码来源:CarroDAO.cs

示例8: deletar

        public Boolean deletar(Mensalista mensalista)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "DELETE Mensalistas WHERE Id_Mensalista = " + mensalista.id_mensalista;
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            con.closeConnection();

            return true;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:16,代码来源:mensalistaDAO.cs

示例9: buscar

        public List<Ticket> buscar(String placa)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Tickets WHERE placa LIKE '%" + placa + "%' ORDER BY DataEntrada";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Ticket> listaTickets = new List<Ticket>();

            while (reader.Read())
            {
                Ticket ticket = new Ticket();

                //Ticket
                ticket.id_ticket = int.Parse(string.Format("{0}", reader[0]));

                //Cliente
                ticket.id_cliente = int.Parse(string.Format("{0}", reader[1]));
                //Carro
                ticket.id_carro = Convert.ToInt32(string.Format("{0}", reader["id_Carro"]));
                //Servico
                ticket.id_servico = int.Parse(string.Format("{0}", reader["Id_Servico"]));
                //Ticket
                ticket.data_entrada = Convert.ToDateTime(reader["DataEntrada"]).ToString("dd/MM/yyyy HH:mm");
                ticket.data_saida = Convert.ToDateTime(reader["DataSaida"]).ToString("dd/MM/yyyy HH:mm");
                ticket.valorTotal = Convert.ToDouble(string.Format("{0}", reader[6]));

                //Placa carro
                ticket.placa = string.Format("{0}", reader[7]);
                ticket.uf = string.Format("{0}", reader[8]);
                ticket.cidade = string.Format("{0}", reader[9]);

                listaTickets.Add(ticket);
            }

            con.closeConnection();
            return listaTickets;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:43,代码来源:TicketDAO.cs

示例10: buscarTicket

        public List<Cliente> buscarTicket(Boolean mensalista,String busca)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "";
            if (mensalista == true)
            {
               sql = "SELECT C.Id_Cliente,C.Nome,C.Cpf,C.Saldo FROM Ticketcar.dbo.Clientes AS C LEFT JOIN Ticketcar.dbo.Mensalistas AS M ON C.Id_Cliente = M.Id_cliente WHERE M.Id_cliente IS NOT NULL AND DAY(M.Data_termino) = DAY(GETDATE()) AND C.Nome LIKE '%" + busca + "%'";
            }
            else
            {
                sql = "SELECT  C.Id_Cliente,C.Nome,C.Cpf,C.Saldo FROM Ticketcar.dbo.Clientes AS C LEFT JOIN Ticketcar.dbo.Mensalistas AS M ON C.Id_Cliente = M.Id_cliente WHERE M.Id_cliente IS NULL  AND C.Nome LIKE '%" + busca+"%'";
            }
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            List<Cliente> listaClientes = new List<Cliente>();

            while (reader.Read())
            {
                Cliente cliente = new Cliente();
                cliente.id_cliente = Int32.Parse(string.Format("{0}", reader[0]));
                cliente.nome = string.Format("{0}", reader[1]);
                cliente.cpf = string.Format("{0}", reader[2]);
                cliente.saldo = double.Parse(string.Format("{0}", reader[3]));

                listaClientes.Add(cliente);
            }

            con.closeConnection();
            return listaClientes;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:36,代码来源:ClienteDAO.cs

示例11: getCarrobyId

        public Carro getCarrobyId(Carro carro)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "SELECT * FROM Carro where ID_carro =" + carro.id_carro;
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();
            Carro returnCarro = new Carro();
            while (reader.Read())
            {
                returnCarro.id_carro = Int32.Parse(string.Format("{0}", reader[0]));
                returnCarro.modelo = string.Format("{0}", reader[1]);
                returnCarro.marca = string.Format("{0}", reader[2]);
                returnCarro.cor = string.Format("{0}", reader[3]);

                return returnCarro;
            }
            con.closeConnection();
            return returnCarro;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:24,代码来源:CarroDAO.cs

示例12: inserir

        public Boolean inserir(Mensalista mensalista)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            string sql = "INSERT INTO Mensalistas (Id_cliente, Data_termino) VALUES(" + mensalista.id_cliente + ",'" + mensalista.data_termino + "')";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            command.ExecuteNonQuery();

            con.closeConnection();

            return true;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:15,代码来源:mensalistaDAO.cs

示例13: getMensalistabyId_mensalista

        public Mensalista getMensalistabyId_mensalista(Mensalista mensalista)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "select * from Mensalistas m inner join Clientes c on m.Id_cliente = c.Id_Cliente where m.Id_mensalista = "+ mensalista.id_mensalista+" ";
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();
            Mensalista returnMensalista = new Mensalista();
            while (reader.Read())
            {
                returnMensalista.id_mensalista = Int32.Parse(string.Format("{0}", reader[0]));
                returnMensalista.id_cliente = Int32.Parse(string.Format("{0}", reader[1]));
                returnMensalista.nome_cliente = string.Format("{0}", reader[4]);
                returnMensalista.data_termino = string.Format("{0}", reader[2]);
            }

            con.closeConnection();
            return returnMensalista;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:23,代码来源:mensalistaDAO.cs

示例14: deletar

        public Boolean deletar(Cliente cliente)
        {
            Connection con = new Connection();
            con.openConnection();
            SqlCommand command = new SqlCommand();
            SqlDataReader reader;
            string sql = "DELETE Clientes WHERE Id_cliente = " + cliente.id_cliente;
            command.CommandText = sql;
            command.CommandType = CommandType.Text;
            command.Connection = con.getConnection();
            reader = command.ExecuteReader();

            con.closeConnection();

            return true;
        }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:16,代码来源:ClienteDAO.cs

示例15: debitarSaldo

 public Boolean debitarSaldo( Cliente cliente, Double valor)
 {
     Double saldo = (cliente.saldo - valor);
     Connection con = new Connection();
     con.openConnection();
     SqlCommand command = new SqlCommand();
     String sql = "UPDATE Clientes SET Saldo = " + saldo + " where Id_cliente = " + cliente.id_cliente;
     command.CommandText = sql;
     command.CommandType = CommandType.Text;
     command.Connection = con.getConnection();
     command.ExecuteNonQuery();
     con.closeConnection();
     return true;
 }
开发者ID:vtrmantovani,项目名称:ticketcar,代码行数:14,代码来源:ClienteDAO.cs


注:本文中的Connection.closeConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。