示例#1
0
        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            List <LineaVenta> laux = new List <LineaVenta>();
            Venta             v    = (Venta)this.listBox2.SelectedItem;

            if (v != null)
            {
                this.textBox1.Text = v.Codigo;
                this.textBox2.Text = v.Dependiente.NSS;
                this.textBox3.Text = v.FechaVenta.ToString();
                if (v is VentaTarjeta)
                {
                    VentaTarjeta v2 = (VentaTarjeta)v;
                    this.textBox4.Text = v2.NumTarjeta;
                }
                else
                {
                    this.textBox4.Text = "No tarjeta";
                }
                this.listBox3.Items.Clear();
                foreach (LineaVenta l in v.Lineas)
                {
                    this.listBox3.Items.Add(new Label().Text = l.ToString());
                }
            }
        }
示例#2
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();
        }
示例#3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (validacion()) //Si cumple las condiciones, da de alta la venta adecuada,
     {
         if (this.checkBox1.Checked == true)
         {
             VentaTarjeta vaux = (VentaTarjeta)this.v;
             vaux.NumTarjeta = this.textBox4.Text;
         }
         this.sv.DarAltaVenta(v);
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         this.DialogResult = DialogResult.Abort;
     }
 }
示例#4
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);
     }
 }
示例#5
0
        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {
            this.textBox1.Text = ((Venta)this.bindingSource1.Current).Codigo;
            this.textBox2.Text = ((Venta)this.bindingSource1.Current).Dependiente.NSS;
            this.textBox3.Text = ((Venta)this.bindingSource1.Current).FechaVenta.ToString();
            this.listBox1.Items.Clear();
            foreach (LineaVenta l in ((Venta)this.bindingSource1.Current).Lineas)
            {
                this.listBox1.Items.Add(new Label().Text = l.ToString());
            }
            VentaTarjeta vtaux = (Venta)this.bindingSource1.Current as VentaTarjeta; //Si se consigue castear, entonces será una VentaTarjeta, si no será una VentaContado
            if (vtaux == null)
            {
                this.checkBox1.Checked = false;

            }
            else
            {
                this.checkBox1.Checked = true;
                this.textBox4.Text = vtaux.NumTarjeta;
            }
        }
        public FormDataGridViewVenta(List <Venta> lv, ServicioVenta sv)
        {
            InitializeComponent();
            this.sv      = sv;
            this.listado = lv;
            this.dataGridView1.Columns.Add("Código", "Código");
            this.dataGridView1.Columns.Add("Dependiente", "Dependiente");
            this.dataGridView1.Columns.Add("Fecha de venta", "Fecha de venta");
            this.dataGridView1.Columns.Add("Tarjeta", "Tarjeta");
            foreach (Venta v in this.listado)
            {
                VentaTarjeta vtaux = v as VentaTarjeta;
                string[]     row   = new string[] { v.Codigo, v.Dependiente.NSS, v.FechaVenta.ToString(), vtaux == null ? "No tarjeta" : vtaux.NumTarjeta };
                this.dataGridView1.Rows.Add(row);
            }
            if (this.dataGridView1.Rows.Count == 1)
            {
                this.dataGridView1.Rows.RemoveAt(this.dataGridView1.Rows.Count);

                this.dataGridView1.ClearSelection();
            }
        }
示例#7
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"));
             */
        }