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 System.Data.SqlClient;

public partial class promise : System.Web.UI.Page
{
    DataBaseLayer db = new DataBaseLayer();
    public int count;
    protected void Page_Load(object sender, EventArgs e)
    {
            count=db.ReturnExecuteNonQuery("Pr_Mp4_CountPromise");
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        if (Contents.Text.Trim() != "" && Author.Text.Trim() != "")
        {
            if (Contents.Text.Length <= 500)
            {
                SqlParameter[] prams ={
                    db.ParamBuilder("@Contents",Contents.Text.Trim(),SqlDbType.VarChar),
                    db.ParamBuilder("@Author",Author.Text.Trim(),SqlDbType.VarChar),
                    db.ParamBuilder("@UpdateTime",DateTime.Now,SqlDbType.DateTime)
                 };
                try
                {
                    db.ExecuteNonQuery("Pr_Mp4_Promise", prams);
                    Response.Write("<script>alert(\"许愿成功了，愿梦想成真！\")</script>");
                    Contents.Text = "";
                    Author.Text = "";
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message, ex);
                    //Response.Write("<script>alert(\"请重新许愿！\")</script>");
                }
            }
            else
            {
                Response.Write("<script>alert(\"许愿要在500字以内哦！\")</script>");
            }
        }
        else
        {
            Response.Write("<script>alert(\"请填写许愿内容和昵称！\")</script>");
        }
    }
}
