cancel
Showing results for 
Search instead for 
Did you mean: 

AddPart function

Former Member
0 Kudos

Hi all

I'm adding some new functionality to the partdetail page. The idea is to hide the current 'add to basket' button and replace it with my own. This button will then link to my own custom page that validates the quantity the user enters, if its invalid then it will send them back to the partdetail page with an error, the problem I am having is when it is valid. I then need to still do the functionality that the old button did, i.e. ad the item to the cart.

I've found the AddPart function in the netpoint.api help file, but a little unsure how to use it, and which one to use, as there are 4 different versions. Any help would be great. Thanks in advance, Andy

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi all, been away on holiday for two weeks so haven't posted regarding this. I've got the add part function working now, so thanks guys for helping me out.

Former Member
0 Kudos

Hi Andy,

For your purposes you can use


public bool AddPart(string partno, int quantity, string catalogcode, string categorycode, NPPartPricingMaster priceList)

The method that takes the parentODID is used for BOMs and Variants. If you are not using them, don't worry about it.

The other method is different only in that it takes notes.

Former Member
0 Kudos

Great, thanks

I'm unsure what to do with this though!

Within my Page_Load would I include something like this

AddPart("5899 10 0", 16, "Online Catalog", "catcode", "unsure what to pass for NPPartPricingMaster priceList");

Former Member
0 Kudos

You can make that call anywhere in your code to add the particular part. I think the partpricing master pricelist value should be the ID of your base price list. You would have to find that in the netpoint PartsPricingmaster table. That tells the order which pricelist to retreive the price from for the item you are adding.

Former Member
0 Kudos

I'm still getting an error

The type or namespace name 'NPPartPricingMaster' could not be found (are you missing a using directive or an assembly reference?)

Here is my code

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using netpoint;
using netpoint.classes;
using netpoint.api.commerce;
using netpoint.commerce;

public partial class catalog_controls_validateItem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AddPart("5899 10 0", 16, "Online Catalog", "catcode", 1);
    }

    public bool AddPart(string partno, int quantity, string catalogcode, string categorycode, NPPartPricingMaster priceList);
}

Former Member
0 Kudos

You also need this using netpoint.api.catalog;

Former Member
0 Kudos

Thanks for all your help on this Curtis, I am now getting the following error

The best overloaded method match for 'catalog_controls_validateItem.AddPart(string, int, string, string, netpoint.api.catalog.NPPartPricingMaster)' has some invalid arguments

Which I think means that I'm not passing the values correctly, they look ok to me, but I'm unsure on NPPartPricingMaster.GetPriceList

public partial class catalog_controls_validateItem : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AddPart("5899 10 0", 16, "catalog", "108-32-226-527", NPPartPricingMaster.GetPriceList);
    }

    public extern bool AddPart(string partno, int quantity, string catalogcode, string categorycode, NPPartPricingMaster priceList);
}

Former Member
0 Kudos

Hey Andy,

It looks like you actually have to create a new NPPartPricingMaster object using its constructor and pass it the id of the price list. That method actually takes a NPPartPricingMaster object and not the pricelist.

Former Member
0 Kudos

You can get the price list of the logged in user from base page.


NPBasePage bp = (NPBasePage)page;
AddPart("5899 10 0", 16, "catalog", "108-32-226-527", bp.PriceList);

That signature for AddPart() may not be accurate for your version of the API, you'll need to make sure it's valid.

Former Member
0 Kudos

cool, like this? NPPartPricingMaster getPriceList = new NPPartPricingMaster(1);

Then pass the AddCart function getPriceList ?

Former Member
0 Kudos

yeah that would work if the API call is expecting a NPPartPricingmaster. As shane said you have to make sure you are passing that call the right objects.

Former Member
0 Kudos

I'm now using this and getting the following error.

The name 'page' does not exist in the current context

Not quite sure what you mean regarding the signature for AddPart()

Former Member
0 Kudos

page probably needs to be capitalized.

Also, you will need to change you class declaration to the following:


public partial class catalog_controls_validateItem : netpoint.classes.NPBasePage

Former Member
0 Kudos

Can you paste your source code? Is this a usercontrol that you run or a .aspx page?

Former Member
0 Kudos

Its an aspx page with nothing else in it, all it needs to do is add a part to the users shopping cart. Is this possible?

Here is the current code, I'm getting a crazy error though.

public partial class catalog_controls_validateItem : netpoint.classes.NPBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        NPBasePage bp = (NPBasePage)Page;
        AddPart("5899 10 0", 16, "catalog", "108-32-226-527", bp.PriceList);
    }

    public extern bool AddPart(string partno, int quantity, string catalogcode, string categorycode, NPPartPricingMaster priceList);
}

Crazy error:

 Could not load type 'catalog_controls_validateItem' from assembly 'App_Web_validateitem.aspx.594775ed.gfvc9nja, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method 'AddPart' has no implementation (no RVA).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'catalog_controls_validateItem' from assembly 'App_Web_validateitem.aspx.594775ed.gfvc9nja, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because the method 'AddPart' has no implementation (no RVA).

Former Member
0 Kudos

capitalized "Page"

Former Member
0 Kudos

Hey Andy,

Not sure why you are doing this:

public extern bool AddPart

All you need to do is add this to your Page_Load:


NPBasePage bp = (NPBasePage)Page;
NPOrder order; 
order = new NPOrder(this.bp.UserID, this.bp.SessionID);
order.AddPart("5899 10 0", 16, "catalog", "108-32-226-527", bp.PriceList);

Former Member
0 Kudos

I changed "Page" back to "page" and got this error again

The name 'page' does not exist in the current context

Former Member
0 Kudos

Did you get this working? Page has to have a capital P or it will not work.

Former Member
0 Kudos

Still not working

Page has a capital P, and I get the crazy error above! No idea what to do.

Former Member
0 Kudos

Did you try the suggestion in this posting:

Hey Andy,

Not sure why you are doing this:

public extern bool AddPart

All you need to do is add this to your Page_Load:

NPBasePage bp = (NPBasePage)Page;

NPOrder order;

order = new NPOrder(this.bp.UserID, this.bp.SessionID);

order.AddPart("5899 10 0", 16, "catalog", "108-32-226-527", bp.PriceList);

Former Member
0 Kudos

Sorry, I must have missed that post. I've tried that and get this error

'catalog_controls_validateItem' does not contain a definition for 'bp'

Former Member
0 Kudos

Sorry about that

try this code

NPBasePage bp = (NPBasePage)Page;

NPOrder order;

order = new NPOrder(bp.UserID, bp.SessionID);

order.AddPart("5899 10 0", 16, "catalog", "108-32-226-527", bp.PriceList);

Former Member
0 Kudos

still no joy

 Version  	 5.9.6.43135
Message 	Object reference not set to an instance of an object.
Source 	netpoint
Stack 	at netpoint.common.controls.header.Page_Init(Object sender, EventArgs e)

at System.Web.UI.Control.OnInit(EventArgs e)

at System.Web.UI.UserControl.OnInit(EventArgs e)

at netpoint.common.controls.header.OnInit(EventArgs e)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Control.AddedControl(Control control, Int32 index)

at System.Web.UI.ControlCollection.AddAt(Int32 index, Control child)

at netpoint.classes.NPBasePage.OnInit(EventArgs e)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Page.ProcessRequestMain(Boolea)

Former Member
0 Kudos

Sorry man you are going to have to debug this and see where it breaks in your code. Also make sure you are logged in on the page where you are trying to use this.

Former Member
0 Kudos

hey Andy,

You should be able to get the users order with this code

 NPOrder order = new NPOrder(this._bp.UserID, this._bp.SessionID);

then you need to call the order.AddPart function and pass the appropriate information including the base price list.

Former Member
0 Kudos

Thanks for the quick reply, I'm getting this error wehn I added the above code.

The type or namespace name 'NPOrder' could not be found (are you missing a using directive or an assembly reference?)

I'm importing the following

<%@ Import Namespace="netpoint.api" %>
<%@ Import Namespace="netpoint.classes" %>

and in the code behind:

using netpoint;
using netpoint.classes;

Also once the above works do I use the order.AddPart function like this

order.AddPart(pass values in here)

Former Member
0 Kudos

Depending on the version of netpoint you will need to include the right namespace:

either

netpoint.api.commerce

or netpoint.commerce

You can use the order.addpart method if you like.