private void ApplyTimeslipSecurity(appDB.TimeSlipRow atr) { try { atriumBE.FileManager FMActivityTime = FM.AtMng.GetFile(atr.FileId); FMActivityTime.GetActivity().Load(atr.ActivityId); atriumDB.ActivityTimeRow actr = FMActivityTime.GetActivityTime().Load(atr.ActivityTimeId); bool canDelete = FMActivityTime.GetActivityTime().CanDelete(actr); if (canDelete) { timeSlipGridEX.RootTable.Columns["Delete"].ButtonStyle = Janus.Windows.GridEX.ButtonStyle.Image; } else { timeSlipGridEX.RootTable.Columns["Delete"].ButtonStyle = Janus.Windows.GridEX.ButtonStyle.NoButton; } if (FMActivityTime.GetActivityTime().CanEdit(actr)) { timeSlipGridEX.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.True; } else { timeSlipGridEX.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.False; } } catch (Exception x) { timeSlipGridEX.RootTable.Columns["Delete"].ButtonStyle = Janus.Windows.GridEX.ButtonStyle.NoButton; timeSlipGridEX.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.False; } }
private void DeleteTimeSlip(appDB.TimeSlipRow actr) { if (UIHelper.ConfirmDelete()) { atriumBE.FileManager FMActivityTime = FM.AtMng.GetFile(actr.FileId); FMActivityTime.GetActivity().Load(actr.ActivityId); atriumDB.ActivityTimeRow atr = FMActivityTime.GetActivityTime().Load(actr.ActivityTimeId); Application.UseWaitCursor = true; atr.Delete(); actr.Delete(); try { atLogic.BusinessProcess bp = FMActivityTime.GetBP(); bp.AddForUpdate(FMActivityTime.GetActivityTime()); bp.Update(); if (CurrentRowSRP().IsSRPSubmittedDateNull()) { CalculateOpenPeriodTotals(CurrentRowSRP()); } } catch (Exception x1) { FMActivityTime.DB.ActivityTime.RejectChanges(); throw x1; } finally { Application.UseWaitCursor = false; } } }
private void CalcFees(atriumDB.ActivityTimeRow dr) { dr.Minutes = dr.Hours * 60; if (!dr.Final) { if (!dr.IsHoursNull()) { officeDB.OfficeRow or = this.myA.AtMng.GetOffice(dr.OfficeId).CurrentOffice; //officeDB.OfficeRow or = (officeDB.OfficeRow)this.myA.AtMng.officeMng.DB.Office.Select("officeID=" + dr.OfficeId.ToString())[0]; //JLL: 2014-10-16 Change from minute to hour //dr.FeesClaimed = decimal.Round(dr.Hours * or.HourlyRate / 60, 2, MidpointRounding.AwayFromZero); dr.FeesClaimed = decimal.Round(dr.Hours * or.HourlyRate, 2, MidpointRounding.AwayFromZero); if (!this.myA.AtMng.GetOffice(dr.OfficeId).CurrentOffice.IsTaxRateNull()) { dr.FeesClaimedTax = Math.Round(this.myA.AtMng.GetOffice(dr.OfficeId).CurrentOffice.TaxRate *dr.FeesClaimed, 2, MidpointRounding.AwayFromZero); } } else { dr.SetFeesClaimedNull(); dr.SetFeesClaimedTaxNull(); } dr.EndEdit(); } }
protected override void BeforeChange(DataColumn dc, DataRow ddr) { atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)ddr; switch (dc.ColumnName) { case "OfficeId": if (dr.IsOfficeIdNull()) { throw new RequiredException(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 ActivityFields.OfficerId: if (dr.IsOfficerIdNull()) { throw new RequiredException(dc.ColumnName); } else if (!myA.CheckDomain(dr.OfficerId, myA.Codes("OfficerList"))) { throw new AtriumException(atriumBE.Properties.Resources.BadDomainValue, dc.ColumnName, dc.Table.TableName, "Officer List"); } break; case ActivityFields.Hours: //JLL: 2014-10-16 Change from minute to hour //if (dr.Hours > (24 * 60)) if (!fixingHours) { if (dr.Hours > 24) { throw new AtriumException("Minutes cannot be greater than 1440 minutes (24 hours) for one entry"); } //if (dr.OfficeId != this.myA.AtMng.OfficeLoggedOn.OfficeId || (dr.Final && !dr.IsIRPIdNull())) // throw new AtriumException(atriumBE.Properties.Resources.ActivityTimeCannotEditHoursFees); } break; case ActivityFields.IRPId: case ActivityFields.FeesClaimed: case ActivityFields.FeesClaimedTax: case ActivityFields.Posted: case ActivityFields.Final: //if (dr.OfficeId != this.myA.AtMng.OfficeLoggedOn.OfficeId || (dr.Final && !dr.IsIRPIdNull())) // throw new AtriumException(atriumBE.Properties.Resources.ActivityTimeCannotEditHoursFees); break; case ActivityFields.Taxed: if (!dr.Final && dr.Taxed) { throw new AtriumException(atriumBE.Properties.Resources.ActivityTimeCannotTax); } break; } }
protected override void BeforeDelete(System.Data.DataRow row) { atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)row; if (!CanDelete(dr)) { throw new AtriumException(atriumBE.Properties.Resources.ActivityTimeNoDeleteCommitted); } }
public override bool CanDelete(DataRow row) { atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)row; bool ok = false; atSecurity.SecurityManager.LevelPermissions perm = myA.AtMng.SecurityManager.CanDelete(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime); switch (perm) { case atSecurity.SecurityManager.LevelPermissions.All: ok = true; break; case atSecurity.SecurityManager.LevelPermissions.Mine: if (dr.OfficerId == myA.AtMng.OfficerLoggedOn.OfficerId) { ok = true; } else if (dr.OfficerId == myA.AtMng.WorkingAsOfficer.OfficerId) { ok = true; } break; case atSecurity.SecurityManager.LevelPermissions.MyOffice: if (dr.OfficeId == myA.AtMng.OfficerLoggedOn.OfficeId) { ok = true; } break; case atSecurity.SecurityManager.LevelPermissions.No: ok = false; break; default: ok = false; break; } bool canOverride = myA.AtMng.SecurityManager.CanOverride(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) == atSecurity.SecurityManager.ExPermissions.Yes; if (dr.Final && !dr.IsIRPIdNull() && !canOverride) { ok = false; } return(ok); }
private void timeSlipGridEX_CellUpdated(object sender, Janus.Windows.GridEX.ColumnActionEventArgs e) { try { int fileid = CurrentRowACTimeSlip().FileId; if (e.Column.Key == "Hours" || e.Column.Key == "Comment") { timeSlipGridEX.UpdateData(); Application.UseWaitCursor = true; //get FM, load activitytime record and update hours/comment atriumBE.FileManager FMActivityTime = FM.AtMng.GetFile(fileid); FMActivityTime.GetActivity().Load(CurrentRowACTimeSlip().ActivityId); atriumDB.ActivityTimeRow atr = FMActivityTime.GetActivityTime().Load(CurrentRowACTimeSlip().ActivityTimeId); if (CurrentRowACTimeSlip().IsHoursNull()) { CurrentRowACTimeSlip().Hours = 0; } atr.Hours = CurrentRowACTimeSlip().Hours; atr.Comment = CurrentRowACTimeSlip().Comment; timeSlipBindingSource.EndEdit(); try { atLogic.BusinessProcess bp = FM.GetBP(); bp.AddForUpdate(FMActivityTime.GetActivityTime()); bp.Update(); CalculateOpenPeriodTotals(CurrentRowSRP()); } catch (Exception x1) { FMActivityTime.DB.ActivityTime.RejectChanges(); throw x1; } Application.UseWaitCursor = false; } } catch (Exception x) { Application.UseWaitCursor = false; UIHelper.HandleUIException(x); } }
protected override void AfterChange(DataColumn dc, DataRow ddr) { string ObjectName = this.myActivityTimeDT.TableName; atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)ddr; switch (dc.ColumnName) { case ActivityFields.Hours: if (!fixingHours) { dr.Hours = decimal.Round(dr.Hours, 1, MidpointRounding.AwayFromZero); CalcFees(dr); } break; default: break; } }
protected override void AfterAdd(DataRow ddr) { string ObjectName = this.myActivityTimeDT.TableName; atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)ddr; ActivityConfig.ActivityCodeRow arc = myA.GetActivity().GetACSeriesRow(dr.ActivityRow).ActivityCodeRow; dr.ActivityTimeId = this.myA.AtMng.PKIDGet(ObjectName, 10); dr.Taxed = false; dr.Final = false; dr.Posted = true; dr.FileId = dr.ActivityRow.FileId; if (!arc.IsDefaultHoursNull() && dr.IsHoursNull()) { dr.Hours = Math.Round(arc.DefaultHours, 1); } else { dr.Hours = 0; } // JLL: 2009-12-21 officeid should default to workingAs office and not activity row's officeid dr.OfficeId = myA.AtMng.WorkingAsOfficer.OfficeId; //dr.ActivityRow.OfficeId; dr.OfficerId = myA.AtMng.WorkingAsOfficer.OfficerId; // JLL: 2009-12-21 changed to now as per PS request if (dr.ActivityRow.RowState == DataRowState.Added) { dr.StartTime = dr.ActivityRow.ActivityDate; } else { dr.StartTime = DateTime.Now; } CalcFees(dr); }
public override bool CanEdit(DataRow ddr) { atriumDB.ActivityTimeRow dr = (atriumDB.ActivityTimeRow)ddr; if (!myA.IsVirtualFM && dr.FileId != myA.CurrentFile.FileId) { return(false); } //2017-08-21 JLL: On refresh, ActivityRow is null, return false; if (dr.ActivityRow == null) { return(false); } if (dr.ActivityRow.EFileRow.RowState == DataRowState.Added) { return(true); } bool doCheck = false; if (dr.RowState != DataRowState.Modified) { doCheck = true; } else { //if only fileid or audit values was changed then return true foreach (DataColumn dc in dr.Table.Columns) { switch (dc.ColumnName.ToLower()) { case "fileid": case "updatedate": case "updateuser": break; default: if (myA.IsFieldChanged(dc, dr)) { doCheck = true; } break; } } } if (doCheck) { bool ok = false;// myA.AtMng.SecurityManager.CanUpdate(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) > atSecurity.SecurityManager.LevelPermissions.No; atSecurity.SecurityManager.LevelPermissions perm = myA.AtMng.SecurityManager.CanUpdate(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime); switch (perm) { case atSecurity.SecurityManager.LevelPermissions.All: ok = true; break; case atSecurity.SecurityManager.LevelPermissions.Mine: if (dr.OfficerId == myA.AtMng.OfficerLoggedOn.OfficerId) { ok = true; } else { OfficeManager myOfficeMng = myA.AtMng.GetOffice(myA.AtMng.OfficeLoggedOn.OfficeId); foreach (lmDatasets.officeDB.OfficerDelegateRow odr in myOfficeMng.GetOfficerDelegate().DelegatesForOfficer(myA.AtMng.OfficerLoggedOn.OfficerId)) { if (dr.OfficerId == odr.OfficerId) { ok = true; } } } //else if (dr.OfficerId == myA.AtMng.WorkingAsOfficer.OfficerId) // ok = true; break; case atSecurity.SecurityManager.LevelPermissions.MyOffice: if (dr.OfficeId == myA.AtMng.OfficerLoggedOn.OfficeId) { ok = true; } break; case atSecurity.SecurityManager.LevelPermissions.No: ok = false; break; default: ok = false; break; } bool canOverride = myA.AtMng.SecurityManager.CanOverride(dr.FileId, atSecurity.SecurityManager.Features.ActivityTime) == atSecurity.SecurityManager.ExPermissions.Yes; if (dr.Final && !dr.IsIRPIdNull() && !canOverride) { ok = false; } return(ok | AllowEdit); } else { return(true); } }