protected virtual void CSAttributeDetail_ValueID_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e) { var row = e.Row as CSAttributeDetail; if (row == null) { return; } if (e.NewValue != null && e.NewValue.Equals(row.ValueID)) { return; } CSAnswers ans = PXSelect <CSAnswers, Where <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> >, And <CSAnswers.value, Equal <Required <CSAnswers.value> > > > > . SelectWindowed(this, 0, 1, row.AttributeID, row.ValueID); CSAttributeGroup group = PXSelect <CSAttributeGroup, Where <CSAttributeGroup.attributeID, Equal <Required <CSAttribute.attributeID> > > > . SelectWindowed(this, 0, 1, row.AttributeID); if (ans != null && group != null) { throw new PXSetPropertyException <CSAttributeDetail.valueID>(Messages.AttributeDetailIdCanNotBeChangedAsItUsed, PXErrorLevel.Error); } }
protected virtual void CSAttributeDetail_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { var row = e.Row as CSAttributeDetail; if (row != null) { CSAnswers ans = PXSelect <CSAnswers, Where <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> >, And <CSAnswers.value, Equal <Required <CSAnswers.value> > > > > . SelectWindowed(this, 0, 1, row.AttributeID, row.ValueID); CSAttributeGroup group = PXSelect <CSAttributeGroup, Where <CSAttributeGroup.attributeID, Equal <Required <CSAttribute.attributeID> > > > . SelectWindowed(this, 0, 1, row.AttributeID); if (ans != null && group != null) { e.Cancel = true; } } }
protected virtual void CSAttributeDetail_RowDeleting(PXCache sender, PXRowDeletingEventArgs e) { var row = e.Row as CSAttributeDetail; if (row != null) { CSAnswers ans = PXSelect <CSAnswers, Where <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> >, And <CSAnswers.value, Equal <Required <CSAnswers.value> > > > > . SelectWindowed(this, 0, 1, row.AttributeID, row.ValueID); CSAttributeGroup group = PXSelect <CSAttributeGroup, Where <CSAttributeGroup.attributeID, Equal <Required <CSAttribute.attributeID> > > > . SelectWindowed(this, 0, 1, row.AttributeID); if (ans != null && group != null) { throw new PXSetPropertyException <CSAttributeDetail.attributeID>(Messages.AttributeDetailCanNotBeDeletedAsItUsed, PXErrorLevel.RowError); } } }
private void SetControlsState(CSAttribute row, PXCache cache) { if (row != null) { AttributeDetails.Cache.AllowDelete = (row.ControlType == CSAttribute.Combo || row.ControlType == CSAttribute.MultiSelectCombo); AttributeDetails.Cache.AllowUpdate = (row.ControlType == CSAttribute.Combo || row.ControlType == CSAttribute.MultiSelectCombo); AttributeDetails.Cache.AllowInsert = (row.ControlType == CSAttribute.Combo || row.ControlType == CSAttribute.MultiSelectCombo); CSAnswers ans = PXSelect <CSAnswers, Where <CSAnswers.attributeID, Equal <Required <CSAnswers.attributeID> > > > .SelectWindowed(this, 0, 1, row.AttributeID); CSAttributeGroup group = null; if (ans == null) { group = PXSelect <CSAttributeGroup, Where <CSAttributeGroup.attributeID, Equal <Required <CSAttribute.attributeID> > > > .SelectWindowed(this, 0, 1, row.AttributeID); } bool enabled = (ans == null && group == null); PXUIFieldAttribute.SetEnabled <CSAttribute.controlType>(cache, row, enabled); cache.AllowDelete = enabled; PXUIFieldAttribute.SetEnabled <CSAttribute.entryMask>(cache, row, row.ControlType == CSAttribute.Text); PXUIFieldAttribute.SetEnabled <CSAttribute.regExp>(cache, row, row.ControlType == CSAttribute.Text); } }