コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     btnSubmitLinks.Click += new EventHandler(btnSubmitLinks_Click);
     btnPicDelete.Click   += new EventHandler(btnPicDelete_Click);
     if (!int.TryParse(base.Request.QueryString["linkId"], out linkId))
     {
         base.GotoResourceNotFound();
     }
     else if (!base.IsPostBack)
     {
         FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);
         if (friendlyLink == null)
         {
             base.GotoResourceNotFound();
         }
         else
         {
             txtaddTitle.Text             = Globals.HtmlDecode(friendlyLink.Title);
             txtaddLinkUrl.Text           = friendlyLink.LinkUrl;
             radioShowLinks.SelectedValue = friendlyLink.Visible;
             imgPic.ImageUrl      = friendlyLink.ImageUrl;
             btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl);
             imgPic.Visible       = !string.IsNullOrEmpty(imgPic.ImageUrl);
         }
     }
 }
コード例 #2
0
        private void btnSubmitLinks_Click(object sender, System.EventArgs e)
        {
            string text = string.Empty;

            if (this.uploadImageUrl.HasFile)
            {
                try
                {
                    text = SubsiteStoreHelper.UploadLinkImage(this.uploadImageUrl.PostedFile);
                }
                catch
                {
                    this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                    return;
                }
            }
            FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(this.linkId);

            friendlyLink.ImageUrl = (this.uploadImageUrl.HasFile ? text : friendlyLink.ImageUrl);
            friendlyLink.LinkUrl  = this.txtaddLinkUrl.Text;
            friendlyLink.Title    = Globals.HtmlEncode(this.txtaddTitle.Text.Trim());
            friendlyLink.Visible  = this.radioShowLinks.SelectedValue;
            if (string.IsNullOrEmpty(friendlyLink.ImageUrl) && string.IsNullOrEmpty(friendlyLink.Title))
            {
                this.ShowMsg("友情链接Logo和网站名称不能同时为空", false);
            }
            else
            {
                ValidationResults validationResults = Validation.Validate <FriendlyLinksInfo>(friendlyLink, new string[]
                {
                    "ValFriendlyLinksInfo"
                });
                string text2 = string.Empty;
                if (!validationResults.IsValid)
                {
                    foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                    {
                        text2 += Formatter.FormatErrorMessage(current.Message);
                    }
                    this.ShowMsg(text2, false);
                    return;
                }
                this.UpdateFriendlyLink(friendlyLink);
                return;
            }
        }
コード例 #3
0
ファイル: MyFriendlyLinks.cs プロジェクト: uvbs/eshopSanQiang
        private void grdGroupList_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int rowIndex = ((System.Web.UI.WebControls.GridViewRow)((System.Web.UI.Control)e.CommandSource).NamingContainer).RowIndex;
            int linkId   = (int)this.grdGroupList.DataKeys[rowIndex].Value;

            if (e.CommandName == "SetYesOrNo")
            {
                FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);
                if (friendlyLink.Visible)
                {
                    friendlyLink.Visible = false;
                }
                else
                {
                    friendlyLink.Visible = true;
                }
                SubsiteStoreHelper.UpdateFriendlyLink(friendlyLink);
                this.BindFriendlyLinks();
                return;
            }
            int displaySequence        = int.Parse((this.grdGroupList.Rows[rowIndex].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
            int num                    = 0;
            int replaceDisplaySequence = 0;

            if (e.CommandName == "Fall")
            {
                if (rowIndex < this.grdGroupList.Rows.Count - 1)
                {
                    num = (int)this.grdGroupList.DataKeys[rowIndex + 1].Value;
                    replaceDisplaySequence = int.Parse((this.grdGroupList.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
                }
            }
            else
            {
                if (e.CommandName == "Rise" && rowIndex > 0)
                {
                    num = (int)this.grdGroupList.DataKeys[rowIndex - 1].Value;
                    replaceDisplaySequence = int.Parse((this.grdGroupList.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as System.Web.UI.WebControls.Literal).Text);
                }
            }
            if (num > 0)
            {
                SubsiteStoreHelper.SwapFriendlyLinkSequence(linkId, num, displaySequence, replaceDisplaySequence);
                this.BindFriendlyLinks();
            }
        }
コード例 #4
0
        private void btnPicDelete_Click(object sender, EventArgs e)
        {
            FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);

            try
            {
                SubsiteStoreHelper.DeleteImage(friendlyLink.ImageUrl);
            }
            catch
            {
            }
            friendlyLink.ImageUrl = imgPic.ImageUrl = string.Empty;
            if (SubsiteStoreHelper.UpdateFriendlyLink(friendlyLink))
            {
                btnPicDelete.Visible = !string.IsNullOrEmpty(imgPic.ImageUrl);
                imgPic.Visible       = !string.IsNullOrEmpty(imgPic.ImageUrl);
            }
        }
コード例 #5
0
        private void grdGroupList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex;
            int linkId   = (int)grdGroupList.DataKeys[rowIndex].Value;

            if (e.CommandName == "SetYesOrNo")
            {
                FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);
                if (friendlyLink.Visible)
                {
                    friendlyLink.Visible = false;
                }
                else
                {
                    friendlyLink.Visible = true;
                }
                SubsiteStoreHelper.UpdateFriendlyLink(friendlyLink);
                BindFriendlyLinks();
            }
            else
            {
                int displaySequence        = int.Parse((grdGroupList.Rows[rowIndex].FindControl("lblDisplaySequence") as Literal).Text);
                int replaceLinkId          = 0;
                int replaceDisplaySequence = 0;
                if (e.CommandName == "Fall")
                {
                    if (rowIndex < (grdGroupList.Rows.Count - 1))
                    {
                        replaceLinkId          = (int)grdGroupList.DataKeys[rowIndex + 1].Value;
                        replaceDisplaySequence = int.Parse((grdGroupList.Rows[rowIndex + 1].FindControl("lblDisplaySequence") as Literal).Text);
                    }
                }
                else if ((e.CommandName == "Rise") && (rowIndex > 0))
                {
                    replaceLinkId          = (int)grdGroupList.DataKeys[rowIndex - 1].Value;
                    replaceDisplaySequence = int.Parse((grdGroupList.Rows[rowIndex - 1].FindControl("lblDisplaySequence") as Literal).Text);
                }
                if (replaceLinkId > 0)
                {
                    SubsiteStoreHelper.SwapFriendlyLinkSequence(linkId, replaceLinkId, displaySequence, replaceDisplaySequence);
                    BindFriendlyLinks();
                }
            }
        }
