Example #1
0
        private void bt_Insertar_Click(object sender, EventArgs e)
        {
            EntradaInv ent = new EntradaInv()
            {
                Articulo = new Artículo()
                {
                    ID     = Convert.ToInt32(tb_ID.Text),
                    Nombre = tb_Nombre.Text,
                    Precio = Convert.ToDouble(tb_Precio.Text)
                },
                Cantidad = Convert.ToInt32(tb_Cantidad.Text)
            };

            if (inv.Insertar(ent, Convert.ToInt32(tb_Pos.Text)))
            {
                MessageBox.Show("Artículo Insertado con éxito");
                tb_ID.Text       = "";
                tb_Nombre.Text   = "";
                tb_Precio.Text   = "";
                tb_Cantidad.Text = "";
                tb_Pos.Text      = "";
            }
            else
            {
                MessageBox.Show("La posición donde se desea insertae el artículo ya está ocupada");
            }
        }
Example #2
0
        private void bt_Agregar_Click(object sender, EventArgs e)
        {
            EntradaInv ent = new EntradaInv()
            {
                Articulo = new Artículo()
                {
                    ID     = Convert.ToInt32(tb_ID.Text),
                    Nombre = tb_Nombre.Text,
                    Precio = Convert.ToDouble(tb_Precio.Text)
                },
                Cantidad = Convert.ToInt32(tb_Cantidad.Text)
            };

            if (inv.Agregar(ent))
            {
                MessageBox.Show("Artículo Agregado con éxito");
                tb_ID.Text       = "";
                tb_Nombre.Text   = "";
                tb_Precio.Text   = "";
                tb_Cantidad.Text = "";
            }
            else
            {
                MessageBox.Show("La lista de artículos está llena");
            }
        }
Example #3
0
        public bool Insertar(EntradaInv ent, int pos)
        {
            if (pos == 1)
            {
                ent.Siguiente = Primero;
                Primero       = ent;
                return(true);
            }
            EntradaInv temp = Primero;
            int        i    = 1;

            while (temp != null && temp.Siguiente != null && i < pos - 1)
            {
                temp = temp.Siguiente;
                i++;
            }
            if (temp == null)
            {
                return(false);
            }
            ent.Siguiente  = temp.Siguiente;
            temp.Siguiente = ent;
            return(true);
            // a -> b -> c -> d
            //
        }
Example #4
0
        public void Agregar(EntradaInv ent)
        {
            if (Primero == null)
            {
                Primero = ent;
            }
            else
            {
                if (ent.Articulo.ID < Primero.Articulo.ID)
                {
                    ent.Siguiente = Primero;
                    Primero       = ent;
                }
                else
                {
                    EntradaInv temp = Primero;

                    /*
                     * while (temp.Siguiente != null)
                     * temp = temp.Siguiente;
                     * temp.Siguiente = ent;
                     */
                    while (temp.Siguiente != null && temp.Siguiente.Articulo.ID < ent.Articulo.ID)
                    {
                        temp = temp.Siguiente;
                    }
                    ent.Siguiente  = temp.Siguiente;
                    temp.Siguiente = ent;
                    // a -> c -> d
                    // b -> c -> d
                    //
                }
            }
        }
Example #5
0
        public EntradaInv Buscar(int ID)
        {
            EntradaInv temp = Primero;

            while (temp != null && temp.Articulo.ID != ID)
            {
                temp = temp.Siguiente;
            }
            return(temp);
        }
Example #6
0
 public bool Agregar(EntradaInv ent)
 {
     for (int i = 0; i < _inventario.Length; i++)
     {
         if (_inventario[i] == null)
         {
             _inventario[i] = ent;
             return(true);
         }
     }
     return(false);
 }
Example #7
0
 public void AgregarPrimero(EntradaInv ent)
 {
     if (Primero == null)
     {
         Primero = ent;
         Ultimo  = ent;
     }
     else
     {
         ent.Siguiente          = Primero;
         Primero                = ent;
         ent.Siguiente.Anterior = ent;
     }
 }
