public BuscarZonaViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            Usuario u = new Usuario();
            u = DataObjects.Seguridad.UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));
            idTienda = u.IdTienda;
            idResponsable = u.IdUsuario;

            TiendaSQL tSQL = new TiendaSQL();
            CmbTiendas = tSQL.BuscarTienda();
            Index = this.CmbTiendas.FindIndex(x => x.IdTienda == idTienda);

            AlmacenSQL aSQL = new AlmacenSQL();
            Almacenes anaquel = aSQL.BuscarAlmacen(-1, idTienda, 2);

            idAnaquel = anaquel.IdAlmacen;

            NumColumns = anaquel.NroColumnas;
            NumRows = anaquel.NroFilas;
            Altura = anaquel.Altura;

            TipoZonaSQL tzSQL = new TipoZonaSQL();
            LstZonasAnq = tzSQL.ObtenerZonasxAlmacen(idAnaquel, 2);
            CmbZonas = lstZonasAnq;
            ProductoSQL pSQL = new ProductoSQL();
            LstProductos = pSQL.BuscarProductoxTienda(idTienda);
        }
        public MantenerNotaDeIngresoViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            pxaSQL = new ProductoSQL();
            this.cmbMotivo = DataObjects.Almacen.MotivoSQL.BuscarMotivos(1);
            AlmacenSQL aGW = new AlmacenSQL();
            u = DataObjects.Seguridad.UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));
            idTienda = u.IdTienda;
            Models.Almacen.Almacenes a;
            if (idTienda != 0)
            {
                //1 deposito
                //2 anaquel
                //3 central va al else
                a = aGW.BuscarAlmacen(-1, idTienda, 1);
            }
            else
            {
                a = aGW.BuscarAlmacen(-1, -1, 3);
            }

            List<Usuario> ul = new List<Usuario>();
            ul.Add(u);
            this.responsable = new List<Usuario>(ul);

            List<Models.Almacen.Almacenes> al = new List<Models.Almacen.Almacenes>();
            al.Add(a);
            this.almacen = al;
            Estado = true;
            EstadoMot = true;
            EstadoPro = true;
        }
        public StockMinListadoViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            Usuario u = new Usuario();
            u = DataObjects.Seguridad.UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));
            idTienda = u.IdTienda;
            idResponsable = u.IdUsuario;

            if (idTienda > 0) Enable = false;
            else Enable = true;

            Tienda central = new Tienda();
            central.Nombre = "ALMACEN CENTRAL";
            central.IdTienda = 0;

            TiendaSQL tSQL = new TiendaSQL();
            CmbTiendas = tSQL.BuscarTienda();
            CmbTiendas.Insert(0, central);

            Index = this.CmbTiendas.FindIndex(x => x.IdTienda == idTienda);

            if (idTienda > 0)
            {
                ProductoSQL pSQL = new ProductoSQL();
                LstProductos = pSQL.BuscarProductoxTienda(idTienda, true);
            }
            else
            {
                ProductoSQL pSQL = new ProductoSQL();
                LstProductos = pSQL.BuscarProductoxCentral(1,-1, true);
            }
        }
        public MantenerAlmacenViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            uSQL = new UbigeoSQL();
            tSQL = new TiendaSQL();
            pxaSQL = new ProductoSQL();
            aSQL = new AlmacenSQL();
            tzSQL = new TipoZonaSQL();
            int existe = aSQL.existeCentral();
            Editar = true;

            if (existe > 0)
            {
                Almacenes central = aSQL.BuscarAlmacen(-1, -1, 3);
                accion = 2;
                Editar = false;
                /* idTienda = t.IdTienda;  */
                /*carga de la informacion general*/
                TxtNombre = central.Nombre;
                TxtTelefono = central.Telefono;
                TxtDir = central.Direccion;
                List<Ubigeo> u = uSQL.buscarUbigeo2(central.IdUbigeo);

                /*carga de los combobox*/
                CmbDpto = uSQL.BuscarDpto();
                Index1 = CmbDpto.FindIndex(x => x.CodDpto == u[0].CodDpto);
                SelectedDpto = u[0].CodDpto;
                Index2 = CmbProv.FindIndex(x => x.CodProv == u[0].CodProv);
                SelectedProv = u[0].CodProv;
                Index3 = CmbDist.FindIndex(x => x.CodDist == u[0].CodDist);

                Content = "Ver distribución";
                TxtNumColumns = central.NroColumnas.ToString();
                TxtNumRows = central.NroFilas.ToString();
                TxtAltura = central.Altura.ToString();

                lstZonas = tzSQL.ObtenerZonasxAlmacen(central.IdAlmacen, 3);
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "El almacen central ya existe"));
            }
            else if (existe == 0)
            {
                CmbZonas = (new TipoZonaSQL()).BuscarZona();
                CmbDpto = uSQL.BuscarDpto();
                Content = "Generar distribución";
            }
            else
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Ocurrió un problema"));
            }
        }
        internal List<ProductoCant> ListaProductos(string idSolicitudAB)
        {
            List<ProductoCant> productos = new List<ProductoCant>();
            ProductoSQL pGw = new ProductoSQL();

            string where = "WHERE idSolicitudAB=@idSolicitudAB";

            db.cmd.Parameters.AddWithValue("@idSolicitudAB", idSolicitudAB);

            db.cmd.CommandText = "SELECT * FROM ProductoxSolicitudAb " + where;

            try
            {
                db.conn.Open();
                SqlDataReader reader = db.cmd.ExecuteReader();

                Producto p = new Producto();
                while (reader.Read())
                {
                    ProductoCant pa = new ProductoCant();
                    pa.IdProducto= reader.IsDBNull(reader.GetOrdinal("idProducto")) ? -1 : int.Parse(reader["idProducto"].ToString());
                    p = pGw.Buscar_por_CodigoProducto(pa.IdProducto);
                    pa.CodigoProd = p.CodigoProd.ToString();
                    pa.Nombre = p.Nombre;
                    pa.Can = reader.IsDBNull(reader.GetOrdinal("cantidad")) ? null : reader["cantidad"].ToString();
                    pa.CanAtend = reader.IsDBNull(reader.GetOrdinal("cantidadAtendida")) ? null : reader["cantidadAtendida"].ToString();

                    productos.Add(pa);

                }
                db.cmd.Parameters.Clear();
                db.conn.Close();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace.ToString());
            }

            return productos;
        }
        public MantenerTiendaViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            uSQL = new UbigeoSQL();
            tSQL = new TiendaSQL();
            pxaSQL = new ProductoSQL();
            aSQL = new AlmacenSQL();
            tzSQL = new TipoZonaSQL();

            CmbZonas = (new TipoZonaSQL()).BuscarZona();
            CmbDpto = uSQL.BuscarDpto();
            LstProductos = new List<ProductoxTienda>();
            LstProdAgregados = new List<ProductoxTienda>();
            //LstProductos = pxaSQL.BuscarProductoxTienda();
            Content = "Generar distribución";
            accion = 1;
        }
        //Botones:
        public void CargarProductos()
        {
            string referencia = TxtDoc;
            if (string.IsNullOrWhiteSpace(referencia))
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se ha ingresado ningun Documento de Referencia"));
                return;
            }
            string mot = this.selectedMotivo;
            if (string.Compare(mot, "Orden de Despacho", true) == 0)
            {

                List<DetalleVenta> l = new DetalleVentaSQL().BuscarTodos();
                List<ProductoCant> lpcan = new List<ProductoCant>();
                for (int i = 0; i < l.Count; i++)
                    if (l[i].IdDetalleV == SelectedDespacho.Venta.IdVenta)
                    {
                        Producto p = new ProductoSQL().Buscar_por_CodigoProducto(l[i].IdProducto);
                        ProductoCant pcan = new ProductoCant();
                        pcan.IdProducto = p.IdProducto;
                        pcan.CodigoProd = p.CodigoProd;
                        pcan.Nombre = p.Nombre;
                        pcan.CanAtender = l.ElementAt(i).Cantidad.ToString();
                        lpcan.Add(pcan);
                    }

                LstProductos = new List<ProductoCant>(lpcan);

            }
            else
            {
                if (string.Compare(mot, "Abastecimiento", true) == 0)
                {

                    List<ProductoCant> psa = new List<ProductoCant>();
                    ProductoxSolicitudAbSQL pasql = new ProductoxSolicitudAbSQL();

                    psa = pasql.ListaProductos(SelectedSolicitud.idSolicitudAB.ToString());

                    List<ProductoCant> lpcan = new List<ProductoCant>();
                    for (int i = 0; i < psa.Count; i++)
                    {
                        ProductoCant pcan = new ProductoCant();
                        pcan.IdProducto = psa.ElementAt(i).IdProducto;
                        pcan.Can = psa.ElementAt(i).Can;
                        pcan.CodigoProd = psa.ElementAt(i).CodigoProd;
                        pcan.Nombre = psa.ElementAt(i).Nombre;
                        pcan.CanAtend = "0";
                        pcan.CanAtender = psa.ElementAt(i).CanAtend;
                        pcan.Ubicaciones = new List<Ubicacion>();
                        lpcan.Add(pcan);
                    }

                    LstProductos = new List<ProductoCant>(lpcan);

                }
            }

            NotifyOfPropertyChange(() => LstProductos);
            EstadoMot = false;
            Estado = false;
        }
        public void GuardarVenta(string cmbTipoVenta)
        {
            int numFilas = LstVenta.Count();
            if (numFilas > 0)
            {
                Venta v = new Venta();
                v.LstDetalle = new List<DetalleVenta>();
                v.LstPagos = new List<VentaPago>();
                v.LstDetalleServicio = new List<DetalleVentaServicio>();
                //guardar datos de la venta
                //completar
                if (tipoVenta[cmbTipoVenta] == 0)
                    v.TipoDocPago = "Boleta";
                else
                {
                    v.TipoDocPago = "Factura";
                    //validar que los datos de ruc y razon social
                    if (!string.IsNullOrEmpty(TxtRuc) && !string.IsNullOrEmpty(TxtRazonSocial))
                    {
                        v.Ruc = TxtRuc;
                        v.RazonSocial = TxtRazonSocial;
                    }
                    else
                    {
                        MessageBox.Show("Falta ingresar Ruc o Razón Social", "AVISO", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                }

                v.NumDocPago = null;
                v.TipoVenta = "Tienda";
                v.Estado = 1;
                v.FechaReg = System.DateTime.Now;
                v.IdUsuario = Convert.ToInt32(Thread.CurrentPrincipal.Identity.Name);
                //idCliente desde la tarjeta de este si es que hay
                if (!string.IsNullOrEmpty(TxtCliente))
                {
                    v.IdCliente = Convert.ToInt32(cliente.Id);
                    v.CodTarjeta = Convert.ToInt32(TxtCliente);
                }
                else
                {
                    v.IdCliente = -1;
                    v.CodTarjeta = -1;
                }

                //guardar detalle de la venta
                foreach (DetalleVenta dv in lstVenta)
                {
                    v.LstDetalle.Add(dv);
                }
                v.Monto = total;
                v.Descuento = desc;
                v.Igv = igv_total;

                v.PtosGanados = Convert.ToInt32(v.Monto / PUNTO);

                foreach (VentaPago vp in lstPagos)
                {
                    if (vp.Nombre.Equals("Efectivo"))
                    {
                        vp.Monto -= Double.Parse(txtVuelto);
                    }
                    v.LstPagos.Add(vp);
                }

                //guardar detalle de servicios de la venta, si es que hay
                if (LstVentaServicios.Count() > 0)
                {
                    foreach (DetalleVentaServicio dvs in LstVentaServicios)
                    {
                        v.LstDetalleServicio.Add(dvs);
                    }
                }

                //insertar en la base de datos
                DBConexion db = new DBConexion();
                db.conn.Open();
                SqlTransaction trans = db.conn.BeginTransaction(IsolationLevel.Serializable);
                db.cmd.Transaction = trans;
                VentaSQL vsql = new VentaSQL(db);
                if (v.IdCliente == -1)
                {
                    int k = vsql.AgregarSinCliente(v);
                    if (k != 0)
                    {

                        NotaISSQL ntgw = new NotaISSQL();
                        NotaIS nota = new NotaIS();
                        AlmacenSQL asql = new AlmacenSQL();
                        nota.IdAlmacen = asql.BuscarAlmacen(-1, idTienda, 2).IdAlmacen;
                        // Logica de  Referencia de documento

                        //Si existe documento de referencia colocar el ID
                        nota.IdDoc = v.IdVenta;

                        nota.IdMotivo = 9;
                        nota.IdResponsable = v.IdUsuario;
                        nota.Observaciones = "Venta en Cajero";
                        nota.Tipo = 2;
                        List<ProductoCant> LstProductos = new List<ProductoCant>();
                        List<ProductoCant> lpcan = new List<ProductoCant>();

                        for (int i = 0; i < v.LstDetalle.Count; i++)
                        {
                            Producto p = new ProductoSQL().Buscar_por_CodigoProducto(v.LstDetalle.ElementAt(i).IdProducto);
                            ProductoCant pcan = new ProductoCant();
                            pcan.IdProducto = p.IdProducto;
                            pcan.CodigoProd = p.CodigoProd;
                            pcan.Nombre = p.Nombre;
                            pcan.CanAtender = v.LstDetalle.ElementAt(i).Cantidad.ToString();
                            lpcan.Add(pcan);

                        }
                        LstProductos = new List<ProductoCant>(lpcan);

                        nota.LstProducto = LstProductos;

                        nota.IdNota = ntgw.AgregarNota(nota);

                        trans.Commit();
                        ntgw.AgregarNotaxSector(nota);
                        MessageBox.Show("Venta Realizada con Exito");
                        Limpiar();
                    }
                    else
                    {
                        trans.Rollback();
                        MessageBox.Show("Ocurrio un Error en el proceso");
                    }
                }
                else
                {
                    int k = vsql.Agregar(v);
                    if (k != 0)
                    {

                        NotaISSQL ntgw = new NotaISSQL();
                        NotaIS nota = new NotaIS();
                        AlmacenSQL asql = new AlmacenSQL();
                        nota.IdAlmacen = asql.BuscarAlmacen(-1, idTienda, 2).IdAlmacen;
                        // Logica de  Referencia de documento

                        //Si existe documento de referencia colocar el ID
                        nota.IdDoc = v.IdVenta;

                        nota.IdMotivo = 9;
                        nota.IdResponsable = v.IdUsuario;
                        nota.Observaciones = "Venta en Cajero";
                        nota.Tipo = 2;
                        List<ProductoCant> LstProductos = new List<ProductoCant>();
                        List<ProductoCant> lpcan = new List<ProductoCant>();

                        for (int i = 0; i < v.LstDetalle.Count; i++)
                        {
                            Producto p = new ProductoSQL().Buscar_por_CodigoProducto(v.LstDetalle.ElementAt(i).IdProducto);
                            ProductoCant pcan = new ProductoCant();
                            pcan.IdProducto = p.IdProducto;
                            pcan.CodigoProd = p.CodigoProd;
                            pcan.Nombre = p.Nombre;
                            pcan.CanAtender = v.LstDetalle.ElementAt(i).Cantidad.ToString();
                            lpcan.Add(pcan);

                        }
                        LstProductos = new List<ProductoCant>(lpcan);

                        nota.LstProducto = LstProductos;

                        nota.IdNota = ntgw.AgregarNota(nota);

                        trans.Commit();

                        ntgw.AgregarNotaxSector(nota);
                        MessageBox.Show("Venta Realizada con Exito");
                        Limpiar();
                    }
                    else
                    {
                        trans.Rollback();
                        MessageBox.Show("Ocurrio un Error en el proceso");
                    }
                }

                if (v.TipoDocPago.Equals("Boleta"))
                {
                    GenerarPDFBoletaProductos(v);
                    if (v.LstDetalleServicio.Count() > 0)
                        GenerarPDFBoletaServicios(v);
                }
                else
                {
                    GenerarPDFFacturaProductos(v);
                    if (v.LstDetalleServicio.Count() > 0)
                        GenerarPDFFacturaServicios(v);
                }

            }
            else
            {
                MessageBox.Show("Debe ingreasar datos de la venta");
                return;
            }
        }
 public void Actualizar()
 {
     LstProductos = new ProductoSQL().BuscarProducto(txtNombre);
 }
        //Botones:
        public void CargarProductos()
        {
            string referencia = TxtDoc;
            if (string.IsNullOrWhiteSpace(referencia))
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se ha ingresado ningun Documento de Referencia"));
                return;
            }
            string mot = this.selectedMotivo;
            if (string.Compare(mot, "Orden de Compra", true) == 0)
            {
                List<ProductoxOrdenCompra> poc = new List<ProductoxOrdenCompra>();
                poc = SelectedOrden.LstProducto;
                List<ProductoCant> lpcan = new List<ProductoCant>();
                for (int i = 0; i < poc.Count; i++)
                {
                    ProductoCant pcan = new ProductoCant();
                    pcan.IdProducto = poc.ElementAt(i).Producto.IdProducto;
                    pcan.Can = poc.ElementAt(i).Cantidad;
                    pcan.CodigoProd = poc.ElementAt(i).Producto.CodigoProd;
                    pcan.Nombre = poc.ElementAt(i).Producto.Nombre;
                    pcan.CanAtend = poc.ElementAt(i).CantAtendida.ToString();
                    pcan.CanAtender = poc.ElementAt(i).CantidadAtender;
                    pcan.Ubicaciones = new List<Ubicacion>();
                    lpcan.Add(pcan);
                }
                LstProductos = new List<ProductoCant>(lpcan);

            }
            else
            {
                if (string.Compare(mot, "Traslado Externo", true) == 0)
                {
                    if (selectedGuia == null)
                    {
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Ingrese un código de guía de remisión valido"));
                    }
                    else
                    {
                        LstProductos = selectedGuia.Nota.LstProducto;
                    }
                }
                else
                {
                    if (string.Compare(mot, "Devolucion", true) == 0)
                    {
                        List<DevolucionProducto> dv = new List<DevolucionProducto>();
                        DevolucionSQL dsql = new DevolucionSQL();

                        dv = dsql.BuscarProductos(-1, -1, null, SelectedDevolucion.IdDevolucion);
                        List<ProductoCant> lpcan = new List<ProductoCant>();
                        for (int i = 0; i < dv.Count; i++)
                        {
                            ProductoCant pcan = new ProductoCant();
                            Producto p = new Producto();
                            ProductoSQL pgw = new ProductoSQL();
                            p = pgw.Buscar_por_CodigoProducto(dv.ElementAt(i).IdProducto);
                            pcan.IdProducto = p.IdProducto;
                            pcan.Nombre = p.Nombre;
                            pcan.Can = "0";
                            pcan.CanAtend = "0";
                            pcan.CanAtender = dv.ElementAt(i).Devuelto.ToString();
                            pcan.Ubicaciones = new List<Ubicacion>();
                            pcan.CodigoProd = p.CodigoProd;
                            lpcan.Add(pcan);
                        }
                        LstProductos = new List<ProductoCant>(lpcan);
                    }
                    else
                    {

                        if (string.Compare(mot, "Abastecimiento", true) == 0)
                        {

                            List<ProductoCant> psa = new List<ProductoCant>();
                            ProductoxSolicitudAbSQL pasql = new ProductoxSolicitudAbSQL();

                            psa = pasql.ListaProductos(SelectedSolicitud.idSolicitudAB.ToString());

                            List<ProductoCant> lpcan = new List<ProductoCant>();
                            for (int i = 0; i < psa.Count; i++)
                            {
                                ProductoCant pcan = new ProductoCant();
                                pcan.IdProducto = psa.ElementAt(i).IdProducto;
                                pcan.Can = psa.ElementAt(i).Can;
                                pcan.CodigoProd = psa.ElementAt(i).CodigoProd;
                                pcan.Nombre = psa.ElementAt(i).Nombre;
                                pcan.CanAtend = "0";
                                pcan.CanAtender = psa.ElementAt(i).CanAtend;
                                pcan.Ubicaciones = new List<Ubicacion>();
                                lpcan.Add(pcan);
                            }

                            LstProductos = new List<ProductoCant>(lpcan);

                        }
                    }
                }
            }

            NotifyOfPropertyChange(() => LstProductos);
            if (LstProductos != null)
            {
                EstadoMot = false;
                Estado = false;
            }
        }
        public void Recargar(MadeInHouse.Dictionary.DynamicGrid dg)
        {
            AlmacenSQL aSQL = new AlmacenSQL();
            Almacenes anaquel = aSQL.BuscarAlmacen(-1, idTienda, 2);

            idAnaquel = anaquel.IdAlmacen;

            NumColumns = anaquel.NroColumnas;
            NumRows = anaquel.NroFilas;
            Altura = anaquel.Altura;
            dg.RecreateGridCells();

            TipoZonaSQL tzSQL = new TipoZonaSQL();
            LstZonasAnq = tzSQL.ObtenerZonasxAlmacen(idAnaquel, 2);
            CmbZonas = lstZonasAnq;
            ProductoSQL pSQL = new ProductoSQL();
            LstProductos = pSQL.BuscarProductoxTienda(idTienda);
            TxtStockActual = "";
            TxtCapacidad = "";
        }
        public void RefrescarOrden()
        {
            Usuario u = getUsuariofromID(Orden.Venta.IdUsuario);
            Cliente c = getClientefromID(Orden.Venta.IdCliente);
            Tienda a = new GuiaDeRemisionSQL().BuscarTIENfromID(u.IdTienda);
            Almacenes alm = new GuiaDeRemisionSQL().BuscarALMDEPfromIdTienda(u.IdTienda);

            tiendaOrigen = a.Nombre;
            TxtAlmacenOrigen = alm.Nombre;
            TxtDirPartida = a.Direccion;
            TxtDirLlegada = Orden.Direccion;
            TxtTienda = c.RazonSocial;

            List<DetalleVenta> l = new DetalleVentaSQL().BuscarTodos();
            List<GuiaRemxProducto> lAux = new List<GuiaRemxProducto>();
            int cantTotal = 0;

            for (int i = 0; i < l.Count; i++)
                if (l[i].IdDetalleV == Orden.Venta.IdVenta)
                {
                    GuiaRemxProducto gp = new GuiaRemxProducto();
                    Producto p = new ProductoSQL().Buscar_por_CodigoProducto(l[i].IdProducto);
                    gp.CodProd = p.CodigoProd;
                    gp.Nombre = p.Nombre;
                    gp.Cantidad = l[i].Cantidad;
                    cantTotal += l[i].Cantidad;
                    lAux.Add(gp);
                }

            LstProductos = new List<GuiaRemxProducto>(lAux);
            TxtCantidad = cantTotal;
        }
        public void RefrescarNotas()
        {
            if (Nota.Tipo == 2)
            {

                Almacenes almOr = new GuiaDeRemisionSQL().BuscarALMfromID(Nota.IdAlmacen);
                Tienda a = new GuiaDeRemisionSQL().BuscarTIENfromID(almOr.IdTienda);

                if (a == null)
                    tiendaOrigen = "ALMACEN CENTRAL";
                else
                    tiendaOrigen = a.Nombre;

                TxtDirPartida = almOr.Direccion;
                TxtAlmacenOrigen = almOr.Nombre;

                List<ProductoxNotaIS> l = new NotaISSQL().BuscarNotasXProductos();
                List<GuiaRemxProducto> lAux = new List<GuiaRemxProducto>();
                int cantTotal = 0;

                for (int i = 0; i < l.Count; i++)
                    if (l[i].IdNota == Nota.IdNota)
                    {
                        GuiaRemxProducto gp = new GuiaRemxProducto();
                        Producto p = new ProductoSQL().Buscar_por_CodigoProducto(l[i].IdProducto);
                        gp.CodProd = p.CodigoProd;
                        gp.Nombre = p.Nombre;
                        gp.Cantidad = l[i].Cantidad;
                        cantTotal += l[i].Cantidad;
                        lAux.Add(gp);
                    }

                LstProductos = new List<GuiaRemxProducto>(lAux);
                TxtCantidad = cantTotal;
            }

            else
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Transacción única para NOTAS DE SALIDA"));
            }
        }
        public List<AbastecimientoProducto> buscarProductosAbastecimiento(int idSolicitud, int idTienda = -1)
        {
            List<AbastecimientoProducto> lstAux = null;
            List<ProductoxTienda> prod;
            ProductoSQL pSQL = new ProductoSQL();
            AlmacenSQL almSQL = new AlmacenSQL();
            AbastecimientoProducto abTemp;
            int posProd, posNomProd, posCant, posAtent;
            int idAlmacen = idTienda;
            if (idTienda == 0)
                idAlmacen = almSQL.obtenerDeposito(idTienda);

            db.cmd.CommandText = "SELECT * FROM ProductoxSolicitudAb ps, Producto p WHERE ps.idProducto = p.idProducto AND ps.idSolicitudAB = @idSolicitudAB ";
            db.cmd.Parameters.Add(new SqlParameter("idSolicitudAB", idSolicitud));

            if (db.cmd.Transaction == null) db.conn.Open();
            SqlDataReader reader = db.cmd.ExecuteReader();

            while (reader.Read())
            {
                if (lstAux == null) lstAux = new List<AbastecimientoProducto>();
                abTemp = new AbastecimientoProducto();
                posProd = reader.GetOrdinal("idProducto");
                posNomProd = reader.GetOrdinal("nombre");
                posCant = reader.GetOrdinal("cantidad");
                posAtent = reader.GetOrdinal("cantidadAtendida");
                abTemp.idProducto = reader.IsDBNull(posProd) ? -1 : reader.GetInt32(posProd);
                abTemp.nombre = reader.IsDBNull(posNomProd) ? null : reader.GetString(posNomProd);
                abTemp.pedido = reader.IsDBNull(posCant) ? -1 : reader.GetInt32(posCant);
                abTemp.atendido = reader.IsDBNull(posAtent) ? -1 : reader.GetInt32(posAtent);
                abTemp.atendidoReal = reader.IsDBNull(posAtent) ? -1 : reader.GetInt32(posAtent);
                if (idTienda == 0)
                    prod = pSQL.BuscarProductoxCentral(idAlmacen, abTemp.idProducto);
                else
                    prod = pSQL.BuscarProductoxTienda(idAlmacen, abTemp.idProducto);
                abTemp.stock = prod == null? -1 : prod.ElementAt(0).StockActual;
                abTemp.stockPendiente = prod == null ? -1 : prod.ElementAt(0).StockPendiente;
                abTemp.sugerido = prod == null ? -1 : ((prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual) > 0 ? (prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual) : 0);
                lstAux.Add(abTemp);
            }

            db.cmd.Parameters.Clear();
            reader.Close();
            if (db.cmd.Transaction == null) db.conn.Close();

            return lstAux;
        }
 public void Recargar()
 {
     if (SelectedTienda > 0)
     {
         ProductoSQL pSQL = new ProductoSQL();
         LstProductos = pSQL.BuscarProductoxTienda(SelectedTienda, true);
     }
     else
     {
         ProductoSQL pSQL = new ProductoSQL();
         LstProductos = pSQL.BuscarProductoxCentral(1, -1, true);
     }
 }
        public int GuardarTienda(MadeInHouse.Dictionary.DynamicGrid anaquel, MadeInHouse.Dictionary.DynamicGrid deposito)
        {
            Evaluador eva = new Evaluador();
            if (String.IsNullOrEmpty(TxtAlturaAnq) || String.IsNullOrEmpty(TxtNumColumnsAnq) || String.IsNullOrEmpty(TxtNumRowsAnq) ||
                 String.IsNullOrEmpty(TxtAlturaDto) || String.IsNullOrEmpty(TxtNumColumnsDto) || String.IsNullOrEmpty(TxtNumRowsDto) ||
                !eva.esNumeroEntero(TxtNumColumnsAnq) || !eva.esNumeroEntero(TxtNumColumnsDto) || !eva.esNumeroEntero(TxtNumRowsAnq) || !eva.esNumeroEntero(TxtNumRowsDto) ||
                !eva.esNumeroEntero(TxtAlturaAnq) || !eva.esNumeroEntero(TxtAlturaDto) ||
                int.Parse(TxtAlturaDto) <= 0 || int.Parse(TxtAlturaAnq) <= 0 || int.Parse(TxtNumColumnsAnq) <= 0 || int.Parse(TxtNumColumnsDto) <= 0 ||
                int.Parse(TxtNumRowsAnq) <= 0 || int.Parse(TxtNumRowsDto) <= 0  )
            {
                System.Windows.MessageBox.Show("Debes ingresar un numero entero para el numero de filas , columnas y altura");
                return 1;
            }

            int exito = 0;

            DBConexion db = new DBConexion();
            db.conn.Open();
            SqlTransaction trans = db.conn.BeginTransaction(IsolationLevel.Serializable);
            db.cmd.Transaction = trans;
            pxaSQL = new ProductoSQL(db);

                /*Agrega una tienda*/
                Tienda tienda = new Tienda();
                tienda.Estado = 1;
                tienda.Nombre = txtNombre;
                tienda.Direccion = txtDir;
                tienda.Telefono = txtTelef;
                tienda.Administrador = txtAdmin;
                Ubigeo seleccionado = new Ubigeo();
                UbigeoSQL uSQL = new UbigeoSQL(db);
                seleccionado = uSQL.buscarUbigeo(selectedDpto, selectedProv, selectedDist);
                tienda.IdUbigeo = seleccionado.IdUbigeo;
                tienda.FechaReg = DateTime.Today;
                TiendaSQL gw = new TiendaSQL(db);
                int idTienda=-1;

                if (accion == 1)
                    idTienda = gw.AgregarTienda(tienda);
                else if (accion == 2)
                {
                    tienda.IdTienda = this.idTienda;
                    exito = gw.ActualizarTienda(tienda);
                }
               if (idTienda > 0 || exito>0)
                {

                    /*Se agregan las dos partes de la tienda*/
                    AlmacenSQL aSQL = new AlmacenSQL(db);

                    /*anaquel*/
                    Almacenes ana = new Almacenes();
                    ana.CodAlmacen = "ANA00" + tienda.IdTienda.ToString();
                    ana.IdTienda = tienda.IdTienda;
                    ana.Nombre = "Anaquel de "+ txtNombre;
                    ana.Telefono = tienda.Telefono;
                    ana.Direccion = tienda.Direccion;
                    ana.NroColumnas = int.Parse(TxtNumColumnsAnq);
                    ana.NroFilas = int.Parse(TxtNumRowsAnq);
                    ana.Altura = int.Parse(TxtAlturaAnq);
                    ana.Tipo = 2;
                    int idAnaquel=-1;
                    if (accion == 1)
                        idAnaquel = aSQL.Agregar(ana);
                    else if (accion == 2)
                    {
                        ana.IdAlmacen = this.idAnaquel;
                        exito = aSQL.Actualizar(ana);
                    }
                    if (idAnaquel > 0 || exito>0)
                    {

                        /*deposito*/
                        Almacenes dto = new Almacenes();
                        dto.CodAlmacen = "DTO00" + tienda.IdTienda.ToString();
                        dto.IdTienda = tienda.IdTienda;
                        dto.Nombre = "Deposito de " + txtNombre;
                        dto.Telefono = tienda.Telefono;
                        dto.Direccion = tienda.Direccion;
                        dto.NroColumnas = int.Parse(TxtNumColumnsDto);
                        dto.NroFilas = int.Parse(TxtNumRowsDto);
                        dto.Altura = int.Parse(TxtAlturaDto);
                        dto.Tipo = 1;
                        int idDeposito=-1;
                        if (accion == 1)
                            idDeposito = aSQL.Agregar(dto);
                        else if (accion == 2)
                        {
                            dto.IdAlmacen = this.idDeposito;
                            exito = aSQL.Actualizar(dto);
                        }

                        if (idDeposito > 0 || exito>0)
                        {
                            if (accion == 1)
                            {
                                /*Productos de la tienda*/
                                for (int i = 0; i < LstProductos.Count; i++)
                                {
                                    LstProductos[i].IdAlmacen = idDeposito;
                                    LstProductos[i].IdTienda = idTienda;
                                     exito = pxaSQL.AgregarProductoxAlmacen(LstProductos[i]);

                                    if (exito <= 0) break;
                                }
                            }
                            else if (accion == 2)
                            {
                                DataTable productoxAlmacenDT= pxaSQL.CrearProductoxAlmacenDT();
                                pxaSQL.AgregarFilasToDT(productoxAlmacenDT, LstProductos);
                                exito = pxaSQL.ActualizarProductoxAlmacen(productoxAlmacenDT,trans);
                            }

                            if (exito > 0)
                            {
                               DataTable zonaxAlmacenData = CrearZonasDT();
                                AgregarFilasToZonasDT(zonaxAlmacenData, anaquel.listaZonas, (accion==1) ? idAnaquel :this.idAnaquel );
                                AgregarFilasToZonasDT(zonaxAlmacenData, deposito.listaZonas, (accion==1) ? idDeposito : this.idDeposito );

                                if (accion==1)
                                    exito = aSQL.AgregarZonasMasivo(zonaxAlmacenData, trans);
                                else if (accion==2)
                                    exito = aSQL.ActualizarZonasMasivo(zonaxAlmacenData, trans);

                                if (exito > 0)
                                {

                                    UbicacionSQL ubSQL = new UbicacionSQL(db);

                                    /*Ubicaciones del anaquel*/
                                    DataTable ubicacionesData = CrearUbicacionesDT();
                                    AgregarFilasToUbicacionesDT(ubicacionesData, anaquel.Ubicaciones, (accion == 1) ? idAnaquel : this.idAnaquel);
                                    AgregarFilasToUbicacionesDT(ubicacionesData, deposito.Ubicaciones, (accion == 1) ? idDeposito : this.idDeposito);

                                    if (accion == 1)
                                        exito = ubSQL.AgregarMasivo(ubicacionesData, trans);
                                    else if (accion == 2)
                                        exito = ubSQL.ActualizarUbicacionMasivo(ubicacionesData, trans);

                                    if (exito > 0)
                                    {
                                        trans.Commit();
                                        if (accion == 1)
                                        {
                                            //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar
                                            DataObjects.Seguridad.LogSQL.RegistrarActividad("Registrar Tienda", tienda.IdTienda+"", 1);
                                            System.Windows.MessageBox.Show("Se creó la tienda correctamente");
                                        }
                                        else if (accion == 2)
                                        {
                                            //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar
                                            DataObjects.Seguridad.LogSQL.RegistrarActividad("Actualizar Tienda",tienda.IdTienda+"" , 2);
                                            System.Windows.MessageBox.Show("Se editó la tienda correctamente");
                                        }
                                        return 1;
                                    }
                                    else
                                    {
                                        System.Windows.MessageBox.Show("ERROR");
                                    }
                                }
                                else
                                {
                                    System.Windows.MessageBox.Show("ERROR");
                                }
                            }
                            else
                            {
                                System.Windows.MessageBox.Show("ERROR");
                            }
                        }
                        else
                        {
                            System.Windows.MessageBox.Show("ERROR");
                        }
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("ERROR");
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("ERROR");
                }

                trans.Rollback();
                return -1;

               // System.Windows.MessageBox.Show("Se creo correctamente la tienda con id: " + idTienda.ToString() + " con anaquel id: " + idAnaquel.ToString() + " y con deposito id :" + idDeposito.ToString());
        }
Beispiel #17
0
        public List<ProductoCant> BuscarNotas(int p)
        {
            DBConexion db1 = new DBConexion();
            List<ProductoCant> lstProCant = new List<ProductoCant>();

            db1.cmd.CommandText = "SELECT idProducto,idNota,sum(cantidad) AS cantidad ,idAlmacen FROM ProductoxNotaIS WHERE idNota=@idNota GROUP BY idProducto, idNota, idAlmacen";
            db1.cmd.Parameters.AddWithValue("@idNota", p);

            try
            {
                db1.conn.Open();
                SqlDataReader reader = db1.cmd.ExecuteReader();

                while (reader.Read())
                {
                    ProductoSQL psql = new ProductoSQL();
                    ProductoCant procan = new ProductoCant();
                    procan.CanAtender = reader.IsDBNull(reader.GetOrdinal("cantidad")) ? null : reader["cantidad"].ToString();
                    procan.IdProducto = reader.IsDBNull(reader.GetOrdinal("idProducto")) ? -1 : int.Parse(reader["idProducto"].ToString());
                    Producto pr = psql.Buscar_por_CodigoProducto(procan.IdProducto);
                    procan.Nombre = pr.Nombre;
                    procan.CodigoProd = pr.CodigoProd;
                    lstProCant.Add(procan);

                }
                db1.cmd.Parameters.Clear();
                db1.conn.Close();

            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace.ToString());
            }

            return lstProCant;
        }
        public void AgregarNota()
        {
            NotaISSQL ntgw = new NotaISSQL();
            NotaIS nota = new NotaIS();
            nota.IdAlmacen = Almacen.ElementAt(0).IdAlmacen;
            // Logica de  Referencia de documento
            if (SelectedOrden!=null || SelectedGuia!=null || SelectedDevolucion!=null || SelectedSolicitud !=null)
            {
                // si hay documento de referencia colocar id;
                nota.IdDoc = TxtDocId;
            }
            else
            {
                //Si no existe documento de referencia colocar 0
                nota.IdDoc = 0;
            }
            if (String.IsNullOrEmpty(SelectedMotivo))
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se pudo guardar"));
                return;
            }

            nota.IdMotivo = DataObjects.Almacen.MotivoSQL.BuscarMotivo(SelectedMotivo).Id;
            nota.IdResponsable = Responsable.ElementAt(0).IdUsuario;
            nota.Observaciones = Observaciones;
            nota.Tipo = 1;

            nota.LstProducto = this.LstProductos;

            nota.IdNota = ntgw.AgregarNota(nota);

            if (nota.IdNota > 0)
            {

                ProductoxTiendaSQL ptgw = new ProductoxTiendaSQL();
                ProductoSQL pgw = new ProductoSQL();

                List<ProductoCant> list = ntgw.BuscarNotas(nota.IdNota);
                if (u.IdTienda != 0) ptgw.ActualizarStockEntrada(list, u.IdTienda);
                else pgw.ActualizarStockEntrada(list);

                //Actualizar Documentos de Referencia para darlos por Terminados! :)

                if (SelectedOrden != null)
                {
                    guardarOrden(list);
                }

                if (SelectedGuia != null)
                {

                    CambiarEstadoGuia(SelectedGuia);

                }

                if (SelectedDevolucion != null)
                {

                    CambiarEstadoDevolucion(SelectedDevolucion);

                }

                if (SelectedSolicitud != null) {
                    CambiarEstadoSolicitud(SelectedSolicitud);
                }
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Nota Creada"));
                //1: Agregar, 2: Editar, 3: Eliminar, 4: Recuperar, 5: Desactivar
                DataObjects.Seguridad.LogSQL.RegistrarActividad("Registrar Nota de Ingreso",  nota.IdNota.ToString(), 1);

            }
            else
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "No se pudo guardar"));
            }
        }
        public int InsertarValidado(CotizacionxProducto cp)
        {
            Producto p = new ProductoSQL().Buscar_por_CodigoProducto(cp.Producto.CodigoProd);
            int k = 0;

            cp.Producto = p;

            if (p != null)
            {

                DBConexion DB = new DBConexion();
                SqlConnection conn = DB.conn;
                SqlCommand cmd = DB.cmd;

                //MessageBox.Show("IDcot = " + cp.IdCotizacion + " IDprod = " + cp.Producto.IdProducto + " precio = " + cp.Precio + " cantidad = " + cp.Cantidad);

                cmd.CommandText = "IF NOT EXISTS(SELECT 1 from CotizacionxProducto where idCotizacion = @idCotizacion and idProducto = @idProducto) " +
                                   "Insert into CotizacionxProducto(idCotizacion,idProducto,cantidad,precio) " +
                                   "VALUES (@idCotizacion,@idProducto,@cantidad,@precio) " +
                                    " else " +
                                    "UPDATE CotizacionxProducto set cantidad = @cantidad, precio = @precio " +
                                    "where idCotizacion = @idCotizacion and idProducto = @idProducto ";

                cmd.Parameters.AddWithValue("@idCotizacion", cp.IdCotizacion);
                cmd.Parameters.AddWithValue("@idProducto", cp.Producto.IdProducto);
                cmd.Parameters.AddWithValue("@cantidad", cp.Cantidad);
                cmd.Parameters.AddWithValue("@precio", cp.Precio);

                cmd.CommandType = CommandType.Text;
                cmd.Connection = conn;

                try
                {
                    conn.Open();
                    k = cmd.ExecuteNonQuery();
                    conn.Close();

                }
                catch (SqlException e)
                {
                   // MessageBox.Show(e.StackTrace.ToString());
                }

            }
            return k;
        }
