コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        public ProductoMovimientosViewModel(IWindowManager windowmanager)
        {
            _windowManager = windowmanager;
            CmbZonas = (new TipoZonaSQL()).BuscarZona();
            Usuario u = new Usuario();
            u = DataObjects.Seguridad.UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));
            idTienda = u.IdTienda;
            idResponsable = u.IdUsuario;

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

            NumColumnAnq = anaquel.NroColumnas;
            NumRowsAnq = anaquel.NroFilas;
            AlturaAnq = anaquel.Altura;

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

            tzSQL = new TipoZonaSQL();
            LstZonas = tzSQL.ObtenerZonasxAlmacen(idDeposito);
            LstZonasAnq = tzSQL.ObtenerZonasxAlmacen(idAnaquel, 2);

            Accion2 = 2;
            Accion1 = 2;

            LstProductos = new List<ProductoCant>();
            Atendido = false;
        }
コード例 #4
0
 public reporteStockViewModel()
 {
     uSQL = new AlmacenSQL();
     CmbDpto = uSQL.BuscarAlmacen();
     deft= new Almacenes();
     deft.Nombre="TODOS";
     CmbDpto.Insert(0, deft);
     Index1 = 0;
 }
コード例 #5
0
        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"));
            }
        }
コード例 #6
0
        public void BuscarAlmacenes()
        {
            if (String.IsNullOrEmpty(TxtCodigo))
                LstAlmacenes = new AlmacenSQL().BuscarAlmacen();
            else
            {
                List<Almacenes> list = new List<Almacenes>();
                List<Almacenes> listAux = new AlmacenSQL().BuscarAlmacen();

                for (int i = 0; i < listAux.Count; i++)
                {
                    if (listAux[i].IdAlmacen == (Convert.ToInt32(TxtCodigo)))
                        list.Add(listAux[i]);
                }

                LstAlmacenes = new List<Almacenes>(list);
            }
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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;
        }
コード例 #9
0
        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;
            }
        }
コード例 #10
0
 public ProductoBuscarViewModel(IWindowManager windowmanager, Ventas.VentaRegistrarViewModel ventaRegistrarViewModel, int ventanaAccion)
     : this(windowmanager)
 {
     this.ventaRegistrarViewModel = ventaRegistrarViewModel;
     this.ventanaAccion = ventanaAccion;
     AlmacenSQL almSQL = new AlmacenSQL();
     idAlmacen = almSQL.obtenerDeposito(ventaRegistrarViewModel.idTienda);
     SelectedTienda = ventaRegistrarViewModel.idTienda;
     Index = CmbTiendas.FindIndex(x => x.IdTienda == SelectedTienda);
 }
コード例 #11
0
        public Tienda BuscarTIENfromID(int id)
        {
            DBConexion db = new DBConexion();
            db.cmd.CommandText = "SELECT * FROM Tienda WHERE idTienda = " + id;

            try
            {
                db.conn.Open();
                SqlDataReader reader = db.cmd.ExecuteReader();
                if (reader.Read())
                {
                    Tienda t = new Tienda();
                    t.IdTienda = int.Parse(reader["idTienda"].ToString());
                    t.IdUbigeo = reader.IsDBNull(reader.GetOrdinal("idUbigeo")) ? -1 : int.Parse(reader["idUbigeo"].ToString());
                    t.Nombre = reader.IsDBNull(reader.GetOrdinal("nombre")) ? null : reader["nombre"].ToString();
                    t.Direccion = reader.IsDBNull(reader.GetOrdinal("direccion")) ? null : reader["direccion"].ToString();
                    t.Telefono = reader.IsDBNull(reader.GetOrdinal("telefono")) ? null : reader["telefono"].ToString();
                    t.Administrador = reader.IsDBNull(reader.GetOrdinal("administrador")) ? null : reader["administrador"].ToString();
                    AlmacenSQL aSQL = new AlmacenSQL();
                    t.Deposito = aSQL.BuscarAlmacen(-1, t.IdTienda, 1);

                    Trace.WriteLine("Deposito: " + t.Deposito.Nombre);
                    return t;
                }

                db.cmd.Parameters.Clear();
                db.conn.Close();
                reader.Close();

            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
                return null;
            }

            return null;
        }
コード例 #12
0
        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 = "";
        }
コード例 #13
0
        public Almacenes getAlmacenfromIDTienda(int id)
        {
            List<Almacenes> list = new AlmacenSQL().BuscarAlmacen();
            for (int i = 0; i < list.Count; i++)
                if (list[i].IdTienda == id)
                {
                    return list[i];
                }

            return null;
        }
コード例 #14
0
        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;
        }
