private 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); }
/// <summary> /// Handles the Click event of the btnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnAdd_Click(object sender, EventArgs e) { List <string> selectedProductIDs = new List <string>(selectedNodes.Value.Split(',')); IList <IOpportunityProduct> ListProducts = DefOppProdHelper.GetList(); foreach (string productID in selectedProductIDs) { IProduct product = EntityFactory.GetRepository <IProduct>().Get(productID); if (product != null) { IOpportunityProduct oppProd = EntityFactory.Create <IOpportunityProduct>(); oppProd.Product = EntityFactory.GetRepository <IProduct>().Get(productID); bool isInList = false; foreach (IOpportunityProduct op in DefOppProdHelper.GetList()) { if (string.Compare(Convert.ToString(op.Product.Id), Convert.ToString(oppProd.Product.Id)) == 0) { op.Quantity++; isInList = true; break; } } if (!isInList) { oppProd.Quantity = 1; oppProd.Discount = 0; if (oppProd.Product.ProductProgram.Count != 0) { foreach (IProductProgram prodProgram in oppProd.Product.ProductProgram) { if (prodProgram.DefaultProgram == true) { oppProd.CalculatedPrice = prodProgram.Price; oppProd.Program = prodProgram.Program; oppProd.Price = prodProgram.Price; } } } else { oppProd.CalculatedPrice = Convert.ToDecimal(oppProd.Product.Price); oppProd.Price = oppProd.Product.Price; } oppProd.ExtendedPrice = oppProd.CalculatedPrice * Convert.ToDecimal(oppProd.Quantity); ListProducts.Add(oppProd); } } } for (int i = 0; i < ListProducts.Count; i++) { ListProducts[i].Sort = i + 1; } DefOppProdHelper.SetList(ListProducts); LoadTreeConfig(); }
public static void ValidateSalesOrderStep( IOpportunityProduct opportunityproduct, out Boolean result) { // TODO: Complete business rule implementation result = false; using (ISession session = new SessionScopeWrapper()) { string strSQL = "select count(*) from salesorderdetail where productid ='"+opportunityproduct.Product.Id.ToString()+"' and salesorderid in (select salesorderid from salesorder where Actual = 'F' and Opportunityid='"+opportunityproduct.Opportunity.Id.ToString()+"')"; int salesorder = session.CreateSQLQuery(strSQL).UniqueResult<int>(); if (salesorder > 0) { result = true; } } }
/// <summary> /// Updates the opportunity products price based on a change of the multi currency pricing value. /// The updated is based on the value changed divided by the exchange rate. This event is only /// called when multi-currency is enabled. /// </summary> /// <param name="form">the instance of the EditOpportunityProduct dialog</param> /// <param name="args">empty</param> public static void curMCCalcPrice_OnChangeStep(IEditOpportunityProduct form, EventArgs args) { IOpportunityProduct opportunityProduct = form.CurrentEntity as IOpportunityProduct; if (opportunityProduct != null) { double exchangeRate = opportunityProduct.Opportunity.ExchangeRate.HasValue ? opportunityProduct.Opportunity.ExchangeRate.Value : 1; form.curMCCalcPrice.CurrentCode = opportunityProduct.Opportunity.ExchangeRateCode; string price = String.IsNullOrEmpty(form.curMCCalcPrice.Text) ? "0" : form.curMCCalcPrice.Text; opportunityProduct.CalculatedPrice = (decimal?)(Convert.ToDouble(price) / exchangeRate); opportunityProduct.CalculateCalcPrice(); } }
public static void ConvertionButtonStep( IOpportunityProduct opportunityproduct, out Boolean result) { // TODO: Complete business rule implementation Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser user = usersvc.GetUser(); int team =0; using (NHibernate.ISession session = new Sage.Platform.Orm.SessionScopeWrapper()) { string sql = "select count(*) from seccodejoins sj join seccode s on s.seccodeid=sj.parentseccodeid where sj.childseccodeid in (select defaultseccodeid from usersecurity where userid='"+user.Id.ToString()+"') and s.seccodetype='G' and s.seccodedesc='Training'"; team = session.CreateSQLQuery(sql).UniqueResult<int>(); } if (team>0 || user.Id.ToString().Trim()=="ADMIN"){ result=true;} else{ result=false;} }
public static void ValidateRequiredStep( IOpportunityProduct opportunityproduct, out Boolean result) { // TODO: Complete business rule implementation bool validate=false; if (opportunityproduct.OpportunityProductCI.Won==true){ //PSG - FHV //Fix Issue: Default Status Value Change //opportunityproduct.Status="Apprehension"; if (string.IsNullOrEmpty(opportunityproduct.OpportunityProductCI.Reason)){ throw new Sage.Platform.Application.ValidationException("Reason is required"); } if (string.IsNullOrEmpty(opportunityproduct.OpportunityProductCI.CompetitorReplaced)){ throw new Sage.Platform.Application.ValidationException("Competitor Replaced is required"); } }else{validate=true;} if (opportunityproduct.OpportunityProductCI.Lost==true){ if (string.IsNullOrEmpty(opportunityproduct.OpportunityProductCI.Reason)){ throw new Sage.Platform.Application.ValidationException("Reason is required"); } if (string.IsNullOrEmpty(opportunityproduct.OpportunityProductCI.CompetitorReplaced)){ throw new Sage.Platform.Application.ValidationException("Competitor Replaced is required"); } } else{validate=true;} // SSI JKL 10/03/2011 // Fix Praxi issue: Validate Estimated Close control... // Estimated Close... if (opportunityproduct.EstimatedClose == null) { throw new Sage.Platform.Application.ValidationException("Estimated Close"); } else { validate = true; } result=validate; }
public static void CreateSalesOrderStep( IOpportunityProduct opportunityproduct) { // TODO: Complete business rule implementation ISession session = new SessionScopeWrapper(); string strSQL = "select max(documentid)+1 from salesorder where len(documentid)>5"; int docid = session.CreateSQLQuery(strSQL).UniqueResult<int>(); //-------- Sage.Entity.Interfaces.ISalesOrder saleso =Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ISalesOrder>(); Sage.Entity.Interfaces.ISalesorderdetail sodetail = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ISalesorderdetail>(); try { saleso.Account = opportunityproduct.Opportunity.Account; saleso.Opportunity = opportunityproduct.Opportunity; if (opportunityproduct.ExtendedPrice!=null){ saleso.OrderTotal = (double) opportunityproduct.ExtendedPrice; } else { saleso.OrderTotal = 0; } if (opportunityproduct.ExtendedPrice!=null){ saleso.Totalcommissionable = (double) opportunityproduct.ExtendedPrice; } else { saleso.Totalcommissionable = 0; } saleso.OrderType = "Regular Order" ; saleso.DocumentId = docid.ToString(); saleso.Status = "Open Order"; saleso.UserId = opportunityproduct.Opportunity.AccountManager.Id.ToString(); if (opportunityproduct.Opportunity.OpportunityCIUDF.Accountmanagerid2!=null){ saleso.UserID2 = opportunityproduct.Opportunity.OpportunityCIUDF.Accountmanagerid2.ToString(); } saleso.Owner = opportunityproduct.Opportunity.Owner; if (opportunityproduct.Product.Family.ToString().Trim()=="FAMCLI"){ saleso.BillToName = opportunityproduct.Opportunity.Account.AccountName; saleso.Billtoaccount = opportunityproduct.Opportunity.Account.Id.ToString(); strSQL = "select contactid from contact where accountid='"+opportunityproduct.Opportunity.Account.Id.ToString()+"' and isprimary='T'"; saleso.Billtocontact = session.CreateSQLQuery(strSQL).UniqueResult<string>(); } saleso.Actual=false; } catch { throw new Sage.Platform.Application.ValidationException("Sales Order Information Incomplete. Please Check that this Opportunity have a Primary Contact Related."); } try { sodetail.SalesOrder = saleso; sodetail.ProductId = opportunityproduct.Product.Id.ToString(); if (opportunityproduct.OpportunityProductCI.Other_fees!=null || opportunityproduct.OpportunityProductCI.Other_fees>0) { // //sodetail.Num2 = (short)opportunityproduct.OpportunityProductCI.Num2; /*sodetail.Num3 = opportunityproduct.OpportunityProductCI.Num3; sodetail.Num4 = opportunityproduct.OpportunityProductCI.Num4; sodetail.Fees1 = opportunityproduct.OpportunityProductCI.Fees1; sodetail.Fees1Desc = opportunityproduct.OpportunityProductCI.Fees1Desc; sodetail.Fees2 = opportunityproduct.OpportunityProductCI.Fees2; sodetail.Fees2Desc = opportunityproduct.OpportunityProductCI.Fees2Desc; sodetail.Fees3 = opportunityproduct.OpportunityProductCI.Fees3; sodetail.Fees3Desc = opportunityproduct.OpportunityProductCI.Fees3Desc; sodetail.Fees4 = opportunityproduct.OpportunityProductCI.Fees4; sodetail.Fees4Desc = opportunityproduct.OpportunityProductCI.Fees4Desc; sodetail.Rate = opportunityproduct.OpportunityProductCI.Rate; sodetail.Rate2 = opportunityproduct.OpportunityProductCI.Rate2; sodetail.Rate3 = opportunityproduct.OpportunityProductCI.Rate3; sodetail.Rate4 = opportunityproduct.OpportunityProductCI.Rate4; */ if (opportunityproduct.CalculatedPrice!=null){ sodetail.Calcprice = (double)opportunityproduct.CalculatedPrice; } if (opportunityproduct.ExtendedPrice!=null){ sodetail.Extendedprice = (double)opportunityproduct.ExtendedPrice; } if (opportunityproduct.Price!=null){ sodetail.Price = (double)opportunityproduct.Price; } if (opportunityproduct.OpportunityProductCI.Commission!=null){ sodetail.Commission = opportunityproduct.OpportunityProductCI.Commission; } if (opportunityproduct.OpportunityProductCI.Discount!=null){ sodetail.Discount = opportunityproduct.OpportunityProductCI.Discount; } if (opportunityproduct.OpportunityProductCI.Onsite_fees!=null){ sodetail.Onsite_fees = (decimal) opportunityproduct.OpportunityProductCI.Onsite_fees; } else { sodetail.Onsite_fees = 0; } if (opportunityproduct.OpportunityProductCI.Other_fees!=null){ sodetail.Other_fees = (decimal) opportunityproduct.OpportunityProductCI.Other_fees; } else { sodetail.Other_fees = 0; } if (opportunityproduct.OpportunityProductCI.Num!=null){ sodetail.Num = opportunityproduct.OpportunityProductCI.Num; } } saleso.OrderDate = DateTime.Now; saleso.Salesorderdetails.Add(sodetail); saleso.Save(); } //End Try catch { throw new Sage.Platform.Application.ValidationException("Creation Process not completed. Please Check that this Opportunity have a Primary Contact Related."); } }
public static void SetOppProductDefaultsStep( IOpportunityProduct opportunityproduct, IProduct product) { opportunityproduct.Product = product; }