protected void LoadItems()
 {
     if (!HasEditPermission)
     {
         dgAds.Columns[dgAds.Columns.Count - 1].Visible = false;
     }
     dgAds.VirtualItemCount = AdvertisementController.GetAllAds().Count;
     if (dgAds.VirtualItemCount == 0)
     {
         phHasItems.Visible   = false;
         phHasNoItems.Visible = true;
         lblNoItems.Text      = AdvertisementsStrings.GetText(@"MessageNoCompaniesFound");
     }
     else
     {
         phHasItems.Visible   = true;
         phHasNoItems.Visible = false;
         if (dgAds.PageSize * dgAds.CurrentPageIndex > dgAds.VirtualItemCount)
         {
             dgAds.CurrentPageIndex = 0;
             hfCurrentPageIndex_dgCompanies.Value = dgAds.CurrentPageIndex.ToString();
         }
         List <AdvertisementUI> items = AdvertisementController.GetAllAds(dgAds.PageSize, dgAds.CurrentPageIndex);
         BindList(items);
     }
 }
Beispiel #2
0
    protected void LoadItems()
    {
        if (!HasEditPermission)
        {
            dgCompanies.Columns[dgCompanies.Columns.Count - 1].Visible = false;
        }
        string searchName  = "%" + txtSearchName.Text.Trim() + "%";
        string searchPhone = "%" + txtSearchPhone.Text.Trim() + "%";

        dgCompanies.VirtualItemCount = AdvertisementController.GetAllCompaniesUI(true, searchName, searchPhone).Count;
        if (dgCompanies.VirtualItemCount == 0)
        {
            phHasItems.Visible   = false;
            phHasNoItems.Visible = true;
            lblNoItems.Text      = AdvertisementsStrings.GetText(@"MessageNoCompaniesFound");
        }
        else
        {
            phHasItems.Visible   = true;
            phHasNoItems.Visible = false;
            if (dgCompanies.PageSize * dgCompanies.CurrentPageIndex > dgCompanies.VirtualItemCount)
            {
                dgCompanies.CurrentPageIndex         = 0;
                hfCurrentPageIndex_dgCompanies.Value = dgCompanies.CurrentPageIndex.ToString();
            }
            List <AdCompany> items = AdvertisementController.GetAllCompaniesUI(true, searchName, searchPhone, dgCompanies.PageSize, dgCompanies.CurrentPageIndex);
            BindList(items);
        }
    }
Beispiel #3
0
    protected void Page_Init(object sender, EventArgs e)
    {
        //HasEditPermission = Permissions.PermissionsForUser(SessionHelper.UserId()).Contains(Permissions.PermissionKeys.sys_edit_users);

        Master.AddButtonNew(AdvertisementsStrings.GetText(@"NewSupplierButton"), @"EditSupplier.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });

        dgCompanies.PageIndexChanged += dgCompanies_PageIndexChanging;
    }
    protected void hlDelete_Click(object sender, EventArgs e)
    {
        Button btn       = (Button)(sender);
        var    arguments = btn.CommandArgument;

        if (AdvertisementController.DeleteAd(Convert.ToInt16(arguments.ToString())))
        {
            Master.MessageCenter.DisplaySuccessMessage(AdvertisementsStrings.GetText(@"DeleteMessage"));
            LoadItems();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        string Email          = null;
        bool   EmailChanged   = false;
        string AdCompanyEmail = null;

        AdCompany company = null;

        if (IsNewMode)
        {
            Membership.UserCreateResults results = Membership.CreateAdCompany(txtEmail.Text, out company);
            switch (results)
            {
            default:
            case Membership.UserCreateResults.UnknownError:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedUnknown"));
                return;

            case Membership.UserCreateResults.AlreadyExists:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedAlreadyExists"));
                return;

            case Membership.UserCreateResults.InvalidEmailAddress:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedEmailAddressInvalid"));
                return;

            case Membership.UserCreateResults.Success:
                break;
            }
            CompanyId           = company.CompanyId;
            company.CreatedDate = DateTime.Now;
            AdCompanyEmail      = company.Email;
        }
        else
        {
            company        = AdCompany.FetchByID(CompanyId);
            AdCompanyEmail = company.Email;
        }
        company.BusinessName = txtBusinessName.Text;
        company.ContactName  = txtContactName.Text;
        company.ContactPhone = txtContactPhone.Text;
        company.Phone        = txtPhone.Text;
        company.Description  = txtDescription.Text;
        company.Save();

        if (IsNewMode)
        {
            CompanyId = company.CompanyId;
        }

        if (company.Email != txtEmail.Text.Trim().NormalizeEmail())
        {
            if (AdCompany.FetchByEmail(txtEmail.Text.Trim().NormalizeEmail()) != null)
            {
                Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessageEmailChangeFailed"));
            }
            else
            {
                company.Email = txtEmail.Text.Trim().NormalizeEmail();
                EmailChanged  = true;
            }
        }

        AdCompanyEmail = company.Email;
        company.Save();

        if (IsNewMode)
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageCompanyCreated");
            string url            = @"EditAdCompany.aspx?Email=" + AdCompanyEmail + "&CompanyId=" + company.CompanyId;
            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
        else
        {
            string successMessage = SuppliersStrings.GetText(@"MessageSupplierSaved");
            if (EmailChanged)
            {
                string url = @"EditAdCompany.aspx?message-success=" + Server.UrlEncode(successMessage) + "&CompanyId=" + company.CompanyId;
                if (CompanyId != company.CompanyId)
                {
                    url += @"&Email=" + AdCompanyEmail;
                }
                Response.Redirect(url, true);
            }
            else
            {
                Master.MessageCenter.DisplaySuccessMessage(successMessage);
                LoadView();
            }
        }
    }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitle  = AdvertisementsStrings.GetText(IsNewMode ? @"NewAdCompanyPageTitle" : @"EditAdCompanyPageTitle");
     Master.ActiveMenu = IsNewMode ? "EditAdCompany" : "AdCompanies";
     Master.AddClientScriptInclude(@"dgDatePicker.js");
 }
Beispiel #7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        Advertisement advertisement = null;

        if (!IsNewMode)
        {
            advertisement = Advertisement.FetchByID(AdId);
        }
        else
        {
            advertisement             = new Advertisement();
            advertisement.CreatedDate = DateTime.Now;
        }
        advertisement.BunnerId  = (BunnerType)Enum.Parse(typeof(BunnerType), ddlBunner.SelectedValue);
        advertisement.CompanyId = Convert.ToInt64(ddlBusinessName.SelectedValue);


        if (fuImage.HasFile)
        {
            MediaUtility.DeleteImageFilePath("Banners", advertisement.FilePath, 64, 64, 0);
            string fn = MediaUtility.SaveFile(fuImage.PostedFile, "Banners", 0);
            advertisement.FilePath = fn;
            HomeImage.ImageUrl     = Snoopi.core.MediaUtility.GetImagePath("Banners", advertisement.FilePath, 0, 64, 64);
            ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl);
        }
        else if (advertisement.FilePath != "" && fuImage.Visible)
        {
            MediaUtility.DeleteImageFilePath("Banners", Settings.GetSetting(Settings.Keys.BANNER_HOME), 64, 64, 0);
            advertisement.FilePath = "";
        }

        DateTime fDate = DateTime.MinValue;
        DateTime tDate = DateTime.MinValue;

        DateTime.TryParse(txtFromDate.Text, out fDate);
        DateTime.TryParse(txtToDate.Text, out tDate);
        advertisement.FromDate = fDate;
        advertisement.ToDate   = tDate;
        advertisement.Href     = href.Text;

        advertisement.Save();


        if (IsNewMode)
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageCompanyCreated");
            string url            = @"EditAd.aspx?AdId=" + advertisement.Id;
            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
        else
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageAdSaved");

            Master.MessageCenter.DisplaySuccessMessage(successMessage);
            LoadView();
        }
    }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitle  = AdvertisementsStrings.GetText(@"AllAds");
     Master.ActiveMenu = "Advertisements";
     Master.AddClientScriptInclude(@"dgDateManager.js");
 }