예제 #1
0
 public void Insert(CentroCustoEntity centroCusto)
 {
     try
     {
         OpenConnection();
         using (cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "fin.UP_CENTRO_CUSTO_CADASTRAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@NOME", SqlDbType.VarChar, 100)).Value = centroCusto.Nome;
             cmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }
예제 #2
0
 public CentroCustoEntity GetById(int id)
 {
     try
     {
         OpenConnection();
         using (cmd = new SqlCommand("", con))
         {
             cmd.CommandText = "fin.UP_CENTRO_CUSTO_BUSCAR";
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int)).Value = id;
             dr = cmd.ExecuteReader();
             CentroCustoEntity centroCusto = null;
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     centroCusto = new CentroCustoEntity()
                     {
                         Id    = Convert.ToInt32(dr["ID"]),
                         Nome  = Convert.ToString(dr["NOME"]),
                         Ativo = Convert.ToBoolean(dr["ATIVO"])
                     };
                 }
             }
             return(centroCusto);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }
예제 #3
0
 public void Update(CentroCustoEntity centroCusto) => new CentroCustoRepository().Update(centroCusto);
예제 #4
0
 public void Insert(CentroCustoEntity centroCusto) => new CentroCustoRepository().Insert(centroCusto);