public void InitializeControl()
    {
        try
        {
            suppliersOperator = new SupplierDAL();

            if (!IsPostBack)
            {
                List<Supplier> suppliersList = suppliersOperator.SelectAll((bool?)IsArabic, true);

                if (suppliersList != null && suppliersList.Count > 0)
                {
                    rptSuppliers.DataSource = suppliersList;
                    rptSuppliers.DataBind();
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault)));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            supplierOperator = new SupplierDAL();

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

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

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

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

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

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

                        if (string.IsNullOrEmpty(info.Website))
                        {
                            websiteAnch.Visible = false;
                        }
                        else
                        {
                            websiteAnch.Visible = true;
                            ltrlWebsite.Text = info.Website;
                            if (info.Website.StartsWith("http://"))
                                websiteAnch.HRef = info.Website;
                            else
                                websiteAnch.HRef = string.Concat("http://", info.Website);
                        }

                        if (string.IsNullOrEmpty(info.Email))
                        {
                            emailAnch.Visible = false;
                        }
                        else
                        {
                            emailAnch.Visible = true;
                            ltrlEmail.Text = info.Email;
                            if (info.Email.StartsWith("mailto:"))
                                emailAnch.HRef = info.Email;
                            else
                                emailAnch.HRef = string.Concat("mailto:", info.Email);
                        }

                        if (string.IsNullOrEmpty(info.HotLine))
                        {
                            hotLineSpan.Visible = false;
                        }
                        else
                        {
                            hotLineSpan.Visible = true;
                            ltrlHotLine.Text = info.HotLine;
                        }

                        if (info.BranchList != null && info.BranchList.Count > 0)
                        {
                            rptBranches.DataSource = info.BranchList;
                            rptBranches.DataBind();
                        }

                        emptyDataDiv.Visible = false;
                    }
                    else
                    {
                        emptyDataDiv.Visible = true;
                    }
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "SuppliersList")));
        }
    }
    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;
    }
Example #4
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();
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            suppliersOperator = new SupplierDAL();

            if (!IsPostBack)
            {
                BindGrid();
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.AdminDefault)));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            suppliersOperator = new SupplierDAL();

            if (!IsPostBack)
            {
                if (Request.QueryString[CommonStrings.ID] != null)
                {
                    Supplier info
                        = suppliersOperator.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;
                        txtContactPerson.Text = info.ContactPerson;
                        txtContactPersonEmail.Text = info.ContactPersonEmail;
                        txtContactPersonMobile.Text = info.ContactPersonMobile;
                        imgPicture.ImageUrl = GetSmallImage(info.Image);
                        txtWebsite.Text = info.Website;
                        txtEmail.Text = info.Email;
                        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();

                        if (info.ActivationDate.HasValue)
                            txtActivationDate.Text = info.ActivationDate.Value.ToShortDateString();

                        if (info.ActivatedBy.HasValue)
                            txtActivatedBy.Text = info.ActivatedBy.Value.ToString();

                        if (info.DeactivationDate.HasValue)
                            txtDeactivationDate.Text = info.DeactivationDate.Value.ToShortDateString();

                        if (info.DeactivatedBy.HasValue)
                            txtDeactivatedBy.Text = info.DeactivatedBy.Value.ToString();

                        if (info.IsActive)
                            txtStatus.Text = Literals.Active;
                        else
                            txtStatus.Text = Literals.NotActive;
                    }
                }
            }
        }
        catch
        {
            Response.Redirect(Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "ListSuppliers")));
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            suppliersOperator = new SupplierDAL();

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

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

                        txtNameAr.Text = info.NameAr;
                        txtNameEn.Text = info.NameEn;
                        txtDescriptionAr.Value = info.DescriptionAr;
                        txtDescriptionEn.Value = info.DescriptionEn;
                        txtContactPerson.Text = info.ContactPerson;
                        txtContactPersonEmail.Text = info.ContactPersonEmail;
                        txtContactPersonMobile.Text = info.ContactPersonMobile;
                        txtWebsite.Text = info.Website;
                        txtEmail.Text = info.Email;

                        if (info.IsActive)
                            chkIsActive.Checked = true;

                        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, "ListSuppliers")));
        }
    }
Example #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)));
        }
    }
Example #9
0
    private void FillSuppliersDrpMenu()
    {
        SupplierDAL supplierOperator = new SupplierDAL();
        List<Supplier> suppliersList = supplierOperator.SelectAll(IsArabic, true);

        if (suppliersList != null && suppliersList.Count > 0)
        {
            drpSupplier.DataSource = suppliersList;
            drpSupplier.DataValueField = Supplier.CommonColumns.ID;
            if (IsArabic)
                drpSupplier.DataTextField = Supplier.TableColumns.NameAr;
            else
                drpSupplier.DataTextField = Supplier.TableColumns.NameEn;

            drpSupplier.DataBind();
        }
        drpSupplier.Items.Insert(0, Literals.ListHeader);
    }