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

public partial class Admin_Message_AddMessage : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if(!IsPostBack)
        {
            this.AddTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            this.ReyTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            this.M_Ip.Text = "127.0.0.1";
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
      // int id = Convert.ToInt32(this.id.Text);
        string Title = this.Title.Text;
        string M_user = this.M_user.Text;
        string Contents = this.Contents.InnerText;
        string ReyContent = this.ReyContent.InnerText;
        string M_IP = this.M_Ip.Text;
        string AddTime = this.AddTime.Text;
        string ReyTime = this.ReyTime.Text;
       // string time = DateTime.Now.ToString("yyyy-MM-dd");

        int result;
        if (ISDatabase.SelectDatebase() == 1)
        {
            string sql = "insert into A_Message(Title,Contents,M_user,M_Ip,Rey_Contents,AddTime,ReyTime) values('" + Title + "','" + Contents + "','" + M_user + "','" + M_IP + "','" + ReyContent + "','" + AddTime + "','" + ReyTime + "')";
            result = DbHelp.ExecuteSql(sql);
        }
        else
        {
            string sql = "insert into A_Message(Title,Contents,M_user,M_Ip,Rey_Contents,AddTime,ReyTime) values('" + Title + "','" + Contents + "','" + M_user + "','" + M_IP + "','" + ReyContent + "',#" + AddTime + "#,#" + ReyTime + "#)";
            result = DbHelperOleDb.ExecuteSql(sql);
        }

        if (result > 0)
        {
            JavaScript.messageBox("保存成功", Page, "main.aspx");
        }
        else
        {
            string sb = "<script>$(function () { $.ligerDialog.alert(\"保存失败\", \"提示\",\"error\", function (result) { window.location.href ='main.aspx'; }); });</script>";
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "Messager", sb.ToString());
        }


    }
}