Exemplo n.º 1
0
        public void GetProductosBodega(string flag = null)
        {
            List <DataAlmacen> contacts = _LogicLayer.GetProductosBodega();

            dataGridView1.DataSource         = contacts;
            dataGridView1.Columns[6].Visible = false;
            dataGridView1.Columns[7].Visible = false;
        }
Exemplo n.º 2
0
        private void BtnCargar_Click(object sender, EventArgs e)
        {
            TxtIdProducto.ReadOnly = true;

            if (flag == "1")

            {
                if (TxtIdProducto.Text == "" || TxtIdProducto.Text == null)
                {
                    TxtIdProducto.Text    = (_LogicLayer.GetMaxIDBodega() + 1).ToString();
                    GroupAdd.Visible      = true;
                    groupCantidad.Visible = true;
                }
                else if (int.Parse(TxtIdProducto.Text) > _LogicLayer.GetMaxIDBodega())
                {
                    MessageBox.Show("Ingrese un Id  Valido", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TxtIdProducto.ReadOnly = false;
                    TxtIdProducto.Text     = "";
                }

                else
                {
                    List <DataAlmacen> Productos = _LogicLayer.GetProductosBodega();
                    if (Productos.Count != 0)
                    {
                        foreach (DataAlmacen Producto in Productos.ToArray())
                        {
                            if (Producto.IdProducto == int.Parse(TxtIdProducto.Text))
                            {
                                GroupAdd.Visible            = true;
                                groupCantidad.Visible       = true;
                                TxtNombre.Text              = Producto.Nombre;
                                TxtNombre.ReadOnly          = true;
                                TxtLote.Text                = Producto.Lote;
                                TxtLote.ReadOnly            = true;
                                datetimeVencimiento.Value   = Producto.FechaVencimiento;
                                datetimeVencimiento.Enabled = false;
                                TxtDescripcion.Text         = Producto.Descripcion;
                                TxtDescripcion.ReadOnly     = true;
                                comboPrograma.Text          = Producto.Programa;
                                comboPrograma.Enabled       = false;
                                txtCantidadActual.Text      = Producto.Cantidad.ToString();
                                flagBodega = "1";
                            }
                        }
                    }
                }
            }

            else if (flag == "0")
            {
                if (TxtIdProducto.Text == "" || TxtIdProducto.Text == null)
                {
                    MessageBox.Show("Ingrese un Id  Valido", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TxtIdProducto.ReadOnly = false;
                    TxtIdProducto.Text     = "";
                }
                else if (int.Parse(TxtIdProducto.Text) > _LogicLayer.GetMaxIDBodega())
                {
                    MessageBox.Show("Ingrese un Id  Valido", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    TxtIdProducto.ReadOnly = false;
                    TxtIdProducto.Text     = "";
                }
                else
                {
                    List <DataAlmacen> Productos = _LogicLayer.GetProductos();
                    if (Productos.Count != 0)
                    {
                        foreach (DataAlmacen Producto in Productos.ToArray())
                        {
                            if (Producto.IdProducto == int.Parse(TxtIdProducto.Text))
                            {
                                GroupAdd.Visible            = true;
                                groupCantidad.Visible       = true;
                                TxtNombre.Text              = Producto.Nombre;
                                TxtNombre.ReadOnly          = true;
                                TxtLote.Text                = Producto.Lote;
                                TxtLote.ReadOnly            = true;
                                datetimeVencimiento.Value   = Producto.FechaVencimiento;
                                datetimeVencimiento.Enabled = false;
                                txtCantidadAlmacen.Text     = Producto.Cantidad.ToString();
                                txtCantidadAlmacen.ReadOnly = true;
                                TxtDescripcion.Text         = Producto.Descripcion;
                                TxtDescripcion.ReadOnly     = true;
                                comboPrograma.Text          = Producto.Programa;
                                comboPrograma.Enabled       = false;
                                flagAlmacen = "1";
                            }
                        }
                    }
                    List <DataAlmacen> ProductosBodega = _LogicLayer.GetProductosBodega();
                    foreach (DataAlmacen ProductoBodega in ProductosBodega.ToArray())
                    {
                        if (ProductoBodega.IdProducto == int.Parse(TxtIdProducto.Text))
                        {
                            txtCantidadActual.Text = ProductoBodega.Cantidad.ToString();
                        }
                    }
                }
            }
        }