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

public partial class inClude_ueditor_net_imgTxt : System.Web.UI.Page
{
    admin a = new admin();
    sqlServer sql = new sqlServer();
    fileDocument f = new fileDocument();

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

        if (!IsPostBack)
        {
            long id = xabara.isNum(Request.QueryString["id"]);

            string strSql = "select fileName,fileContent from upFileName where Fid=" + id.ToString();
            DataTable dt = sql.getDataTable(strSql);
            if (dt.Rows.Count > 0)
            {
                img.ImageUrl = f.filePath(dt.Rows[0]["fileName"].ToString());
                txt.Text = CHAR.htmReturn(dt.Rows[0]["fileContent"].ToString());
            }
            else
            {
                Response.Redirect("img.aspx", true);
            }
            dt.Dispose();
        }
    }

    protected void postTxt_Click(object sender, EventArgs e)
    {
        long id = xabara.isNum(Request.QueryString["id"]);

        string[] strValue = new string[5];
        strValue[0] = CHAR.htmSafe(txt.Text);

        sql.update("upFileName", "@fileContent", strValue, " fid=" + id.ToString());

        Response.Redirect("img.aspx", true);
    }
}