Example #1
0
        private void búsquedaToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            FormIntroducir fi = new FormIntroducir("Código");

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

            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 dato?", "No existe una venta con ese código", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr2 == DialogResult.Yes)
                    {
                        fi.Dispose();
                        this.búsquedaToolStripMenuItem2.PerformClick();
                    }
                    else
                    {
                        fi.Dispose();
                    }
                }
                else
                {
                    fi.Dispose();
                    FormBajaVentas fbv = new FormBajaVentas("Búsqueda");
                    fbv.textBox1.Text     = v.Codigo;
                    fbv.textBox1.ReadOnly = true;
                    fbv.textBox2.Text     = v.FechaVenta.ToString();
                    fbv.textBox2.ReadOnly = true;
                    fbv.textBox3.Text     = v.Dependiente.NSS;
                    fbv.textBox3.ReadOnly = true;
                    foreach (LineaVenta l in v.Lineas)
                    {
                        fbv.listBox1.Items.Add(new Label().Text = l.ToString());
                    }
                    fbv.button3.Dispose();
                    fbv.checkBox1.Enabled = false;
                    fbv.textBox4.ReadOnly = true;
                    VentaTarjeta vtaux = v as VentaTarjeta; //Si se consigue castear, entonces será una VentaTarjeta, si no será una VentaContado
                    if (vtaux == null)
                    {
                        fbv.checkBox1.Checked = false;
                    }
                    else
                    {
                        fbv.checkBox1.Checked = true;
                        fbv.textBox4.Text     = vtaux.NumTarjeta;
                    }

                    DialogResult dr3 = fbv.ShowDialog();
                }
            }
            fi.Dispose();
        }
 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;
         }
     }
 }
Example #3
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (this.checkBox1.Checked)
     {
         this.textBox4.ReadOnly = false;
         Venta vn = new VentaTarjeta("", this.v.Codigo, this.v.Dependiente);
         vn.Lineas = v.Lineas;
         sv.DarBajaVenta(v);
         this.v = vn;
         sv.DarAltaVenta(v);
     }
     else
     {
         this.textBox4.ReadOnly = true;
         this.textBox4.Text     = "";
         Venta vn = new VentaContado(this.v.Codigo, this.v.Dependiente);
         vn.Lineas = v.Lineas;
         sv.DarBajaVenta(v);
         this.v = vn;
         sv.DarAltaVenta(v);
     }
 }
Example #4
0
        public ServicioVenta()//el constructor crea una conexion con la base de datos.
        {
            this.bd = BDVenta.GetInstance();
            Venta v;

            v = new VentaContado("1001", new Dependiente("101", "Manuel", "Rodríguez"));
            AnadirLineaVenta(v, new Articulo("1", tipoIva.normal, 1), 2);
            this.bd.AnadirVenta(v);
            v = new VentaContado("1002", new Dependiente("101", "Manuel", "Rodríguez"));
            AnadirLineaVenta(v, new Articulo("1", tipoIva.normal, 1), 3);
            AnadirLineaVenta(v, new Articulo("2", tipoIva.normal, 10), 3);
            this.bd.AnadirVenta(v);
            v = new VentaContado("1003", new Dependiente("103", "Alex", "Martínez"));
            AnadirLineaVenta(v, new Articulo("5", tipoIva.reducido, 3), 2);
            this.bd.AnadirVenta(v);
            v = new VentaTarjeta("XXXX", "1004", new Dependiente("106", "Oscar", "Ramírez"));
            AnadirLineaVenta(v, new Articulo("1", tipoIva.normal, 1), 2);
            AnadirLineaVenta(v, new Articulo("7", tipoIva.superReducido, 2), 6);
            AnadirLineaVenta(v, new Articulo("5", tipoIva.reducido, 3), 6);
            this.bd.AnadirVenta(v);
            v = new VentaTarjeta("YYYY", "1005", new Dependiente("102", "Pepe", "Pérez"));
            AnadirLineaVenta(v, new Articulo("6", tipoIva.superReducido, 6), 2);
            this.bd.AnadirVenta(v);

            /* this.bd.AnadirArticulo(new Articulo("1", tipoIva.normal, 1));
             * this.bd.AnadirArticulo(new Articulo("2", tipoIva.normal, 10));
             * this.bd.AnadirArticulo(new Articulo("3", tipoIva.normal, 15));
             * this.bd.AnadirArticulo(new Articulo("4", tipoIva.reducido, 2));
             * this.bd.AnadirArticulo(new Articulo("5", tipoIva.reducido, 3));
             * this.bd.AnadirArticulo(new Articulo("6", tipoIva.superReducido, 6));
             * this.bd.AnadirArticulo(new Articulo("7", tipoIva.superReducido, 2));
             * this.bd.AnadirDependiente(new Dependiente("101", "Manuel", "Rodríguez"));
             * this.bd.AnadirDependiente(new Dependiente("102", "Pepe", "Pérez"));
             * this.bd.AnadirDependiente(new Dependiente("103", "Alex", "Martínez"));
             * this.bd.AnadirDependiente(new Dependiente("104", "David", "Madorrán"));
             * this.bd.AnadirDependiente(new Dependiente("105", "Rodrigo", "Ortega"));
             * this.bd.AnadirDependiente(new Dependiente("106", "Oscar", "Ramírez"));
             */
        }
