private void Limpiar() { Detalle = new Entidades.FacturasProductos(); Factura = new Entidades.Facturas(); FacturaIdmaskedTextBox.Clear(); ClienteIdmaskedTextBox.Clear(); NombreClientetextBox.Clear(); MontotextBox.Clear(); FechadateTimePicker.Value = DateTime.Now; ProductoIdmaskedTextBox.Clear(); DescripcionProductotextBox.Clear(); ProductodataGridView.DataSource = null; CantidadnumericUpDown.Value = 0; PreciotextBox.Clear(); DevueltatextBox.Clear(); RecibidomaskedTextBox.Clear(); ComentariotextBox.Clear(); NombreClienteerrorProvider.Clear(); CantidaderrorProvider.Clear(); ProductoerrorProvider.Clear(); RecibidoerrorProvider.Clear(); GriderrorProvider.Clear(); ClienteIderrorProvider.Clear(); FacturaIderrorProvider.Clear(); DevueltaerrorProvider.Clear(); FormaPagoComboBox.Text = null; ClienteIdmaskedTextBox.Enabled = true; ProductoIdmaskedTextBox.Enabled = true; FechadateTimePicker.Enabled = true; ComentariotextBox.Enabled = true; FormaPagoComboBox.Enabled = true; ProductodataGridView.Enabled = true; RecibidomaskedTextBox.Enabled = false; FacturaIdmaskedTextBox.Enabled = true; CantidadnumericUpDown.Enabled = false; }
private void Eliminarbutton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(FacturaIdmaskedTextBox.Text)) { MessageBox.Show("Por favor insertar el id de la factura que desea eliminar."); } else { VerificarExistenciaFactura(); if (Factura != null) { DialogResult eliminar = MessageBox.Show("¿Seguro desea eliminar la factura seleccionada?", "¡Advertencia!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (eliminar == DialogResult.Yes) { int id = Utilidades.TOINT(FacturaIdmaskedTextBox.Text); if (BLL.FacturasBLL.Eliminar(BLL.FacturasBLL.Buscar(p => p.FacturaId == id))) { AumentarExistenciaProducto(CantidadnumericUpDown.Value); Limpiar(); RecibidomaskedTextBox.Enabled = false; } else { MessageBox.Show("No se pudo eliminar la factura."); } } } else { FacturaIderrorProvider.SetError(FacturaIdmaskedTextBox, "No existe factura con ese id."); FacturaIdmaskedTextBox.Focus(); } } }