private void btnUpdateUser_Click(object sender, RoutedEventArgs e) { var editUser = new Login_FT { Id = cboUser.SelectedIndex + 1, Login_name = txtUserUpdate.Text, Login_pass = txtPassUpdate.Password, Question = txtQuestUpdate.Text, Answer = txtAmwserUpdate.Password, IsActive = cboStatusAccUpdate.SelectedIndex + 1, Roles = cboRolesUpdate.SelectedIndex + 1, Id_employee = idEmployeeUpdate }; try { if (txtPassUpdate.Password == txtPass2Update.Password) { LoginBL.GetInstance().UpdateUser(editUser); cboUser.SelectedIndex = -1; cboStatusAccUpdate.SelectedIndex = -1; cboRolesUpdate.SelectedIndex = -1; txtUserUpdate.Clear(); txtPassUpdate.Clear(); txtPass2Update.Clear(); txtQuestUpdate.Clear(); txtAmwserUpdate.Clear(); MessageBoxRM.Show("Usuario actualizado correctamente!", "Actualizacion Usuario", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = txtPass2Update; txtPass2Update.ToolTip = toolTip; toolTip.Content = "La contraseña no coinciden"; ToolTipService.SetShowDuration(txtPass2Update, 4000); ToolTipService.SetPlacement(txtPass2Update, System.Windows.Controls.Primitives.PlacementMode.Bottom); txtPass2Update.BorderBrush = Brushes.Red; txtPass2Update.BorderThickness = new Thickness(1, 1, 1, 1); bdrValidation.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.Pass; timer.Start(); } } catch (Exception ex) { MessageBoxRM.Show(ex.InnerException.Message, "Erro al actualizar usuario", MessageBoxButtonRM.OK, MessageBoxIconRM.Error); } }
private void btnRegProduct_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrEmpty(txtProduct.Text)) { if (!string.IsNullOrEmpty(txtPrice.Text)) { if (cboCategory.SelectedIndex > -1) { int idCategory = cboCategory.SelectedIndex + 1; int price = Convert.ToInt32(txtPrice.Text); MenuBL.GetInstance().RegisterProduct(txtProduct.Text, price, idCategory); MessageBoxRM.Show("Producto registrado correctamente!", "Registro de Producto", MessageBoxButtonRM.OK, MessageBoxIconRM.Information); txtProduct.Clear(); txtPrice.Clear(); cboCategory.SelectedIndex = -1; RechargeAllCbo(); } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = cboCategory; cboCategory.ToolTip = toolTip; toolTip.Content = "Esta opcion es requerida"; ToolTipService.SetShowDuration(cboCategory, 4000); ToolTipService.SetPlacement(cboCategory, System.Windows.Controls.Primitives.PlacementMode.Bottom); cboCategory.BorderBrush = Brushes.Red; bdrValidation_Copy1.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.Caegory; timer.Start(); } } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = txtPrice; txtPrice.ToolTip = toolTip; toolTip.Content = "Este campo es requerido"; ToolTipService.SetShowDuration(txtPrice, 4000); ToolTipService.SetPlacement(txtPrice, System.Windows.Controls.Primitives.PlacementMode.Bottom); txtPrice.BorderBrush = Brushes.Red; txtPrice.BorderThickness = new Thickness(1, 1, 1, 1); bdrValidation_Copy.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.Price; timer.Start(); } } else { ToolTip toolTip = new ToolTip(); toolTip.PlacementTarget = txtProduct; txtProduct.ToolTip = toolTip; toolTip.Content = "Este campo es requerido"; ToolTipService.SetShowDuration(txtProduct, 4000); ToolTipService.SetPlacement(txtProduct, System.Windows.Controls.Primitives.PlacementMode.Bottom); txtProduct.BorderBrush = Brushes.Red; txtProduct.BorderThickness = new Thickness(1, 1, 1, 1); bdrValidation.Visibility = Visibility.Visible; validationIcon = bdrValidationIcon.User; timer.Start(); } } catch (Exception ex) { MessageBoxRM.Show(ex.InnerException.Message, "Ha ocurrido un error :(", MessageBoxButtonRM.OK, MessageBoxIconRM.Error); } }