コード例 #15
0
        public PosicionProductoViewModel(IWindowManager windowmanager, object sender, int accion)
        {
            _windowManager = windowmanager;
            this.accion = accion;
            if (accion == 1)
            {
                this.mantenerNotaDeIngresoViewModel = (sender as MantenerNotaDeIngresoViewModel);
                this.LstProductos = (sender as MantenerNotaDeIngresoViewModel).LstProductos;
                ImSource = "/Assets/add.png";
                Ejecutar = "Agregar";

            }
            else
            {
                this.mantenerNotaDeSalidaViewModel = (sender as MantenerNotaDeSalidaViewModel);
                this.LstProductos = (sender as MantenerNotaDeSalidaViewModel).LstProductos;
                ImSource = "/Assets/minus.png";
                Ejecutar = "Disminuir";

            }

            Usuario u = new Usuario();
            u = DataObjects.Seguridad.UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));

            idTienda = u.IdTienda;
            aSQL = new AlmacenSQL();
            Almacenes deposito = aSQL.BuscarAlmacen(-1, idTienda == 0 ? -1 : idTienda, idTienda == 0 ? 3 : 1);

            id = deposito.IdAlmacen;

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

            tzSQL = new TipoZonaSQL();
            LstZonas = tzSQL.ObtenerZonasxAlmacen(deposito.IdAlmacen);

            Accion2 = 2;
            Accion1 = 2;
            Enable = true;
        }
コード例 #16
0
ファイル: NotaISSQL.cs プロジェクト: alfonsobp/made-in-house
        public List<NotaIS> BuscarNotas(string a = null)
        {
            List<NotaIS> lstNotaIs = new List<NotaIS>();

            AlmacenSQL asql = new AlmacenSQL();
            if (a != null)
            {
            if (string.Compare("Entrada", a, true) == 0)
            {
                string where = " WHERE tipo=1 ORDER BY fechaReg Desc";
                db.cmd.CommandText = "SELECT * FROM NotaIS" + where;

            }
            if (string.Compare("Salida", a, true) == 0)
            {
                string where = " WHERE tipo=2 ORDER BY fechaReg Desc";
                db.cmd.CommandText = "SELECT * FROM NotaIS" + where;

            }
            if (string.Compare("MovimientoInterno", a, true) == 0)
            {
                string where = " WHERE tipo=3 ORDER BY fechaReg Desc";
                db.cmd.CommandText = "SELECT * FROM NotaIS" + where;

            }
            }
            else {
            db.cmd.CommandText = "SELECT * FROM NotaIS ORDER BY fechaReg Desc";

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

                while (reader.Read())
                {
                    NotaIS nota = new NotaIS();

                    nota.FechaReg = reader.IsDBNull(reader.GetOrdinal("fechaReg")) ? DateTime.MinValue : DateTime.Parse(reader["fechaReg"].ToString());
                    nota.IdAlmacen = reader.IsDBNull(reader.GetOrdinal("idAlmacen")) ? -1 : int.Parse(reader["idAlmacen"].ToString());
                    nota.IdDoc = reader.IsDBNull(reader.GetOrdinal("idDoc")) ? -1 : int.Parse(reader["idDoc"].ToString());
                    nota.IdMotivo = reader.IsDBNull(reader.GetOrdinal("idMotivo")) ? -1 : int.Parse(reader["idMotivo"].ToString());
                    nota.IdNota = reader.IsDBNull(reader.GetOrdinal("idNota")) ? -1 : int.Parse(reader["idNota"].ToString());
                    nota.IdResponsable = reader.IsDBNull(reader.GetOrdinal("responsable")) ? -1 : int.Parse(reader["responsable"].ToString());
                    nota.Observaciones = reader.IsDBNull(reader.GetOrdinal("observaciones")) ? "" : reader["observaciones"].ToString();
                    nota.Tipo = reader.IsDBNull(reader.GetOrdinal("tipo")) ? -1 : int.Parse(reader["tipo"].ToString());
                    nota.IdNotaString = "Nota00000" + nota.IdNota.ToString();
                    nota.IdAlmacenString = asql.BuscarAlmacen(nota.IdAlmacen, -1, -1).Nombre;
                    if (nota.Tipo == 1) nota.TipoString = "Entrada";
                    if (nota.Tipo == 2) nota.TipoString = "Salida";
                    if (nota.Tipo == 3) nota.TipoString = "Movimiento Interno";
                    nota.LstProducto = BuscarNotas(nota.IdNota);
                    lstNotaIs.Add(nota);

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

            return lstNotaIs;
        }
コード例 #17
0
        public List<OrdenDespacho> BuscarOrdenDespacho(int idOrdenDespacho, int idVenta, int estado)
        {
            List<OrdenDespacho> listaOrdenDespacho = new List<OrdenDespacho>();

            string select = "SELECT * ";
            string from = "FROM OrdenDespacho ";
            string where = "WHERE 1 = 1";

            if (estado > 0)
            {
                where += " AND estado = @estado ";
                db.cmd.Parameters.AddWithValue("@estado", estado);
            }
            if (idOrdenDespacho > 0)
            {
                where += " AND idOrdenDespacho = @idOrdenDespacho ";
                db.cmd.Parameters.AddWithValue("@idOrdenDespacho", idOrdenDespacho);
            }

            if (idVenta > 0)
            {
                where += " AND idVenta = @idVenta ";
                db.cmd.Parameters.AddWithValue("@idVenta", idVenta);
            }

            Usuario u = UsuarioSQL.buscarUsuarioPorIdUsuario(Int32.Parse(Thread.CurrentPrincipal.Identity.Name));

            // PARA USUARIO EN ALMACEN

            if (u.IdTienda != 0)
            {
                AlmacenSQL aSQL = new AlmacenSQL();
                int idTi = u.IdTienda;
                Almacenes alm = aSQL.BuscarAlmacen(-1, idTi, 1);

                if (alm != null)
                {
                    Trace.WriteLine("IDALMACEN: " + alm.IdAlmacen);
                    Trace.WriteLine("IDTIENDA: " + idTi);

                    where += " AND idAlmacen = @idAlmacen ";
                    db.cmd.Parameters.AddWithValue("@idAlmacen", alm.IdAlmacen);
                }
            }

            db.cmd.CommandText = select + from + where;

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

                while (reader.Read())
                {

                    OrdenDespacho p = new OrdenDespacho();

                    p.IdOrdenDespacho = Int32.Parse(reader["idOrdenDespacho"].ToString());
                    p.CodOrden = "OD-" + (1000000 + p.IdOrdenDespacho).ToString();

                    int id = Int32.Parse(reader["idVenta"].ToString());
                    p.Venta = new MantenerGuiaDeRemisionViewModel(new MyWindowManager()).getVentafromID(id);
                    p.Estado = Int32.Parse(reader["estado"].ToString());
                    p.FechaDespacho = DateTime.Parse(reader["fechaDespacho"].ToString());
                    p.Direccion = reader["direccion"].ToString();
                    p.Telefono = reader["telefono"].ToString();

                    int idTienda = u.IdTienda;

                    //Trace.WriteLine("IdTienda: "+idTienda);
                    p.AlmOrigen = BuscarTIENfromID(idTienda).Deposito;

                    if (p.Venta.IdUsuario == Int32.Parse(Thread.CurrentPrincipal.Identity.Name))
                        listaOrdenDespacho.Add(p);
                }
                db.cmd.Parameters.Clear();
                reader.Close();
                db.conn.Close();
            }
            catch (SqlException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.StackTrace.ToString());
            }

            return listaOrdenDespacho;
        }
