コード例 #1
0
 public GenerarSolicitud_Response GenerarSolicitud(GenerarSolicitud_Request entidad)
 {
     try
     {
         GenerarSolicitud_Response response = new GenerarSolicitud_Response();
         string texto = "";
         List <GenerarSolicitud_Req> lista = entidad.lista;
         foreach (GenerarSolicitud_Req tmp in lista)
         {
             if (tmp.show)
             {
                 response = solicitudDA.GenerarSolicitud(tmp);
                 if (response.respuesta == 0)
                 {
                     return(response);
                 }
                 else
                 {
                     texto = response.str_mensaje + "<br>" + texto;
                 }
             }
         }
         return(response);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
        public GenerarSolicitud_Response GenerarSolicitud(GenerarSolicitud_Req obj)
        {
            GenerarSolicitud_Response retorno = new GenerarSolicitud_Response();

            try
            {
                using (SqlConnection conection = new SqlConnection(ConfigurationManager.ConnectionStrings["cnxIndra"].ConnectionString))
                {
                    conection.Open();

                    using (SqlCommand command = new SqlCommand("[pa_spi_solicitud]", conection))
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Parameters.AddWithValue("@vi_nid_recurso", obj.nid_recurso);
                        command.Parameters.AddWithValue("@vi_nid_componente", obj.nid_componente);
                        command.Parameters.AddWithValue("@vi_nu_solicitado", obj.cantidad);
                        command.Parameters.AddWithValue("@vi_no_nombre", obj.descripcion);
                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    if ((dr.GetInt32(dr.GetOrdinal("nid_retorno")) > 0))
                                    {
                                        retorno.respuesta   = 1;
                                        retorno.str_mensaje = dr.GetString(dr.GetOrdinal("msj_retorno"));
                                    }
                                    else
                                    {
                                        retorno.respuesta   = 0;
                                        retorno.str_mensaje = "No se pudo eliminar la solicitud, debido a que tiene componentes en ejecución";
                                    }
                                }
                            }
                        }
                    }
                    conection.Close();
                }
                return(retorno);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }