Ejemplo n.º 1
0
        /*
         * Añade un artículo. No pide el id al usuario, se genera automaticamente por la
         * capa de Lógica de Negocio
         */
        private void altaArticulo_Click(object sender, EventArgs e)
        {
            FArticulo ad = new FArticulo("Asignado automaticamente");

            ad.ShowDialog();
            if (DialogResult.OK == ad.DialogResult)
            {
                lna.anadirArticulo(new Articulo("0", ad.Descripcion, ad.Precio, ad.TipoIVA));
            }
            ad.Dispose();
        }
Ejemplo n.º 2
0
        /*
         * Revisará si todos los datos necesarios se han insertado y en caso correcto
         * añadirá el articulo nuevo (si no tiene id) o lo modificará (si ya tiene id)
         */
        private bool actualizarDato(DataGridViewCellValidatingEventArgs e)
        {
            //Si todos los datos excepto el id están completos, guardo el nuevo articulo, Sino guardo cambios directamente
            string id = dataGridView1.CurrentRow.Cells[0].FormattedValue.ToString();
            int    iva;

            int.TryParse(dataGridView1.CurrentRow.Cells[3].FormattedValue.ToString(), out iva);
            float coste;

            float.TryParse(dataGridView1.CurrentRow.Cells[2].FormattedValue.ToString(), out coste);
            string descripcion = dataGridView1.CurrentRow.Cells[1].FormattedValue.ToString();

            //Para el valor recien insertado
            switch (e.ColumnIndex)
            {
            case 1:
            {
                descripcion = e.FormattedValue.ToString();
                break;
            }

            case 2:
            {
                float.TryParse(e.FormattedValue.ToString(), out coste);
                break;
            }

            case 3:
            {
                int.TryParse(e.FormattedValue.ToString(), out iva);
                break;
            }
            }

            if (descripcion != "" && coste != 0 && iva != 0)
            {
                if (id == "")
                {
                    return(serviciosArticulos.anadirArticulo(new Articulo("0", descripcion, coste, iva)));
                }
                else
                {
                    return(serviciosArticulos.modificarArticulo(id, descripcion, coste, iva));
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 private void bindingAdd_Click(object sender, EventArgs e)
 {
     if (tipoDeClase == TipoDeClase.Articulo)
     {
         FArticulo ad = new FArticulo("Asignado automaticamente");
         ad.ShowDialog();
         if (ad.DialogResult == DialogResult.OK)
         {
             serviciosArticulos.anadirArticulo(new Articulo("0", ad.Descripcion, ad.Precio, ad.TipoIVA));
         }
         ad.Dispose();
         bindingSource.Clear();
         bindingSource.DataSource = serviciosArticulos.getTodosArticulos();
     }
     else if (tipoDeClase == TipoDeClase.Dependiente)
     {
         FIntroducir f = new FIntroducir(TipoDeClase.Dependiente);
         f.ShowDialog();
         if (f.DialogResult == DialogResult.OK)
         {
             String clave = f.Clave;
             if (!serviciosDependiente.existeDependiente(clave))
             {
                 FDependiente ad = new FDependiente(clave);
                 ad.ShowDialog();
                 if (ad.DialogResult == DialogResult.OK)
                 {
                     serviciosDependiente.anadirDependiente(new Dependiente(clave, ad.Nombre, ad.Apellidos, ad.Comision));
                 }
                 ad.Dispose();
             }
             else
             {
                 DialogResult dr = MessageBox.Show(this, "Error", "Ya existe un dependiente con ese nºSS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             }
         }
         f.Dispose();
         bindingSource.Clear();
         bindingSource.DataSource = serviciosDependiente.getDependientesTienda();
     }
 }