/// <summary> /// Updates a field of a customer (Numeric field) /// </summary> /// <param name="column"></param> /// <param name="customer"></param> /// <param name="mandatory"></param> private void UpdateFieldNumeric(string column, Customer customer, bool mandatory) { string ans = Microsoft.VisualBasic.Interaction.InputBox("Digite el nuevo valor de " + column, column); int value; if (!(Int32.TryParse(ans.Trim(), out value))) { SystemSounds.Beep.Play(); MessageBox.Show("Campo invalido!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } new Thread(() => { Thread.CurrentThread.IsBackground = true; try { if (BDManager.UpdateCustomer(column, value, customer.Cedula)) { switch (column) { case "nodo": customer.Nodo = value; break; case "megas": customer.Megas = value; break; case "descuento": customer.Descuento = value; break; default: Debugger.Break(); break; } SystemSounds.Beep.Play(); MessageBox.Show("Valor actualizado!", Messages.Titles.Success, MessageBoxButton.OK, MessageBoxImage.Information); this.ListViewCustomers.Dispatcher.Invoke(delegate { ICollectionView view = CollectionViewSource.GetDefaultView(this.ListViewCustomers.ItemsSource); view.Refresh(); }); } } catch (Exception) { SystemSounds.Beep.Play(); MessageBox.Show("Error!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); } }).Start(); }
/// <summary> /// Updates an attribute of a customer /// </summary> /// <param name="column"></param> /// <param name="customer"></param> /// <param name="mandatory"></param> private void UpdateField(string column, Customer customer, bool mandatory) { string ans = Microsoft.VisualBasic.Interaction.InputBox("Digite el nuevo valor de " + column, column); if (ans.Trim() == String.Empty) { ans = null; } if (mandatory) { if (String.IsNullOrEmpty(ans)) { SystemSounds.Beep.Play(); MessageBox.Show("El campo " + column + " no puede ser vacio!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); return; } } new Thread(() => { Thread.CurrentThread.IsBackground = true; try { ans = ans.ToUpper(); if (BDManager.UpdateCustomer(column, ans, customer.Cedula)) { switch (column) { case "telefono": customer.Telefono = ans; break; case "celular": customer.Celular = ans; break; case "correo": customer.Correo = ans; break; case "direccion": customer.Direccion = ans; break; case "barrio": customer.Barrio = ans; break; case "mac": customer.MAC = ans; break; case "precinto": customer.MAC = ans; break; default: Debugger.Break(); break; } SystemSounds.Beep.Play(); MessageBox.Show("Valor actualizado!", Messages.Titles.Success, MessageBoxButton.OK, MessageBoxImage.Information); this.ListViewCustomers.Dispatcher.Invoke(delegate { ICollectionView view = CollectionViewSource.GetDefaultView(this.ListViewCustomers.ItemsSource); view.Refresh(); }); } } catch (Exception) { SystemSounds.Beep.Play(); MessageBox.Show("Error!", Messages.Titles.Alert, MessageBoxButton.OK, MessageBoxImage.Error); } }).Start(); }