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 webXabara_study_cerFlag : System.Web.UI.Page
{
    sqlServer sql = new sqlServer();
    classify c = new classify();
    webPublic wp = new webPublic();
    admin a = new admin();
    fileDocument f = new fileDocument();
    javasrcipt js = new javasrcipt();

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

        if (!IsPostBack)
        {
            regExpression reg = new regExpression();
            fromDateRegExpree.ValidationExpression = reg.dateTime;
            fromDateRegExpree.ErrorMessage = reg.dateTimeError;
            toDateRegExpree.ValidationExpression = reg.dateTime;
            toDateRegExpree.ErrorMessage = reg.dateTimeError;

            long id = xabara.isNum(Request["id"]);

            DataTable dt = sql.getDataTable("select * from cerPic where id=" + id.ToString());
            if (dt.Rows.Count > 0)
            {
                string img = dt.Rows[0]["picName"].ToString().Trim();
                pic.ImageUrl = f.picDisplay(img);

                userID.Text = dt.Rows[0]["postID"].ToString().Trim();
                fromDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                toDate.Text = DateTime.Now.AddYears(1).ToString("yyyy-MM-dd HH:mm:ss");
                payClass.Text = c.readClassName_Link(xabara.isNum(dt.Rows[0]["picType"].ToString().Trim()), string.Empty, string.Empty);
            }
            else
            {
                js.div(false, "", "text", "不存在此条信息！", 350, 150, "cer.aspx", "goto");
            }
            dt.Dispose();
        }
    }

    protected void edit_Click(object sender, EventArgs e)
    {
        string strDim = "@cerName,@fromDate,@toDate,@flagID,@adminID,@adminDate,@adminIP";
        string[] strVlaue = new string[7];
        strVlaue[0] = picName.Text;
        strVlaue[1] = fromDate.Text;
        strVlaue[2] = toDate.Text;
        strVlaue[3] = "1";
        strVlaue[4] = a.uid;
        strVlaue[5] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        strVlaue[6] = new ipAddress().address();

        string returnStr = sql.update("cerPic", strDim, strVlaue, "id=" + xabara.isNum(Request["id"].ToString().Trim()));
        js.div(false, "", "text", returnStr, 350, 150, "cer.aspx", "goto");
    }
}