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

📄 presentprojectui.cs

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

    public class PresentProjectUI : AdminPage
    {
        protected ExtendedButton BtnSubmit;
        protected CheckBox ChkPresentContent1;
        protected CheckBox ChkPresentContent2;
        protected CheckBox ChkPresentContent3;
        protected CheckBox ChkPresentContent4;
        protected CompareValidator CompareValidator1;
        protected CompareValidator CompareValidator2;
        protected DatePicker DpkBeginDate;
        protected DatePicker DpkEndDate;
        protected HiddenField HdnPresent;
        protected Label LblMsg;
        protected Label LblMsg1;
        protected Label LblTitle;
        protected ListBox LstPresent;
        public string PointName;
        public string PointUnit;
        protected RangeValidator RangeValidator1;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TextBox TxtCash;
        protected TextBox TxtMaxMoney;
        protected TextBox TxtMinMoney;
        protected TextBox TxtPresentExp;
        protected TextBox TxtPresentPoint;
        protected TextBox TxtPrice;
        protected TextBox TxtProjectName;
        protected PowerEasy.Controls.RequiredFieldValidator ValrMaxMoney;
        protected PowerEasy.Controls.RequiredFieldValidator ValrProjectName;

        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            string str = "";
            bool flag = false;
            PresentProjectInfo presentProject = new PresentProjectInfo();
            presentProject.ProjectId = (this.ViewState["projectId"] == null) ? 0 : DataConverter.CLng(this.ViewState["projectId"].ToString());
            if (this.ChkPresentContent1.Checked)
            {
                str = str + "1,";
                if (string.IsNullOrEmpty(this.TxtPrice.Text))
                {
                    AdminPage.WriteErrMsg("请指定换购价格!");
                }
                else
                {
                    presentProject.Price = DataConverter.CDecimal(this.TxtPrice.Text);
                }
                if (string.IsNullOrEmpty(this.HdnPresent.Value))
                {
                    AdminPage.WriteErrMsg("请指定换购的商品!");
                }
                else
                {
                    presentProject.PresentId = this.HdnPresent.Value;
                }
            }
            if (this.ChkPresentContent2.Checked)
            {
                str = str + "2,";
                if (string.IsNullOrEmpty(this.TxtCash.Text))
                {
                    AdminPage.WriteErrMsg("请指定返还的现金券的金额!");
                }
                else
                {
                    presentProject.Cash = DataConverter.CDecimal(this.TxtCash.Text);
                }
            }
            if (this.ChkPresentContent3.Checked)
            {
                str = str + "3,";
                if (string.IsNullOrEmpty(this.TxtPresentExp.Text))
                {
                    AdminPage.WriteErrMsg("请指定可以得到的积分分数!");
                }
                else
                {
                    presentProject.PresentExp = DataConverter.CLng(this.TxtPresentExp.Text);
                }
            }
            if (this.ChkPresentContent4.Checked)
            {
                str = str + "4";
                if (string.IsNullOrEmpty(this.TxtPresentPoint.Text))
                {
                    AdminPage.WriteErrMsg("请指定可以得到的" + SiteConfig.UserConfig.PointName + "数!");
                }
                else
                {
                    presentProject.PresentPoint = DataConverter.CLng(this.TxtPresentPoint.Text);
                }
            }
            else if (string.IsNullOrEmpty(str))
            {
                AdminPage.WriteErrMsg("请最少要选择一种促销方式!");
            }
            else
            {
                str = str.Substring(0, str.Length - 1);
            }
            presentProject.ProjectName = this.TxtProjectName.Text;
            presentProject.BeginDate = DataConverter.CDate(this.DpkBeginDate.Date);
            presentProject.EndDate = DataConverter.CDate(this.DpkEndDate.Date);
            presentProject.MinMoney = DataConverter.CDecimal(this.TxtMinMoney.Text);
            presentProject.MaxMoney = DataConverter.CDecimal(this.TxtMaxMoney.Text);
            presentProject.PresentContent = str;
            presentProject.Disabled = true;
            string str2 = this.ViewState["action"].ToString();
            if (str2 != null)
            {
                if (!(str2 == "Add"))
                {
                    if (str2 == "Modify")
                    {
                        flag = PresentProject.Update(presentProject);
                        goto Label_02BF;
                    }
                }
                else
                {
                    flag = PresentProject.Add(presentProject);
                    goto Label_02BF;
                }
            }
            flag = PresentProject.Update(presentProject);
        Label_02BF:
            if (flag)
            {
                BasePage.ResponseRedirect("PresentProjectManage.aspx");
            }
            else
            {
                this.LblMsg.Text = "添加数据失败";
                this.LblMsg.Visible = true;
            }
        }

        private void FillData()
        {
            this.ViewState["projectId"] = BasePage.RequestString("ProjectId");
            PresentProjectInfo presentProjectById = new PresentProjectInfo();
            presentProjectById = PresentProject.GetPresentProjectById(DataConverter.CLng(this.ViewState["projectId"]));
            this.TxtProjectName.Text = presentProjectById.ProjectName;
            this.DpkBeginDate.Text = presentProjectById.BeginDate.ToString("yyyy-MM-dd");
            this.DpkEndDate.Text = presentProjectById.EndDate.ToString("yyyy-MM-dd");
            this.TxtMinMoney.Text = presentProjectById.MinMoney.ToString("0.00");
            this.TxtMaxMoney.Text = presentProjectById.MaxMoney.ToString("0.00");
            if (presentProjectById.PresentContent.IndexOf("1") != -1)
            {
                this.ChkPresentContent1.Checked = true;
                if (!string.IsNullOrEmpty(presentProjectById.PresentId))
                {
                    this.LstPresent.DataSource = PowerEasy.Shop.Present.GetPresentList(presentProjectById.PresentId);
                    this.LstPresent.DataBind();
                }
            }
            if (presentProjectById.PresentContent.IndexOf("2") != -1)
            {
                this.ChkPresentContent2.Checked = true;
            }
            if (presentProjectById.PresentContent.IndexOf("3") != -1)
            {
                this.ChkPresentContent3.Checked = true;
            }
            if (presentProjectById.PresentContent.IndexOf("4") != -1)
            {
                this.ChkPresentContent4.Checked = true;
            }
            this.TxtPrice.Text = presentProjectById.Price.ToString("0.00");
            this.TxtCash.Text = presentProjectById.Cash.ToString("0.00");
            this.TxtPresentExp.Text = Convert.ToString(presentProjectById.PresentExp, (IFormatProvider) null);
            this.TxtPresentPoint.Text = Convert.ToString(presentProjectById.PresentPoint, (IFormatProvider) null);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                SiteConfigInfo info = SiteConfig.ConfigInfo();
                this.PointUnit = info.UserConfig.PointUnit;
                this.PointName = info.UserConfig.PointName;
                switch (BasePage.RequestString("Action", "Add"))
                {
                    case "Add":
                        this.ViewState["action"] = "Add";
                        this.DpkBeginDate.Text = DateTime.Now.Date.ToString("yyyy-MM-dd");
                        this.DpkEndDate.Text = DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd");
                        this.TxtMinMoney.Text = "100.00";
                        this.TxtMaxMoney.Text = "500.00";
                        this.ChkPresentContent1.Checked = true;
                        this.TxtPrice.Text = "10";
                        this.TxtCash.Text = "20";
                        this.TxtPresentExp.Text = "20";
                        this.TxtPresentPoint.Text = "20";
                        return;

                    case "Modify":
                        this.ViewState["action"] = "Modify";
                        this.LblTitle.Text = "修改促销方案";
                        this.FillData();
                        return;
                }
                this.ViewState["action"] = "Add";
            }
        }
    }
}

⌨️ 快捷键说明

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