Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            brandOperator = new BrandDAL();

            if (!IsPostBack)
            {
                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    Brand info
                        = brandOperator.SelectByID(Convert.ToInt32(Request.QueryString[CommonStrings.ID]), (bool?)IsArabic);

                    if (info != null)
                    {
                        imgBrand.ImageUrl = GetSmallImage(info.Image);

                        offersAnch.HRef = Utility.AppendQueryString(PagesPathes.OffersList, new KeyValue("BrandID", Request.QueryString[CommonStrings.ID]));

                        if (IsArabic)
                        {
                            imgBrand.AlternateText = info.NameAr;
                            imgBrand.ToolTip = info.NameAr;

                            ltrlName.Text = info.NameAr;
                            if (string.IsNullOrEmpty(info.DescriptionAr))
                                ltrlDescription.Text = info.ShortDescriptionAr;
                            else
                                ltrlDescription.Text = info.DescriptionAr;
                        }
                        else
                        {
                            imgBrand.AlternateText = info.NameEn;
                            imgBrand.ToolTip = info.NameEn;

                            ltrlName.Text = info.NameEn;
                            if (string.IsNullOrEmpty(info.DescriptionEn))
                                ltrlDescription.Text = info.ShortDescriptionEn;
                            else
                                ltrlDescription.Text = info.DescriptionEn;
                        }

                        emptyDataDiv.Visible = false;
                    }
                    else
                    {
                        emptyDataDiv.Visible = true;
                    }
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "BrandsList")));
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            brandsOperator = new BrandDAL();

            if (!IsPostBack)
            {
                BindGrid();
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.AdminDefault)));
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            brandsOperator = new BrandDAL();

            if (!IsPostBack)
            {
                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    Brand info
                        = brandsOperator.SelectByID(Convert.ToInt32(Request.QueryString[CommonStrings.ID]), null);

                    if (info != null)
                    {
                        txtID.Text = info.ID.ToString();
                        txtNameAr.Text = info.NameAr;
                        txtNameEn.Text = info.NameEn;
                        txtDescriptionAr.Value = info.DescriptionAr;
                        txtDescriptionEn.Value = info.DescriptionEn;
                        imgPicture.ImageUrl = GetSmallImage(info.Image);
                        txtCreationDate.Text = info.CreationDate.ToShortDateString();

                        if (info.CreatedBy.HasValue)
                            txtCreatedBy.Text = info.CreatedBy.Value.ToString();

                        if (info.ModificationDate.HasValue)
                            txtModificationDate.Text = info.ModificationDate.Value.ToShortDateString();

                        if (info.ModifiedBy.HasValue)
                            txtModifiedBy.Text = info.ModifiedBy.Value.ToString();
                    }
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "ListBrands")));
        }
    }
Ejemplo n.º 4
0
    public void InitializeControl()
    {
        try
        {
            brandsOperator = new BrandDAL();

            if (!IsPostBack)
            {
                List<Brand> brandsList = brandsOperator.SelectAll((bool?)IsArabic);

                if (brandsList != null && brandsList.Count > 0)
                {
                    rptBrands.DataSource = brandsList;
                    rptBrands.DataBind();
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault)));
        }
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            brandsOperator = new BrandDAL();

            if (!IsPostBack)
            {
                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    Brand info
                        = brandsOperator.SelectByID(Convert.ToInt32(Request.QueryString[CommonStrings.ID]), null);

                    if (info != null)
                    {
                        imgPicture.ImageUrl = GetSmallImage(info.Image);
                        ViewState.Add("BrandImage", info.Image);

                        txtNameAr.Text = info.NameAr;
                        txtNameEn.Text = info.NameEn;
                        txtDescriptionAr.Value = info.DescriptionAr;
                        txtDescriptionEn.Value = info.DescriptionEn;

                        divPicture.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLBlock;
                        divPathHeader.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLNone;
                        divUploader.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLNone;
                    }

                    hidImageFlag.Value = CommonStrings.OldImage;
                }
                else
                {
                    divPicture.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLNone;
                    divPathHeader.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLBlock;
                    divUploader.Style[CommonStrings.HTMLDisplay] = CommonStrings.HTMLBlock;
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "ListBrands")));
        }
    }
