using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using JuSNS.ApiInterface;
using JuSNS.Model.ApiInterface;
using JuSNS.Common;

namespace JuSNS.Web.system.app
{
    public partial class toadmin : JuSNS.UI.Page.UserPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int appid = 0;
                string aid = Request.QueryString["id"];
                if (JuSNS.Common.Input.IsInteger(aid))
                {
                    appid = Convert.ToInt32(aid);
                    this.appID.Value = appid.ToString();
                    JuSNS.Model.ApiInterface.AppInfo apmdl = new JuSNS.Model.ApiInterface.AppInfo();
                    apmdl = App.GetAppInfo(appid);
                    this.TXTName.Text = apmdl.AppName;
                    if (apmdl.ToAdmin == 1)
                    {
                        PageError("此应用软件已经提交给管理员了。", rooDir + "/dev", true);
                    }
                }
                else
                {
                    PageError("错误的参数", rooDir + "/dev", true);
                }
            }
        }

        protected void submit_click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                AppInfo info = App.GetAppInfo(Convert.ToInt32(this.appID.Value));
                info.AppID = Convert.ToInt32(this.appID.Value);
                info.AppName = this.TXTName.Text;
                info.ToAdmin = 1;
                info.Mobile = this.TXTMobile.Text;
                info.Tel = this.TXTTel.Text;
                info.Email = this.TXTEmal.Text;
                JuSNS.ApiInterface.Developer.EditAppAdmin(info);
                PageRight("提交应用软件给管理员成功！", rooDir + "/dev");
            }
        }
    }
}
