Beispiel #1
0
        public List <MotivoApontamento> ListaMotivoApontamento()
        {
            List <MotivoApontamento> ListMotivo = new List <MotivoApontamento>();

            using (FbConnection con = bd.ConexaoSJC())
            {
                con.Open();
                string Consulta = "SELECT pat_codigo, pat_codigo|| ' - ' ||pat_nome AS Motivo FROM pcp_apto_tipo";
                using (FbCommand cmd = new FbCommand(Consulta, con))
                {
                    using (FbDataReader rd = cmd.ExecuteReader())
                    {
                        if (rd.HasRows)
                        {
                            while (rd.Read())
                            {
                                MotivoApontamento motivoApontamento = new MotivoApontamento()
                                {
                                    CodMotivo = (int)rd["pat_codigo"],
                                    Motivo    = rd["Motivo"].ToString(),
                                };
                                ListMotivo.Add(motivoApontamento);
                            }
                        }
                    }
                }
                return(ListMotivo);
            }
        }
Beispiel #2
0
        public List <Apontamentos> BuscaApontamentoIdOP(string IdOP)
        {
            MotivoApontamento   motivoapontamento = new MotivoApontamento();
            List <Apontamentos> ListApontamentos  = new List <Apontamentos>();
            string Res;

            using (SqlConnection conn = conexao.ConexaoSQL())
            {
                using (SqlCommand cmd = new SqlCommand("SP_Apontamento_Select_IdOP", conn))
                {
                    conn.Open();
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@IdOP", IdOP.TrimStart('0'));

                    using (SqlDataReader drResultado = cmd.ExecuteReader())
                    {
                        if (drResultado.HasRows)
                        {
                            while (drResultado.Read())
                            {
                                Res = motivoapontamento.BuscaMotivo(Convert.ToInt32(drResultado["IdMotivo"]));

                                Apontamentos apontamentos = new Apontamentos()
                                {
                                    IdFabrica          = Convert.ToInt32(drResultado["IdFabrica"]),
                                    CodSetor           = Convert.ToInt32(drResultado["CodSetor"]),
                                    NomeSetor          = drResultado["NomeSetor"].ToString(),
                                    CodAtividade       = Convert.ToInt32(drResultado["CodAtividade"]),
                                    DescricaoAtividade = drResultado["DescricaoAtividade"].ToString(),
                                    Sequencia          = Convert.ToInt32(drResultado["Sequencia"]),
                                    IdApontamento      = Convert.ToInt32(drResultado["IdApontamento"]),
                                    IdRoteiro          = Convert.ToInt32(drResultado["IdRoteiro"]),
                                    IdMotivo           = Convert.ToInt32(drResultado["IdMotivo"]),
                                    Motivo             = Res,
                                    Usuario            = drResultado["Usuario"].ToString(),
                                    DataCadastro       = Convert.ToDateTime(drResultado["DataCadastro"]),
                                    Qtde = Convert.ToInt32(drResultado["Qtde"]),
                                    Peso = Convert.ToDouble(drResultado["Peso"])
                                };
                                ListApontamentos.Add(apontamentos);
                            }

                            return(ListApontamentos);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
            }
        }