Ejemplo n.º 6
0
    private List<KeyValue> FilterList(List<Offer> offersList, string filterBy)
    {
        List<KeyValue> filteredList = null;

        if (offersList != null && offersList.Count > 0)
        {
            filteredList = new List<KeyValue>();
            List<Offer> subList = null;

            if (filterBy == "Brand")
            {
                List<Offer> nullList = new List<Offer>();

                for (int i = 0; i < offersList.Count; i++)
                {
                    if (offersList[i].BrandID == null)
                    {
                        nullList.Add(offersList[i]);
                        offersList.RemoveAt(i);
                        i = i - 1;
                    }
                }

                while (offersList.Count > 0)
                {
                    subList = new List<Offer>();
                    subList.Add(offersList[0]);
                    for (int j = 1; j < offersList.Count; j++)
                    {
                        if (offersList[j].BrandID == offersList[0].BrandID)
                        {
                            subList.Add(offersList[j]);
                            offersList.RemoveAt(j);
                            j = j - 1;
                        }
                    }
                    offersList.RemoveAt(0);

                    string brandName = null;
                    if (IsArabic)
                        brandName = new BrandDAL().SelectByID(subList[0].BrandID.Value, IsArabic).NameAr;
                    else
                        brandName = new BrandDAL().SelectByID(subList[0].BrandID.Value, IsArabic).NameEn;

                    filteredList.Add(new KeyValue(brandName, subList));
                }

                SortAlpha(filteredList);

                if (nullList != null && nullList.Count > 0)
                    filteredList.Add(new KeyValue(Resources.Literals.NoBrand, nullList));
            }
            else if (filterBy == "Supplier")
            {
                while (offersList.Count > 0)
                {
                    subList = new List<Offer>();
                    subList.Add(offersList[0]);
                    for (int j = 1; j < offersList.Count; j++)
                    {
                        if (offersList[j].SupplierID == offersList[0].SupplierID)
                        {
                            subList.Add(offersList[j]);
                            offersList.RemoveAt(j);
                            j = j - 1;
                        }
                    }
                    offersList.RemoveAt(0);

                    string supplierName = null;
                    if (IsArabic)
                        supplierName = new SupplierDAL().SelectByID(subList[0].SupplierID, IsArabic).NameAr;
                    else
                        supplierName = new SupplierDAL().SelectByID(subList[0].SupplierID, IsArabic).NameEn;

                    filteredList.Add(new KeyValue(supplierName, subList));
                }
                SortAlpha(filteredList);
            }
            else if (filterBy == "Category")
            {
                while (offersList.Count > 0)
                {
                    subList = new List<Offer>();
                    subList.Add(offersList[0]);
                    for (int j = 1; j < offersList.Count; j++)
                    {
                        if (offersList[j].CategoryID == offersList[0].CategoryID)
                        {
                            subList.Add(offersList[j]);
                            offersList.RemoveAt(j);
                            j = j - 1;
                        }
                    }
                    offersList.RemoveAt(0);

                    string categoryName = null;
                    if (IsArabic)
                        categoryName = new CategoryDAL().SelectByID(subList[0].CategoryID, IsArabic).NameAr;
                    else
                        categoryName = new CategoryDAL().SelectByID(subList[0].CategoryID, IsArabic).NameEn;

                    filteredList.Add(new KeyValue(categoryName, subList));
                }
                SortAlpha(filteredList);
            }
        }

        return filteredList;
    }
Ejemplo n.º 7
0
    private void SearchOffers()
    {
        MainPager = new PagedDataSource();

        if (!string.IsNullOrEmpty(Request.QueryString["SuppID"]))
        {
            MainPager.DataSource = offersOperator.SelectBySupplierID(Convert.ToInt32(Request.QueryString["SuppID"].Trim()), "All", IsArabic, true);

            Supplier temp = new SupplierDAL().SelectByID(Convert.ToInt32(Request.QueryString["SuppID"].Trim()), IsArabic);
            if (temp != null)
            {
                if (IsArabic)
                    ltrlTitle.Text = temp.NameAr;
                else
                    ltrlTitle.Text = temp.NameEn;
            }
        }
        else if (!string.IsNullOrEmpty(Request.QueryString["BrandID"]))
        {
            MainPager.DataSource = offersOperator.SelectByBrandID(Convert.ToInt32(Request.QueryString["BrandID"].Trim()), "All", IsArabic, true);

            Brand temp = new BrandDAL().SelectByID(Convert.ToInt32(Request.QueryString["BrandID"].Trim()), IsArabic);
            if (temp != null)
            {
                if (IsArabic)
                    ltrlTitle.Text = temp.NameAr;
                else
                    ltrlTitle.Text = temp.NameEn;
            }
        }
        else if (!string.IsNullOrEmpty(Request.QueryString["CatID"]))
        {
            ArrayList categoryList = new ArrayList();
            GetCategoriesList(Convert.ToInt32(Request.QueryString["CatID"].Trim()), categoryList);

            if (categoryList != null && categoryList.Count > 0)
                MainPager.DataSource = offersOperator.SelectByCategoryID(categoryList, "All", IsArabic, true);
            else
                MainPager.DataSource = null;

            Category temp = new CategoryDAL().SelectByID(Convert.ToInt32(Request.QueryString["CatID"].Trim()), IsArabic);
            if (temp != null)
            {
                if (IsArabic)
                    ltrlTitle.Text = temp.NameAr;
                else
                    ltrlTitle.Text = temp.NameEn;
            }
        }
        else
        {
            ltrlTitle.Text = string.Empty;
        }

        BindMainRepeater();
    }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            offersOperator = new OfferDAL();
            categoryOperator = new CategoryDAL();
            supplierOperator = new SupplierDAL();
            brandOperator = new BrandDAL();

            if (!IsPostBack)
            {
                FillCategoryDrpMenu();
                FillSuppliersDrpMenu();
                FillBrandsDrpMenu();
                BindGrid();
            }

            #region Select JS Script

            String csSelect = "SelectScript";
            Type csType = this.GetType();
            ClientScriptManager clientScript = Page.ClientScript;
            if (!clientScript.IsStartupScriptRegistered(csType, csSelect))
            {
                clientScript.RegisterStartupScript(csType, csSelect, "javascript:rblSelectedValue();", true);
            }

            #endregion
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.AdminDefault)));
        }
    }
Ejemplo n.º 9
0
    private void FillBrandsDrpMenu()
    {
        BrandDAL brandOperator = new BrandDAL();
        List<Brand> brandsList = brandOperator.SelectAll(IsArabic);

        if (brandsList != null && brandsList.Count > 0)
        {
            drpBrand.DataSource = brandsList;
            drpBrand.DataValueField = Brand.CommonColumns.ID;
            if (IsArabic)
                drpBrand.DataTextField = Brand.TableColumns.NameAr;
            else
                drpBrand.DataTextField = Brand.TableColumns.NameEn;

            drpBrand.DataBind();
        }
        drpBrand.Items.Insert(0, Literals.None);
    }