📄 configweb.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Botheighten.Yanghui.BusinessFacade;
using Botheighten.Yanghui.Framework;
using Botheighten.Yanghui.BusinessRules;
namespace Botheighten.Yanghui.Web
{
/// <summary>
/// ConfigWeb 的摘要说明。
/// </summary>
public class ConfigWeb : BasePage
{
protected System.Web.UI.WebControls.Label lblTitle;
protected System.Web.UI.WebControls.TextBox txtId;
protected System.Web.UI.WebControls.TextBox txtCodeHide;
protected System.Web.UI.WebControls.Label lblCode;
protected System.Web.UI.WebControls.TextBox txtCode;
protected System.Web.UI.WebControls.RequiredFieldValidator reqId;
protected System.Web.UI.WebControls.ValidationSummary ErrorSummary;
protected System.Web.UI.WebControls.Button btnAdd;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox txtPrintCount;
protected System.Web.UI.WebControls.RangeValidator RangeValidator1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label lblIsFirst;
protected System.Web.UI.WebControls.Label lblMessage;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Principal p=this.CurrentUser();
this.CheckPermissionPage(p.Id,"Y","111");
this.lblMessage.Visible=false;
if(!Page.IsPostBack)
{
string isFirst="";
if(Request.QueryString["IsFirst"]!=null)
isFirst=Request.QueryString["IsFirst"].ToString();
this.ViewState["IsFirst"]=isFirst;
if(isFirst=="Y")
this.lblIsFirst.Text ="提示:本系统第一次启动,请进行系统设置";
else
{
this.lblIsFirst.Text="";
Config config=ConfigSystem.GetConfig();
if(config!=null)
{
this.txtCode.Text = config.CompanyName;
this.txtPrintCount.Text = config.PrintCount.ToString();
}
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
Response.Redirect("../../Welcome.aspx",true);
}
private void btnAdd_Click(object sender, System.EventArgs e)
{
string comName=this.txtCode.Text;
string count=this.txtPrintCount.Text;
Config config=ConfigSystem.GetConfig();
if(config==null)
{
config=new Config();
config.Id="1";
config.Author="";
config.IsFirst="N";
config.PrintCount=int.Parse(count);
config.CompanyName=comName;
config.UserDate=System.DateTime.Now.ToShortDateString();
}
else
{
config.CompanyName=comName;
config.PrintCount=int.Parse(count);
config.IsFirst="N";
}
try
{
config.Save();
Application["CompanyInfo"]=config.CompanyName;
Application["PageSize"]=config.PrintCount;
}
catch
{
this.lblMessage.Text="失败:系统设置时遇到错误";
this.lblMessage.Visible=true;
return;
}
this.lblMessage.Text="成功:系统设置成功";
this.lblMessage.Visible=true;
if(this.ViewState["IsFirst"].ToString()=="Y")
{
Response.Redirect("../../Welcome.aspx");
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -