MVC 5 how to add search functionality into Controller/Create? - asp.net-mvc-5

I have 3 tables as shown below. I have 3 controllers and views. In Payment/Create.cshtml I need to add customer search functionality before creating any payment.
I need to check first the right customer and when I found it I need to add into payment create table and enter other values and create a new payment. How do I do that?

In that Customer field u need to display all customer name means
In Controller:
public ActionResult Create()
{
ViewBag.CUSTId = new SelectList(db.CUSTOMERS, "CUSTId", "CustomerName");
return View();
}
In View:
#Html.DropDownList("CUSTId ", String.Empty)
You Need Search Method means Just see the following video u il get to know how to do it
https://www.youtube.com/watch?v=Slw-gs2vcWo

Related

In acumatica, how can I make changes in the Cost tab show up in the Revenue tab?

For example, if I change the "Original Budgeted Quantity" field to 9.00 (see first image below), I would like that to also change in the Revenue tab (see second image) without having to change the same thing twice.
Is there a way I can achieve this?
Cost Tab
Revenue Tab
Here are the details of the two fields I have highlighted in the images above:
Cost Tab Field
Revenue Tab Field
Let me know if I need to clarify anything or provide more information :)
Unfortunately I'm not very familiar with the Project Entry screen, and after a quick glance I couldn't find an easy way to tie the records from the Cost Budget tab to the Revenue Budget tab.
If you are planning on tying these two records together you may need some additional customization work to create the link that you are looking for if it doesn't already exist.
As far as the update itself, that is pretty straightforward and can be accomplished with a simple event handler, as demonstrated below.
namespace MyCompany.MyCustomization
{
public class ProjectEntryExtMyCustomization : PXGraphExtension<ProjectEntry>
{
public static bool IsActive() => true;
#region Actions
#endregion
#region Events
protected virtual void _(Events.FieldUpdated<PMCostBudget, PMCostBudget.qty> eventHandler)
{
PMCostBudget row = eventHandler.Row;
if (row is null) return;
// Replace the stub below with your PMRevenueBudget lookup
// using the link that you have defined.
PMRevenueBudget revenueDetail = new PMRevenueBudget();
// Assigns the PMRevenueBudget Qty field to match the PMCostBudget new value.
revenueDetail.Qty = eventHandler.NewValue as decimal?;
// Updates the PMRevenueBudget record in the cache.
Base.RevenueBudget.Update(revenueDetail);
}
#endregion
}
}
Don't forget to replace the line where I create a new PMRevenueBudget with the logic that you need for looking up the linked PMRevenueBudget record that you need. Let me know if you have any questions.

How to add a column to the grid that shows value from another screen in Acumatica?

I'm new to Acumatica, could you please help me? I have too screens IN202500 (stock items) and SO301000(sales orders). I added a field to stock items and now I need to show a value from that field in grid column of sale orders for each stock items. I suppose that I need to use PXDefault attribute for this?
There are a number of ways you can do this. I'll provide 3 possibilities.
If your View used by the grid contains InventoryItem, you may be able simply to select your custom field from InventoryItem and add it directly to the screen. I'll assume this is not an option or you likely would have found it already.
Create a custom field in a DAC extension on SOLine where you add your custom field as unbound (PXString, not PXDBString) and then use PXDBScalar or PXFormula to populate it. I haven't used PXDBScalar or PXFormula to retrieve a value from a DAC Extension, so I'll leave it to you to research. I do know this is super easy if you were pulling a value directly from InventoryItem, so worth doing the research.
Create as an unbound field as in #2, but populate it in the SOLine_RowSelecting event. This is similar to JvD's suggestion, but I'd go with RowSelecting because it is the point where the cache data is being built. RowSelected should be reserved, in general, for controlling the UI experience once the record is already in the cache. Keep in mind that this will require using a new PXConnectionScope, as Acuminator will advise and help you add. (Shown in example.) In a pinch, this is how I would do it if I don't have time to sort out the generally simpler solution provided as option 2.
Code for Option 3:
#region SOLine_RowSelecting
protected virtual void _(Events.RowSelecting<SOLine> e)
{
SOLine row = (SOLine)e.Row;
if (row == null)
{
return;
}
using (new PXConnectionScope())
{
SOLineExt rowExt = row.GetExtension<SOLineExt>();
InventoryItem item = SelectFrom<InventoryItem>
.Where<InventoryItem.inventoryID.IsEqual<#P.AsInt>>
.View.Select(Base, row.InventoryID);
InventoryItemExt itemExt = item.GetExtension<InventoryItemExt>();
rowExt.UsrSSMyDatAField = itemExt.UsrSSMyDataField;
}
}
#endregion

How to charge existing customers for a products?

