protected void dgPriceMarckups_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            DataGridItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is IGrouping <int, DistributorPriceMarkupBO> )
            {
                var lstPriceMarckups = ((IGrouping <int, DistributorPriceMarkupBO>)item.DataItem).ToList();
                DistributorPriceMarkupBO objPriceMarckup = lstPriceMarckups[0];

                ((System.Web.UI.WebControls.WebControl)(item)).CssClass = "irow_" + objPriceMarckup.Distributor.ToString();

                Literal litDistributor = (Literal)item.FindControl("litDistributor");
                litDistributor.Text = objPriceMarckup.Distributor.ToString();

                Literal lblDistributor = (Literal)item.FindControl("lblDistributor");
                lblDistributor.Text = ((objPriceMarckup.Distributor > 0) ? objPriceMarckup.objDistributor.Name : "PLATINUM");

                Repeater rptDistributorPriceLevels = (Repeater)item.FindControl("rptDistributorPriceLevels");
                rptDistributorPriceLevels.DataSource = lstPriceMarckups;
                rptDistributorPriceLevels.DataBind();

                HyperLink linkEdit = (HyperLink)item.FindControl("linkEdit");
                linkEdit.Attributes.Add("qid", objPriceMarckup.Distributor.ToString());
                linkEdit.Attributes.Add("isType", "distributor");

                HyperLink linkDelete = (HyperLink)item.FindControl("linkDelete");
                linkDelete.Attributes.Add("qid", objPriceMarckup.Distributor.ToString());
                linkDelete.Attributes.Add("isType", "distributor");
                if (lblDistributor.Text == "PLATINUM")
                {
                    linkDelete.Visible = false;
                }
            }
        }
        protected void btnSaveClonePriceMarkup_Click(object sender, EventArgs e)
        {
            if (this.IsNotRefresh)
            {
                ReturnIntViewBO objReturnInt = new ReturnIntViewBO();

                if (this.ddlExistDistributors.SelectedValue != null && this.ddlNewDistributors.SelectedValue != "0")
                {
                    objReturnInt = DistributorPriceMarkupBO.CloneDistributorPriceMarkup(int.Parse(this.ddlExistDistributors.SelectedValue), int.Parse(this.ddlNewDistributors.SelectedValue));

                    if (objReturnInt.RetVal == 1)
                    {
                        ViewState["ClonePriceMarkup"] = false;
                        Response.Redirect("~/ViewPriceMarckups.aspx");
                    }
                    else
                    {
                        CustomValidator customValidator = new CustomValidator();
                        customValidator.ErrorMessage       = "Insertion Failed Distributor Price Markup";
                        customValidator.IsValid            = false;
                        customValidator.EnableClientScript = false;

                        this.ClonevalidationSummary.Controls.Add(customValidator);
                        ViewState["ClonePriceMarkup"] = true;
                    }
                }
            }
        }
        protected void rptPriceLevels_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is PriceLevelBO)
            {
                PriceLevelBO objPriceLevel = (PriceLevelBO)item.DataItem;

                Literal litCellHeader = (Literal)item.FindControl("litCellHeader");
                litCellHeader.Text = objPriceLevel.Name + "<em>( " + objPriceLevel.Volume + " )</em>";

                TextBox txtCellData = (TextBox)item.FindControl("txtCellData");
                txtCellData.Attributes.Add("qid", objPriceLevel.ID.ToString());
                txtCellData.CssClass = "level" + objPriceLevel.ID.ToString();
            }
            else if (item.ItemIndex > -1 && item.DataItem is DistributorPriceMarkupBO)
            {
                DistributorPriceMarkupBO objPriceMarckup = (DistributorPriceMarkupBO)item.DataItem;

                Literal litCellHeader = (Literal)item.FindControl("litCellHeader");
                litCellHeader.Text = objPriceMarckup.objPriceLevel.Name + "<em>( " + objPriceMarckup.objPriceLevel.Volume + " )</em>";

                HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID");
                hdnCellID.Value = objPriceMarckup.ID.ToString();

                Label lblCellData = (Label)item.FindControl("lblCellData");
                lblCellData.Attributes.Add("qid", objPriceMarckup.PriceLevel.ToString());
                lblCellData.Text = objPriceMarckup.Markup.ToString();
            }
        }
