async protected void btnIngresar_Click(object sender, EventArgs e) { try { if (ValidarInsertar()) { Models.Factura facturaIngresada = new Models.Factura(); Models.Factura factura = new Models.Factura() { FACT_FEC_RENT = clFechRenta.SelectedDate, FACT_FEC_DEVOLU = clFechDevo.SelectedDate, FACT_MONTO_TOT = Convert.ToInt32(txtMontoTotal.Text), FACT_DETALLE = txtDetalle.Text, EMP_CODIGO = Convert.ToInt32(ddEMP_CODIGO.SelectedItem.Value.ToString()), SUC_CODIGO = Convert.ToInt32(ddSUC_CODIGO.SelectedItem.Value.ToString()), USU_CODIGO = Convert.ToInt32(ddUSU_CODIGO.SelectedItem.Value.ToString()), ORD_CODIGO = Convert.ToInt32(ddORD_CODIGO.SelectedItem.Value.ToString()) }; facturaIngresada = await facturaManager.Ingresar(factura, Session["TokenUsuario"].ToString()); if (facturaIngresada != null) { lblResultado.Text = "Factura ingresada correctamente"; lblResultado.ForeColor = Color.Green; lblResultado.Visible = true; InicializarControles(); } else { lblResultado.Text = "Error al crear factura"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } } } catch (Exception ex) { lblResultado.Text = "Hubo un error al ingresar la factura. Detalle: " + ex.Message; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } }
async protected void btnModificar_Click(object sender, EventArgs e) { if (ValidarInsertar() && (!string.IsNullOrEmpty(txtCodigo.Text))) { Models.Factura facturaModificado = new Models.Factura(); Models.Factura factura = new Models.Factura() { FACT_CODIGO = Convert.ToInt32(txtCodigo.Text), FACT_FEC_DEVOLU = clFechDevo.SelectedDate, FACT_FEC_RENT = clFechRenta.SelectedDate, FACT_MONTO_TOT = Convert.ToInt32(txtMontoTotal.Text), FACT_DETALLE = txtDetalle.Text, EMP_CODIGO = Convert.ToInt32(ddEMP_CODIGO.SelectedItem.Value.ToString()), SUC_CODIGO = Convert.ToInt32(ddSUC_CODIGO.SelectedItem.Value.ToString()), USU_CODIGO = Convert.ToInt32(ddUSU_CODIGO.SelectedItem.Value.ToString()), ORD_CODIGO = Convert.ToInt32(ddORD_CODIGO.SelectedItem.Value.ToString()) }; facturaModificado = await facturaManager.Actualizar(factura, Session["TokenUsuario"].ToString()); if (facturaModificado != null) { lblResultado.Text = "Factura actualizada correctamente"; lblResultado.ForeColor = Color.Green; lblResultado.Visible = true; InicializarControles(); } else { lblResultado.Text = "Error al actualizar factura"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } } else { lblResultado.Text = "Debe ingresar todos los datos"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } }