private void cmbNumero_SelectedIndexChanged(object sender, EventArgs e) { if (cmbNumero.SelectedItem != null) { if (cmbNumero.SelectedItem.Equals("Remision")) { MostrarReporteRemision ReporteRemision = new MostrarReporteRemision(); ReporteRemision.NumeroRemision = Convert.ToInt32(TxtNumero.Text); ReporteRemision.ShowDialog(); } else if (cmbNumero.SelectedItem.Equals("Factura")) { MostrarReporteFactura ReporteFactura = new MostrarReporteFactura(); ReporteFactura.NumeroFactura = Convert.ToInt32(TxtNumero.Text); ReporteFactura.ShowDialog(); } else { MostrarReporteOrden ReporteOrden = new MostrarReporteOrden(); ReporteOrden.NumeroOrden = Convert.ToInt32(TxtNumero.Text); ReporteOrden.ShowDialog(); } } Clear(); }
public void Guardar() { TxtObservaciones.Text = TxtObservaciones.Text.Trim(); var Total = TxtTotal.Text; var Fecha = DateVencimiento.Value.DayOfYear - DateTime.Now.DayOfYear; if (string.IsNullOrWhiteSpace(TxtCc.Text) || string.IsNullOrWhiteSpace(TxtNombre.Text) || string.IsNullOrWhiteSpace(TxtDireccion.Text) || string.IsNullOrWhiteSpace(TxtTotal.Text) || string.IsNullOrWhiteSpace(TxtTelefono.Text) || string.IsNullOrWhiteSpace(DateVencimiento.Text) || Convert.ToInt32(Total) <= 0 || GridViewRemision == null) { MessageBox.Show("Por favor ingrese la información solicitada", "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (DateTime.Now > DateVencimiento.Value) { MessageBox.Show("No puede ser la fecha de vencimiento menor a la fecha de hoy", "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (Fecha > 30) { MessageBox.Show("No puede ingresar una fecha de vencimiento mayor a 30 días", "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { _remi.NumeroRemision = Convert.ToInt32(TxtNumero.Text); _remi.Cedula = TxtCc.Text; _remi.FechaVencimiento = Convert.ToDateTime(DateVencimiento.Text); _remi.Observaciones = TxtObservaciones.Text; _remi.SubTotal = Convert.ToInt32(txtSubtotal.Text); _remi.Iva = Convert.ToInt32(txtIva.Text); _remi.Total = Convert.ToInt32(TxtTotal.Text); _remi.Usuario = perfil["Usuario"]; if (MessageBox.Show("¿Seguro que desea Continuar?", "SmartPrint", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _remi.GuardarRemision(_remi); var contador = GridViewRemision.Rows.Count; var i = 0; foreach (DataGridViewRow dts in GridViewRemision.Rows) { if (i <= (contador - 1)) { _remi.CodigoServicio = Convert.ToInt32(dts.Cells[0].Value); _remi.Cantidad = Convert.ToInt32(dts.Cells[3].Value); _remi.ValorUnitario = Convert.ToInt32(dts.Cells[2].Value); _remi.ValorTotal = Convert.ToInt32(dts.Cells[4].Value); _remi.Nombre = (dts.Cells[1].Value).ToString(); _remi.GuardarRemisionServicios(_remi); i++; } } MessageBox.Show("Operación Exitosa", "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Information); if (MessageBox.Show("¿Desea Generar Informe?", "SmartPrint", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MostrarReporteRemision ReporteRemision = new MostrarReporteRemision(); ReporteRemision.NumeroRemision = Convert.ToInt32(TxtNumero.Text); ReporteRemision.ShowDialog(); Clear(); } else { Clear(); } } else { MessageBox.Show("Operación cancelada", "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception e) { MessageBox.Show("Excepción no controlada" + e, "SmartPrint", MessageBoxButtons.OK, MessageBoxIcon.Error); Dispose(); } } }