⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 present.aspx.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
    using PowerEasy.Common;
    using PowerEasy.Components;
    using PowerEasy.Controls;
    using PowerEasy.Controls.Editor;
    using PowerEasy.Enumerations;
    using PowerEasy.Model.Shop;
    using PowerEasy.ModelControls;
    using PowerEasy.Shop;
    using PowerEasy.Web.UI;
    using PowerEasy.WebSite.Controls.Shop;
    using System;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class Present : AdminPage
    {
        protected Button BtnSave;
        protected CheckBoxList ChklCharacter;
        protected CheckBox ChkPresentPicWatermark;
        protected CheckBox ChkProductThumbWatermark;
        protected CheckBox ChkThumb;
        protected CompareValidator CompareValidator1;
        protected DropDownList DropServiceTermUnit;
        protected FileUploadControl FileUploadProductPic;
        protected FileUploadControl FileUploadProductThumb;
        protected HiddenField HdnAction;
        private string m_ColspanControl;
        protected PEeditor PresentExplain;
        protected ProductNumBuilder ProductNumPick;
        protected ProductUnitPicker ProductUnit1;
        protected ScriptManager ScriptManager1;
        protected ExtendedSiteMapPath SmpNavigator;
        protected HtmlGenericControl tbDownload;
        protected HtmlGenericControl tbThumb;
        protected TextBox TxtAlarmNum;
        protected TextBox TxtDownloadUrl;
        protected TextBox TxtPresentIntro;
        protected TextBox TxtPrice;
        protected TextBox TxtPrice_Market;
        protected TextBox TxtProductName;
        protected TextBox TxtRemark;
        protected TextBox TxtServiceTerm;
        protected TextBox TxtStocks;
        protected TextBox TxtWeight;
        protected CompareValidator ValcAlarmNum;
        protected CompareValidator ValcServiceTerm;
        protected CompareValidator ValcStocks;
        protected PowerEasy.Controls.RequiredFieldValidator ValrUnit;
        protected PositiveNumValidator VpnumPrice;
        protected PositiveNumValidator VpnumPrice_Market;

        protected void BtnSave_Click(object sender, EventArgs e)
        {
            if (base.IsValid)
            {
                PresentInfo info;
                if (this.HdnAction.Value == "Add")
                {
                    info = new PresentInfo();
                    this.FillInfo(info);
                    if (PowerEasy.Shop.Present.AddPresent(info))
                    {
                        AdminPage.WriteSuccessMsg("促销礼品添加成功!", "PresentManager.aspx");
                    }
                    else
                    {
                        AdminPage.WriteErrMsg("促销礼品添加失败!");
                    }
                }
                else
                {
                    info = this.ViewState["info"] as PresentInfo;
                    this.FillInfo(info);
                    if (PowerEasy.Shop.Present.UpdatePressent(info))
                    {
                        AdminPage.WriteSuccessMsg("促销礼品更新成功!", "PresentManager.aspx");
                    }
                    else
                    {
                        AdminPage.WriteErrMsg("促销礼品更新失败!");
                    }
                }
            }
        }

        private void FillInfo(PresentInfo info)
        {
            if (info != null)
            {
                info.PresentName = this.TxtProductName.Text.Trim();
                info.PresentNum = this.ProductNumPick.ProductNum.Trim();
                info.ServiceTerm = DataConverter.CLng(this.TxtServiceTerm.Text);
                info.ServiceTermUnit = (ServiceTermUnit) DataConverter.CLng(this.DropServiceTermUnit.SelectedValue);
                ProductCharacter none = ProductCharacter.None;
                foreach (ListItem item in this.ChklCharacter.Items)
                {
                    if (item.Selected)
                    {
                        none |= DataConverter.CLng(item.Value);
                    }
                }
                info.ProductCharacter = none;
                info.Stocks = DataConverter.CLng(this.TxtStocks.Text);
                info.AlarmNum = DataConverter.CLng(this.TxtAlarmNum.Text);
                info.Unit = this.ProductUnit1.ProductUnit;
                info.Weight = DataConverter.CDouble(this.TxtWeight.Text);
                info.Price = DataConverter.CDecimal(this.TxtPrice.Text);
                info.PriceMarket = DataConverter.CDecimal(this.TxtPrice_Market.Text);
                string uploadDir = SiteConfig.SiteOption.UploadDir;
                if ((!string.IsNullOrEmpty(this.FileUploadProductPic.FilePath) && FileSystemObject.IsExist(base.Server.MapPath("~") + @"\" + uploadDir + @"\" + this.FileUploadProductPic.FilePath.Replace("/", @"\"), FsoMethod.File)) && (string.Compare(info.PresentPic, this.FileUploadProductPic.FilePath, true) != 0))
                {
                    info.PresentPic = this.FileUploadProductPic.FilePath;
                    if (this.ChkPresentPicWatermark.Checked)
                    {
                        WaterMark.AddWaterMark(info.PresentPic.Replace(base.BasePath + SiteConfig.SiteOption.UploadDir, ""));
                    }
                }
                if (!this.ChkThumb.Checked)
                {
                    if (!string.IsNullOrEmpty(this.FileUploadProductThumb.FilePath) && FileSystemObject.IsExist(base.Server.MapPath("~") + @"\" + uploadDir + @"\" + this.FileUploadProductThumb.FilePath.Replace("/", @"\"), FsoMethod.File))
                    {
                        if (string.Compare(info.PresentThumb, this.FileUploadProductThumb.FilePath, true) != 0)
                        {
                            info.PresentThumb = this.FileUploadProductThumb.FilePath;
                            if (this.ChkProductThumbWatermark.Checked)
                            {
                                WaterMark.AddWaterMark(info.PresentThumb.Replace(base.BasePath + SiteConfig.SiteOption.UploadDir, ""));
                            }
                        }
                    }
                    else
                    {
                        info.PresentThumb = string.Empty;
                    }
                }
                info.DownloadUrl = this.TxtDownloadUrl.Text;
                info.Remark = this.TxtRemark.Text;
                info.PresentIntro = this.TxtPresentIntro.Text;
                info.PresentExplain = this.PresentExplain.Value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.ChkThumb.Attributes.Add("onclick", "SetThumb()");
                this.ChklCharacter.Items[2].Attributes.Add("onclick", "SetDownload()");
                this.HdnAction.Value = BasePage.RequestString("Action", "Add");
                int id = BasePage.RequestInt32("ID");
                this.ChkPresentPicWatermark.Checked = SiteConfig.ShopConfig.IsWatermark;
                if ((this.HdnAction.Value == "Modify") && (id > 0))
                {
                    this.TxtStocks.Enabled = false;
                    this.TxtStocks.ToolTip = "修改库存请到“库存管理”进行操作!";
                    PresentInfo presentById = PowerEasy.Shop.Present.GetPresentById(id);
                    if (!presentById.IsNull)
                    {
                        this.ViewState["info"] = presentById;
                        this.TxtProductName.Text = presentById.PresentName;
                        this.ProductNumPick.ProductNum = presentById.PresentNum;
                        this.TxtPrice.Text = presentById.Price.ToString("0.00");
                        this.TxtPrice_Market.Text = presentById.PriceMarket.ToString("0.00");
                        this.ProductUnit1.ProductUnit = presentById.Unit;
                        this.TxtStocks.Text = presentById.Stocks.ToString();
                        this.TxtAlarmNum.Text = presentById.AlarmNum.ToString();
                        this.TxtWeight.Text = presentById.Weight.ToString();
                        this.TxtServiceTerm.Text = presentById.ServiceTerm.ToString();
                        this.DropServiceTermUnit.SelectedValue = presentById.ServiceTermUnit.ToString("D");
                        this.TxtPresentIntro.Text = presentById.PresentIntro;
                        this.PresentExplain.Value = presentById.PresentExplain;
                        foreach (ListItem item in this.ChklCharacter.Items)
                        {
                            item.Selected = Product.CharacterIsExists(presentById.ProductCharacter, (ProductCharacter) DataConverter.CLng(item.Value));
                            if ((item.Value == "4") && item.Selected)
                            {
                                this.TxtDownloadUrl.Text = presentById.DownloadUrl;
                                this.TxtRemark.Text = presentById.Remark;
                                this.tbDownload.Style.Add("display", "");
                            }
                        }
                        this.FileUploadProductPic.FilePath = presentById.PresentPic;
                        this.FileUploadProductThumb.FilePath = presentById.PresentThumb;
                    }
                }
                else if (SiteConfig.ShopConfig.IsThumb)
                {
                    this.tbThumb.Style.Add("display", "none");
                }
            }
        }

        public string ColspanControl
        {
            get
            {
                if (!string.IsNullOrEmpty(this.m_ColspanControl))
                {
                    return ("colspan=\"" + this.m_ColspanControl + "\"");
                }
                return string.Empty;
            }
            set
            {
                this.m_ColspanControl = value;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -