Beispiel #1
0
        private void Modificar_Click(object sender, EventArgs e)
        {
            int             cont        = 0;
            DataGridViewRow row1        = new DataGridViewRow();
            ProductoDTO     productoDTO = new ProductoDTO();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool isSelected = Convert.ToBoolean(row.Cells["Cb"].Value);
                if (isSelected)
                {
                    cont++;
                    row1 = row;
                }
            }
            if (cont == 1)
            {
                productoDTO.Id                   = Convert.ToInt32(row1.Cells[1].Value);
                productoDTO.Nombre               = row1.Cells[2].Value.ToString();
                productoDTO.Descripcion          = row1.Cells[3].Value.ToString();
                productoDTO.StockMinimo          = Convert.ToInt32(row1.Cells[4].Value);
                productoDTO.CantidadEnStock      = Convert.ToInt32(row1.Cells[5].Value);
                productoDTO.PorcentajeDeGanancia = Convert.ToDouble(row1.Cells[6].Value);
                productoDTO.PrecioDeCompra       = Convert.ToDouble(row1.Cells[7].Value);
                productoDTO.Activo               = Convert.ToBoolean(row1.Cells[9].Value);
                this.Hide();
                VAgregarModificarProducto vAgregarModificarProducto = new VAgregarModificarProducto(productoDTO);
                vAgregarModificarProducto.ShowDialog();
                this.Close();
            }
            else if (cont > 1)
            {
                MessageBox.Show("Seleccione solo un producto");
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    row.Cells["Cb"].Value = false;
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un producto");
            }
        }
Beispiel #2
0
        private void Agregar_Click(object sender, EventArgs e)
        {
            Boolean seleccion = false;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool isSelected = Convert.ToBoolean(row.Cells["Cb"].Value);
                if (isSelected)
                {
                    seleccion = true;
                }
            }
            if (seleccion)
            {
                MessageBox.Show("No puede agregar con un elemento seleccionado");
            }
            else
            {
                this.Hide();
                VAgregarModificarProducto vAgregarModificarProducto = new VAgregarModificarProducto();
                vAgregarModificarProducto.ShowDialog();
                this.Close();
            }
        }
        private void AsociarProducto_Click(object sender, EventArgs e)
        {
            int             cont = 0;
            DataGridViewRow row1 = new DataGridViewRow();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                bool isSelected = Convert.ToBoolean(row.Cells["Cb"].Value);
                if (isSelected)
                {
                    cont++;
                    row1 = row;
                }
            }

            if (cont == 1)
            {
                Producto.IdCategoria = controladorFachada.BuscarCategoriaPorNombre(row1.Cells[2].Value.ToString());
                this.Hide();
                VAgregarModificarProducto vAgregarModificarProducto = new VAgregarModificarProducto(Producto);
                vAgregarModificarProducto.ShowDialog();
                this.Close();
            }
            else if (cont > 1)
            {
                MessageBox.Show("Seleccione solo una categoría");
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    row.Cells["Cb"].Value = false;
                }
            }
            else
            {
                MessageBox.Show("Debe seleccionar un producto");
            }
        }