using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Links;
using Base;

public partial class admin_Links_LinksEdit :Base.BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CheckRights("Basic", "C1");
        if (!IsPostBack)
        {
            Bind();
        }
    }
    private void Bind()
    {
        int id=0;
        if(Request.QueryString["ID"].ToString()!=null)
        id = int.Parse(Request.QueryString["ID"].ToString());
        ILinks RLink=new RLinks();
        TLinks TLink =RLink.GateItem(id);
        if (TLink.LinkType == 1)
        {
            radLinkType.Checked = true;
            ImgUrl1.Value = TLink.WebLOGO;
            ImgUrl.Src = TLink.WebLOGO;
        }
        else
        {
            radLinkType1.Checked = true;
            logo.Style.Add("display", "none");
        }
        txtWebName.Text = TLink.WebName;
        txtWebURL.Text = TLink.WebURL;
        txtWebIntro.Text = TLink.WebIntro;
        txtWebAdmin.Text = TLink.WebAdmin;
        txtEmail.Text = TLink.Email;
        txtSequence.Text = TLink.Sequence;
   
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            int id = 0;
            if (Request.QueryString["ID"].ToString() != null)
                id = int.Parse(Request.QueryString["ID"].ToString());
            TLinks TLink = new TLinks();
            TLink.ID = id;
            if (radLinkType.Checked == true)
            {
                TLink.LinkType = int.Parse(radLinkType.Value);
                TLink.WebLOGO = ImgUrl1.Value;
            }
            else
            {
                TLink.LinkType = int.Parse(radLinkType1.Value);
                TLink.WebLOGO = "../../Images/System/wutu.gif";
            }
         
            TLink.WebName = txtWebName.Text;
            TLink.WebURL = txtWebURL.Text;
            if (radLinkType.Checked == true)
            {
                
                TLink.WebLOGO = ImgUrl1.Value;
            }

            TLink.WebIntro = txtWebIntro.Text;
            TLink.WebAdmin = txtWebAdmin.Text;
            TLink.Email = txtEmail.Text;
            TLink.Sequence = txtSequence.Text;
            ILinks RLink = new RLinks();
            RLink.Update(TLink);
            ShowMessage("友情链接修改成功！","Links/LinksManage.aspx");
        }
        catch (Exception ex)
        {

            ShowMessage("友情链接修改失败！", "Links/LinksManage.aspx");
        }
    }
    protected void btnBack_Click(object sender, EventArgs e)
    {
        Response.Write("<script language=javascript>window.location.href='LinksManage.aspx'</script>");
    }
}
