/// <summary> /// This method is used to delete the tax /// </summary> /// <param name="param"></param> void DeleteTax(object param) { Mouse.OverrideCursor = Cursors.Wait; ITaxOperationRepository taxRepository = new TaxOperationRepository(); ITaxCodesAndRatesRepository tax = new TaxCodesAndRatesRepository(); var taxModel = SelectedTax as TaxModel; if (taxModel != null) { if (taxModel.Predefined == false || taxModel.Predefined == null) { MessageBoxResult result = MessageBox.Show("Do you want to delete tax?\n" + "@ Simple Accounting Software Pte Ltd", "Delete Tax", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { var Check = tax.IsTaxDeleted(taxModel.TaxID); if (Check.Equals("1") && Check != null) { TaxErrors = "# GST Code cannot be deleted because it is used in transaction."; } else { taxRepository.DeleteTax(taxModel.TaxID); SelectedTax = new TaxModel(); Tax = new ObservableCollection <TaxModel>(tax.GetAllTaxes()); } } } else { TaxErrors = "# GST Free cannot be deleted."; } } Mouse.OverrideCursor = null; }
/// <summary> /// This method is used to delete the tax /// </summary> /// <param name="param"></param> void DeleteTax(object param) { Mouse.OverrideCursor = Cursors.Wait; ITaxOperationRepository taxRepository = new TaxOperationRepository(); ITaxCodesAndRatesRepository tax = new TaxCodesAndRatesRepository(); var taxModel = SelectedTax as TaxModel; if (taxModel != null) { if (taxModel.Predefined == false || taxModel.Predefined == null) { MessageBoxResult result = MessageBox.Show("Do you want to delete tax?", "Delete Tax", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { taxRepository.DeleteTax(taxModel.TaxID); SelectedTax = new TaxModel(); Tax = new ObservableCollection <TaxModel>(tax.GetAllTaxes()); } } else { TaxErrors = "# GST Free cannot be deleted."; } } Mouse.OverrideCursor = null; }
/// <summary> /// This is to cancel the operation /// </summary> /// <param name="param"></param> void DoCancel(object param) { ITaxCodesAndRatesRepository tax = new TaxCodesAndRatesRepository(); SelectedTax = new TaxModel(); Tax = new ObservableCollection <TaxModel>(tax.GetAllTaxes()); TaxErrors = string.Empty; }
//private List<string> FlattenErrors() //{ // List<string> errors = new List<string>(); // Dictionary<string, List<string>> allErrors = taxM.GetAllErrors(); // foreach (string propertyName in allErrors.Keys) // { // foreach (var errorString in allErrors[propertyName]) // { // errors.Add(errorString); // } // } // return errors; //} private void SaveTax() { ITaxOperationRepository taxRepository = new TaxOperationRepository(); ITaxCodesAndRatesRepository tax = new TaxCodesAndRatesRepository(); ICompanyDetails details = new CompanyDetails(); var taxModel = SelectedTax as TaxModel; if (SelectedTaxName != null) { taxModel.TaxName = SelectedTaxName; } if (taxModel != null) { TaxErrors = ValidateTaxCodesAndRates(taxModel); if (TaxErrors == string.Empty) { MessageBoxResult result = MessageBox.Show("Do you want to save changes?", "Save Tax", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CompanyDetailsEntities compEntities = details.GetCompanyDetails(); if (compEntities.Comp_Reg_No == null) { if (taxModel.Predefined == false) { if (taxModel.IsDefault == true) { MessageBox.Show("Your Company is not registered to collect GST/VAT.\n" + "@ Simple Accounting Software Pte Ltd", "Warning Message", MessageBoxButton.OK); } } } else { if (compEntities.Comp_GST_Dereg_Date != null) { if (Convert.ToDateTime(compEntities.Comp_GST_Dereg_Date).Date > DateTime.Now.Date) { if (taxModel.Predefined == false) { if (taxModel.IsDefault == true) { MessageBox.Show("Your Company is not registered to collect GST/VAT.\n" + "@ Simple Accounting Software Pte Ltd", "Warning Message", MessageBoxButton.OK); } } } } } if (taxModel.Predefined == true) { if (taxModel.TaxRate != 0 || taxModel.IsInActive == "Y") { TaxErrors = "# GST Free cannot be made inactive. Description and Code can be edited but not rate."; Mouse.OverrideCursor = null; return; } } if (taxRepository.IsCodeAndRateExists(taxModel)) { TaxErrors = "Tax Code should be unique"; Mouse.OverrideCursor = null; return; } else { if (SelectedIndex == -1) { taxRepository.SaveTax(taxModel); } else { taxRepository.UpdateTax(taxModel); } } //MessageBox.Show("Record Saved successfully", "Save Content", MessageBoxButton.OK); Tax = new ObservableCollection <TaxModel>(tax.GetAllTaxes()); SelectedTax = null; TaxErrors = string.Empty; } } } }