public void SaveBannerContent(SageBannerInfo obj)
        {
            try
            {
                List<KeyValuePair<string, object>> param = new List<KeyValuePair<string, object>>();
                param.Add(new KeyValuePair<string, object>("@Caption", obj.Caption));
                param.Add(new KeyValuePair<string, object>("@ImagePath", obj.ImagePath));
                param.Add(new KeyValuePair<string, object>("@ReadMorePage", obj.ReadMorePage));
                param.Add(new KeyValuePair<string, object>("@LinkToImage", obj.LinkToImage));
                param.Add(new KeyValuePair<string, object>("@UserModuleID", obj.UserModuleID));
                param.Add(new KeyValuePair<string, object>("@BannerID", obj.BannerID));
                param.Add(new KeyValuePair<string, object>("@ImageID", obj.ImageID));
                param.Add(new KeyValuePair<string, object>("@ReadButtonText", obj.ReadButtonText));
                param.Add(new KeyValuePair<string, object>("@NavigationImage", obj.NavigationImage));
                param.Add(new KeyValuePair<string, object>("@Description", obj.Description));
                param.Add(new KeyValuePair<string, object>("@PortalID", obj.PortalID));
                param.Add(new KeyValuePair<string, object>("@CultureCode", obj.CultureCode));
                SQLHandler sagesql = new SQLHandler();
                sagesql.ExecuteNonQuery("usp_SageBannerSaveBannerContent", param);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
        public void SaveBannerInformation(SageBannerInfo objB)
        {
            try
            {
                List<KeyValuePair<string, object>> para = new List<KeyValuePair<string, object>>();
                para.Add(new KeyValuePair<string, object>("@BannerName", objB.BannerName));
                para.Add(new KeyValuePair<string, object>("@BannerDescription", objB.BannerDescription));
                para.Add(new KeyValuePair<string, object>("@UserModuleID", objB.UserModuleID));
                para.Add(new KeyValuePair<string, object>("@PortalID", objB.PortalID));
                para.Add(new KeyValuePair<string, object>("@CultureCode", objB.CultureCode));
                SQLHandler sagesql = new SQLHandler();
                sagesql.ExecuteNonQuery("usp_SageBannerSaveBannerInformation", para);
            }
            catch (Exception ex)
            {
                throw ex;
            }


        }
 private void EditHTMLContentByID(int ImageId)
 {
     try
     {
         imgEditNavImage.Visible = true;
         SageBannerInfo objEHtmlContent = new SageBannerInfo();
         SageBannerController objHTMl = new SageBannerController();
         objEHtmlContent = objHTMl.GetHTMLContentForEditByID(ImageId);
         txtBody.Text = objEHtmlContent.HTMLBodyText;
         imgEditNavImage.ImageUrl = modulePath + "images/ThumbNail/" + objEHtmlContent.NavigationImage;
         Session["NavigationImage"] = objEHtmlContent.NavigationImage;
         divHtmlBannerContainer.Attributes.Add("style", "display:none");
         divEditWrapper.Attributes.Add("style", "display:block");
         int BannerId = Convert.ToInt32(ViewState["EditBannerID"]);
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        public List<SageBannerInfo> LoadBannerOnDropDown(int UserModuleID, int PortalID,string CultureCode)
        {
            SqlDataReader Reader = null;
            try
            {
                List<KeyValuePair<string, object>> Parameter = new List<KeyValuePair<string, object>>();
                Parameter.Add(new KeyValuePair<string, object>("@UserModuleID", UserModuleID));
                Parameter.Add(new KeyValuePair<string, object>("@PortalID", PortalID));
                Parameter.Add(new KeyValuePair<string, object>("@CultureCode", CultureCode));
                SQLHandler sqlH = new SQLHandler();

                Reader = sqlH.ExecuteAsDataReader("usp_SageBannerGetAllBanner", Parameter);
                List<SageBannerInfo> BannerListForDropDown = new List<SageBannerInfo>();
                while (Reader.Read())
                {
                    SageBannerInfo obj = new SageBannerInfo();
                    obj.BannerID = Convert.ToInt32(Reader["BannerID"]);
                    obj.BannerName = Convert.ToString(Reader["BannerName"]);
                    BannerListForDropDown.Add(obj);
                }
                return BannerListForDropDown;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (Reader != null)
                {
                    Reader.Close();
                }
            }


        }
 private void EditImageByImageID(int ImageId)
 {
     SageBannerInfo obj = new SageBannerInfo();
     SageBannerController objcnt = new SageBannerController();
     obj = objcnt.GetImageInformationByID(ImageId);
     _imageEditor.ImageUrl = modulePath + "images/OriginalImage/" + obj.ImagePath;
     divImageEditor.Attributes.Add("style", "display:block");
     ViewState["ImageToBeEdit"] = obj.ImagePath;
 }
 private void BannerEditByImageID(int ImageId)
 {
     int BannerId = Convert.ToInt32(ViewState["EditBannerID"]);
     SageBannerInfo objEd = new SageBannerInfo();
     SageBannerController objEc = new SageBannerController();
     objEd = objEc.GetImageInformationByID(ImageId);
     txtCaption.Text = objEd.Caption;
     if (objEd.LinkToImage != null && objEd.LinkToImage != string.Empty)
     {
         rdbReadMorePageType.SelectedValue = "1";
         txtWebUrl.Text = objEd.LinkToImage;
         WebUrl = 1;
     }
     else if (objEd.ReadMorePage != null)
     {
         ddlPagesLoad.SelectedIndex = ddlPagesLoad.Items.IndexOf(ddlPagesLoad.Items.FindByValue(objEd.ReadMorePage));
         WebUrl = 0;
     }
     txtReadButtonText.Text = objEd.ReadButtonText;
     Session["ImageName"] = objEd.ImagePath;
     imgEditBannerImageImage.ImageUrl = modulePath + "images/Thumbnail/Large/" + objEd.ImagePath;
     txtBannerDescriptionToBeShown.Text = objEd.Description;
     imgEditBannerImageImage.Visible = true;
     divbannerImageContainer.Attributes.Add("style", "display:none");
     divEditBannerImage.Attributes.Add("style", "display:block");
     LoadBannerImagesOnGrid(BannerId, Int32.Parse(SageUserModuleID), GetPortalID);
     Session["EditImageID"] = ImageId;
 }
    private void SaveBannerInformation()
    {
        try
        {
            SageBannerInfo obj = new SageBannerInfo();
            obj.BannerName = txtBannerName.Text.Trim();
            obj.BannerDescription = txtBannerDescription.Text;
            obj.UserModuleID = Int32.Parse(SageUserModuleID);
            obj.PortalID = GetPortalID;
            obj.CultureCode = GetCurrentCulture();
            SageBannerController objBcon = new SageBannerController();
            objBcon.SaveBannerInformation(obj);
            LoadBannerListOnGrid(GetPortalID, Int32.Parse(SageUserModuleID), GetCurrentCulture());
        }
        catch (Exception ex)
        {
            ProcessException(ex);
        }

    }
    private void SaveBannerContent(int BannerId, int ImageId)
    {
        try
        {
            string fName = fuFileUpload.FileName;
            if (SageFrame.Web.PictureManager.ValidImageExtension(fName))
            {

                //bool isEdit = false;
                SageBannerInfo obj = new SageBannerInfo();
                if (Session["EditImageID"] != null && Session["EditImageID"].ToString() != string.Empty)
                {
                    obj.ImageID = Int32.Parse(Session["EditImageID"].ToString());
                    if (fuFileUpload.HasFile)
                    {
                        obj.ImagePath = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                        obj.NavigationImage = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                    }
                    else
                    {
                       // isEdit = true;
                        obj.ImagePath = Convert.ToString(Session["ImageName"]);
                        obj.NavigationImage = Convert.ToString(Session["ImageName"]);
                    }
                }
                else
                {
                    obj.ImageID = 0;
                    obj.ImagePath = fuFileUpload.FileName.Replace(" ", "_");
                    obj.NavigationImage = fuFileUpload.FileName.Replace(" ", "_");
                }
                obj.Caption = string.Empty;
                if (rdbReadMorePageType.SelectedItem.Text == "Page")
                {
                    obj.ReadMorePage = ddlPagesLoad.SelectedValue.ToString();
                    obj.LinkToImage = string.Empty;
                }
                if (rdbReadMorePageType.SelectedItem.Text == "Web Url")
                {
                    obj.LinkToImage = txtWebUrl.Text;
                    obj.ReadMorePage = string.Empty;
                }
                obj.UserModuleID = Int32.Parse(SageUserModuleID);
                obj.BannerID = BannerId;
                obj.ImageID = ImageId;
                obj.ReadButtonText = txtReadButtonText.Text;
                obj.Description = txtBannerDescriptionToBeShown.Text.Trim();
                obj.PortalID = GetPortalID;
                obj.CultureCode = GetCurrentCulture();
                string swfExt = System.IO.Path.GetExtension(fuFileUpload.PostedFile.FileName);
                if (swfExt == ".swf")
                {
                    if (fuFileUpload.FileContent.Length > 0)
                    {
                        string Path = GetUplaodImagePhysicalPath();
                        string fileName = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                        DirectoryInfo dirUploadImage = new DirectoryInfo(Path);
                        if (dirUploadImage.Exists == false)
                        {
                            dirUploadImage.Create();
                        }
                        string fileUrl = Path + fileName;
                        int i = 1;
                        while (File.Exists(fileUrl))
                        {

                            fileName = i + fileName;
                            fileUrl = Path + i + fileName;
                            i++;
                        }
                        fuFileUpload.PostedFile.SaveAs(fileUrl);
                        swfFileName = "Modules/Sage_Banner/images/" + fileName;
                        obj.ImagePath = fileName;
                        obj.NavigationImage = fileName;
                    }
                }
                else
                {
                    string target = Server.MapPath("~/Modules/Sage_Banner/images/OriginalImage/");
                    string thumbLarge = Server.MapPath("~/Modules/Sage_Banner/images/ThumbNail/Large/");
                    string thumbMedium = Server.MapPath("~/Modules/Sage_Banner/images/ThumbNail/Medium/");
                    string thumbSmall = Server.MapPath("~/Modules/Sage_Banner/images/ThumbNail/Small/");
                    string defaultImage = Server.MapPath("~/Modules/Sage_Banner/images/ThumbNail/Default/");
                    //System.Drawing.Image.GetThumbnailImageAbort thumbnailImageAbortDelegate = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                    if (fuFileUpload.HasFile)
                    {
                        string fileName = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                        int i = 1;
                        while (File.Exists(target + "/" + fileName))
                        {
                            fileName = i + fileName;
                            i++;
                        }
                        fuFileUpload.SaveAs(Path.Combine(target, fileName));
                        fuFileUpload.SaveAs(Path.Combine(defaultImage, fileName));
                        string SourcePath = target + fileName;
                         //Resize Banner Images using Image Resizer
                        InterceptImageController.ResizeBannerImage(SourcePath, 320, thumbSmall, fileName);
                        InterceptImageController.ResizeBannerImage(SourcePath, 768, thumbMedium, fileName);
                        InterceptImageController.ResizeBannerImage(SourcePath, 965, thumbLarge, fileName);
                        obj.ImagePath = fileName;
                        obj.NavigationImage = fileName;
                    }
                }
                SageBannerController objcont = new SageBannerController();
                objcont.SaveBannerContent(obj);
                int userModuleID = Int32.Parse(SageUserModuleID);
                BannerCacheClear();
                ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/Sage_Banner/ModuleLocalText", "BannerSavedsuccesfully"), "", SageMessageType.Success);
            }
            else
            {
                ShowMessage("Invalid File Extension", "Invalid File Extension", "The File you want to upload is invalid", SageMessageType.Error);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        
        Session["ImageName"] = null;
        Session["EditImageID"] = null;
    }
 /// <summary>
 /// Saves banner information.
 /// </summary>
 /// <param name="objB">SageBannerInfo object</param>
 public void SaveBannerInformation(SageBannerInfo objB)
 {
     SageBannerProvider objBP = new SageBannerProvider();
     objBP.SaveBannerInformation(objB);
 }
 /// <summary>
 /// Saves banner content.
 /// </summary>
 /// <param name="obj">SageBannerInfo object.</param>
 public void SaveBannerContent(SageBannerInfo obj)
 {
     SageBannerProvider objpro = new SageBannerProvider();
     objpro.SaveBannerContent(obj);
 }
    private void SaveBannerContent(int BannerId, int ImageId)
    {
        try
        {
            bool isEdit = false;
            SageBannerInfo obj = new SageBannerInfo();
            if (Session["EditImageID"] != null && Session["EditImageID"].ToString() != string.Empty)
            {
                obj.ImageID = Int32.Parse(Session["EditImageID"].ToString());
                if (fuFileUpload.HasFile)
                {
                    obj.ImagePath = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                    obj.NavigationImage = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                }
                else
                {
                    isEdit = true;
                    obj.ImagePath = Convert.ToString(Session["ImageName"]);
                    obj.NavigationImage = Convert.ToString(Session["ImageName"]);
                }
            }
            else
            {
                obj.ImageID = 0;
                obj.ImagePath = fuFileUpload.FileName.Replace(" ", "_");
                obj.NavigationImage = fuFileUpload.FileName.Replace(" ", "_");
            }
            obj.Caption = string.Empty;
            if (rdbReadMorePageType.SelectedItem.Text == "Page")
            {
                obj.ReadMorePage = ddlPagesLoad.SelectedValue.ToString();
                obj.LinkToImage = string.Empty;
            }
            if (rdbReadMorePageType.SelectedItem.Text == "Web Url")
            {
                obj.LinkToImage = txtWebUrl.Text;
                obj.ReadMorePage = string.Empty;
            }
            obj.UserModuleID = Int32.Parse(SageUserModuleID);
            obj.BannerID = BannerId;
            obj.ImageID = ImageId;
            obj.ReadButtonText = txtReadButtonText.Text;
            obj.Description = txtBannerDescriptionToBeShown.Text.Trim();
            obj.PortalID = GetPortalID;
            obj.CultureCode = GetCurrentCulture();
            string swfExt = System.IO.Path.GetExtension(fuFileUpload.PostedFile.FileName);
            if (swfExt == ".swf")
            {
                if (fuFileUpload.FileContent.Length > 0)
                {
                    string Path = GetUplaodImagePhysicalPath();
                    string fileName = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                    DirectoryInfo dirUploadImage = new DirectoryInfo(Path);
                    if (dirUploadImage.Exists == false)
                    {
                        dirUploadImage.Create();
                    }
                    string fileUrl = Path + fileName;
                    int i = 1;
                    while (File.Exists(fileUrl))
                    {

                        fileName = i + fileName;
                        fileUrl = Path + i + fileName;
                        i++;
                    }
                    fuFileUpload.PostedFile.SaveAs(fileUrl);
                    swfFileName = "Modules/Sage_Banner/images/" + fileName;
                    obj.ImagePath = fileName;
                    obj.NavigationImage = fileName;
                }
            }
            else
            {
                string target = Server.MapPath("~/Modules/Sage_Banner/images/OriginalImage");
                string CropImageTarget = Server.MapPath("~/Modules/Sage_banner/images/CroppedImages");
                string thumbTarget = Server.MapPath("~/Modules/Sage_Banner/images/ThumbNail");
                System.Drawing.Image.GetThumbnailImageAbort thumbnailImageAbortDelegate = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
                if (fuFileUpload.HasFile)
                {
                    string fileName = fuFileUpload.PostedFile.FileName.Replace(" ", "_");
                    int i = 1;
                    while (File.Exists(target + "/" + fileName))
                    {
                        fileName = i + fileName;
                        i++;
                    }
                    fuFileUpload.SaveAs(Path.Combine(target, fileName));
                    fuFileUpload.SaveAs(Path.Combine(CropImageTarget, fileName));
                    using (Bitmap originalImage = new Bitmap(fuFileUpload.PostedFile.InputStream))
                    {
                        using (System.Drawing.Image thumbnail = originalImage.GetThumbnailImage(80, 80, thumbnailImageAbortDelegate, IntPtr.Zero))
                        {
                            thumbnail.Save(Path.Combine(thumbTarget, fileName));
                        }
                    }
                    obj.ImagePath = fileName;
                    obj.NavigationImage = fileName;
                }
            }

            SageBannerController objcont = new SageBannerController();
            objcont.SaveBannerContent(obj);
            int userModuleID = Int32.Parse(SageUserModuleID);
            BannerCacheClear();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/Sage_Banner/ModuleLocalText", "BannerSavedsuccesfully"), "", SageMessageType.Success);
        Session["ImageName"] = null;
        Session["EditImageID"] = null;
    }