Exemplo n.º 1
0
        public List <beNotaIngreso> ListarxEstado(SqlConnection con, String pstrEstado)
        {
            List <beNotaIngreso> lista = new List <beNotaIngreso>();
            SqlCommand           cmd   = new SqlCommand("uspNotaIngresoListarxEstado", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@estado", pstrEstado);
            SqlDataReader drd = cmd.ExecuteReader(CommandBehavior.SingleRow);

            if (drd != null)
            {
                while (drd.Read())
                {
                    beNotaIngreso obeNotaIngreso = new beNotaIngreso();
                    obeNotaIngreso.NumeroNotaIngreso = drd.GetInt32(0);
                    obeNotaIngreso.Fecha             = drd.GetDateTime(1);
                    obeNotaIngreso.NumeroOrdenCompra = drd.GetString(2);
                    obeNotaIngreso.IdEmpleado        = drd.GetInt32(3);
                    obeNotaIngreso.UsuarioRecibo     = drd.GetString(4);
                    obeNotaIngreso.IdAlmacen         = drd.GetInt32(5);
                    obeNotaIngreso.GuiaRemision      = drd.GetString(6);
                    obeNotaIngreso.Observaciones     = drd.GetString(7);
                    obeNotaIngreso.EstadoNotaIngreso = drd.GetString(8);
                    obeNotaIngreso.IdProveedor       = drd.GetInt32(9);
                    obeNotaIngreso.NombreAlmacen     = drd.GetString(10);
                    obeNotaIngreso.EstadoDescripcion = drd.GetString(11);
                    obeNotaIngreso.FechaFormateada   = obeNotaIngreso.Fecha.ToString("dd/MM/yyyy");
                    lista.Add(obeNotaIngreso);
                }
                drd.Close();
            }
            return(lista);
        }
Exemplo n.º 2
0
        public Boolean ActualizarEstado(SqlConnection con, beNotaIngreso obeNotaIngreso)
        {
            SqlCommand cmd = new SqlCommand("uspNotaIngresoActualizarEstado", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@NumeroNotaIngreso", obeNotaIngreso.NumeroNotaIngreso);
            cmd.Parameters.AddWithValue("@EstadoNotaIngreso", obeNotaIngreso.EstadoNotaIngreso);
            cmd.ExecuteNonQuery();

            return(true);
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        public ActionResult Guardar(beNotaIngreso obeNotaIngreso)
        {
            if (String.IsNullOrEmpty(obeNotaIngreso.Observaciones))
            {
                obeNotaIngreso.Observaciones = "";
            }
            bool bNuevo = false;

            if (obeNotaIngreso.NumeroNotaIngreso == 0)
            {
                bNuevo = true;
            }
            var r = obeNotaIngreso.NumeroNotaIngreso > 0 ?
                    obrNotaIngreso.Actualizar(obeNotaIngreso) :
                    obrNotaIngreso.Insertar(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     = "Error al momento de grabar";
                TempData["MENSAJE"] = ViewBag.Mensaje;
                //return View("~/Views/Shared/_Mensajes.cshtml");
                return(Redirect("~/NotaIngreso/Editar"));
            }
            else
            {
                if (obeNotaIngreso.NumeroNotaIngreso > 0)
                {
                    if (bNuevo)
                    {
                        ViewBag.Mensaje = "Se generó Nota de Ingreso N° " + obeNotaIngreso.NumeroNotaIngreso.ToString();
                    }
                    else
                    {
                        ViewBag.Mensaje = "Se actualizó Nota de Ingreso N° " + obeNotaIngreso.NumeroNotaIngreso.ToString();
                    }
                    TempData["MENSAJE"] = ViewBag.Mensaje;
                    return(Redirect("~/NotaIngreso/Editar/" + obeNotaIngreso.NumeroNotaIngreso.ToString()));
                }
                else
                {
                    ViewBag.Mensaje     = "Se generó Nota de Ingreso N° " + obeNotaIngreso.NumeroNotaIngreso.ToString();
                    TempData["MENSAJE"] = ViewBag.Mensaje;
                }
            }

            return(Redirect("~/NotaIngreso/Index"));
        }
Exemplo n.º 5
0
 public Boolean ActualizarEstado(beNotaIngreso obeNotaIngreso)
 {
     using (SqlConnection con = new SqlConnection(CadenaConexion))
     {
         try
         {
             con.Open();
             daNotaIngreso odaNotaIngreso = new daNotaIngreso();
             odaNotaIngreso.ActualizarEstado(con, obeNotaIngreso);
             return(true);
         }
         catch (Exception ex)
         {
             GrabarLog(ex);
             return(false);
         }
     }
 }
Exemplo n.º 6
0
        public beNotaIngreso ListarxID(int id)
        {
            beNotaIngreso obeNotaIngreso = new beNotaIngreso();

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                try
                {
                    con.Open();
                    daNotaIngreso odaNotaIngreso = new daNotaIngreso();
                    obeNotaIngreso = odaNotaIngreso.ListarxID(con, id);
                }
                catch (Exception ex)
                {
                    GrabarLog(ex);
                }
            }
            return(obeNotaIngreso);
        }
Exemplo n.º 7
0
        public Boolean Insertar(SqlConnection con, beNotaIngreso obeNotaIngreso)
        {
            SqlCommand cmd = new SqlCommand("uspNotaIngresoInsertar", con);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@NumeroNotaIngreso", obeNotaIngreso.NumeroNotaIngreso);
            cmd.Parameters.AddWithValue("@Fecha", obeNotaIngreso.Fecha);
            cmd.Parameters.AddWithValue("@NumeroOrdenCompra", obeNotaIngreso.NumeroOrdenCompra);
            cmd.Parameters.AddWithValue("@IdEmpleado", obeNotaIngreso.IdEmpleado);
            //cmd.Parameters.AddWithValue("@UsuarioRecibo", obeNotaIngreso.UsuarioRecibo);
            cmd.Parameters.AddWithValue("@IdAlmacen", obeNotaIngreso.IdAlmacen);
            cmd.Parameters.AddWithValue("@GuiaRemision", obeNotaIngreso.GuiaRemision);
            cmd.Parameters.AddWithValue("@Observaciones", obeNotaIngreso.Observaciones);
            cmd.Parameters.AddWithValue("@EstadoNotaIngreso", obeNotaIngreso.EstadoNotaIngreso);
            cmd.Parameters.AddWithValue("@IdProveedor", obeNotaIngreso.IdProveedor);
            obeNotaIngreso.NumeroNotaIngreso = (int)cmd.ExecuteScalar();

            return(true);
        }
Exemplo n.º 8
0
        public ActionResult Editar(int id = 0)
        {
            List <beProveedor> listaProveedor = obrProveedor.Listar();

            ViewBag.DetalleNotaIngreso = obrDetalleNotaIngreso.ListarxNota(id);
            beNotaIngreso obeNotaIngeso = new beNotaIngreso();

            obeNotaIngeso.IdAlmacen = 0;
            var proveedores = new SelectList(listaProveedor.ToArray(), "idProveedor", "nombreProveedor");
            List <beAlmacen> listaAlmacen = obrAlmacen.Listar();
            var almacenes = new SelectList(listaAlmacen.ToArray(), "idAlmacen", "nombreAlmacen");
            List <beEmpleadoRH> listaSupervisor = obrEmpleado.Listar();
            var supervisores = new SelectList(listaSupervisor.ToArray(), "codEmpleado", "nombreCompleto");

            ViewBag.Proveedor  = proveedores;
            ViewBag.Almacen    = almacenes;
            ViewBag.Supervisor = supervisores;

            ViewBag.Mensaje = TempData["MENSAJE"];

            beNotaIngreso registro = new beNotaIngreso();

            if (id == 0)
            {
                registro.Fecha             = DateTime.Now;
                registro.IdEmpleado        = 2;
                registro.EstadoNotaIngreso = "G";
            }
            else
            {
                registro = obrNotaIngreso.ListarxID(id);
            }
            registro.FechaFormateada = registro.Fecha.ToShortDateString();

            return(View(registro));
        }