Beispiel #20
0
        public object Buscar(params object[] filters)
        {
            List<Servicio> lstServicio = new List<Servicio>();
            DBConexion db = new DBConexion();
            SqlDataReader reader;

            String where = "";
            string codProducto = "";

            if (filters.Length > 0 && filters.Length <= 3)
            {

                string proveedor = Convert.ToString(filters[0]);
                string nombre = Convert.ToString(filters[1]);
                codProducto = Convert.ToString(filters[2]);

                if (proveedor != "")
                {
                    int idProveedor = getIDfromProv(proveedor);
                    where += " and idProveedor = '" + idProveedor.ToString() + "' ";
                }

                if (nombre != "")
                {
                    where += " and nombre LIKE  '%" + nombre + "%' ";
                }

            }

            db.cmd.CommandText = "SELECT * FROM Servicio WHERE  estado = 1   " + where;
            db.cmd.CommandType = CommandType.Text;
            db.cmd.Connection = db.conn;

            try
            {
                db.conn.Open();

                reader = db.cmd.ExecuteReader();

                while (reader.Read())
                {

                    Servicio s = new Servicio();

                    s.IdServicio = Convert.ToInt32(reader["idServicio"].ToString());
                    s.IdProveedor = Convert.ToInt32(reader["idProveedor"].ToString());
                    s.CodServicio = reader["codServicio"].ToString();
                    s.Nombre = reader["nombre"].ToString();
                    s.Descripcion = reader["descripcion"].ToString();

                    if (codProducto != "")
                    {
                        ServicioxProductoSQL spSQL = new ServicioxProductoSQL();
                        Producto p = new ProductoSQL().Buscar_por_CodigoProducto(codProducto);

                        if (p != null)
                        {
                            //MessageBox.Show("idServ = " + s.IdServicio + " IdProd = " + p.IdProducto);
                            if (spSQL.productoPertenece(s.IdServicio, p.IdProducto) == true)
                                lstServicio.Add(s);
                        }
                    }

                    else
                        lstServicio.Add(s);
                }

                db.conn.Close();

            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace.ToString());
            }

            return lstServicio;
        }
        public int Insertar(ProveedorxProducto pp)
        {
            Producto p = new ProductoSQL().Buscar_por_CodigoProducto(pp.Producto.CodigoProd);
            int k = 0;

            if (p != null)
            {

                DBConexion DB = new DBConexion();

                SqlConnection conn = DB.conn;
                SqlCommand cmd = DB.cmd;
                SqlDataReader reader;

                cmd.CommandText = "IF NOT EXISTS(SELECT 1 from ProveedorxProducto where idProveedor = @idProveedor and idProducto = @idProducto  )" +
                                   "Insert into ProveedorxProducto(idProducto,idProveedor,codComercial,precio, estado,descripcion,fechaReg,fechaAct) " +
                                   "VALUES (@idProducto,@idProveedor,@codComercial,@precio,@estado,@descripcion,GETDATE(),GETDATE() )" +
                                    " else " +
                                    "UPDATE ProveedorxProducto set fechaAct = GETDATE() , precio = @precio , descripcion = @descripcion ,codComercial  = @codComercial " +
                                    " , estado = @estado where idProveedor = @idProveedor and idProducto = @idProducto ";

                cmd.Parameters.AddWithValue("@idProveedor", pp.IdProveedor);
                cmd.Parameters.AddWithValue("@idProducto", p.IdProducto);
                cmd.Parameters.AddWithValue("@codComercial", pp.CodComercial);
                cmd.Parameters.AddWithValue("@precio", pp.Precio);
                cmd.Parameters.AddWithValue("@estado", 1);
                cmd.Parameters.AddWithValue("@fechaReg", DateTime.Now);
                cmd.Parameters.AddWithValue("@fechaAct", DateTime.Now);
                cmd.Parameters.AddWithValue("@descripcion", pp.Descripcion);

                cmd.CommandType = CommandType.Text;
                cmd.Connection = conn;

                try
                {
                    conn.Open();

                    k = cmd.ExecuteNonQuery();

                    reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {

                        p = new Producto();
                        p.IdProducto = Convert.ToInt32(reader["idProducto"].ToString());
                        p.Nombre = reader["nombre"].ToString();
                        p.CodigoProd = reader["codProducto"].ToString();
                    }

                    conn.Close();

                }
                catch (Exception e)
                {
                    MessageBox.Show(e.StackTrace.ToString());
                }

            }
            return k;
        }
 public void Actualizar()
 {
     if (solicitudView != null)
     {
         ProductoSQL pSQL = new ProductoSQL();
         AbastecimientoProducto prodPedido = new AbastecimientoProducto();
         prodPedido.idProducto = productoSel.IdProducto;
         prodPedido.nombre = productoSel.Nombre;
         List<ProductoxTienda> prod = pSQL.BuscarProductoxTienda(idAlmacen, productoSel.IdProducto);
         prodPedido.stock = prod.ElementAt(0).StockActual;
         prodPedido.sugerido = prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual > 0 ? prod.ElementAt(0).StockMin - prod.ElementAt(0).StockActual : 0;
         prodPedido.pedido = prodPedido.sugerido;
         prodPedido.atendido = 0;
         solicitudView.addProducto(prodPedido);
     }
     else
     {
         _windowManager.ShowWindow(new ProductoMantenerViewModel(_windowManager, ProductoSel));
     }
 }
        public void BuscarProductos(MadeInHouse.Dictionary.DynamicGrid almacen, MadeInHouse.Dictionary.DynamicGrid ubicacionCol)
        {
            if (TxtProducto == null || TxtProducto == "")
            {
                _windowManager.ShowWindow(new ProductoBuscarViewModel(_windowManager, this, 7, idTienda));
            }

            else
            {

                ProductoCant pc = new ProductoCant();
                //Buscar producto del textBox Inicial:
                if (productoSeleccionado == null)
                {
                    ProductoSQL prodSQL = new ProductoSQL();
                    List<Producto> lstProd;
                    lstProd = prodSQL.BuscarProducto(TxtProducto);
                    if (lstProd == null)
                        _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Producto no existente con ese código"));
                    else
                    {
                        pc.Nombre = lstProd[0].Nombre;
                        pc.IdProducto = lstProd[0].IdProducto;
                        pc.CodigoProd = TxtProducto;
                        productoSeleccionado = null;
                    }
                }
                else
                {
                    pc.Nombre = ProductoSeleccionado.Nombre;
                    pc.IdProducto = ProductoSeleccionado.IdProducto;
                    pc.CodigoProd = ProductoSeleccionado.CodigoProd;
                    productoSeleccionado = null;
                }

                ubicacionCol.SelectedProduct = pc;
                almacen.UbicarProducto(pc.IdProducto);
                pc = null;
            }
        }