public bool Set(MassVoucher massVoucher) { bool isValid = true; double ignored = 0; if (massVoucher.Project == null) { isValid = SetErrorMessage("NoProjectSelected"); } else if (massVoucher.VoucherType != "Contra" && massVoucher.Head == null) { isValid = SetErrorMessage("NoHeadSelected"); } else if (massVoucher.Amount == 0) { isValid = SetErrorMessage("AmountCannotBeZero"); } else if (massVoucher.VoucherType == "Contra" && string.IsNullOrWhiteSpace(massVoucher.ContraType)) { isValid = SetErrorMessage("ContraTypeIsNotSelected"); } else if (massVoucher.VoucherType == "JV" && string.IsNullOrWhiteSpace(massVoucher.JVDebitOrCredit)) { isValid = SetErrorMessage("JVDebitOrCreditNotSelected"); } else if (massVoucher.IsFixedAsset && string.IsNullOrWhiteSpace(massVoucher.FixedAssetName)) { isValid = SetWarningMessage("NoFixedAssetParticularNameFound"); } else if (massVoucher.IsCheque && (string.IsNullOrWhiteSpace(massVoucher.ChequeNo) || string.IsNullOrWhiteSpace(massVoucher.BankName))) { isValid = SetInformationMessage("NoChequeOrBankInfo"); } else if (massVoucher.IsFixedAsset && massVoucher.FixedAssetDepreciationRate == 0) { isValid = SetInformationMessage("ZeroDepreciationProvidedForFixedAsset"); } else if (_voucherManager.GetVouchers(massVoucher.Project.ID, massVoucher.VoucherType + "-" + massVoucher.VoucherSerialNo.ToString(), ref ignored).Count() != 0) { isValid = SetWarningMessage("VoucherAlreadyExists"); } if (isValid) { _massVoucher = massVoucher; if (!massVoucher.VoucherType.Equals("Contra", StringComparison.OrdinalIgnoreCase)) { _projectHead = _projectHeadRepository.GetSingle( ph => ph.Project.ID == massVoucher.Project.ID && ph.Head.ID == massVoucher.Head.ID); } isValid = SetEntryableRecords(); } return isValid; }
public bool Set(MassVoucher massVoucher) { bool isValid = true; if (massVoucher.Project == null) { isValid = SetErrorMessage("NoProjectSelected"); } else if (massVoucher.VoucherType != "Contra" && massVoucher.Head == null) { isValid = SetErrorMessage("NoHeadSelected"); } else if (massVoucher.Amount == 0) { isValid = SetErrorMessage("AmountCannotBeZero"); } else if (massVoucher.VoucherType == "Contra" && string.IsNullOrWhiteSpace(massVoucher.ContraType)) { isValid = SetErrorMessage("ContraTypeIsNotSelected"); } else if (massVoucher.VoucherType == "JV" && string.IsNullOrWhiteSpace(massVoucher.JVDebitOrCredit)) { isValid = SetErrorMessage("JVDebitOrCreditNotSelected"); } else if (massVoucher.IsFixedAsset && string.IsNullOrWhiteSpace(massVoucher.FixedAssetName)) { isValid = SetWarningMessage("NoFixedAssetParticularNameFound"); } else if (massVoucher.IsCheque && (string.IsNullOrWhiteSpace(massVoucher.ChequeNo) || string.IsNullOrWhiteSpace(massVoucher.BankName))) { isValid = SetInformationMessage("NoChequeOrBankInfo"); } else if (massVoucher.IsFixedAsset && massVoucher.FixedAssetDepreciationRate == 0) { isValid = SetInformationMessage("ZeroDepreciationProvidedForFixedAsset"); } if (isValid) { _massVoucher = massVoucher; _projectHead = _projectHeadRepository.GetSingle( ph => ph.Project.ID == massVoucher.Project.ID && ph.Head.ID == massVoucher.Head.ID); isValid = SetEntryableRecords(); } return isValid; }