private bool UpdatePayment(long paymentId) { var aff = HccApp.ContactServices.Affiliates.FindByAffiliateId(txtAffiliateID.Text); var payment = HccApp.ContactServices.AffiliatePayments.Find(paymentId); if (aff != null) { payment.AffiliateId = aff.Id; payment.PaymentAmount = decimal.Parse(txtAmount.Text); payment.PaymentDateUtc = DateTime.UtcNow; payment.Notes = txtMemo.Text; if (fuAttachment.HasFile) { payment.FileName = DiskStorage.UploadPaymanentsAttachment(HccApp.CurrentStore.Id, fuAttachment.PostedFile); } Payments = new List <AffiliatePayment> { payment }; return(true); } ucMessageBox.ShowError("Affiliate ID is invalid."); return(false); }
private bool AddMultiplePayments() { Payments = new List <AffiliatePayment>(); foreach (var affId in AffiliateIDs) { var affTotals = HccApp.ContactServices.Affiliates.GetAffiliateTotals(affId, new AffiliateReportCriteria()); var payment = new AffiliatePayment(); payment.AffiliateId = affId; payment.PaymentAmount = affTotals.CommissionOwed; payment.PaymentDateUtc = DateTime.UtcNow; payment.Notes = txtMemo.Text; payment.FileName = DiskStorage.UploadPaymanentsAttachment(HccApp.CurrentStore.Id, fuAttachment.PostedFile); Payments.Add(payment); } return(true); }
private bool AddOnePayment() { Affiliate aff = null; if (AffiliateIDs.Count == 1) { aff = HccApp.ContactServices.Affiliates.Find(AffiliateIDs[0]); } else { aff = HccApp.ContactServices.Affiliates.FindByAffiliateId(txtAffiliateID.Text); } if (aff == null) { ucMessageBox.ShowError("Affiliate ID is invalid."); return(false); } if (!aff.Approved) { ucMessageBox.ShowError("Affiliate is not approved."); return(false); } var payment = new AffiliatePayment { AffiliateId = aff.Id, PaymentAmount = decimal.Parse(txtAmount.Text), PaymentDateUtc = DateTime.UtcNow, Notes = txtMemo.Text, FileName = DiskStorage.UploadPaymanentsAttachment(HccApp.CurrentStore.Id, fuAttachment.PostedFile) }; Payments = new List <AffiliatePayment> { payment }; return(true); }