Esempio n. 1
0
        public int DisminuirProductos(int cant, int idProducto)
        {
            LinearGradientBrush vacio = new LinearGradientBrush();
            vacio.StartPoint = new System.Windows.Point(0, 0.5);
            vacio.EndPoint = new System.Windows.Point(10, 0.5);
            vacio.GradientStops.Add(new GradientStop(Colors.White, 0.1));

            int cantAux;
            if (selectedUbicacion == null)
            {
                return -1;
            }

            if (selectedUbicacion.Cantidad>0)
            {

                cantAux = selectedUbicacion.Cantidad - cant ;
                if (cantAux < 0)
                {
                    System.Windows.MessageBox.Show("No hay suficientes productos");
                    return -1;
                }
                else selectedUbicacion.VolOcupado = selectedUbicacion.VolOcupado - cant * selectedUbicacion.VolOcupado / selectedUbicacion.Cantidad;
            }
            else
            {
                System.Windows.MessageBox.Show("No hay productos en esa ubicacion");
                return -1;
            }

            Ubicacion ubiModificada = new Ubicacion();
            ubiModificada.IdProducto = SelectedProduct.IdProducto;
            ubiModificada.IdUbicacion = selectedUbicacion.IdUbicacion;
            ubiModificada.Cantidad = cant;
            SelectedProduct.Ubicaciones.Add(ubiModificada);

            selectedUbicacion.Cantidad -= cant;
            if (selectedUbicacion.Cantidad == 0)
            {
                if (ColorAntU != null) ColorAntU = vacio;
                Columna[selectedUbicacion.CordZ].IdProducto = 0;
            }
            Columna[selectedUbicacion.CordZ].Cantidad = selectedUbicacion.Cantidad;
            Columna[selectedUbicacion.CordZ].VolOcupado = selectedUbicacion.VolOcupado;

            CantActual = selectedUbicacion.Cantidad.ToString();
            VolOcu = selectedUbicacion.VolOcupado.ToString();
            this.Mostrar();

            return 1;
        }
