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 JuSNS.Model;
using JuSNS.UI.Control;
namespace JuSNS.Web.system.sys
{
    public partial class AreaEdit : JuSNS.UI.Page.ManagePage
    {
        protected string sort = "sys";
        JuSNS.Home.User us = new JuSNS.Home.User();
        JuSNS.Home.Space sp = new JuSNS.Home.Space();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["Type"] == "Edit")
                {
                    UpdateArea();
                }
                else
                {
                    if (!IsPostBack)
                    {
                        this.txtID.Value = Request.QueryString["ID"];//地区编号
                        this.txtAreaName.Value = Request.QueryString["Name"];
                    }
                }
            }
            catch { }
        }

        #region 修改地区
        public void UpdateArea()
        {
            int n = us.UpdateAddArea(int.Parse(Request.QueryString["ID"]), 0, Request.QueryString["name"], 1);
            if (n == 1)
            {
                Response.Redirect("area.aspx");
            }
            else if (n == 2)
            {
                PageError("修改地区失败,地区名称已经存在!", "AreaList.aspx");
            }
            else
            {
                PageError("修改地区失败!", "AreaList.aspx");
            }
        }
        #endregion
    }
}
