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

📄 operation.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Data;
using YXShop.Common;
using YXShop.BLL;
using System.Collections.Generic;
using System.Text;
using Shop.Web.UI;

namespace YXShop.Web.Admin.Area
{
    public partial class Operation : System.Web.UI.Page
    {
        Provinces provinces = new Provinces();
        Model.Provinces model = new YXShop.Model.Provinces();
        BasePage bp = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                string operationType = Request.QueryString["operationType"];
                if (operationType == "Edit")
                {
                    if (!PowerTree.PowerPass.isPass("009006004", PowerTree.PowerPanel.PowerType.update))
                    {
                        bp = new BasePage();
                        bp.PageError("对不起,你没有修改分站的权限!", "../index.aspx");
                    }
                    BindData();
                }
                else 
                {
                    if (!PowerTree.PowerPass.isPass("009006002", PowerTree.PowerPanel.PowerType.add))
                    {
                        bp = new BasePage();
                        bp.PageError("对不起,你没有添加分站的权限!", "../index.aspx");
                    }
                }
            }
        }

        protected string BindData()
        {
            int ID = Convert.ToInt32(Request.QueryString["ID"]);

            List<Model.Provinces> listProvinces = provinces.GetListByColumn("ID",ID);
            if (listProvinces.Count > 0) 
            {
                for (int i = 0; i < listProvinces.Count; i++)
                {
                    this.txtCName.Text = listProvinces[i].Province_city;
                    this.txtECName.Text = listProvinces[i].Enprovince_city;
                    this.rbtUse.Text = listProvinces[i].IsUse.ToString();
                }
            }
            return null;
        }

        protected string Area(int fid)
        {
            int RQ_FID = Convert.ToInt32(Request.QueryString["FID"]);
            StringBuilder sb = new StringBuilder();
            List<Model.Provinces> listProvinces = provinces.GetListByColumn(string.Format("Fid={0} Order By OrderID", fid));
            if (listProvinces.Count > 0)
            {
                for (int i = 0; i < listProvinces.Count; i++)
                {
                    string prefix = "";for (int depth = 1; depth < (int)listProvinces[i].Depth; depth++)prefix += "&nbsp;&nbsp;";if (listProvinces[i].Child > 0) prefix += "+";else prefix += "-";
                    if (listProvinces[i].ID == RQ_FID) sb.Append(string.Format("<option value=\"{0}\" selected=\"selected\">{1}</option>", listProvinces[i].ID, prefix+listProvinces[i].Province_city));
                    else sb.Append(string.Format("<option value=\"{0}\">{1}</option>", listProvinces[i].ID, prefix + listProvinces[i].Province_city)); sb.Append(Area(listProvinces[i].ID));
                }
            }
            return sb.ToString();
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            #region Old

            

            #endregion
            string operationType = Request.QueryString["operationType"];

            if (operationType == "Edit")
            {
                update();
            }

            else
            {
                Add();
            }
        }


        void Add()
        {
            string CName = txtCName.Text;
            string ECName = txtECName.Text;
            int OrderID = 0;
            int ParentID = Convert.ToInt16(Request.Form["sltParentID"]);
            string P_ParentPath = "";
            int P_Child = 0;
            int P_Depth = 0;
            List<Model.Provinces> listProvinces = provinces.GetListByColumn("ID", ParentID);
            if (listProvinces.Count > 0)
            {
                P_ParentPath = listProvinces[0].ParentPath;
                P_Child = (int)listProvinces[0].Child;

                P_Depth = (int)listProvinces[0].Depth;
                provinces.Amend(ParentID);
            }
            model.Fid = ParentID;
            OrderID = provinces.GetValue("MaxOrderId", model);

            model.IsUse = Convert.ToInt32(rbtUse.Text);            
            model.ParentPath = P_ParentPath + "," + ParentID;
            if (string.IsNullOrEmpty(P_ParentPath))
            {
                model.ParentPath = ParentID.ToString();
            }
            model.Child = 0;
            model.OrderID = OrderID + 1;
            model.Province_city = CName;
            model.Enprovince_city = ECName;
            model.Depth = P_Depth+1;
            model.AddDate = DateTime.Now;
            if (provinces.Create(model) > 0) alert.showAndGo("添加省份成功", "default.aspx?FID=" + ParentID); else alert.showOnly("添加省份失败");            
        }

        //void update()
        //{
        //    int ID = Convert.ToInt32(Request.QueryString["ID"]);
        //    int ParentID = Convert.ToInt16(Request.Form["sltParentID"]);

        //    string CName = this.txtCName.Text;
        //    string ECName = this.txtECName.Text;
        //    string Isuse = this.rbtUse.Text;

        //    model.Province_city = CName;
        //    model.Enprovince_city = txtCName.Text;
        //    model.IsUse = Convert.ToInt32(Isuse);
        //    model.ID = ID;
        //    model.Fid = ParentID;
        //    model.ParentPath = ParentID.ToString();
        //    if (provinces.Amend(model) > 0) alert.showAndGo("修改省份成功", "default.aspx?FID=" + ParentID);else alert.showOnly("修改省份失败");
        //}
        void update()
        {
            int ID = Convert.ToInt32(Request.QueryString["ID"]);
            string CName = txtCName.Text;
            string ECName = txtECName.Text;
            int OrderID = 0;
            int ParentID = Convert.ToInt16(Request.Form["sltParentID"]);
            string P_ParentPath = "";
            int P_Child = 0;
            int P_Depth = 0;
            List<Model.Provinces> listProvinces = provinces.GetListByColumn("ID", ParentID);
            if (listProvinces.Count > 0)
            {
                P_ParentPath = listProvinces[0].ParentPath;
                P_Child = (int)listProvinces[0].Child;

                P_Depth = (int)listProvinces[0].Depth;
                provinces.Amend(ParentID);
            }
            model.ID = ID;
            model.Fid = ParentID;
            OrderID = provinces.GetValue("MaxOrderId", model);

            model.IsUse = Convert.ToInt32(rbtUse.Text);
            model.ParentPath = P_ParentPath + "," + ParentID;
            if (string.IsNullOrEmpty(P_ParentPath))
            {
                model.ParentPath = ParentID.ToString();
            }
            model.Child = 0;
            model.OrderID = OrderID + 1;
            model.Province_city = CName;
            model.Enprovince_city = ECName;
            model.Depth = P_Depth + 1;
            model.AddDate = DateTime.Now;
            if (provinces.Amend(model) > 0) alert.showAndGo("修改省份成功", "default.aspx?FID=" + ParentID); else alert.showOnly("修改省份失败"); 
        }
    }
}

⌨️ 快捷键说明

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