コード例 #18
0
 public ProductoBuscarViewModel(IWindowManager windowmanager, SolicitudAbRegistrarViewModel solicitudView)
     : this(windowmanager)
 {
     this.solicitudView = solicitudView;
     AlmacenSQL almSQL = new AlmacenSQL();
     idAlmacen = solicitudView.idTienda;
     SelectedTienda = solicitudView.idTienda;
     Index = CmbTiendas.FindIndex(x => x.IdTienda == SelectedTienda);
 }
コード例 #19
0
        public int GuardarAlmacen(MadeInHouse.Dictionary.DynamicGrid deposito)
        {
            int exito = 1;

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

            Almacenes central = new Almacenes();
            central.Estado = 1;
            central.CodAlmacen = "CENTRAL001";
            central.Nombre = TxtNombre;
            central.Direccion = TxtDir;
            central.Telefono = TxtTelefono;
            central.Administrador = txtAdmin;
            Ubigeo seleccionado = new Ubigeo();
            UbigeoSQL uSQL = new UbigeoSQL(db);
            seleccionado = uSQL.buscarUbigeo(selectedDpto, selectedProv, selectedDist);
            central.IdUbigeo = seleccionado.IdUbigeo;
            central.FechaReg = DateTime.Today;
            AlmacenSQL aSQL = new AlmacenSQL(db);
            if (TxtNumColumns != null) central.NroColumnas = int.Parse(TxtNumColumns);
            else return -1;
            central.NroFilas = int.Parse(TxtNumRows);

            if (TxtAltura != null) central.Altura = int.Parse(TxtAltura);
            else return -1;
            central.Tipo = 3;
            int idAlmacen = aSQL.Agregar(central);
            central.IdAlmacen = idAlmacen;
            central.CodAlmacen = "CENTRAL001";
            int up = aSQL.Actualizar(central);

            if (idAlmacen > 0 && up > 0)
            {
                DataTable zonaxAlmacenData = CrearZonasDT();
                AgregarFilasToZonasDT(zonaxAlmacenData, deposito.listaZonas, idAlmacen);
                /*Agrego las zonas por almacen*/

                exito = aSQL.AgregarZonasMasivo(zonaxAlmacenData, trans);

                if (exito > 0)
                {
                    UbicacionSQL ubSQL = new UbicacionSQL(db);

                    /*Ubicaciones del anaquel*/
                    DataTable ubicacionesData = CrearUbicacionesDT();
                    AgregarFilasToUbicacionesDT(ubicacionesData, deposito.Ubicaciones, idAlmacen);
                    exito = ubSQL.AgregarMasivo(ubicacionesData, trans);

                    trans.Commit();
                    _windowManager.ShowDialog(new AlertViewModel(_windowManager, "Se creó el almacen central correctamente"));
                    return 1;
                }
                else
                {
                    _windowManager.ShowDialog(new AlertViewModel(_windowManager, "ERROR"));
                }
            }
            else
            {
                _windowManager.ShowDialog(new AlertViewModel(_windowManager, "ERROR"));
            }

            trans.Rollback();
            return -1;
        }