That's what I've been doing, but running into problems.
When i use the code below, I get an error " CS0103: The Name "GetOppProd" does not exist in the current context:using System;
using System.Collections.Generic;
using Sage.Entity.Interfaces;
using Sage.Platform;
using System.ComponentModel;
using Sage.Platform.ChangeManagement;
using Sage.SalesLogix.BusinessRules.Properties;
using Sage.SalesLogix.BusinessRules;
using System.Reflection;
namespace Sage.SalesLogix.Client.App_Code
{
/// <summary>
/// Opportunity Helper rules class
/// </summary>
public class AddOpportunityProductHelperClass
{
#region public gridview methods
/// <summary>
/// Selects the specified opportunity.
/// </summary>
/// <param name="opportunityId">The opportunity.</param>
/// <returns></returns>
public static IList<IOpportunityProduct> Select(string opportunityId)
{
return Sage.SalesLogix.Opportunity.OpportunityHelperClass.Select(opportunityId);
}
/// <summary>
/// This method exists for the rare case where the object data source will call select without
/// our custom parameters.
/// </summary>
/// <returns></returns>
public static IList<IOpportunityProduct> Select()
{
return Sage.SalesLogix.Opportunity.OpportunityHelperClass.Select();
}
/// <summary>
/// Updates the specified original_ id.
/// </summary>
/// <param name="original_Id">The original_ id.</param>
/// <param name="original_InstanceId">The original_ instance id.</param>
/// <param name="calculatedPrice">The calculated price.</param>
/// <param name="quantity">The quantity.</param>
/// <param name="netRevenue">Net Revenue</param>
/// <param name="comments">Comments</param>
public static void Update(string original_Id, object original_InstanceId, decimal calculatedPrice, double quantity, decimal netRevenue, string comments)
{
Sage.SalesLogix.Client.App_Code.AddOpportunityProductHelperClass1.Update(original_Id, original_InstanceId, calculatedPrice, quantity, netRevenue, comments);
//Sage.SalesLogix.Opportunity.OpportunityHelperClass.Update(original_Id, original_InstanceId, discount,
// calculatedPrice, quantity, program);
}
/// <summary>
/// Deletes the specified original_ id.
/// </summary>
/// <param name="original_Id">The original_ id.</param>
/// <param name="original_InstanceId">The original_ instance id.</param>
public static void Delete(string original_Id, object original_InstanceId)
{
Sage.SalesLogix.Opportunity.OpportunityHelperClass.Delete(original_Id, original_InstanceId);
}
/// <summary>
/// Inserts the specified opportunity.
/// </summary>
/// <param name="opportunity">The opportunity.</param>
/// <returns></returns>
public static IList<IOpportunityProduct> Insert(string opportunity)
{
return Sage.SalesLogix.Opportunity.OpportunityHelperClass.Insert(opportunity);
}
/// <summary>
/// Gets the current opportunity.
/// </summary>
/// <value>The current opportunity.</value>
public static IOpportunity CurrentOpportunity
{
get
{
return Sage.SalesLogix.Opportunity.OpportunityHelperClass.CurrentOpportunity;
}
}
#endregion
#region Private Static Methods
public static IOpportunityProduct GetOppProd(string original_Id, object original_InstanceId)
{
IOpportunityProduct oppProd = null;
if (CurrentOpportunity != null)
{
foreach (IOpportunityProduct op in CurrentOpportunity.Products)
{
if (op.Id != null)
{
if (String.Equals(op.Id.ToString(), original_Id))
{
oppProd = op;
break;
}
}
else
{
if (String.Equals(op.InstanceId.ToString(), original_InstanceId.ToString()))
{
oppProd = op;
break;
}
}
}
}
else
{
oppProd = EntityFactory.GetRepository<IOpportunityProduct>().Get(original_Id);
}
return oppProd;
}
#endregion
}
public class AddOpportunityProductHelperClass1
{
public static void Update(string original_Id, object original_InstanceId, decimal calculatedPrice, double quantity, decimal NetRevenue, string comments)
{
IOpportunityProduct oppProd = GetOppProd(original_Id, original_InstanceId);
oppProd.Program = program;
oppProd.comments = comments;
oppProd.Quantity = new double?(quantity);
if (oppProd.CalculatedPrice.HasValue && (oppProd.CalculatedPrice.Value != calculatedPrice))
{
oppProd.CalculatedPrice = new decimal?(calculatedPrice);
oppProd.CalculateCalcPrice();
}
else
{
oppProd.CalculateDiscount();
}
if (oppProd.NetRevenue.HasValue && (oppProd.CalculatedPrice.Value != netRevenue))
{
oppProd.NetRevenue = new decimal?(netRevenue);
oppProd.NetRevenue();
}
else
{
oppProd.NetRevenue();
}
}
}
} |