Example #8
0
        /*
         * public void Agregar(EntradaInv ent)
         * {
         *  if (Primero == null)
         *      Primero = ent;
         *  else
         *  {
         *      EntradaInv temp = Primero;
         *      while (temp.Siguiente != null)
         *          temp = temp.Siguiente;
         *      temp.Siguiente = ent;
         *  }
         * }
         */

        public void Agregar(EntradaInv ent)
        {
            if (Ultimo == null)
            {
                Primero = ent;
                Ultimo  = ent;
            }
            else
            {
                ent.Anterior           = Ultimo;
                Ultimo                 = ent;
                ent.Anterior.Siguiente = ent;
            }
        }
Example #9
0
        /*
         * public bool Insertar(EntradaInv ent, int pos)
         * {
         *  if (pos == 1)
         *  {
         *      ent.Siguiente = Primero;
         *      Primero = ent;
         *      return true;
         *  }
         *  EntradaInv temp = Primero;
         *  int i = 1;
         *  while (temp != null && temp.Siguiente != null && i < pos - 1)
         *  {
         *      temp = temp.Siguiente;
         *      i++;
         *  }
         *  if (temp == null)
         *      return false;
         *  ent.Siguiente = temp.Siguiente;
         *  temp.Siguiente = ent;
         *  return true;
         *  // a -> b -> c -> d
         *  //
         * }
         */
        public override string ToString()
        {
            string     Reporte = "Comenza Reporte de inventario:" + Environment.NewLine;
            EntradaInv temp    = Primero;
            int        i       = 1;

            while (temp != null)
            {
                Reporte += "Registro " + i.ToString() + ": " + Environment.NewLine;
                Reporte += temp.ToString() + Environment.NewLine;
                temp     = temp.Siguiente;
                i++;
            }
            Reporte += "Fin Reporte de Inventario.";
            return(Reporte);
        }
Example #10
0
        private void bt_Buscar_Click(object sender, EventArgs e)
        {
            EntradaInv ent = inv.Buscar(Convert.ToInt32(tb_ID.Text));

            if (ent != null)
            {
                MessageBox.Show("Producto Encontrado");
                tb_Nombre.Text   = ent.Articulo.Nombre;
                tb_Precio.Text   = ent.Articulo.Precio.ToString();
                tb_Cantidad.Text = ent.Cantidad.ToString();
            }
            else
            {
                MessageBox.Show("El producto con el Código " + tb_ID.Text + " no existe");
            }
        }
Example #11
0
 public void Agregar(EntradaInv ent)
 {
     if (Primero == null)
     {
         Primero = ent;
     }
     else
     {
         EntradaInv temp = Primero;
         while (temp.Siguiente != null)
         {
             temp = temp.Siguiente;
         }
         temp.Siguiente = ent;
     }
 }
Example #12
0
        public string ReporteInverso()
        {
            string Reporte = "Comienza Reporte inverso de inventario:" + Environment.NewLine;

            if (Ultimo == null)
            {
                Reporte += "No hay datos.";
                return(Reporte);
            }
            EntradaInv temp = Ultimo;

            while (temp != null)
            {
                Reporte += temp.ToString() + Environment.NewLine;
                temp     = temp.Anterior;
            }
            Reporte += "Termina Reporte Inverso de Inventario.";
            return(Reporte);
        }
Example #13
0
        public override string ToString()
        {
            string Reporte = "Comenza Reporte de inventario:" + Environment.NewLine;

            if (Primero == null)
            {
                Reporte += "No hay datos.";
                return(Reporte);
            }
            EntradaInv temp = Primero;

            while (temp != null)
            {
                Reporte += temp.ToString() + Environment.NewLine;
                temp     = temp.Siguiente;
            }
            Reporte += "Fin Reporte de Inventario.";
            return(Reporte);
        }
