private void ValidateDataDetailsManual(PmJobAssignmentRow ARow) { TVerificationResultCollection VerificationResultCollection = FPetraUtilsObject.VerificationResultCollection; TSharedPersonnelValidation_Personnel.ValidateJobAssignmentManual(this, ARow, ref VerificationResultCollection, FValidationControlsDict); }
/// <summary> /// Code to be run after the deletion process /// </summary> /// <param name="ARowToDelete">the row that was/was to be deleted</param> /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param> /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> private void PostDeleteManual(PmJobAssignmentRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { if (ADeletionPerformed) { DoRecalculateScreenParts(); } }
private void ShowDetailsManual(PmJobAssignmentRow ARow) { // In theory, the next Method call could be done in Methods NewRowManual; however, NewRowManual runs before // the Row is actually added and this would result in the Count to be one too less, so we do the Method call here, short // of a non-existing 'AfterNewRowManual' Method.... DoRecalculateScreenParts(); if (ARow != null) { txtUnitKey.Enabled = (ARow.RowState == DataRowState.Added); } }
private void NewRowManual(ref PmJobAssignmentRow ARow) { ARow.PartnerKey = FMainDS.PPerson[0].PartnerKey; ARow.UnitKey = 0; ARow.PositionName = ""; ARow.PositionScope = "O"; ARow.FromDate = DateTime.Now.Date; // set job key to random value for now as this will be set correctly during saving on server side // depending on if job record already exists or not ARow.JobKey = -1; ARow.JobAssignmentKey = Convert.ToInt32(TRemote.MCommon.WebConnectors.GetNextSequence(TSequenceNames.seq_job_assignment)); }
/// <summary> /// Performs checks to determine whether a deletion of the current /// row is permissable /// </summary> /// <param name="ARowToDelete">the currently selected row to be deleted</param> /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param> /// <returns>true if user is permitted and able to delete the current row</returns> private bool PreDeleteManual(PmJobAssignmentRow ARowToDelete, ref string ADeletionQuestion) { /*Code to execute before the delete can take place*/ ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2},{0} {3} {4} {5},{0} {6} {7})", Environment.NewLine, lblFromDate.Text, dtpFromDate.Date.Value.ToString("dd-MMM-yyyy").ToUpper(), lblUnitKey.Text, txtUnitKey.Text, txtUnitKey.LabelText, lblPositionName.Text, cmbPositionName.GetSelectedString()); return(true); }
/// <summary> /// Performs checks to determine whether a deletion of the current /// row is permissable /// </summary> /// <param name="ARowToDelete">the currently selected row to be deleted</param> /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param> /// <returns>true if user is permitted and able to delete the current row</returns> private bool PreDeleteManual(PmJobAssignmentRow ARowToDelete, ref string ADeletionQuestion) { /*Code to execute before the delete can take place*/ ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2},{0} {3} {4} {5},{0} {6} {7})", Environment.NewLine, lblFromDate.Text, dtpFromDate.Date.Value.ToString("dd-MMM-yyyy").ToUpper(), lblUnitKey.Text, txtUnitKey.Text, txtUnitKey.LabelText, lblPositionName.Text, cmbPositionName.GetSelectedString()); return true; }
/// <summary> /// Validates the Job Assignment data of a Partner. /// </summary> /// <param name="AContext">Context that describes where the data validation failed.</param> /// <param name="ARow">The <see cref="DataRow" /> which holds the the data against which the validation is run.</param> /// <param name="AVerificationResultCollection">Will be filled with any <see cref="TVerificationResult" /> items if /// data validation errors occur.</param> /// <param name="AValidationControlsDict">A <see cref="TValidationControlsDict" /> containing the Controls that /// display data that is about to be validated.</param> /// <returns>void</returns> public static void ValidateJobAssignmentManual(object AContext, PmJobAssignmentRow ARow, ref TVerificationResultCollection AVerificationResultCollection, TValidationControlsDict AValidationControlsDict) { DataColumn ValidationColumn; TValidationControlsData ValidationControlsData; TVerificationResult VerificationResult; // Don't validate deleted DataRows if (ARow.RowState == DataRowState.Deleted) { return; } // 'From Date' must be defined ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnFromDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedValidationControlHelper.IsNotInvalidDate(ARow.FromDate, ValidationControlsData.ValidationControlLabel, AVerificationResultCollection, true, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'To Date' must be later than 'From Date' ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnToDateId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TDateChecks.FirstGreaterOrEqualThanSecondDate(ARow.ToDate, ARow.FromDate, ValidationControlsData.ValidationControlLabel, ValidationControlsData.SecondValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Handle addition to/removal from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Unit' must be a Partner of Class 'UNIT' and must not be 0 ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnUnitKeyId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { VerificationResult = TSharedPartnerValidation_Partner.IsValidUNITPartner( ARow.UnitKey, false, THelper.NiceValueDescription( ValidationControlsData.ValidationControlLabel) + " must be set correctly.", AContext, ValidationColumn, ValidationControlsData.ValidationControl); // Since the validation can result in different ResultTexts we need to remove any validation result manually as a call to // AVerificationResultCollection.AddOrRemove wouldn't remove a previous validation result with a different // ResultText! AVerificationResultCollection.Remove(ValidationColumn); AVerificationResultCollection.AddAndIgnoreNullValue(VerificationResult); } // 'Assignment Type' must not be unassignable ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnAssignmentTypeCodeId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtAssignmentTypeTable TypeTable; PtAssignmentTypeRow TypeRow; VerificationResult = null; if ((!ARow.IsAssignmentTypeCodeNull()) && (ARow.AssignmentTypeCode != String.Empty)) { TypeTable = (PtAssignmentTypeTable)TSharedDataCache.TMPersonnel.GetCacheableUnitsTable( TCacheableUnitTablesEnum.JobAssignmentTypeList); TypeRow = (PtAssignmentTypeRow)TypeTable.Rows.Find(ARow.AssignmentTypeCode); // 'Assignment Type' must not be unassignable if ((TypeRow != null) && TypeRow.UnassignableFlag && (TypeRow.IsUnassignableDateNull() || (TypeRow.UnassignableDate <= DateTime.Today))) { // if 'Assignment Type' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmJobAssignmentTable.GetAssignmentTypeCodeDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.AssignmentTypeCode })), ValidationColumn, ValidationControlsData.ValidationControl); } } } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } // 'Position' must be not be null and not unassignable ValidationColumn = ARow.Table.Columns[PmJobAssignmentTable.ColumnPositionNameId]; if (AValidationControlsDict.TryGetValue(ValidationColumn, out ValidationControlsData)) { PtPositionTable PositionTable; PtPositionRow PositionRow; VerificationResult = null; if ((!ARow.IsPositionNameNull()) && (ARow.PositionName != String.Empty)) { PositionTable = (PtPositionTable)TSharedDataCache.TMPersonnel.GetCacheableUnitsTable( TCacheableUnitTablesEnum.PositionList); PositionRow = (PtPositionRow)PositionTable.Rows.Find(new object[] { ARow.PositionName, ARow.PositionScope }); // 'Position' must not be unassignable if ((PositionRow != null) && PositionRow.UnassignableFlag && (PositionRow.IsUnassignableDateNull() || (PositionRow.UnassignableDate <= DateTime.Today))) { // if 'Position' is unassignable then check if the value has been changed or if it is a new record if (TSharedValidationHelper.IsRowAddedOrFieldModified(ARow, PmJobAssignmentTable.GetPositionNameDBName())) { VerificationResult = new TScreenVerificationResult(new TVerificationResult(AContext, ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_VALUEUNASSIGNABLE_WARNING, new string[] { ValidationControlsData.ValidationControlLabel, ARow.PositionName })), ValidationColumn, ValidationControlsData.ValidationControl); } } } else { // Position name must not be null VerificationResult = TStringChecks.StringMustNotBeEmpty(ARow.PositionName, ValidationControlsData.ValidationControlLabel, AContext, ValidationColumn, ValidationControlsData.ValidationControl); } // Handle addition/removal to/from TVerificationResultCollection AVerificationResultCollection.Auto_Add_Or_AddOrRemove(AContext, VerificationResult, ValidationColumn); } }