Exemplo n.º 1
0
 private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (this.dataGridView1.SelectedRows.Count != 0)
     {
         if (this.dataGridView1.SelectedRows[0].Cells[0].Value != null)
         {
             string codigo = this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
             Venta  vaux   = new VentaContado(codigo, null);
             Venta  v      = sv.ObtenerInfoVenta(vaux);
             this.bindingSource1.DataSource = v.Lineas;
             this.dataGridView2.DataSource  = this.bindingSource1;
         }
     }
 }
Exemplo n.º 2
0
        //metodos venta
        private void altaToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            FormIntroducir fi = new FormIntroducir("Código");

            fi.ShowDialog();
            DialogResult dr = fi.DialogResult;

            if (dr == DialogResult.OK)
            {
                while (fi.textBox1.Text == "" & dr == DialogResult.OK)
                {
                    DialogResult drDelay = MessageBox.Show(this, "Debe introducir un código para la nueva Venta", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    fi.Dispose();
                    fi = new FormIntroducir("Código");
                    dr = fi.ShowDialog();
                }

                if (dr == DialogResult.OK)
                {
                    Venta vaux = new VentaContado(fi.textBox1.Text, null);
                    Venta v    = sv.ObtenerInfoVenta(vaux);
                    if (v != null)
                    {
                        DialogResult dr2 = MessageBox.Show(this, "¿Quieres introducir otro?", "Ya existe una venta con ese código", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr2 == DialogResult.Yes)
                        {
                            fi.Dispose();
                            this.altaToolStripMenuItem2.PerformClick();
                        }
                        else
                        {
                            fi.Dispose();
                        }
                    }
                    else //le dejaremos crear una al no haber ninguno aun
                    {
                        fi.Dispose();
                        FormVentas fv = new FormVentas("Alta", vaux.Codigo, sa, sv, sd);
                        fv.textBox1.Text = vaux.Codigo; //codigo que hemos buscado que no existía
                        fv.textBox2.Text = vaux.FechaVenta.ToString();
                        DialogResult dr3 = fv.ShowDialog();

                        while (dr3 == DialogResult.Abort)
                        {
                            DialogResult drDelay = MessageBox.Show(this, "Debe introducir un dependiente válido, añadir al menos un artículo, o añadir el número de tarjeta si la ha seleccionado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            dr3 = fv.ShowDialog();
                        }
                        if (dr3 == DialogResult.OK)
                        {
                            //hacer que vuelva a dejar meter datos
                            while ((fv.textBox3.Text == "") & dr3 == DialogResult.OK)
                            {
                                fv.Dispose();
                                fv = new FormVentas("Alta", vaux.Codigo, sa, sv, sd);
                                fv.textBox1.Text = vaux.Codigo; //codigo que hemos buscado que no existía
                                fv.textBox2.Text = vaux.FechaVenta.ToString();
                                dr3 = fv.ShowDialog();
                            }
                            if (dr3 == DialogResult.OK)
                            {
                                //Aquí comprobaremos que el dependiente ya existe y que hemos añadido al menos un articulo a la venta
                                Dependiente daux = new Dependiente(fv.textBox3.Text, null, null);
                                Dependiente d    = sd.ObtenerInfoDependiente(daux);
                                if (d != null & fv.listBox1.Items.Count > 0)
                                {
                                    Venta vBuena = sv.ObtenerInfoVenta(new VentaContado(fv.textBox1.Text, null));
                                    vBuena.Dependiente = d;
                                    sd.AnadirVentaADependiente(vBuena, d);
                                }
                            }
                        }

                        else
                        {
                            fv.Dispose();
                        }
                    }
                }
            }
            fi.Dispose();
        }