If you know Audible, that's how my service works. You can have subscriptions which you get credits for but you can also just buy single items right away (if you want).
Subscriptions work for me but what I can't get my head around is how I can charge an existing customer, using his default payment method, on a single item. Let's stick to Audible.
A user wants to buy a single audio-track.
I though I can:
Create a Product for this track (setting a name and an image-url)
Create or re-use a Price and set the charge-amount as stated in my database
Somehow create an Invoice or Charge for this Price/Product and move one
However, I just don't quite get how to do that.
Looking at the docs of Invoice, it appears to me that I am not able to add a single product or price and let Stripe automatically charge the customer.
I thought it would look something like this:
public void buyProduct(String productId, Customer customer) {
InvoiceCreateParams.builder()
.setCustomer(customer.getId())
.setDefaultPaymentMethod(customer.getPaymentMethod())
.setAutoAdvance(true)
.setCollectionMethod(CollectionMethod.CHARGE_AUTOMATICALLY)
// Add product/price here ?
.build();
// ...
}
So, what is the simplest way to charge a customer for a product?
Update
I noticed that an InvoiceItem can take a Invoice ID.
Is the following correct (in principal)?
Setting autoAdvance to true and CHARGE_AUTOMATICALLY as collection-method, will the user charged correctly as I intend to using the code below?
public void createInvoice() throws StripeException {
String customerId = null;
String paymentMethodId = null;
String priceId = null;
boolean chargeAutomatically = true;
InvoiceCreateParams invoiceCreateParams = InvoiceCreateParams.builder()
.setCustomer(customerId)
.setDefaultPaymentMethod(paymentMethodId)
.setAutoAdvance(chargeAutomatically)
.setCollectionMethod(CollectionMethod.CHARGE_AUTOMATICALLY)
.build();
Invoice invoice = Invoice.create(invoiceCreateParams);
InvoiceItemCreateParams invoiceItemCreateParams = InvoiceItemCreateParams.builder()
.setCustomer(customerId)
.setPrice(priceId)
.setInvoice(invoice.getId())
.build();
InvoiceItem invoiceItem = InvoiceItem.create(invoiceItemCreateParams);
}
It feels weird to create an invoice at first, and set everything up for charging a customer immediatelly, and only after having done so, set the actual item that the user wants to buy.
You should take a look at this: https://stripe.com/docs/billing/invoices/sending#one-off
First, you'll want to create an Invoice Item using the Price and Customer ID (no need to create the invoice first). You can create as many Invoice Items as you want, depending on how many things you want to charge your customer for. Then you can create an Invoice which will automatically pick up all the pending Invoice Items for a given Customer.

Orchard - how to access taxonomy field of a custom content type programmatically

I have a custom content type called Store, which has a Brands taxonomy field. A Store can have multiple Brands associated with it.
I have been tasked with building an import/export routine that allows the user to upload a CSV file containing new Stores and their associated Brands.
I can create the Stores other fields OK, but can't work out how to set the taxonomy field?
Can anyone tell me how I access the Taxonomy field for my custom content type?
Thanks in advance.
OK so (as Bertrand suggested), using the Import/Export feature might be a better way to go, but as a relative noob on Orchard I don't have the time to spend looking at it and couldn't find a good tutorial.
Below is an alternative approach, using the TaxonomyService to programatically assign Terms to a ContentItem.
First of all, inject the ContentManager and TaxonomyService into the constructor...
private ITaxonomyService _taxonomyService;
private IContentManager _contentManager;
public MyAdminController(IContentManager contentManager, ITaxonomyService taxonomyService)
{
_contentManager = contentManager;
_taxonomyService = taxonomyService;
}
Create your ContentItem & set the title
var item = _contentManager.New("MyContentType");
item.As<TitlePart>().Title = "My New Item";
_contentManager.Create(item);
Now we have a ContentItem to work with. Time to get your taxonomy & find your term(s)...
var taxonomy = _taxonomyService.GetTaxonomyByName("Taxonomy Name");
var termPart = _taxonomyService.GetTermByName(taxonomy.Id, "Term Name");
Add the terms to a List of type TermPart...
List<TermPart> terms = new List<TermPart>();
terms.Add(termPart);
Finally, call UpdateTerms, passing in the ContentItem, terms to assign and the name of the field on the ContentItem you want to update...
_taxonomyService.UpdateTerms(item, terms.AsEnumerable<TermPart>(), "My Field");
Hope this helps someone. Probably me next time round! : )

Default the "Look for" field in a lookup view

If the "look for" drop down contains more than one item (e.g. Account, Contact) is it possible to set the default option (in my scenario to the second option Contact)?
In CRM 2015 you can use the following if you want to filter the lookup so it contains only contacts
// Filter the dropdown of the lookup so that it only contains contacts + do not allow accounts ,in the contact views, visible when the user clicks more records
var noAccountsfilter = "<filter type='and'><condition attribute='statecode' operator='ne' value='0' /></filter>";
Xrm.Page.getControl("parentcustomerid").addCustomFilter(noAccountsfilter, 'account');
function Form_OnLoad()
...
preFilterLookup();
..
}
function preFilterLookup() {
Xrm.Page.getControl("customerid").addPreSearch(addLookupFilter);
}
function addLookupFilter() {
document.getElementById("customerid_i").setAttribute ("lookuptypenames", "contact:2:Contact");
document.getElementById("customerid_i").setAttribute("lookuptypes", "2");
}
How do I change the default quick form for the CustomerId field in Dynamics CRM 2013?

Resources