using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using xabaraCOM;

public partial class WebXabara_Link_add : System.Web.UI.Page
{
    admin a = new admin();
    classify c = new classify();
    javasrcipt js = new javasrcipt();
    fileDocument f = new fileDocument();

    protected void Page_Load(object sender, EventArgs e)
    {
        a.check("|link|");

        if (!IsPostBack)
        {
            c.bindingDropDownList("all", true, 0, "link", linkList);

            regExpression reg = new regExpression();
            RegHttp.ValidationExpression = reg.urlHttp;
            RegHttp.ErrorMessage = reg.urlHttpError;
        }
    }

    protected void addLink_Click(object sender, EventArgs e)
    {
        string[] strValue = new string[8];

        string uploadFileStr = f.upload(imgUpload, "Img", false);   //原图片

        string newFile = string.Empty;
        if (uploadFileStr.Equals("上传成功"))
        {
            newFile = Session["NewFile"].ToString().Trim();
        }

        sqlServer sql = new sqlServer();
        if (sql.getDataTable("select * from linkXabara where linkURL='" + linkHttp.Text.Trim() + "'").Rows.Count > 0)
        {
            js.div(false, "", "text", "已存在该用户的友情链接！", 350, 150, "default.aspx", "goto");
        }
        else
        {
            string strDim = "@classID,@uploadFile,@linkName,@linkURL,@AdminID,@postDate,@postIP,@listID";
            strValue[0] = linkList.Text.Trim();
            strValue[1] = newFile;
            strValue[2] = linkName.Text.Trim();
            strValue[3] = linkHttp.Text.Trim();
            strValue[4] = a.uid;
            strValue[5] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            strValue[6] = new ipAddress().address();
            strValue[7] = "0";

            sql.log(a.uid, "admin", "添加链接：" + linkName.Text.Trim());
            string returnStr = sql.add("linkXabara", strDim, strValue);
            js.div(false, "", "text", returnStr + "！", 350, 150, "default.aspx", "goto");
        }
    }
}
