예제 #1
0
        public Envio CrearEnvio(Envio envioACrear)
        {
            bool valida = false;

            valida = tdao.ValidarCarga(Convert.ToInt32(envioACrear.IdTransporte), Convert.ToInt32(envioACrear.Peso), Convert.ToInt32(envioACrear.Cantidad));

            if (valida == false)
            {

                throw new WebFaultException<string>("El Peso excede el Peso Maximo del transporte, asigne otro tranpsorte", HttpStatusCode.InternalServerError);

            }

            tdao.ActualizarCarga(Convert.ToInt32(envioACrear.IdTransporte), Convert.ToInt32(envioACrear.Peso), Convert.ToInt32(envioACrear.Cantidad));
            return dao.Crear(envioACrear);
        }
예제 #2
0
        public Envio Crear(Envio envioACrear)
        {
            Envio envioCreado = null;
            string sql = "INSERT INTO t_envio VALUES (@idEnvio, @idCliente, @cantidad, @peso, @destinoInicio, @destinoFin, @idTransporte, @estado)";
            using (SqlConnection con = new SqlConnection(ConexionUtil.Cadena))
            {
                con.Open();
                using (SqlCommand com = new SqlCommand(sql, con))
                {
                    com.Parameters.Add(new SqlParameter("@idEnvio", envioACrear.IdEnvio));
                    com.Parameters.Add(new SqlParameter("@idCliente", envioACrear.IdCliente));
                    com.Parameters.Add(new SqlParameter("@cantidad", envioACrear.Cantidad));
                    com.Parameters.Add(new SqlParameter("@peso", envioACrear.Peso));
                    com.Parameters.Add(new SqlParameter("@destinoInicio", envioACrear.DestinoInicio));
                    com.Parameters.Add(new SqlParameter("@destinoFin", envioACrear.DestinoFin));
                    com.Parameters.Add(new SqlParameter("@idTransporte", envioACrear.IdTransporte));
                    com.Parameters.Add(new SqlParameter("@estado", envioACrear.Estado));
                    com.ExecuteNonQuery();
                }

            }
            envioCreado = Obtener(envioACrear.IdEnvio);
            return envioCreado;
        }
예제 #3
0
 public Envio Obtener(string idEnvio)
 {
     Envio envioEncontrado = null;
     string sql = "SELECT * FROM t_envio WHERE idEnvio=@idEnvio";
     using (SqlConnection con = new SqlConnection(ConexionUtil.Cadena))
     {
         con.Open();
         using (SqlCommand com = new SqlCommand(sql, con))
         {
             com.Parameters.Add(new SqlParameter("@idEnvio", idEnvio));
             using (SqlDataReader resultado = com.ExecuteReader())
             {
                 if (resultado.Read())
                 {
                     envioEncontrado = new Envio()
                     {
                         IdEnvio = (string)resultado["idEnvio"],
                         IdCliente = (string)resultado["idCliente"],
                         Cantidad = (string)resultado["cantidad"],
                         Peso = (string)resultado["peso"],
                         DestinoInicio = (string)resultado["destinoInicio"],
                         DestinoFin = (string)resultado["destinoFin"],
                         IdTransporte = (string)resultado["idTransporte"],
                         Estado = (string)resultado["estado"]
                     };
                 }
             }
         }
     }
     return envioEncontrado;
 }
예제 #4
0
 public Envio Modificar(Envio envioAModificar)
 {
     return null;
 }