예제 #1
0
        public static int Buscar(String placa)
        {
            Conexao.Query = $"SELECT V.ID " +
                            $"FROM VEICULO V " +
                            $"WHERE V.PLACA LIKE '{placa}' AND DISPONIVEL = 1";
            SqlDataReader dr = Conexao.ExecReader();
            int           id = 0;

            if (dr != null)
            {
                if (!dr.Read())
                {
                    id = 0;
                }
                else
                {
                    id = Int32.Parse(dr[0].ToString());
                }
            }
            if (!dr.IsClosed)
            {
                dr.Close();
            }
            return(id);
        }
예제 #2
0
        public bool Registrar()
        {
            Conexao.Query = $"INSERT INTO VEICULO (CODMODELOVEICULO, CODCLIENTE, PLACA, TIPOVEICULO, DATARESGISTRO, CUSTOMEDIOPKM, ULTIMAALTERA)" +
                            $" VALUES ({codModelo}, {codCliente}, '{placa.ToUpper().Replace("-", "")}', (SELECT ID FROM TIPOVEICULO WHERE NOME LIKE '{tipoVeiculo.ToUpper()}'), GETDATE(), (SELECT CAST({custoMedio.ToString().Replace(",", ".")} AS MONEY) ), GETDATE()); " +
                            $"SELECT SCOPE_IDENTITY() AS ID";
            SqlDataReader dr = Conexao.ExecReader();

            if (dr.Read())
            {
                id = Int32.Parse(dr[0].ToString());
                MessageBox.Show(Form1.container, "Cadastro de Veiculo Realizado com Êxito!.".ToUpper(), "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                throw new Exception();
            }
            dr.Close();
            return(true);
        }
예제 #3
0
        public static String consultaCustoMedio(String placa)
        {
            String custo = "";

            Conexao.Query = $"SELECT CUSTOMEDIOPKM FROM VEICULO WHERE PLACA LIKE '{placa}'";
            SqlDataReader dr = Conexao.ExecReader();

            if (dr != null)
            {
                if (dr.Read())
                {
                    custo = dr[0].ToString();
                }
            }
            if (!dr.IsClosed)
            {
                dr.Close();
            }
            return(custo);
        }
예제 #4
0
        public static String Buscar(int idVeiculo)
        {
            Conexao.Query = $"SELECT V.PLACA, M.NOME " +
                            $"FROM VEICULO V " +
                            $"INNER JOIN MODELOVEICULO M " +
                            $"ON V.CODMODELOVEICULO = M.ID " +
                            $"WHERE V.ID = {idVeiculo} AND DISPONIVEL = 1";
            SqlDataReader dr = Conexao.ExecReader();
            String        nome;

            if (!dr.Read())
            {
                nome = "";
            }
            else
            {
                nome = dr[0].ToString();
            }
            dr.Close();
            return(nome);
        }
예제 #5
0
        public static int Buscar(String nome)
        {
            Conexao.Query = $"SELECT ID FROM PESSOA WHERE NOME LIKE '{nome}'";
            SqlDataReader dr = Conexao.ExecReader();
            int           id = 0;

            if (dr != null)
            {
                if (dr.Read())
                {
                    id = Int32.Parse(dr[0].ToString());
                }
                else
                {
                    id = 0;
                }
            }
            if (!dr.IsClosed)
            {
                dr.Close();
            }
            return(id);
        }