Example #14
0
        private void bt_AgregarPrimero_Click(object sender, EventArgs e)
        {
            EntradaInv ent = new EntradaInv()
            {
                Articulo = new Artículo()
                {
                    ID     = Convert.ToInt32(tb_ID.Text),
                    Nombre = tb_Nombre.Text,
                    Precio = Convert.ToDouble(tb_Precio.Text)
                },
                Cantidad = Convert.ToInt32(tb_Cantidad.Text)
            };

            inv.AgregarPrimero(ent);
            MessageBox.Show("Artículo Agregado con éxito");
            tb_ID.Text       = "";
            tb_Nombre.Text   = "";
            tb_Precio.Text   = "";
            tb_Cantidad.Text = "";
        }
Example #15
0
        public bool BorrarUltimo()
        {
            if (Ultimo == null)
            {
                return(false);
            }
            if (Ultimo.Anterior == null)
            {
                Primero = null;
                Ultimo  = null;
                return(true);
            }
            EntradaInv temp = Ultimo;

            Ultimo           = Ultimo.Anterior;
            Ultimo.Siguiente = null;
            temp.Anterior    = null;
            temp             = null;
            return(true);
        }
Example #16
0
        public bool BorrarPrimero()
        {
            if (Primero == null)
            {
                return(false);
            }
            if (Primero.Siguiente == null)
            {
                Primero = null;
                Ultimo  = null;
                return(true);
            }
            EntradaInv temp = Primero;

            Primero          = Primero.Siguiente;
            Primero.Anterior = null;
            temp.Siguiente   = null;
            temp             = null;
            return(true);
        }
Example #17
0
        public bool Borrar(int ID)
        {
            EntradaInv temp = Buscar(ID);

            if (temp == null)
            {
                return(false);
            }
            if (temp.Anterior != null)
            {
                temp.Anterior.Siguiente = temp.Siguiente;
            }
            if (temp.Siguiente != null)
            {
                temp.Siguiente.Anterior = temp.Anterior;
            }
            temp.Siguiente = null;
            temp.Anterior  = null;
            return(true);
        }
Example #18
0
        public bool Borrar(int ID)
        {
            EntradaInv temp = Primero;

            while (temp != null && temp.Siguiente != null && temp.Siguiente.Articulo.ID != ID)
            {
                temp = temp.Siguiente;
            }
            if (temp == null)
            {
                return(false);
            }
            if (temp.Siguiente == null)
            {
                Primero = null;
                return(true);
            }
            temp.Siguiente = temp.Siguiente.Siguiente;
            return(true);
        }
Example #19
0
        private void bt_Reporte_Inverso_Click(object sender, EventArgs e)
        {
            ReporteTxt r = new ReporteTxt(inv.ReporteInverso());

            r.ShowDialog();

            EntradaInv temp = inv.Ultimo;

            dgv_Reporte.Rows.Clear();
            while (temp != null)
            {
                dgv_Reporte.Rows.Add(new string[]
                {
                    temp.Articulo.ID.ToString(),
                    temp.Articulo.Nombre,
                    temp.Cantidad.ToString(),
                    temp.Articulo.Precio.ToString("c2")
                });
                temp = temp.Anterior;
            }
        }
Example #20
0
        private void bt_Reporte_Click(object sender, EventArgs e)
        {
            ReporteTxt r = new ReporteTxt(inv.ToString());

            r.ShowDialog();

            string[] row = new string[4];
            dgv_Reporte.Rows.Clear();

            EntradaInv temp = inv.Primero;

            while (temp != null)
            {
                row[0] = temp.Articulo.ID.ToString();
                row[1] = temp.Articulo.Nombre;
                row[2] = temp.Cantidad.ToString();
                row[3] = temp.Articulo.Precio.ToString("c2");
                dgv_Reporte.Rows.Add(row);
                temp = temp.Siguiente;
            }
        }
Example #21
0
        public bool Insertar(EntradaInv ent, int pos)
        {
            pos--;
            if (pos >= _inventario.Length)
            {
                return(false);
            }
            int i = pos;

            while (_inventario[i] != null && i < _inventario.Length)
            {
                i++;
            }
            if (i == _inventario.Length)
            {
                return(false);
            }
            for (; i > pos; i--)
            {
                _inventario[i] = _inventario[i - 1];
            }
            _inventario[pos] = ent;
            return(true);
        }
Example #22
0
 public Inventario()
 {
     Primero = null;
 }