Ejemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            BLL.ClassColores existencia = new ClassColores();
            if (existencia.ExisteProd(Convert.ToInt32(textBox2.Text)) == true)
            {
                ///
                BLL.ClassColores prod = new ClassColores();
                this.dataGridView4.DataSource = prod.MostrarProductoE(Convert.ToInt32(textBox2.Text));
                this.dataGridView4.Refresh();

                if (dataGridView1.Rows.Count > 0)
                {
                    FacturaXML.Append("<Detalle>");
                    FacturaXML.Append("<Producto>");
                    FacturaXML.Append(Convert.ToInt32(this.dataGridView4.Rows[0].Cells[0].Value.ToString()));
                    FacturaXML.Append("</Producto>");
                    FacturaXML.Append("<Cantidad>");
                    FacturaXML.Append(1);
                    FacturaXML.Append("</Cantidad>");
                    FacturaXML.Append("<Precio>");
                    FacturaXML.Append(Convert.ToInt32(this.dataGridView4.Rows[0].Cells[2].Value.ToString()));
                    FacturaXML.Append("</Precio>");
                    FacturaXML.Append("<Descuento>");
                    FacturaXML.Append(Convert.ToInt32(textBox1.Text));
                    FacturaXML.Append("</Descuento>");
                    FacturaXML.Append("<Subtotal>");
                    FacturaXML.Append(this.dataGridView4.Rows[0].Cells[2].Value.ToString());
                    FacturaXML.Append("</Subtotal>");
                    FacturaXML.Append("</Detalle>");
                    totalPagar  += Convert.ToInt32(this.dataGridView4.Rows[0].Cells[2].Value.ToString());
                    label14.Text = Convert.ToString(totalPagar);

                    listBox1.Items.Add(this.dataGridView4.Rows[0].Cells[0].Value.ToString() + " - " + this.dataGridView4.Rows[0].Cells[1].Value.ToString() + "-" + this.dataGridView4.Rows[0].Cells[3].Value.ToString() + "-" + this.dataGridView4.Rows[0].Cells[4].Value.ToString() + "-" + this.dataGridView4.Rows[0].Cells[5].Value.ToString());
                    textBox2.Text = "";

                    //Actualizar y eliminar producto
                    ClassColores    Logica    = new ClassColores();
                    MODELS.Producto claseProd = new MODELS.Producto();
                    claseProd.ProductoId     = Convert.ToInt32(this.dataGridView4.Rows[0].Cells[0].Value);
                    claseProd.Estado         = false;
                    claseProd.TipoProductoId = Convert.ToInt32(this.dataGridView4.Rows[0].Cells[6].Value);
                    string resp = Logica.ActualizarProd(claseProd);
                    MessageBox.Show(resp);
                }
                else
                {
                    MessageBox.Show("El producto no existe");
                    textBox2.Text = "";
                }
            }
            else
            {
                MessageBox.Show("El producto no existe");
                textBox2.Text = "";
            }
        }