Example #5
0
        private void bajaToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            FormIntroducir fi = new FormIntroducir("Código");

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

            if (dr == DialogResult.OK)
            {
                Venta vaux = new VentaContado(fi.textBox1.Text, null);
                Venta v    = sv.ObtenerInfoVenta(vaux);
                if (v == null) //No está
                {
                    DialogResult dr2 = MessageBox.Show(this, "¿Quieres introducir otro?", "No existe una venta con ese código", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr2 == DialogResult.Yes)
                    {
                        fi.Dispose();
                        this.bajaToolStripMenuItem2.PerformClick();
                    }
                    else
                    {
                        fi.Dispose();
                    }
                }
                else //le enseñamos los datos y le damos la opcion de dar de baja
                {
                    fi.Dispose();
                    FormBajaVentas fbv = new FormBajaVentas();
                    fbv.textBox1.Text     = v.Codigo;
                    fbv.textBox1.ReadOnly = true;
                    fbv.textBox2.Text     = v.FechaVenta.ToString();
                    fbv.textBox2.ReadOnly = true;
                    fbv.textBox3.Text     = v.Dependiente.ToString();
                    fbv.textBox3.ReadOnly = true;
                    foreach (LineaVenta l in v.Lineas)
                    {
                        fbv.listBox1.Items.Add(new Label().Text = l.ToString());
                    }
                    fbv.button3.Dispose();
                    fbv.checkBox1.Enabled = false;
                    fbv.textBox4.ReadOnly = true;
                    var vtaux = v as VentaTarjeta; //Si se consigue castear, entonces será una VentaTarjeta, si no será una VentaContado
                    if (vtaux == null)
                    {
                        fbv.checkBox1.Checked = false;
                    }
                    else
                    {
                        fbv.checkBox1.Checked = true;
                        fbv.textBox4.Text     = vtaux.NumTarjeta;
                    }

                    DialogResult dr3 = fbv.ShowDialog();

                    if (dr3 == DialogResult.OK)
                    {
                        DialogResult dr4 = MessageBox.Show(this, "¿Está seguro que desea dar de baja la venta?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dr4 == DialogResult.Yes)
                        {
                            sv.DarBajaVenta(v);
                            MessageBox.Show(this, "Venta eliminada", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        else
                        {
                            fbv.Dispose();
                        }
                    }
                    else
                    {
                        fbv.Dispose();
                    }
                }
            }
            fi.Dispose();
        }
Example #6
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();
        }