public FamiliaArticuloForm(string Titulo, string Evento, CedForecastEntidades.FamiliaArticulo Familia) : base(Titulo) { InitializeComponent(); CedForecastRN.FamiliaArticulo accion = new CedForecastRN.FamiliaArticulo(Aplicacion.Sesion); accion.Leer(Familia); familia = Familia; evento = Evento; IdFamiliaArticuloEditBox.Text = familia.Id; IdFamiliaArticuloEditBox.Enabled = false; DescrFamiliaArticuloEditBox.Text = familia.Descr; switch (evento) { case "Baja": InhabilitarControles(); AceptarUiButton.Focus(); break; case "Consulta": InhabilitarControles(); SalirUiButton.Text = "Salir"; AceptarUiButton.Visible = false; SalirUiButton.Focus(); break; case "Modificacion": DescrFamiliaArticuloEditBox.Focus(); break; } }
private void AceptarUiButton_Click(object sender, EventArgs e) { try { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; familia.Id = IdFamiliaArticuloEditBox.Text; familia.Descr = DescrFamiliaArticuloEditBox.Text; CedForecastRN.FamiliaArticulo accion = new CedForecastRN.FamiliaArticulo(Aplicacion.Sesion); switch (evento) { case "Alta": accion.Crear(familia); break; case "Baja": accion.Eliminar(familia); break; case "Modificacion": accion.Modificar(familia); break; case "Consulta": break; } this.DialogResult = DialogResult.OK; } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.Message.Substring(0, 60) == "Instrucción DELETE en conflicto con la restricción REFERENCE") { MessageBox.Show("Esta Familia todavía tiene Artículos asociados. Asocie estos Artículos a otra Familia, antes de volver a intentar eliminarla.", "ADVERTENCIA"); } else { Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex); } } finally { Cursor.Current = System.Windows.Forms.Cursors.Default; } }
private void AceptarUiButton_Click(object sender, EventArgs e) { try { Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; string cedForecastWSURL = System.Configuration.ConfigurationManager.AppSettings["CedForecastWSURL"]; bool seChequeoAlgo = false; bool huboErrores = false; int cantidadMilisegundos = 100; #region Articulos / Familias de Articulos if (ArticuloUiCheckBox.Checked) { CedForecastRN.Articulo proceso = new CedForecastRN.Articulo(Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(proceso.EnviarNovedades)); thread.Start(); while (true) { BarraActualizar(ArticuloUIProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } CedForecastRN.FamiliaArticulo procesoFamilias = new CedForecastRN.FamiliaArticulo(Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(procesoFamilias.Enviar)); thread.Start(); while (true) { BarraActualizar(ArticuloUIProgressBar, procesoFamilias); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } if (procesoFamilias.Errores().Count != 0) { huboErrores = true; if (procesoFamilias.Errores()[0].InnerException != null) { MostrarMensajeError(procesoFamilias.Errores()[0].InnerException); } else { MostrarMensajeError(procesoFamilias.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Clientes if (ClienteUiCheckBox.Checked) { CedForecastRN.Cliente proceso = new CedForecastRN.Cliente(Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(proceso.EnviarNovedades)); thread.Start(); while (true) { BarraActualizar(ClienteUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Cuentas (vendedores) if (CuentaUiCheckBox.Checked) { CedForecastRN.Cuenta proceso = new CedForecastRN.Cuenta(Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(proceso.EnviarNovedades)); thread.Start(); while (true) { BarraActualizar(CuentaUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Ventas if (VentaUiCheckBox.Checked) { CedForecastRN.Venta proceso = new CedForecastRN.Venta(VentaCalendarCombo.Value.ToString("yyyyMM"), Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(proceso.EnviarNovedades)); thread.Start(); while (true) { BarraActualizar(VentaUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Zonas if (ZonaUiCheckBox.Checked) { CedForecastRN.Zona proceso = new CedForecastRN.Zona(Aplicacion.Sesion, cedForecastWSURL); thread = new Thread(new ThreadStart(proceso.EnviarNovedades)); thread.Start(); while (true) { BarraActualizar(ZonaUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Proyección Anual if (ProyeccionAnualUiCheckBox.Checked) { CedForecastRN.ProyeccionAnual proceso = new CedForecastRN.ProyeccionAnual(Aplicacion.Sesion, cedForecastWSURL, ProyeccionAnualCalendarCombo.Value.ToString("yyyyMM")); thread = new Thread(new ThreadStart(proceso.RecibirNovedades)); thread.Start(); while (true) { BarraActualizar(ProyeccionAnualUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion #region Rolling Forecast if (RollingForecastUiCheckBox.Checked) { CedForecastRN.RollingForecast proceso = new CedForecastRN.RollingForecast(Aplicacion.Sesion, cedForecastWSURL, RollingForecastCalendarCombo.Value.ToString("yyyyMM")); thread = new Thread(new ThreadStart(proceso.RecibirNovedades)); thread.Start(); while (true) { BarraActualizar(RollingForecastUiProgressBar, proceso); this.Refresh(); this.BringToFront(); Thread.Sleep(cantidadMilisegundos); if (thread.ThreadState == ThreadState.Stopped) { break; } } if (proceso.Errores().Count != 0) { huboErrores = true; if (proceso.Errores()[0].InnerException != null) { MostrarMensajeError(proceso.Errores()[0].InnerException); } else { MostrarMensajeError(proceso.Errores()[0]); } } seChequeoAlgo = true; } #endregion if (!seChequeoAlgo) { MessageBox.Show("Elija el elemento que desea sincronizar", "ATENCIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!huboErrores) { MessageBox.Show("Sincronización concluída satisfactoriamente", "NOTIFICACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Sincronización concluída con errores", "NOTIFICACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning); } this.DialogResult = DialogResult.OK; } } catch (Exception ex) { Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex); } finally { Cursor.Current = System.Windows.Forms.Cursors.Default; } }