private void btnDelete_Click(object sender, RoutedEventArgs e) { try { if (ID != 0) { if (MessageBox.Show("Do you want to delete '" + txtReasonName.Text + "'", "DELETE", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { MASTERRESIGNSTATU ms = db.MASTERRESIGNSTATUS.Where(x => x.RESIGNSTATUS_CODE == ID).FirstOrDefault(); var OldData = new JSonHelper().ConvertObjectToJSon(ms); db.MASTERRESIGNSTATUS.Remove(ms); db.SaveChanges(); AppLib.EventHistory(this.Tag.ToString(), 2, OldData, "", "MASTERRESIGNSTATUS"); MessageBox.Show("Deleted Successfully!", "DELETED", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } } else { MessageBox.Show("Please Select any Reason! (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 (txtReasonName.Text == "") { MessageBox.Show("Enter Reason...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtReasonName.Focus(); } else if (chkIsBefitValid.IsChecked == true && string.IsNullOrEmpty(txtMinimumYear.Text)) { MessageBox.Show("Enter Minimum Year...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtMinimumYear.Focus(); } else if (chkIsBefitValid.IsChecked == true && string.IsNullOrEmpty(txtMinimumRefund.Text)) { MessageBox.Show("Enter Minimum Refund...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtMinimumRefund.Focus(); } else if (chkIsBefitValid.IsChecked == true && string.IsNullOrEmpty(txtMAximumRefund.Text)) { MessageBox.Show("Enter Maximum Refund...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtMAximumRefund.Focus(); } else if (chkIsBefitValid.IsChecked == true && string.IsNullOrEmpty(txtAmnt1.Text)) { MessageBox.Show("Enter Amount1...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtAmnt1.Focus(); } else if (chkIsBefitValid.IsChecked == true && string.IsNullOrEmpty(txtAmnt2.Text)) { MessageBox.Show("Enter Amount2...", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtAmnt2.Focus(); } else { if (MessageBox.Show("Do you want to save this record?", "SAVE CONFIRMATION", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { if (ID != 0) { MASTERRESIGNSTATU ms = db.MASTERRESIGNSTATUS.Where(x => x.RESIGNSTATUS_CODE == ID).FirstOrDefault(); var OldData = new JSonHelper().ConvertObjectToJSon(ms); ms.RESIGNSTATUS_NAME = txtReasonName.Text; if (chkIsBefitValid.IsChecked == true) { ms.IsBenefitValid = Convert.ToBoolean(chkIsBefitValid.IsChecked); ms.MinimumYear = Convert.ToInt32(txtMinimumYear.Text); ms.MinimumRefund = Convert.ToInt32(txtMinimumRefund.Text); ms.MaximumRefund = Convert.ToInt32(txtMAximumRefund.Text); ms.AmtPerYear1 = Convert.ToInt32(txtAmnt1.Text); ms.AmtPerYear2 = Convert.ToInt32(txtAmnt2.Text); } db.SaveChanges(); var NewData = new JSonHelper().ConvertObjectToJSon(ms); AppLib.EventHistory(this.Tag.ToString(), 1, OldData, NewData, "MASTERRESIGNSTATUS"); MessageBox.Show("Saved Successfully!", "SAVED", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } else { if (db.MASTERRESIGNSTATUS.Where(x => x.RESIGNSTATUS_NAME == txtReasonName.Text).ToString() == txtReasonName.Text.ToString()) { MessageBox.Show("'" + txtReasonName.Text + "' Already exist.Enter new relation.", "Information", MessageBoxButton.OK, MessageBoxImage.Error); txtReasonName.Focus(); } else { MASTERRESIGNSTATU ms = new MASTERRESIGNSTATU(); ms.RESIGNSTATUS_NAME = txtReasonName.Text; if (chkIsBefitValid.IsChecked == true) { ms.IsBenefitValid = Convert.ToBoolean(chkIsBefitValid.IsChecked); ms.MinimumYear = Convert.ToInt32(txtMinimumYear.Text); ms.MinimumRefund = Convert.ToInt32(txtMinimumRefund.Text); ms.MaximumRefund = Convert.ToInt32(txtMAximumRefund.Text); ms.AmtPerYear1 = Convert.ToInt32(txtAmnt1.Text); ms.AmtPerYear2 = Convert.ToInt32(txtAmnt2.Text); } db.MASTERRESIGNSTATUS.Add(ms); db.SaveChanges(); var NewData = new JSonHelper().ConvertObjectToJSon(ms); AppLib.EventHistory(this.Tag.ToString(), 0, "", NewData, "MASTERRESIGNSTATUS"); MessageBox.Show("Saved Successfully!", "SAVED", MessageBoxButton.OK, MessageBoxImage.Information); FormClear(); } } } } } catch (Exception ex) { Nube.ExceptionLogging.SendErrorToText(ex); } }