Пример #4
0
        protected void rptPriceLevelCost_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemIndex > -1 && item.DataItem is DistributorPriceMarkupBO)
            {
                DistributorPriceMarkupBO objPriceMarkup = (DistributorPriceMarkupBO)item.DataItem;

                Literal litCellHeader = (Literal)item.FindControl("litCellHeader");
                litCellHeader.Text = objPriceMarkup.objPriceLevel.Name + "<em>( " + objPriceMarkup.objPriceLevel.Volume + " )</em>";

                HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID");
                hdnCellID.Value = "0";

                TextBox txtCIFPrice = (TextBox)item.FindControl("txtCIFPrice");
                txtCIFPrice.Attributes.Add("level", objPriceMarkup.PriceLevel.ToString());
                txtCIFPrice.Text    = "0.00";
                txtCIFPrice.Enabled = false;

                Label lblFOBPrice = (Label)item.FindControl("lblFOBPrice");
                lblFOBPrice.Text = "0.00";

                Label lblMarkup = (Label)item.FindControl("lblMarkup");
                lblMarkup.Text = objPriceMarkup.Markup + "%";

                Label lblCIFCost = (Label)item.FindControl("lblCIFCost");
                lblCIFCost.Text = "$0.0";

                Label lblFOBCost = (Label)item.FindControl("lblFOBCost");
                lblFOBCost.Text = "$0.0";
            }
            else if (item.ItemIndex > -1 && item.DataItem is PriceLevelCostBO)
            {
                PriceLevelCostBO         objPriceLevelCost = (PriceLevelCostBO)item.DataItem;
                DistributorPriceMarkupBO objPriceMarkup    = objPriceLevelCost.objPriceLevel.DistributorPriceMarkupsWhereThisIsPriceLevel.SingleOrDefault(o => (int)o.Distributor == int.Parse(this.ddlDistributors.SelectedValue.Trim()));

                decimal convertion     = objPriceLevelCost.objPrice.objPattern.ConvertionFactor;
                decimal factoryCost    = objPriceLevelCost.FactoryCost;
                decimal indimanCIFCost = (factoryCost == 0) ? 0 : Math.Round(Convert.ToDecimal((factoryCost * (100 + objPriceMarkup.Markup)) / 100), 2);

                Literal litCellHeader = (Literal)item.FindControl("litCellHeader");
                litCellHeader.Text = objPriceLevelCost.objPriceLevel.Name + "<em>( " + objPriceLevelCost.objPriceLevel.Volume + " )</em>";

                HiddenField hdnCellID = (HiddenField)item.FindControl("hdnCellID");
                hdnCellID.Value = objPriceLevelCost.ID.ToString();

                TextBox txtCIFPrice = (TextBox)item.FindControl("txtCIFPrice");
                txtCIFPrice.Attributes.Add("level", objPriceLevelCost.PriceLevel.ToString());
                txtCIFPrice.Text    = objPriceLevelCost.IndimanCost.ToString("0.00");
                txtCIFPrice.Enabled = isEnableIndimanCost;

                Label lblFOBPrice = (Label)item.FindControl("lblFOBPrice");
                lblFOBPrice.Text = ((objPriceLevelCost.IndimanCost != 0) ? (objPriceLevelCost.IndimanCost - objPriceLevelCost.objPrice.objPattern.ConvertionFactor).ToString("0.00") : "0.00");

                Label lblMarkup = (Label)item.FindControl("lblMarkup");
                lblMarkup.Text = objPriceMarkup.Markup.ToString() + "%";

                Label lblCIFCost = (Label)item.FindControl("lblCIFCost");
                lblCIFCost.Text = "$" + indimanCIFCost.ToString("0.00");

                Label lblFOBCost = (Label)item.FindControl("lblFOBCost");
                lblFOBCost.Text = "$" + ((indimanCIFCost == 0) ? 0 : Convert.ToDecimal(indimanCIFCost - convertion)).ToString("0.00");
            }
        }
        /// <summary>
        /// Process the page data.
        /// </summary>
        private void ProcessForm(int distributorID, bool isDelete, bool isEdit, string isType)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    if (isEdit)
                    {
                        //Delete Statment
                        if (isDelete)
                        {
                            ReturnIntViewBO objReturnIntView = new ReturnIntViewBO();
                            if (isType == "distributor")
                            {
                                objReturnIntView = DistributorPriceMarkupBO.DeleteDistributorPriceMarkup(distributorID);
                                if (objReturnIntView.RetVal == 0)
                                {
                                    return;
                                }
                            }

                            if (isType == "label")
                            {
                                objReturnIntView = PriceMarkupLabelBO.DeleteLabelPriceMarkup(distributorID);
                                if (objReturnIntView.RetVal == 0)
                                {
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (isType == "distributor")
                            {
                                foreach (RepeaterItem item in this.rptPriceLevels.Items)
                                {
                                    HiddenField hdnCellID   = (HiddenField)item.FindControl("hdnCellID");
                                    TextBox     txtCellData = (TextBox)item.FindControl("txtCellData");

                                    int markup = int.Parse(hdnCellID.Value);

                                    DistributorPriceMarkupBO objPriceMarckup = new DistributorPriceMarkupBO(this.ObjContext);
                                    if (markup > 0)
                                    {
                                        objPriceMarckup.ID = int.Parse(hdnCellID.Value.Trim());
                                        objPriceMarckup.GetObject();
                                    }

                                    if (isEdit)
                                    {
                                        objPriceMarckup.Distributor = (distributorID > 0) ? distributorID : 0;
                                    }
                                    objPriceMarckup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString());
                                    objPriceMarckup.Markup     = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00"));
                                }
                            }

                            if (isType == "label")
                            {
                                foreach (RepeaterItem item in this.rptPriceLevels.Items)
                                {
                                    HiddenField hdnCellID   = (HiddenField)item.FindControl("hdnCellID");
                                    TextBox     txtCellData = (TextBox)item.FindControl("txtCellData");

                                    int Labelmarkup = int.Parse(hdnCellID.Value);

                                    LabelPriceMarkupBO objLabelPriceMarkup = new LabelPriceMarkupBO(this.ObjContext);

                                    if (Labelmarkup > 0)
                                    {
                                        objLabelPriceMarkup.ID = int.Parse(hdnCellID.Value.Trim());
                                        objLabelPriceMarkup.GetObject();
                                    }

                                    objLabelPriceMarkup.Label      = distributorID;
                                    objLabelPriceMarkup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString());
                                    objLabelPriceMarkup.Markup     = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00"));
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (RepeaterItem item in this.rptPriceLevels.Items)
                        {
                            int         distributor = int.Parse(this.ddlDistributors.SelectedValue);
                            HiddenField hdnCellID   = (HiddenField)item.FindControl("hdnCellID");
                            TextBox     txtCellData = (TextBox)item.FindControl("txtCellData");

                            int markup = int.Parse(hdnCellID.Value);

                            DistributorPriceMarkupBO objPriceMarckup = new DistributorPriceMarkupBO(this.ObjContext);
                            if (markup > 0)
                            {
                                objPriceMarckup.ID = int.Parse(hdnCellID.Value.Trim());
                                objPriceMarckup.GetObject();
                            }

                            if (distributor > 0)
                            {
                                objPriceMarckup.Distributor = (int?)distributor;
                            }
                            objPriceMarckup.PriceLevel = int.Parse(txtCellData.Attributes["qid"].ToString());
                            objPriceMarckup.Markup     = Convert.ToDecimal(decimal.Parse(txtCellData.Text.Trim()).ToString("0.00"));
                        }
                    }

                    this.ObjContext.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                // Log the error
                IndicoLogging.log.Error("Error occured while Adding, upadting and deleting the PriceMarkups", ex);
            }
        }
        private void PopulateDataGrid()
        {
            // Hide Controls
            this.dvEmptyContent.Visible   = false;
            this.dvDataContent.Visible    = false;
            this.dvNoSearchResult.Visible = false;

            // Search text
            string searchText = this.txtSearch.Text.ToLower().Trim();

            // Populate Items
            DistributorPriceMarkupBO objPriceMarckup     = new DistributorPriceMarkupBO();
            LabelPriceMarkupBO       objLabelPriceMarkup = new LabelPriceMarkupBO();

            List <IGrouping <int, DistributorPriceMarkupBO> > lstPriceMarckups     = new List <IGrouping <int, DistributorPriceMarkupBO> >();
            List <IGrouping <int, LabelPriceMarkupBO> >       lstLabelPriceMarkups = new List <IGrouping <int, LabelPriceMarkupBO> >();

            if ((searchText != string.Empty) && (searchText != "search"))
            {
                lstPriceMarckups = (from o in objPriceMarckup.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList()
                                    where o.Distributor != 0 && o.objDistributor.Name.ToLower().Contains(searchText)
                                    orderby(int) o.Distributor
                                    group o by(int) o.Distributor into g
                                    select g).ToList();

                lstLabelPriceMarkups = (from o in objLabelPriceMarkup.SearchObjects().AsQueryable().ToList()
                                        where o.Label != 0 && o.objLabel.Name.ToLower().Contains(searchText)
                                        orderby(int) o.Label
                                        group o by(int) o.Label into g
                                        select g).ToList();
            }
            else
            {
                lstPriceMarckups = (from o in objPriceMarckup.SearchObjects().AsQueryable().OrderBy(SortExpression).ToList()
                                    orderby(int) o.Distributor
                                    group o by(int) o.Distributor into g
                                    select g).ToList();

                lstLabelPriceMarkups = (from o in objLabelPriceMarkup.SearchObjects().AsQueryable().ToList()
                                        orderby(int) o.Label
                                        group o by(int) o.Label into g
                                        select g).ToList();
            }

            if (lstPriceMarckups.Count > 0)
            {
                this.dgPriceMarckups.AllowPaging = (lstPriceMarckups.Count > this.dgPriceMarckups.PageSize);
                this.dgPriceMarckups.DataSource  = lstPriceMarckups;
                this.dgPriceMarckups.DataBind();

                this.dvDataContent.Visible = true;
            }
            else if ((searchText != string.Empty && searchText != "search"))
            {
                this.lblSerchKey.Text = searchText;

                this.dvDataContent.Visible    = true;
                this.dvNoSearchResult.Visible = true;
            }
            else
            {
                this.dvEmptyDistributor.Visible = true;
            }

            if (lstLabelPriceMarkups.Count > 0)
            {
                this.dgLabelPriceMarckups.AllowPaging = (lstLabelPriceMarkups.Count > this.dgLabelPriceMarckups.PageSize);
                this.dgLabelPriceMarckups.DataSource  = lstLabelPriceMarkups;
                this.dgLabelPriceMarckups.DataBind();
            }
            else if ((searchText != string.Empty && searchText != "search"))
            {
                this.lblLabelSerchKey.Text = searchText;

                this.dvDataContent.Visible         = true;
                this.dvNoSearchResultLabel.Visible = true;
            }
            else
            {
                this.dvEmptyLabel.Visible = true;
            }

            if (lstPriceMarckups.Count == 0 && lstLabelPriceMarkups.Count == 0)
            {
                this.dvEmptyContent.Visible     = true;
                this.btnAddPriceMarckup.Visible = false;
            }

            this.dgPriceMarckups.Visible      = (lstPriceMarckups.Count > 0);
            this.dgLabelPriceMarckups.Visible = (lstLabelPriceMarkups.Count > 0);
        }