📄 regions.cs
字号:
namespace PowerEasy.WebSite.Admin.Accessories
{
using PowerEasy.Accessories;
using PowerEasy.Controls;
using PowerEasy.Model.Accessories;
using PowerEasy.Web.UI;
using System;
using System.Web.UI.WebControls;
public class Regions : AdminPage
{
protected AlternateLiteral AltrTitle;
protected Button BtnSave;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtArea;
protected TextBox TxtAreaCode;
protected TextBox TxtCity;
protected TextBox TxtCountry;
protected TextBox TxtPostCode;
protected TextBox TxtProvince;
protected RegularExpressionValidator ValeAreaCode;
protected PowerEasy.Controls.RequiredFieldValidator ValrAreaCode;
protected PowerEasy.Controls.RequiredFieldValidator ValrCountry;
protected PowerEasy.Controls.RequiredFieldValidator ValrPostCode;
protected PowerEasy.Controls.RequiredFieldValidator ValrProvince;
protected ZipCodeValidator Vzip;
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
RegionInfo info;
bool flag = false;
string area = this.TxtArea.Text.Trim();
string province = this.TxtProvince.Text.Trim();
string city = this.TxtCity.Text.Trim();
if (BasePage.RequestString("Action") == "Modify")
{
info = this.ViewState["Info"] as RegionInfo;
if ((((info.Area != area) || (info.Province != province)) || (info.City != city)) && Region.AreaExists(area, province, city))
{
AdminPage.WriteErrMsg("已存在该区域,请重新输入!");
}
}
else
{
info = new RegionInfo();
}
info.Country = this.TxtCountry.Text.Trim();
info.Province = province;
info.City = city;
info.Area = area;
info.PostCode = this.TxtPostCode.Text.Trim();
info.AreaCode = this.TxtAreaCode.Text.Trim();
if (BasePage.RequestString("Action") == "Modify")
{
flag = Region.Update(info);
}
else if (Region.AreaExists(area, province, city))
{
AdminPage.WriteErrMsg("已存在该区域,请重新输入!");
}
else
{
flag = Region.Add(info);
}
if (flag)
{
AdminPage.WriteSuccessMsg("保存数据成功!", "RegionManage.aspx");
}
else
{
AdminPage.WriteErrMsg("操作失败!", "");
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack && (BasePage.RequestString("Action") == "Modify"))
{
RegionInfo regionById = Region.GetRegionById(BasePage.RequestInt32("ID"));
this.ViewState["Info"] = regionById;
this.TxtCountry.Text = regionById.Country;
this.TxtProvince.Text = regionById.Province;
this.TxtCity.Text = regionById.City;
this.TxtArea.Text = regionById.Area;
this.TxtPostCode.Text = regionById.PostCode;
this.TxtAreaCode.Text = regionById.AreaCode;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -