Example #1
0
    protected void ProductsRepeater_ItemBound(object sender, RepeaterItemEventArgs args)
    {
        try
        {
            if (args.Item.ItemType == ListItemType.Item || args.Item.ItemType == ListItemType.AlternatingItem)
            {
                LinqToSqlDataContext db = new LinqToSqlDataContext();
                if (String.IsNullOrEmpty(hidProductCode.Value))
                {
                    hidProductCode.Value = (args.Item.FindControl("lblProductCode") as Label).Text;
                }

                else if (hidProductCode.Value.ToString() != (args.Item.FindControl("lblProductCode") as Label).Text)
                {
                    hidProductCode.Value = (args.Item.FindControl("lblProductCode") as Label).Text;
                    count = 1;
                }
                if (Session[enumSessions.User_Role.ToString()] != null && Session[enumSessions.User_Role.ToString()].ToString() == enumRoles.ARC_Admin.ToString())
                {
                    Label lblProductPrice = (Label)args.Item.FindControl("lblProductPrice");
                    lblProductPrice.Text = "0.00";

                    Label lblProductPriceTotal = (Label)args.Item.FindControl("lblProductPriceTotal");
                    lblProductPriceTotal.Text = "0.00";
                }

                Label lblProductCode = (Label)args.Item.FindControl("lblProductCode");
                int   rowCount       = db.USP_GetBasketProductsOnCheckOut(Convert.ToInt32(Session[enumSessions.PreviousOrderId.ToString()].ToString())).Where(i => i.ProductCode == lblProductCode.Text.Trim()).Count();
                if (rowCount == count)
                {
                    USP_GetBasketProductsOnPreviousOrders_OrderingResult product = (USP_GetBasketProductsOnPreviousOrders_OrderingResult)args.Item.DataItem;
                    Repeater rep = (Repeater)args.Item.FindControl("rptrDependentProducts");

                    rep.DataSource = db.USP_GetPreviousOrdersDependentProductsByProductId(Convert.ToInt32(Session[enumSessions.PreviousOrderId.ToString()].ToString()), product.ProductId, product.CategoryId);
                    rep.DataBind();

                    if (rep.Items.Count == 0)
                    {
                        rep.Visible = false;
                    }
                    db.Dispose();
                }
                count++;

                Repeater dlProducts = (Repeater)args.Item.FindControl("rptrItemDetails");

                HiddenField hdnOrderItemId = args.Item.FindControl("hdnOrderItemId") as HiddenField;
                db = new LinqToSqlDataContext();
                //List<OrderItemDetailsDTO> objItemDetails = new List<OrderItemDetailsDTO>();
                //objItemDetails = CSLOrderingARCBAL.BAL.OrdersBAL.GetOrderDetailsforReport(Convert.ToInt32(hdnOrderItemId.Value));
                if (db.USP_GetOrderDetailsforReport(Convert.ToInt32(hdnOrderItemId.Value)).Count() > 0)
                {
                    dlProducts.DataSource = db.USP_GetOrderDetailsforReport(Convert.ToInt32(hdnOrderItemId.Value));
                    dlProducts.DataBind();
                }
                else
                {
                    // HtmlControl trrptrItemDetails = args.Item.FindControl("trrptrItemDetails") as HtmlControl;
                    // trrptrItemDetails.Visible = false;
                }
            }

            if (args.Item.ItemType == ListItemType.Footer)
            {
                Label lblTotalPrice = (Label)args.Item.FindControl("lblTotalPrice");
                Label lblTotalQty   = (Label)args.Item.FindControl("lblTotalQty");

                lblTotalPrice.Text = lblDtlsOrderTotal.Text;
                lblTotalQty.Text   = lblOrderQty.Text;

                if (Session[enumSessions.User_Role.ToString()] != null && Session[enumSessions.User_Role.ToString()].ToString() == enumRoles.ARC_Admin.ToString())
                {
                    lblTotalPrice.Text     = "0.00";
                    lblDtlsOrderTotal.Text = "0.00";
                    lblDtlsTotalToPay.Text = "0.00";
                }
            }
        }
        catch (Exception objException)
        {
            CSLOrderingARCBAL.LinqToSqlDataContext db;
            db = new CSLOrderingARCBAL.LinqToSqlDataContext();
            db.USP_SaveErrorDetails(Request.Url.ToString(), "ProductsRepeater_ItemBound", Convert.ToString(objException.Message), Convert.ToString(objException.InnerException), Convert.ToString(objException.StackTrace), "", HttpContext.Current.Request.UserHostAddress, false, Convert.ToString(HttpContext.Current.Session[enumSessions.User_Id.ToString()]));
        }
    }