protected virtual void PaymentTypeInstanceDetail_Value_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            PaymentTypeInstanceDetail row = e.Row as PaymentTypeInstanceDetail;
            PaymentMethodDetail       def = this.FindTemplate(row);

            if (def != null)
            {
                if (def.IsIdentifier ?? false)
                {
                    string id = CustomerPaymentMethodMaint.IDObfuscator.MaskID(row.Value, def.DisplayMask);
                    if (this.PaymentTypeInstance.Current.Descr != id)
                    {
                        PaymentTypeInstance parent = this.PaymentTypeInstance.Current;
                        parent.Descr = String.Format("{0}:{1}", parent.PaymentMethodID, id);
                        this.PaymentTypeInstance.Update(parent);
                    }
                }
                //bool isExpirationDate = def.IsExpirationDate ?? false;
                bool isExpirationDate = false;
                if (isExpirationDate)
                {
                    PaymentTypeInstance parent = this.PaymentTypeInstance.Current;
                    try
                    {
                        parent.ExpirationDate = ParseExpiryDate(row.Value);
                    }
                    catch (FormatException)
                    {
                        parent.ExpirationDate = null;
                        this.Details.Cache.RaiseExceptionHandling <PaymentTypeInstanceDetail.value>(row, row.Value, new PXSetPropertyException(Messages.ERR_IncorrectFormatOfPTInstanceExpiryDate));
                    }
                    this.PaymentTypeInstance.Update(parent);
                }
            }
        }
        protected virtual PaymentMethodDetail FindTemplate(PaymentTypeInstanceDetail aDet)
        {
            PaymentMethodDetail res = PXSelect <PaymentMethodDetail, Where <PaymentMethodDetail.paymentMethodID, Equal <Required <PaymentMethodDetail.paymentMethodID> >,
                                                                            And <PaymentMethodDetail.detailID, Equal <Required <PaymentMethodDetail.detailID> >,
                                                                                 And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForAPCards> > > > > .Select(this, aDet.PaymentMethodID, aDet.DetailID);

            return(res);
        }
 protected virtual void PaymentTypeInstanceDetail_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
 {
     if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
     {
         PaymentTypeInstanceDetail row = (PaymentTypeInstanceDetail)e.Row;
         //ValidateDetail(row);
     }
 }
        protected virtual void PaymentTypeInstanceDetail_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
        {
            PaymentTypeInstanceDetail row = (PaymentTypeInstanceDetail)e.Row;
            PaymentMethodDetail       def = this.FindTemplate(row);

            if (def.IsIdentifier ?? false)
            {
                this.PaymentTypeInstance.Current.Descr = null;
            }
        }
        protected virtual bool ValidateDetail(PaymentTypeInstanceDetail aRow)
        {
            PaymentMethodDetail iTempl = this.FindTemplate(aRow);

            if (iTempl != null && ((iTempl.IsRequired ?? false) || (iTempl.IsIdentifier ?? false)) && String.IsNullOrEmpty(aRow.Value))
            {
                this.Details.Cache.RaiseExceptionHandling <PaymentTypeInstanceDetail.value>(aRow, aRow.Value, new PXSetPropertyException(Messages.ERR_RequiredValueNotEnterd));
                return(false);
            }
            return(true);
        }
        protected virtual void PaymentTypeInstanceDetail_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            PaymentTypeInstanceDetail row = (PaymentTypeInstanceDetail)e.Row;

            if (row != null)
            {
                PaymentMethodDetail iTempl = this.FindTemplate(row);
                bool isRequired            = (iTempl != null) && (iTempl.IsRequired ?? false);
                PXDefaultAttribute.SetPersistingCheck <PaymentTypeInstanceDetail.value>(cache, row, (isRequired) ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                bool showDecripted = !(iTempl.IsEncrypted ?? false);
                PXRSACryptStringAttribute.SetDecrypted <PaymentTypeInstanceDetail.value>(cache, row, showDecripted);
            }
        }
 protected virtual void AddDetails()
 {
     if (this.PaymentTypeInstance.Current != null)
     {
         string pmID = PaymentTypeInstance.Current.PaymentMethodID;
         if (!String.IsNullOrEmpty(pmID))
         {
             foreach (PaymentMethodDetail it in this.PMDetails.Select(pmID))
             {
                 PaymentTypeInstanceDetail det = new PaymentTypeInstanceDetail();
                 det.DetailID        = it.DetailID;
                 det.PaymentMethodID = pmID;
                 det = this.Details.Insert(det);
             }
         }
     }
 }
 protected virtual void MergeDetailsWithDefinition(string aPaymentType)
 {
     if (aPaymentType != this.mergedPaymentType)
     {
         List <PaymentMethodDetail> toAdd = new List <PaymentMethodDetail>();
         foreach (PaymentMethodDetail it in this.PMDetails.Select(aPaymentType))
         {
             PaymentTypeInstanceDetail detail = null;
             foreach (PaymentTypeInstanceDetail iPDet in this.Details.Select())
             {
                 if (iPDet.DetailID == it.DetailID)
                 {
                     detail = iPDet;
                     break;
                 }
             }
             if (detail == null)
             {
                 toAdd.Add(it);
             }
         }
         using (ReadOnlyScope rs = new ReadOnlyScope(this.Details.Cache))
         {
             foreach (PaymentMethodDetail it in toAdd)
             {
                 PaymentTypeInstanceDetail detail = new PaymentTypeInstanceDetail();
                 detail.DetailID = it.DetailID;
                 detail          = this.Details.Insert(detail);
             }
             if (toAdd.Count > 0)
             {
                 this.Details.View.RequestRefresh();
             }
         }
         this.mergedPaymentType = aPaymentType;
     }
 }