Exemple #1
0
    /// <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();
    }
Exemple #2
0
    protected void pklProductFamily_PickListValueChanged(object sender, EventArgs e)
    {
        string productId = ((HiddenField)grdProducts.Rows[grdProducts.EditIndex].FindControl("hidProductId")).Value;
        string program   = ((Sage.SalesLogix.Web.Controls.PickList.PickListControl)grdProducts.Rows[grdProducts.EditIndex].FindControl("txtProgram")).PickListValue;

        IList <IOpportunityProduct> ListProducts = DefOppProdHelper.GetList();

        foreach (IOpportunityProduct op in ListProducts)
        {
            if (op.Product.Id.ToString() == productId)
            {
                op.Program         = program;
                op.Product.Program = program;
                Sage.SalesLogix.Opportunity.Rules.CalcPriceFromProgramPrice(op);

                break;
            }
        }

        //grdProducts.DataBind();
    }
Exemple #3
0
    protected void cmdOK_Click(object sender, EventArgs e)
    {
        StringBuilder xml = new StringBuilder("<xml xmlns:z='#RowsetSchema' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'>");

        xml.Append("<s:Schema id='RowsetSchema'>");
        xml.Append("<s:ElementType name='row' content='eltOnly' rs:updatable='true'>");
        xml.Append("<s:AttributeType name='SORT' rs:number='1' rs:write='true'>");
        xml.Append("<s:datatype dt:type='int' dt:maxLength='4' rs:precision='0'");
        xml.Append(" rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='PRODUCTID' rs:number='2' rs:write='true'>");
        xml.Append("<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='12'");
        xml.Append(" rs:precision='0' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='KEYFIELDID' rs:number='3' rs:write='true'>");
        xml.Append("<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='16'");
        xml.Append(" rs:precision='0' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='PRODUCT' rs:number='4' rs:write='true'>");
        xml.Append("<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='64'");
        xml.Append(" rs:precision='0' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='FAMILY' rs:number='5' rs:write='true'>");
        xml.Append("<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='64'");
        xml.Append(" rs:precision='0' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='PRICELEVEL' rs:number='6' rs:write='true'>");
        xml.Append("<s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='32'");
        xml.Append(" rs:precision='0' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='PRICE' rs:number='7' rs:write='true'>");
        xml.Append("<s:datatype dt:type='number' rs:dbtype='currency' dt:maxLength='8'");
        xml.Append(" rs:precision='0' rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='DISCOUNT' rs:number='8' rs:write='true'>");
        xml.Append(" <s:datatype dt:type='float' dt:maxLength='8' rs:precision='0'");
        xml.Append(" rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='ADJPRICE' rs:number='9' rs:write='true'>");
        xml.Append(" <s:datatype dt:type='number' rs:dbtype='currency' dt:maxLength='8'");
        xml.Append(" rs:precision='0' rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='PRICELOCAL' rs:number='10' rs:write='true'>");
        xml.Append(" <s:datatype dt:type='number' rs:dbtype='currency' dt:maxLength='8'");
        xml.Append(" rs:precision='0' rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='QUANTITY' rs:number='11' rs:write='true'>");
        xml.Append(" <s:datatype dt:type='float' dt:maxLength='8' rs:precision='0'");
        xml.Append(" rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='EXTENDED' rs:number='12' rs:write='true'>");
        xml.Append(" <s:datatype dt:type='number' rs:dbtype='currency' dt:maxLength='8'");
        xml.Append(" rs:precision='0' rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:AttributeType name='EXTENDEDLOCAL' rs:number='13'");
        xml.Append(" rs:write='true'>");
        xml.Append(" <s:datatype dt:type='number' rs:dbtype='currency' dt:maxLength='8'");
        xml.Append(" rs:precision='0' rs:fixedlength='true' rs:maybenull='false'/>");
        xml.Append("</s:AttributeType>");
        xml.Append("<s:extends type='rs:rowbase'/>");
        xml.Append("</s:ElementType>");
        xml.Append("</s:Schema>");
        xml.Append("<rs:data>");
        string rowstring = "<z:row SORT='{0}' PRODUCTID='{1}' KEYFIELDID='{11}' PRODUCT='{2}' FAMILY='{12}' PRICELEVEL='{3}' PRICE='{4}' DISCOUNT='{5}' ADJPRICE='{6}' PRICELOCAL='{7}' QUANTITY='{8}' EXTENDED='{9}' EXTENDEDLOCAL='{10}' />";

        foreach (IOpportunityProduct op in DefOppProdHelper.GetList())
        {
            xml.AppendFormat(rowstring, op.Sort, op.Product.Id, op.Product.Name, op.Program, op.Price, op.Discount, op.CalculatedPrice, op.CalculatedPrice, op.Quantity, op.ExtendedPrice, op.ExtendedPrice, op.Id, op.Product.Family);
        }
        xml.Append("</rs:data></xml>");
        _UserOptions.SetCommonOption("Products", "OpportunityDefaults", xml.ToString(), false);

        Sage.Platform.WebPortal.WebPortalPage wpPage = Page as Sage.Platform.WebPortal.WebPortalPage;
        IPanelRefreshService refresher = wpPage.PageWorkItem.Services.Get <IPanelRefreshService>();

        if (refresher != null)
        {
            refresher.RefreshAll();
        }
    }