private void bgwEnvioNotificaciones_DoWork(object sender, DoWorkEventArgs e) { try { Notificaciones DatosAux = this.ObtenerDatosNotificaciones(); Notificaciones_Negocio NN = new Notificaciones_Negocio(); DatosAux.Conexion = Comun.Conexion; DatosAux.IDUsuario = Comun.IDUsuario; NN.ObtenerReenvioNotificacion(DatosAux); int total = DatosAux.tablaNotificaciones.Rows.Count; int cont = 0; foreach (DataRow notificacion in DatosAux.tablaNotificaciones.Rows) { int IDTipoCelular = 0, Badge = 0; IDTipoCelular = Convert.ToInt32(notificacion["id_tipoCelular"].ToString()); Badge = Convert.ToInt32(notificacion["Badge"].ToString()); EnviaNotificaciones.EnviarMensaje(notificacion["tokenCelular"].ToString(), notificacion["nombre"].ToString(), notificacion["descripcion"].ToString(), Badge, IDTipoCelular); cont++; this.bgwEnvioNotificaciones.ReportProgress((cont * 100) / total); if (cont == total) { System.Threading.Thread.Sleep(1000); } } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNotificaciones ~ bgwEnvioNotificaciones_DoWork"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnReenvio_Click(object sender, EventArgs e) { try { if (this.dgvNotificaciones.SelectedRows.Count == 1) { try { Notificaciones DatosAux = this.ObtenerDatosNotificaciones(); if (!string.IsNullOrEmpty(DatosAux.IDNotificaciones)) { if (MessageBox.Show("¿Está seguro de reenviar las notificaciones?", Comun.Sistema, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Notificaciones_Negocio NN = new Notificaciones_Negocio(); DatosAux.Conexion = Comun.Conexion; if (DatosAux.EnviarNotificacion == true) { try { Espere = new frmWait(); this.bgwEnvioNotificaciones.RunWorkerAsync(DatosAux); Espere.ShowDialog(); } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNotificaciones ~ btnReenvio_Click ~ if (DatosAux.EnviarNotificacion == true)"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { MessageBox.Show("Seleccione un registro.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { } } else { MessageBox.Show("Seleccione un registro.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNotificaciones ~ btnReenvio_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BusquedaNotificaciones() { try { if (!this.chkBuscarXFecha.Checked && !this.chkBuscarXNotificacion.Checked) { MessageBox.Show("Debe seleccionar al menos un criterio de Búsqueda.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Notificaciones DatosAux = new Notificaciones { Conexion = Comun.Conexion, BusqNotificaciones = chkBuscarXNotificacion.Checked, BusqFechas = chkBuscarXFecha.Checked, Descripcion = string.Empty }; if (this.chkBuscarXNotificacion.Checked) { if (string.IsNullOrEmpty(this.txtTagBusqueda.Text.Trim())) { MessageBox.Show("Ingrese el nombre de la notificación. ", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DatosAux.Descripcion = this.txtTagBusqueda.Text.Trim(); } if (this.chkBuscarXFecha.Checked) { if (this.dtpFecha.Value > this.dtpFecha2.Value) { MessageBox.Show("La fecha tiene que se mayor a la actual", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DatosAux.FechaBusq = this.dtpFecha.Value; DatosAux.FechaBusq2 = this.dtpFecha2.Value; } Notificaciones_Negocio MN = new Notificaciones_Negocio(); MN.ObtenerNotificacionesBusqueda(DatosAux); this.dgvNotificaciones.AutoGenerateColumns = false; this.dgvNotificaciones.DataSource = DatosAux.TablaDatos; Busqueda = true; } } catch (Exception ex) { throw ex; } }
private void CargarGridNotificaciones(bool Band) { try { Notificaciones DatosAux = new Notificaciones { Conexion = Comun.Conexion, Todos = Band }; Notificaciones_Negocio NN = new Notificaciones_Negocio(); NN.ObtenerNotificaciones(DatosAux); this.dgvNotificaciones.AutoGenerateColumns = false; this.dgvNotificaciones.DataSource = DatosAux.TablaDatos; } catch (Exception ex) { throw ex; } }
private void btnEliminarr_Click(object sender, EventArgs e) { try { if (this.dgvNotificaciones.SelectedRows.Count == 1) { Notificaciones DatosAux = this.ObtenerDatosNotificaciones(); if (!string.IsNullOrEmpty(DatosAux.IDNotificaciones)) { DatosAux.Conexion = Comun.Conexion; DatosAux.IDUsuario = Comun.IDUsuario; Notificaciones_Negocio NN = new Notificaciones_Negocio(); NN.EliminarNotificaciones(DatosAux); if (DatosAux.Completado) { MessageBox.Show("Notificacion eliminada correctamente", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information); Int32 RowToDelete = this.dgvNotificaciones.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (RowToDelete > -1) { this.dgvNotificaciones.Rows.RemoveAt(RowToDelete); } else { this.CargarGridNotificaciones(false); } } else { MessageBox.Show("Error al guardar los datos. Contacte a Soporte Técnico.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Seleccione un registro.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNotificaciones ~ btnEliminar_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnGuardar_Click(object sender, EventArgs e) { try { this.txtMensajeError.Visible = false; List <Error> Errores = this.ValidarDatos(); if (Errores.Count == 0) { Notificaciones DatosAux = this.ObtenerDatos(); Notificaciones_Negocio NN = new Notificaciones_Negocio(); NN.Notificaciones(DatosAux); if (DatosAux.Completado) { foreach (DataRow notificacion in DatosAux.tablaNotificaciones.Rows) { int IDTipoCelular = 0, Badge = 0; IDTipoCelular = Convert.ToInt32(notificacion["id_tipoCelular"].ToString()); Badge = Convert.ToInt32(notificacion["Badge"].ToString()); EnviaNotificaciones.EnviarMensaje(notificacion["tokenCelular"].ToString(), notificacion["nombre"].ToString(), notificacion["descripcion"].ToString(), Badge, IDTipoCelular); } MessageBox.Show("Notificacion enviada correctamente", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Ocurrió un error al enviar la notificación. Contacte a Soporte Técnico.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { this.MostrarMensajeError(Errores); } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "frmNuevaNotificacion ~ btnGuardar_Click"); MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); } }