protected override void AfterAdd(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; string ObjectName = this.myDisbursementDT.TableName; if (dr.IsNull("DisbId") || dr.DisbId > 0) { dr.DisbId = this.myA.AtMng.PKIDGet(ObjectName, 1); } dr.DisbDate = dr.ActivityRow.ActivityDate;// DateTime.Today; dr.FileID = dr.ActivityRow.FileId; dr.Final = false; dr.Posted = true; dr.OfficeId = this.myA.AtMng.WorkingAsOfficer.OfficeId; dr.Taxed = false; //2017-08-09 JLL IUTIR - 9755 if (!myA.AtMng.WorkingAsOfficer.OfficeRow.IsDefaultTaxRateNull()) { dr.TaxRateId = myA.AtMng.WorkingAsOfficer.OfficeRow.DefaultTaxRate; } //2017-09-20 JLL //validate disbdate on entry, otherwise on ACs older than 6 months, date can be saved if not edited without being validated properly this.BeforeChange(this.myDisbursementDT.Columns["DisbDate"], row); }
public override bool CanEdit(DataRow ddr) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr; if (dr == null || dr.ActivityRow == null) { return(false); } if (dr.ActivityRow.EFileRow.RowState == DataRowState.Added) { return(true); } if (dr.IsNull("FileId")) { return(true); } if (!myA.IsVirtualFM && dr.FileID != myA.CurrentFile.FileId) { return(false); } if (dr.Final) { return(false); } if (!dr.IsNull("OfficeId") && dr.OfficeId != this.myA.AtMng.WorkingAsOfficer.OfficeId) { return(false); } if (dr.ActivityRow != null && dr.ActivityRow.OfficeId != this.myA.AtMng.WorkingAsOfficer.OfficeId) { return(false); } return(myA.AtMng.SecurityManager.CanUpdate(dr.FileID, atSecurity.SecurityManager.Features.Disbursement) > atSecurity.SecurityManager.LevelPermissions.No | AllowEdit); }
protected override void BeforeUpdate(DataRow row) { atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)row; if (!CanEdit(dr)) { throw new AtriumException(atriumBE.Properties.Resources.CACannotEditAnotherOffice); } if (dr.IsDisbDateNull()) { this.BeforeChange(DisbursementFields.DisbDate, dr); } if (dr.IsNull(dr.Table.Columns[DisbursementFields.DisbType])) { this.BeforeChange(DisbursementFields.DisbType, dr); } if (dr.IsDisbTaxableNull() && dr.IsDisbTaxExemptNull()) { throw new RequiredException(DisbursementFields.DisbTaxable); } }
protected override void BeforeChange(DataColumn dc, DataRow ddr) { string ObjectName = this.myDisbursementDT.TableName; atriumDB.DisbursementRow dr = (atriumDB.DisbursementRow)ddr; switch (dc.ColumnName) { case DisbursementFields.DisbDate: if (dr.IsDisbDateNull() || myA.IsEmpty(dr.DisbDate.ToString())) { throw new RequiredException(Resources.DisbursementDisbDate); } this.myA.IsValidDate(Resources.DisbursementDisbDate, dr.DisbDate, false, DateTime.Today.AddMonths(-6), DateTime.Today, Resources.ValidationSixMonthsAgo, Resources.ValidationToday); break; case DisbursementFields.DisbType: if (dr.IsNull(dc) || dr.DisbType.Length == 0) { throw new RequiredException(Resources.DisbursementDisbType); } else if (!myA.CheckDomain(dr.DisbType, myA.Codes("DisbursementType"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dr.Table.TableName, "Dsibursement Type"); } break; case "TaxRateId": if (!dr.IsTaxRateIdNull() && !myA.CheckDomain(dr.TaxRateId, myA.Codes("TaxRate"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Tax Rate"); } break; case "OfficeId": if (!myA.CheckDomain(dr.OfficeId, myA.Codes("OfficeList"))) { throw new AtriumException(atriumBE.Properties.Resources.IsNotValid, dc.ColumnName); } else if (!myA.CheckDomain(dr.OfficeId, myA.Codes("officelist"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Office List"); } break; case DisbursementFields.IRPId: case DisbursementFields.DisbTaxExempt: case DisbursementFields.DisbTaxable: case DisbursementFields.DisbTax: case DisbursementFields.Posted: case DisbursementFields.Final: if (dr.Final) { throw new AtriumException(Resources.DisbNoEditAfterCommit); } break; case DisbursementFields.Taxed: if (!dr.Final && dr.Taxed) { throw new AtriumException(Resources.DisbNoTaxUnlessCommit); } break; default: break; } }