📄 producermodify.aspx.cs
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Controls.Editor;
using PowerEasy.ExtendedControls;
using PowerEasy.Model.Shop;
using PowerEasy.ModelControls;
using PowerEasy.Shop;
using PowerEasy.Web.UI;
using System;
using System.Web;
using System.Web.UI.WebControls;
public class ProducerModify : AdminPage
{
protected ExtendedButton BtnSubmit;
protected DatePicker DpkBirthDay;
protected PEeditor EditorProducerIntro;
protected FileUploadControl ExtenFileUpload;
protected HiddenField HdnProducerId;
protected HiddenField HdnProducerName;
protected Image ImgProducerPhoto;
protected RadioButtonList RadlProducerType;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtAddress;
protected TextBox TxtEmail;
protected TextBox TxtFax;
protected TextBox TxtHomepage;
protected TextBox TxtPhone;
protected TextBox TxtPostcode;
protected TextBox TxtProducerName;
protected TextBox TxtProducerShortName;
protected string UploadDir;
protected PowerEasy.Controls.RequiredFieldValidator ValrProducerName;
protected DateValidator VdateBirthDay;
protected EmailValidator VmailEmail;
protected ZipCodeValidator VzipTxtPostcode;
protected void BtnSubmit_Click(object sender, EventArgs e)
{
string text = this.TxtProducerName.Text;
if (!string.IsNullOrEmpty(text))
{
bool flag;
ProducerInfo producerInfo = new ProducerInfo();
if (this.HdnProducerName.Value == text)
{
flag = false;
}
else
{
flag = Producer.ProducerNameExists(text);
}
if (!flag)
{
producerInfo.ProducerId = DataConverter.CLng(this.HdnProducerId.Value);
producerInfo.ProducerName = text;
producerInfo.ProducerShortName = this.TxtProducerShortName.Text;
producerInfo.BirthDay = DataConverter.CDate(this.DpkBirthDay.Text, null);
producerInfo.Address = this.TxtAddress.Text;
producerInfo.Phone = this.TxtPhone.Text;
producerInfo.Fax = this.TxtFax.Text;
producerInfo.Postcode = this.TxtPostcode.Text;
producerInfo.Homepage = this.TxtHomepage.Text;
producerInfo.Email = this.TxtEmail.Text;
producerInfo.ProducerIntro = this.EditorProducerIntro.Value;
producerInfo.ProducerPhoto = this.ExtenFileUpload.FilePath;
producerInfo.ProducerType = DataConverter.CLng(this.RadlProducerType.SelectedValue);
if (Producer.Update(producerInfo))
{
AdminPage.WriteSuccessMsg("修改厂商成功", "ProducerManage.aspx");
}
else
{
AdminPage.WriteErrMsg("修改厂商数据失败!", "");
}
}
else
{
AdminPage.WriteErrMsg("数据库中已经存在此厂商!", "");
}
}
else
{
AdminPage.WriteErrMsg("厂商名称不能为空!", "");
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
int producerId = BasePage.RequestInt32("ProducerId");
if (producerId != 0)
{
ProducerInfo producerById = Producer.GetProducerById(producerId);
if (!producerById.IsNull)
{
this.UploadDir = SiteConfig.SiteOption.UploadDir + "/";
this.HdnProducerId.Value = Convert.ToString(producerId, (IFormatProvider) null);
this.HdnProducerName.Value = producerById.ProducerName;
this.TxtProducerName.Text = producerById.ProducerName;
this.TxtProducerShortName.Text = producerById.ProducerShortName;
if (producerById.BirthDay.HasValue)
{
this.DpkBirthDay.Text = producerById.BirthDay.Value.ToString("yyyy-MM-dd");
}
this.TxtAddress.Text = producerById.Address;
this.TxtPhone.Text = producerById.Phone;
this.TxtFax.Text = producerById.Fax;
this.TxtPostcode.Text = producerById.Postcode;
this.TxtHomepage.Text = producerById.Homepage;
this.TxtEmail.Text = producerById.Email;
this.EditorProducerIntro.Value = producerById.ProducerIntro;
if (!string.IsNullOrEmpty(producerById.ProducerPhoto))
{
this.ImgProducerPhoto.ImageUrl = Utility.ConvertAbsolutePath(SiteConfig.SiteInfo.VirtualPath + VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir), producerById.ProducerPhoto);
}
this.ExtenFileUpload.FilePath = producerById.ProducerPhoto;
this.RadlProducerType.SelectedValue = Convert.ToString(producerById.ProducerType, (IFormatProvider) null);
}
else
{
AdminPage.WriteErrMsg("<li>没有找到对应的厂商信息!</li>");
}
}
else
{
AdminPage.WriteErrMsg("<li>ProducerId不能为空!</li>", "ProducerManage.aspx");
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -