Ejemplo n.º 1
0
    private void BindData()
    {
        ZNode.Libraries.Admin.StoreLocatorAdmin StoreBind = new StoreLocatorAdmin();

        ZNode.Libraries.DataAccess.Entities.Store StoreList = StoreBind.GetByStoreID(ItemID);

        if (StoreList != null)
        {
            Name = StoreList.Name;
        }
    }
Ejemplo n.º 2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        System.IO.FileInfo _FileInfo = null;
        ZNode.Libraries.Admin.StoreLocatorAdmin StoreLocatorAdmin = new StoreLocatorAdmin();
        ZNode.Libraries.DataAccess.Entities.Store store = new Store();
        if (ItemID > 0)
        {
            store = StoreLocatorAdmin.GetByStoreID(ItemID);
        }
        store.Name = txtstorename.Text;
        store.Address1 = txtaddress1.Text;
        store.Address2 = txtaddress2.Text;
        store.Address3 = txtaddress3.Text;
        store.City = txtcity.Text;
        store.State = txtstate.Text;
        store.Zip = txtzip.Text;
        store.Phone = txtphone.Text;
        store.Fax = txtfax.Text;
        store.ContactName = txtcname.Text;
        if (ListAccounts.SelectedItem.Text.Equals(""))
        {
            store.AccountID = null;
        }
        else
        {
            store.AccountID = Convert.ToInt32(ListAccounts.SelectedValue);
        }
        if (txtdisplayorder.Text != "")
        {
            store.DisplayOrder = Convert.ToInt32(txtdisplayorder.Text);
        }
        else
        {
            store.DisplayOrder = null;
        }

        store.ActiveInd = chkActiveInd.Checked;

        #region Image Validation

        if (RadioStoreNoImage.Checked == false)
        {
            //Validate image
            if ((ItemID == 0) || (RadioStoreNewImage.Checked == true))
            {
                if (UploadStoreImage.PostedFile.FileName != "")
                {
                    //Check for Store Image
                    _FileInfo = new System.IO.FileInfo(UploadStoreImage.PostedFile.FileName);

                    if (_FileInfo != null)
                    {
                        store.ImageFile = _FileInfo.Name;
                    }
                }
            }
            else
            {
                store.ImageFile = store.ImageFile;
            }
        }
        else
        {
            store.ImageFile = null;
        }

        #endregion

        //Upload File if this is a new Store or the New Image option was selected for an existing Store
        if (RadioStoreNewImage.Checked || ItemID == 0)
        {
            if (_FileInfo != null)
            {
                UploadStoreImage.SaveAs(Server.MapPath(ZNodeConfigManager.EnvironmentConfig.OriginalImagePath + _FileInfo.Name));

                ZNodeImage.ResizeImage(_FileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemLargeWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.LargeImagePath));
                ZNodeImage.ResizeImage(_FileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemThumbnailWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.ThumbnailImagePath));
                ZNodeImage.ResizeImage(_FileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemMediumWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.MediumImagePath));
                ZNodeImage.ResizeImage(_FileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSmallWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SmallImagePath));
            }
        }

        bool check = false;

        if (ItemID > 0)
        {
            check = StoreLocatorAdmin.UpdateStore(store);
        }
        else
        {
            check = StoreLocatorAdmin.InsertStore(store);
        }
        if (check)
        {
            Response.Redirect("List.aspx");
        }
        else
        {
            //display error message
            lblError.Text = "An error occurred while updating. Please try again.";
        }
    }