Пример #1
0
        private void bbiEliminarArticulo_Click(object sender, EventArgs e)
        {
            string   codigo   = dgvArticulos.Rows[dgvArticulos.CurrentRow.Index].Cells[0].Value.ToString();
            Articulo articulo = Articulo.GetWhere(Conexiones.conexion, $"Codigo = '{codigo}'").FirstOrDefault();

            if (articulo != null)
            {
                DialogResult dialogResult = MessageBox.Show($"Se va a eliminar el artículo: {articulo.Descripcion}\n¿Está seguro?", "Eliminar Artículo", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Articulo.Delete(Conexiones.conexion, articulo);
                    MessageBox.Show("Artículo eliminado");
                    CargarDatos();
                }
            }
        }
Пример #2
0
 void BtnEliminarClick(object sender, EventArgs e)
 {
     if (dgvArticulos.SelectedRows.Count > 0)
     {
         Articulo articulo = Articulo.FindByID(Convert.ToInt16(dgvArticulos.CurrentRow.Cells["ID"].Value.ToString()));
         if (MessageBox.Show("¿Esta seguro de eliminar el articulo?", "Advertencia!", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             articulo.Estado            = false;
             articulo.Eliminado         = true;
             articulo.FechaModificacion = DateTime.Now;
             articulo.Delete();
             MessageBox.Show("Articulo eliminado con exito!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             CargarArticulos();
             return;
         }
     }
 }
Пример #3
0
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        SingletonConnection.Instancia.iniciar();

        IDbCommand dbCommand = SingletonConnection.Connection.CreateCommand();

        TreeViewHelper.fillV2(treeview1, "SELECT * FROM articulo", dbCommand);

        treeview1.Selection.Changed += delegate
        {
            deleteAction.Sensitive = treeview1.Selection.CountSelectedRows() > 0;
            editAction.Sensitive   = treeview1.Selection.CountSelectedRows() > 0;
        };

        newAction.Activated += delegate
        {
            new edit_Articulo(null).Destroyed += delegate
            {
                TreeViewHelper.fillV2(treeview1, "SELECT * FROM articulo", dbCommand);
            };;
        };

        editAction.Activated += delegate
        {
            new edit_Articulo(Articulo.seleccionado(treeview1)).Destroyed += delegate
            {
                TreeViewHelper.fillV2(treeview1, "SELECT * FROM articulo", dbCommand);
            };;
        };

        refreshAction.Activated += delegate
        {
            TreeViewHelper.fillV2(treeview1, "SELECT * FROM articulo", dbCommand);
        };
        deleteAction.Activated += delegate
        {
            Articulo.Delete(Articulo.seleccionado(treeview1));
            TreeViewHelper.fillV2(treeview1, "SELECT * FROM articulo", dbCommand);
        };
    }