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;

public partial class N38_SystemConfig : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            N38_Config myConfig = new N38_Config();
            if (myConfig.ExitConfig())
            {
                myConfig.GetConfigData(tbteaamount, tbteaday, tbstuamount, tbstuday);
            }
        }
    }
    protected void ibtnok_Click(object sender, ImageClickEventArgs e)
    {
        int stuamount = int.Parse(tbstuamount.Text.Trim());
        int studay = int.Parse(tbstuday.Text.Trim());
        int teaamount = int.Parse(tbteaamount.Text.Trim());
        int teaday = int.Parse(tbteaday.Text.Trim());
        N38_Config myConfig = new N38_Config();
        if (myConfig.ExitConfig())
        {
            bool result = myConfig.UpdateConfig(teaamount, teaday, stuamount, studay);
            if (result)
            {
                Response.Write("<script>alert('修改配置成功')</script>");
                myConfig.GetConfigData(tbteaamount, tbteaday, tbstuamount, tbstuday);
            }
            else
            {
                Response.Write("<script>alert('修改配置失败')</script>");
            }
        }
        else
        {
            bool result = myConfig.InsertConfig(teaamount, teaday, stuamount, studay);
            if (result)
            {
                Response.Write("<script>alert('添加配置成功')</script>");
                myConfig.GetConfigData(tbteaamount, tbteaday, tbstuamount, tbstuday);
            }
            else
            {
                Response.Write("<script>alert('添加配置失败')</script>");
            }
        }
    }
}
