public ActionResult InternarNotaIngreso(List<beDetalleNotaIngreso> listaDetalleNotaIngreso, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                String strAlmacen = form["IdAlmacen"].ToString();
                String strNumero = "";
                foreach (beDetalleNotaIngreso fila in listaDetalleNotaIngreso)
                {
                    beKardex obeKardex = new beKardex();
                    obeKardex.NumeroKardex = Int32.Parse(strAlmacen);
                    obeKardex.IdAlmacen = Int32.Parse(strAlmacen);
                    obeKardex.IdProducto = fila.IdProducto;
                    obeKardex.Observaciones = "";
                    obeKardex.SaldoActual = 0;
                    obeKardex.IdNotaIngreso = fila.NumeroNotaIngreso;
                    obeKardex.Fecha = DateTime.Now;
                    obeKardex.Ingreso = (int)fila.CantidadInternar;
                    obeKardex.CodigoCompra = "";
                    obeKardex.Cantidad = (int)fila.CantidadInternar;
                    obeKardex.Costo = 0;
                    obrKardex.Insertar(obeKardex);

                    //DETALLE DE KARDEX
                    beDetalleKardex obeDetalleKardex = new beDetalleKardex();
                    obeDetalleKardex.NumeroKardex = obeKardex.NumeroKardex;
                    obeDetalleKardex.NumeroDocumento = fila.NumeroNotaIngreso.ToString();
                    obeDetalleKardex.TipodeMovimiento = 1;
                    obeDetalleKardex.NumeroNotaIngreso = fila.NumeroNotaIngreso.ToString();
                    obeDetalleKardex.NumeroSalida = "";
                    obeDetalleKardex.Fecha = DateTime.Now;
                    obeDetalleKardex.Cantidad = (int)fila.CantidadInternar;

                    obrKardex.InsertarDetalle(obeDetalleKardex);

                    strNumero = fila.NumeroNotaIngreso.ToString();
                }
                //ACTUALIZAR ESTADO DE LA NOTA DE INGRESO
                beNotaIngreso obeNotaIngreso = new beNotaIngreso();
                obeNotaIngreso.NumeroNotaIngreso = Int32.Parse(strNumero);
                obeNotaIngreso.EstadoNotaIngreso = "I";
                obrNotaIngreso.ActualizarEstado(obeNotaIngreso);
            }
            //if (!r)
            //{
            //    // Podemos validar para mostrar un mensaje personalizado, por ahora el aplicativo se caera por el throw que hay en nuestra capa DAL
            //    ViewBag.Mensaje = "Ocurrio un error inesperado";
            //    return View("~/Views/Shared/_Mensajes.cshtml");
            //}
            return Redirect("~/ProductoAlmacenar/Index");
        }
示例#2
0
 public Boolean Insertar(beKardex obeKardex)
 {
     using (SqlConnection con = new SqlConnection(CadenaConexion))
     {
         try
         {
             con.Open();
             daKardex odaKardex = new daKardex();
             odaKardex.Insertar(con, obeKardex);
             return true;
         }
         catch (Exception ex)
         {
             GrabarLog(ex);
             return false;
         }
     }
 }
示例#3
0
        public Boolean Insertar(SqlConnection con, beKardex obeKardex)
        {
            SqlCommand cmd = new SqlCommand("uspKardexInsertar", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@NumeroKardex", obeKardex.NumeroKardex);
            cmd.Parameters.AddWithValue("@IdProducto", obeKardex.IdProducto);
            cmd.Parameters.AddWithValue("@IdAlmacen", obeKardex.IdAlmacen);
            cmd.Parameters.AddWithValue("@Observaciones", obeKardex.Observaciones);
            cmd.Parameters.AddWithValue("@SaldoActual", obeKardex.SaldoActual);
            cmd.Parameters.AddWithValue("@IdNotaIngreso", obeKardex.IdNotaIngreso);
            cmd.Parameters.AddWithValue("@IdNotaSalida", obeKardex.IdNotaSalida);
            cmd.Parameters.AddWithValue("@Fecha", obeKardex.Fecha);
            cmd.Parameters.AddWithValue("@Ingreso", obeKardex.Ingreso);
            cmd.Parameters.AddWithValue("@Salidas", obeKardex.Salidas);
            cmd.Parameters.AddWithValue("@CodigoCompra", obeKardex.CodigoCompra);
            cmd.Parameters.AddWithValue("@Cantidad", obeKardex.Cantidad);
            cmd.Parameters.AddWithValue("@Costo", obeKardex.Costo);

            cmd.ExecuteNonQuery();

            return true;
        }