Exemplo n.º 1
0
        private bool Eliminar()
        {
            bool res = true;

            try
            {
                int indice = this.dgvGrilla.SelectedRows[0].Index;

                DataRow fila = this.dt.Rows[indice];

                int    id       = int.Parse(fila["id"].ToString());
                string producto = fila["producto"].ToString();
                Single precio   = Single.Parse(fila["precio"].ToString());

                Producto p = new Producto(id, producto, precio);

                frmProducto fp = new frmProducto(p);

                if (fp.ShowDialog() == DialogResult.OK)
                {
                    fila.Delete();
                }
            }
            catch (Exception e)
            {
                res = false;
                MessageBox.Show(e.Message);
            }

            return(res);
        }
Exemplo n.º 2
0
        private bool AgregarObjeto()
        {
            bool res = true;

            try
            {
                frmProducto fp = new frmProducto();

                if (fp.ShowDialog() == DialogResult.OK)
                {
                    DataRow fila = this.dt.NewRow();

                    fila["producto"] = fp.Producto.Nombre;
                    fila["precio"]   = fp.Producto.Precio;

                    this.dt.Rows.Add(fila);
                }
            }
            catch (Exception e)
            {
                res = false;
                MessageBox.Show(e.Message);
            }

            return(res);
        }