Esempio n. 2
0
        public void onClickChange(object sender, RoutedEventArgs e)
        {
            int X = Int16.Parse((sender as Button).Name.Substring(1, (sender as Button).Name.IndexOf("X") - 1));
            int Y = Int16.Parse((sender as Button).Name.Substring((sender as Button).Name.IndexOf("Y") + 1));
            BrushConverter conv = new BrushConverter();
            SolidColorBrush colorClick = conv.ConvertFromString("LightSkyBlue") as SolidColorBrush;

            if (Accion == 1)
            {
                (sender as Button).Background = this.Background;

                if (listaZonas == null)
                {
                    listaZonas = new Dictionary<int, int>();
                }

                try
                {

                    if (Ubicaciones[X][Y][0].IdTipoZona == 0)
                    {
                        listaZonas[this.IdZona] += 1;
                    }
                    else if (Ubicaciones[X][Y][0].IdTipoZona != this.IdZona)
                    {
                        if (listaZonas[Ubicaciones[X][Y][0].IdTipoZona] < 0) listaZonas[Ubicaciones[X][Y][0].IdTipoZona] = 0;
                        else listaZonas[Ubicaciones[X][Y][0].IdTipoZona] -= 1;
                        listaZonas[this.IdZona] += 1;
                    }

                }
                catch (Exception d)
                {
                    listaZonas.Add(this.IdZona, 1);
                }

                for (int k = 0; k < Altura; k++)
                    Ubicaciones[X][Y][k].IdTipoZona = this.IdZona;
            }
            else if (Accion ==2)
            {
                if (Tipo == 1)
                {
                    if (colorAnt != null)
                    {
                         (this.Children[Ubicaciones[xAnt][yAnt][0].CordY + Ubicaciones[xAnt][yAnt][0].CordX * NumColumns] as Button).Background = colorAnt;
                    }
                    xAnt = X;
                    yAnt = Y;

                    NumColumnsU = 1;
                    AlturaU = 1;
                    NumRowsU = Altura;
                    ColumnaU = Ubicaciones[X][Y];
                    colorAnt = (this.Children[Ubicaciones[X][Y][0].CordY + Ubicaciones[X][Y][0].CordX * NumColumns] as Button).Background as SolidColorBrush ;
                    ColorAntU = null;
                }

                if (Tipo == 2)
                {
                    if (ColorAntU != null)
                    {
                        (this.Children[Ubicaciones[xAntU][yAntU][0].CordY + Ubicaciones[xAntU][yAntU][0].CordX * NumColumns] as Button).Background = ColorAntU;
                    }
                    xAntU = X;
                    yAntU = Y;
                    ColorAntU = (this.Children[Ubicaciones[X][Y][0].CordY + Ubicaciones[X][Y][0].CordX * NumColumns] as Button).Background as LinearGradientBrush;
                    if (SelectedProduct != null)
                    {
                        if (Columna[X].IdProducto == SelectedProduct.IdProducto)
                        {

                            CantActual = Columna[X].Cantidad.ToString();
                            VolOcu = Columna[X].VolOcupado.ToString();
                            if (int.Parse(VolOcu) > 0) Enable = false;
                            else Enable = true;
                            Permitir = true;
                        }
                        else if (Columna[X].IdProducto == 0)
                        {
                            CantActual = "0";
                            VolOcu = "0";
                            Enable = true;
                            Permitir = true;

                        }
                        else
                        {
                            CantActual = "---";
                            VolOcu = "---";
                            Enable = false;
                            Permitir = false;
                        }
                        selectedUbicacion = Columna[X];
                    }

                }
                (this.Children[Ubicaciones[X][Y][0].CordY + Ubicaciones[X][Y][0].CordX * NumColumns] as Button).Background = colorClick;

            }
            else if (Accion == 3)
            {
                if (SelectedProduct != null)
                {

                    if (Ubicaciones[X][Y][0].IdProducto == 0 ) {

                        TipoZona tz=lstZonas.Find(x => x.IdTipoZona == SelectedZona);
                        Sector sector= tz.LstSectores.Find(x => x.IdProducto == SelectedProduct.IdProducto);
                        Ubicaciones[X][Y][0].IdProducto = SelectedProduct.IdProducto;
                        if (sector != null)
                        {
                            //verifico si puedo agregar o no esa ubicacion al sector ( es decir , si es contigua)
                            Ubicaciones[X][Y][0].IdSector = sector.IdSector;

                            if (sector.Capacidad != 0)
                            {
                                sector.Capacidad = sector.Capacidad /sector.NroUbicaciones + sector.Capacidad ;
                                sector.VolOcupado = (sector.Cantidad / sector.Capacidad) * 100;
                            }
                            sector.NroUbicaciones += 1;
                            sector.LstUbicaciones.Add(Ubicaciones[X][Y][0]);

                        }
                        else
                        {
                            string capAux= Microsoft.VisualBasic.Interaction.InputBox("Ingrese la capacidad que tendra cada columna ", "Capacidad de la columna");
                            if (String.IsNullOrEmpty(capAux))
                            {
                                return;
                            }
                            sector = new Sector();
                            sector.IdProducto = SelectedProduct.IdProducto;
                            sector.Cantidad = 0;
                            sector.VolOcupado = 0;
                            sector.Capacidad = int.Parse(capAux);
                            sector.NroUbicaciones = 1;
                            sector.IdTipoZona = SelectedZona;
                            sector.IdAlmacen = Ubicaciones[X][Y][0].IdAlmacen;
                            sector.LstUbicaciones = new List<Ubicacion>();
                            sector.LstUbicaciones.Add(Ubicaciones[X][Y][0]);
                            tz.LstSectores.Add(sector);
                        }
                        (this.Children[Ubicaciones[X][Y][0].CordY + Ubicaciones[X][Y][0].CordX * NumColumns] as Button).Background = colorClick;
                    }

                }

            }
        }
Esempio n. 3
0
        public int AgregarProductos(int cant, int vol, int idProducto)
        {
            if (selectedUbicacion==null) return -1;
            int volAux;
            if (selectedUbicacion.VolOcupado != 0)
            {

                volAux =selectedUbicacion.VolOcupado + cant * selectedUbicacion.VolOcupado / selectedUbicacion.Cantidad;
                if (volAux > 100)
                {
                    System.Windows.MessageBox.Show("No se pudo ingresar , se superó la capacidad");
                    return -1;
                }
                else if (volAux == 100)
                {
                    System.Windows.MessageBox.Show("La ubicación esta en su máxima capacidad");
                    selectedUbicacion.VolOcupado=volAux;
                }
                else selectedUbicacion.VolOcupado = volAux;
            }
            else
            {
                selectedUbicacion.IdProducto = idProducto;
                selectedUbicacion.VolOcupado = vol;
            }

            Ubicacion ubiModificada = new Ubicacion();
            ubiModificada.IdProducto = SelectedProduct.IdProducto;
            ubiModificada.IdUbicacion = selectedUbicacion.IdUbicacion;
            ubiModificada.Cantidad = cant;
            SelectedProduct.Ubicaciones.Add(ubiModificada);

            selectedUbicacion.Cantidad += cant;
            Columna[selectedUbicacion.CordZ].Cantidad = selectedUbicacion.Cantidad;
            Columna[selectedUbicacion.CordZ].VolOcupado = selectedUbicacion.VolOcupado;
            Columna[selectedUbicacion.CordZ].IdProducto = selectedUbicacion.IdProducto;

            CantActual = selectedUbicacion.Cantidad.ToString();
            VolOcu = selectedUbicacion.VolOcupado.ToString();
            this.Mostrar();

            return 1;
        }