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

📄 deliveradd.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Shop.Web.UI;

namespace YXShop.Web.Admin.Shop
{
    public partial class DeliverAdd : System.Web.UI.Page
    {
        YXShop.BLL.YXShop_Deliver bll = new YXShop.BLL.YXShop_Deliver();
        BasePage bp = new BasePage();
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(YXShop.Web.Admin.Shop.DeliverAdd));
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    ViewState["ID"] = Request.QueryString["ID"];
                }
                if (ViewState["ID"] != null)
                {
                    if (!PowerTree.PowerPass.isPass("005001004",PowerTree.PowerPanel.PowerType.update))
                    {
                        bp.PageError("对不起,你没有编辑此项的权限!", "../index.aspx");
                    }
                    Bind(Convert.ToInt32(ViewState["ID"]));
                }
                else
                {
                    if (!PowerTree.PowerPass.isPass("005001002", PowerTree.PowerPanel.PowerType.add))
                    {
                        bp.PageError("对不起,你没有添加的权限!", "../index.aspx");
                    }
                }
            }
        }
        private void Bind(int id)
        {
            YXShop.Model.YXShop_Deliver deliver = bll.GetModel(id);
            if (deliver != null)
            {
                DeliverName.Text = deliver.D_Name;
                PromName0.Text = deliver.D_InceptPrice.ToString();
                PromName1.Text = deliver.D_InceptWeight.ToString();
                PromName2.Text = deliver.D_AddPriceLadder.ToString();
                PromName3.Text = deliver.D_AddWeightLadder.ToString();
                //PromName4.Text = deliver.D_BoundPrice.ToString();
                CheckBox1.Checked = deliver.D_ArrivePay > 0 ? true : false;
                CheckBox2.Checked = deliver.D_IsSpecial > 0 ? true : false;
                CheckBox3.Checked = deliver.D_IsUsed > 0 ? true : false;
                TextBox9.Text = deliver.D_Description;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
                YXShop.Model.YXShop_Deliver Deliver = new YXShop.Model.YXShop_Deliver();
                Deliver.D_Name = YXShop.Common.WebUtility.replaceStr(DeliverName.Text.Trim());
                YXShop.Common.WebUtility.isDecimal(PromName1.Text);
                Deliver.D_InceptPrice = Convert.ToDecimal(PromName0.Text.Trim());
                Deliver.D_InceptWeight = Convert.ToDecimal(PromName1.Text.Trim());
                Deliver.D_AddPriceLadder = Convert.ToDecimal(PromName2.Text.Trim());
                Deliver.D_AddWeightLadder = Convert.ToDecimal(PromName3.Text.Trim());
                Deliver.D_BoundPrice = GetPriceList();
                Deliver.D_ArrivePay = CheckBox1.Checked ? 1 : 0;
                Deliver.D_IsSpecial = CheckBox2.Checked ? 1 : 0;
                Deliver.D_IsUsed = CheckBox3.Checked ? 1 : 0;
                Deliver.D_Description = YXShop.Common.WebUtility.replaceStr(TextBox9.Text.Trim());
                if (ViewState["ID"] != null)
                {
                    Deliver.D_ID = Convert.ToInt32(ViewState["ID"]);
                    bll.Update(Deliver);
                    bp.PageRight("送货方式修改成功!<li><a href=\"DeliverAdd.aspx\" class=\"list_link\"><b><font color=\"red\">继续添加</font></b></a>&nbsp;</li>", "DeliverList.aspx");
                }
                else
                {
                    bll.Add(Deliver);
                    bp.PageRight("送货方式添加成功!<li><a href=\"DeliverAdd.aspx\" class=\"list_link\"><b><font color=\"red\">继续添加</font></b></a>&nbsp;</li>", "DeliverList.aspx");
                }
            
        }

        private string GetPriceList()
        {
            string rePriceList = string.Empty;
            string weightStr1, weightStr2, priceStr;
            for (int i = 1; i < 8; i = i + 2)
            {
                weightStr1 = getTextBoxValue(string.Format("weight", i));
                weightStr2 = getTextBoxValue(string.Format("weight", i++));
                priceStr = getTextBoxValue(string.Format("price", i));
                if (!(string.IsNullOrEmpty(weightStr1) || string.IsNullOrEmpty(weightStr2) || string.IsNullOrEmpty(priceStr)))
                {
                    rePriceList += string.Format("{0},{1}|{2};", weightStr1, weightStr2, priceStr);
                }

            }
            return rePriceList.TrimEnd(';');
        }
        private string getTextBoxValue(string tbName)
        {
            string reStr = string.Empty;
            TextBox tb = (TextBox)Page.Controls[0].Controls[3].Controls[3].FindControl(tbName);
            if (tb != null)
            {
                reStr = tb.Text.Trim();
                if (!isNumeric(reStr))
                    reStr = "";
            }
            return reStr;
        }
        public bool isNumeric(string num)
        {
            if (string.IsNullOrEmpty(num))
                return false;
            System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("^[0-9]+$");
            return r.IsMatch(num);
        }
    }
}

⌨️ 快捷键说明

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