private void btnDelete_Click(object sender, RoutedEventArgs e) { try { if (ID != 0) { if (MessageBox.Show("Do you want to delete '" + txtName.Text + "'", "DELETE", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { SalutationSetup c = db.SalutationSetups.Where(x => x.Id == ID).FirstOrDefault(); var OldData = new JSonHelper().ConvertObjectToJSon(c); db.SalutationSetups.Remove(c); db.SaveChanges(); AppLib.EventHistory(this.Tag.ToString(), 2, OldData, "", "SalutationSetup"); MessageBox.Show("Deleted Successfully", "DELETED", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } } else { MessageBox.Show("Please Select Any Salutation! (Double Click to Select)", "SELECT", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Nube.ExceptionLogging.SendErrorToText(ex); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { try { if (txtName.Text == "") { MessageBox.Show("Enter Name...", "Information"); } else { if (MessageBox.Show("Do you want to save this record?", "SAVE CONFIRMATION", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (ID != 0) { SalutationSetup c = db.SalutationSetups.Where(x => x.Id == ID).FirstOrDefault(); var OldData = new JSonHelper().ConvertObjectToJSon(c); c.Salutation = txtName.Text; db.SaveChanges(); var NewData = new JSonHelper().ConvertObjectToJSon(c); AppLib.EventHistory(this.Tag.ToString(), 1, OldData, NewData, "SalutationSetup"); MessageBox.Show("Saved Successfully!", "Saved", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } else { if (db.SalutationSetups.Where(x => x.Salutation == txtName.Text).Select(x => x.Salutation).FirstOrDefault() == txtName.Text.ToString()) { MessageBox.Show("'" + txtName.Text + "' already exist! Enter new Country...", "Information"); } else { SalutationSetup c = new SalutationSetup(); c.Salutation = txtName.Text; db.SalutationSetups.Add(c); db.SaveChanges(); var NewData = new JSonHelper().ConvertObjectToJSon(c); AppLib.EventHistory(this.Tag.ToString(), 0, "", NewData, "SalutationSetup"); MessageBox.Show("Saved Successfully!", "Saved", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } } } } } catch (Exception ex) { Nube.ExceptionLogging.SendErrorToText(ex); } }
private void dgvTitle_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { if (bIsEdit == true) { SalutationSetup c = dgvTitle.SelectedItem as SalutationSetup; ID = c.Id; txtName.Text = c.Salutation; } } catch (Exception ex) { Nube.ExceptionLogging.SendErrorToText(ex); } }