public FormIngreso(int?idIngreso) { this.idIngreso = idIngreso; this.ingresoBusiness = new IngresoBusiness(); this.commonBusiness = new CommonBusiness(); InitializeComponent(); }
private void Btn_guardar_Click(object sender, EventArgs e) { try { if (!ValidarRegistro()) { return; } IngresoBusiness ctr = new IngresoBusiness(); ClassResult cr = ctr.Ingreso_Crea(ingresoModel, ingresoDetModel); if (cr.HuboError) { MessageBox.Show("Error al registrar el ingreso", cr.ErrorMsj, MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } else { MessageBox.Show("Ingreso registrado correctamente", cr.ErrorMsj, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("error al registrar ingreo vuelva realizar el registro: " + ex.Message, ex.StackTrace.ToString(), MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } //MessageBox.Show(Cd_Prod); }
}//cargarDatos /// <summary> /// Este método realizará la selección de una fila para cargarla en el formulario /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteRowButton_Click(object sender, GridViewDeleteEventArgs e) { int idIngreso = int.Parse(this.gvIngresos.DataKeys[e.RowIndex].Value.ToString());//(id) el cual se cargarán y modificarán los datos this.ib = new IngresoBusiness(); this.ingresos = null; this.ingresos = this.ib.obtenerIngreso(TbFechaInicio.Text, TbFechaFinal.Text); foreach (Ingreso ingresoActual in this.ingresos) //buscar los datos seleccionados y mostrarlos en los campos de texto { if (ingresoActual.Id == idIngreso)//se buscan los datos { //se desgrana la fecha para luego darle formato String[] fecha = ingresoActual.Fecha.ToString().Split(' ');//se obtiene la fecha String[] datos = fecha[0].ToString().Split('/');//se obtneien las partes de la fecha día, mes, año String fechaLista = ""; if (int.Parse(datos[0]) < 10 && int.Parse(datos[1]) < 10) { fechaLista = datos[2] + '-' + '0' + datos[1] + '-' + '0' + datos[0];// la fecha se debe acomodar a un formato nuevo para mostrarse } else if (int.Parse(datos[0]) < 10) { fechaLista = datos[2] + '-' + datos[1] + '-' + '0' + datos[0];// la fecha se debe acomodar a un formato nuevo para mostrarse } else if (int.Parse(datos[1]) < 10) { fechaLista = datos[2] + '-' + '0' + datos[1] + '-' + datos[0];// la fecha se debe acomodar a un formato nuevo para mostrarse } else { fechaLista = datos[2] + '-' + datos[1] + '-' + datos[0];// la fecha se debe acomodar a un formato nuevo para mostrarse }//if-else String[] hora = ingresoActual.Hora.ToString().Split('.');//se obtiene la hora String horaC = hora[0];// Se almacena lo deseado String[] horaCa = horaC.Split(':'); String horaLista = horaCa[0] + ":" + horaCa[1]; //se llenan los campos para la posterior edición this.tbID.Text = idIngreso + ""; this.tbID.Enabled = false;//no se puede modificar el ID this.tbFecha.Text = fechaLista.ToString(); this.tbHora.Text = horaLista.ToString(); this.tbConcepto.Text = ingresoActual.Concepto; this.tbTotal.Text = ingresoActual.Total+""; this.tbFecha.Enabled = true; this.tbHora.Enabled = true; this.tbConcepto.Enabled = true; this.tbTotal.Enabled = true; this.btnActualizar.Enabled = true; } }//foreach }//btnAccion
}//btnAccion /// <summary> /// Este método actualizará la información que se encuentra en el formulario /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnActualizar_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(this.tbID.Text) || String.IsNullOrWhiteSpace(this.tbFecha.Text) || String.IsNullOrWhiteSpace(this.tbHora.Text) || String.IsNullOrWhiteSpace(this.tbConcepto.Text) || String.IsNullOrWhiteSpace(this.tbTotal.Text)) {//si existe un tb en blanco se indica al usuario y no se aplica ningún cambio ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.error('Error, campos en blanco')", true); } else { this.ib = new IngresoBusiness(); Ingreso ingresoNuevo = new Ingreso(int.Parse(tbID.Text.ToString()),tbFecha.Text.ToString(),tbHora.Text.ToString(),tbConcepto.Text.ToString(),float.Parse(tbTotal.Text.ToString()),"u"); bool respuesta = this.ib.actualizarIngreso(ingresoNuevo); if (respuesta)// Si se actualiza el usuario se recargan los datos y se dejan los tb en blanco { ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.success('El ingreso se actualizó exitosamente')", true); //dejar los campos de texto en blanco this.tbID.Text = ""; this.tbID.Enabled = false;//no se puede modificar el ID del ingreso this.tbFecha.Text = ""; this.tbHora.Text = ""; this.tbConcepto.Text = ""; this.tbTotal.Text = ""; this.tbFecha.Enabled = false; this.tbHora.Enabled = false; this.tbConcepto.Enabled = false; this.tbTotal.Enabled = false; this.btnActualizar.Enabled = false; cargarDatos(); }//if else { ClientScript.RegisterStartupScript(this.GetType(), "alertify", "alertify.error('Se ha producido un error al procesar la solicitud')", true); }//else }//else - no hay datos en blanco }//controlador de actualizarIngreso
public ABMIngreso() { this.commonBusiness = new CommonBusiness(); this.ingresoBusiness = new IngresoBusiness(); InitializeComponent(); }
public MenuPrincipal() { this.gastoBusines = new GastoBusiness(); this.ingresoBusiness = new IngresoBusiness(); InitializeComponent(); }