コード例 #6
0
        private void btnSubmitLinks_Click(object sender, EventArgs e)
        {
            string str = string.Empty;

            if (uploadImageUrl.HasFile)
            {
                try
                {
                    str = SubsiteStoreHelper.UploadLinkImage(uploadImageUrl.PostedFile);
                }
                catch
                {
                    ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
                    return;
                }
            }
            FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);

            friendlyLink.ImageUrl = uploadImageUrl.HasFile ? str : friendlyLink.ImageUrl;
            friendlyLink.LinkUrl  = txtaddLinkUrl.Text;
            friendlyLink.Title    = Globals.HtmlEncode(txtaddTitle.Text.Trim());
            friendlyLink.Visible  = radioShowLinks.SelectedValue;
            if (!string.IsNullOrEmpty(friendlyLink.ImageUrl) || !string.IsNullOrEmpty(friendlyLink.Title))
            {
                ValidationResults results = Hishop.Components.Validation.Validation.Validate <FriendlyLinksInfo>(friendlyLink, new string[] { "ValFriendlyLinksInfo" });
                string            msg     = string.Empty;
                if (!results.IsValid)
                {
                    foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                    {
                        msg = msg + Formatter.FormatErrorMessage(result.Message);
                    }
                    ShowMsg(msg, false);
                }
                else
                {
                    UpdateFriendlyLink(friendlyLink);
                }
            }
            else
            {
                ShowMsg("友情链接Logo和网站名称不能同时为空", false);
            }
        }
コード例 #7
0
ファイル: MyFriendlyLinks.cs プロジェクト: uvbs/eshopSanQiang
        private void grdGroupList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            int linkId = (int)this.grdGroupList.DataKeys[e.RowIndex].Value;
            FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);

            if (SubsiteStoreHelper.FriendlyLinkDelete(linkId) > 0)
            {
                try
                {
                    SubsiteStoreHelper.DeleteImage(friendlyLink.ImageUrl);
                }
                catch
                {
                }
                this.BindFriendlyLinks();
                this.ShowMsg("成功删除了选择的友情链接", true);
                return;
            }
            this.ShowMsg("未知错误", false);
        }
コード例 #8
0
        private void grdGroupList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int linkId = (int)grdGroupList.DataKeys[e.RowIndex].Value;
            FriendlyLinksInfo friendlyLink = SubsiteStoreHelper.GetFriendlyLink(linkId);

            if (SubsiteStoreHelper.FriendlyLinkDelete(linkId) > 0)
            {
                try
                {
                    SubsiteStoreHelper.DeleteImage(friendlyLink.ImageUrl);
                }
                catch
                {
                }
                BindFriendlyLinks();
                ShowMsg("成功删除了选择的友情链接", true);
            }
            else
            {
                ShowMsg("未知错误", false);
            }
        }