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

📄 adzoneimport.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.AD
{
    using PowerEasy.AccessManage;
    using PowerEasy.AD;
    using PowerEasy.Controls;
    using PowerEasy.Enumerations;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Generic;
    using System.Data.OleDb;
    using System.Text;
    using System.Web.UI.WebControls;

    public class ADZoneImport : AdminPage
    {
        protected Button BtnImport;
        protected ListBox LstImportZoneId;
        protected ListBox LstSystemZoneId;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TextBox TxtImportMdb;
        protected WizardStep WizardStep1;
        protected WizardStep WizardStep2;
        protected Wizard WzdAd;

        protected void BtnImport_Click(object sender, EventArgs e)
        {
            this.SaveImportData();
        }

        private void DataBasePath(string importPath)
        {
            OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + base.Server.MapPath(importPath));
            try
            {
                connection.Open();
            }
            catch (OleDbException exception)
            {
                AdminPage.WriteErrMsg("<li>数据库操作失败,请以后再试,错误原因:" + exception.Message + "</li>", "ModelTemplateImport.aspx?ModelType=" + BasePage.RequestInt32("ModelType").ToString());
            }
            finally
            {
                connection.Close();
                connection.Dispose();
            }
        }

        public void ImportDataBind(ListControl dropName, string importDatabase)
        {
            IList<ADZoneInfo> importList = ADZone.GetImportList(importDatabase);
            if (importList.Count > 0)
            {
                dropName.Items.Clear();
                dropName.DataSource = importList;
                dropName.DataBind();
            }
            else
            {
                dropName.Items.Clear();
            }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            RolePermissions.BusinessAccessCheck(OperateCode.AdManage);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int num = BasePage.RequestInt32("Step");
                if (num == 1)
                {
                    this.WzdAd.ActiveStepIndex = num;
                    string importPath = base.Request.QueryString["ImportPath"];
                    this.DataBasePath(importPath);
                    this.ImportDataBind(this.LstImportZoneId, base.Server.MapPath(importPath));
                    this.SystemDataBind(this.LstSystemZoneId);
                }
            }
        }

        private void SaveImportData()
        {
            string selectedValue = this.LstImportZoneId.SelectedValue;
            string text = this.TxtImportMdb.Text;
            if (string.IsNullOrEmpty(selectedValue))
            {
                AdminPage.WriteErrMsg("<li>请选择要导入的广告版位列表!</li>");
            }
            if (string.IsNullOrEmpty(text))
            {
                AdminPage.WriteErrMsg("<li>导入的数据库链接不能为空!</li>");
            }
            StringBuilder builder = new StringBuilder("");
            for (int i = 0; i < this.LstImportZoneId.Items.Count; i++)
            {
                if (this.LstImportZoneId.Items[i].Selected)
                {
                    builder.Append(this.LstImportZoneId.Items[i].Value);
                    builder.Append(",");
                }
            }
            if (builder.Length < 1)
            {
                AdminPage.WriteErrMsg("请选择要导入的项目!");
            }
            else
            {
                builder.Remove(builder.Length - 1, 1);
                if (ADZone.ImportData(builder.ToString(), base.Server.MapPath(text)))
                {
                    BasePage.ResponseRedirect("ADZoneImport.aspx?Step=1&ImportPath=" + base.Server.HtmlEncode(this.TxtImportMdb.Text) + "&ModelType=" + BasePage.RequestInt32("ModelType").ToString());
                }
            }
        }

        public void SystemDataBind(ListControl dropName)
        {
            IList<ADZoneInfo> aDZoneList = ADZone.GetADZoneList(0, 0);
            if (aDZoneList.Count > 0)
            {
                dropName.Items.Clear();
                dropName.DataSource = aDZoneList;
                dropName.DataBind();
            }
            else
            {
                dropName.Items.Clear();
            }
        }

        protected void WzdAd_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            BasePage.ResponseRedirect("ADZoneManage.aspx");
        }

        protected void WzdAd_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            string text = this.TxtImportMdb.Text;
            if (string.IsNullOrEmpty(text))
            {
                AdminPage.WriteErrMsg("<li>请填写导入数据库名!</li>", "ADZoneImport.aspx");
            }
            this.DataBasePath(text);
            this.ImportDataBind(this.LstImportZoneId, base.Server.MapPath(text));
            this.SystemDataBind(this.LstSystemZoneId);
        }
    }
}

⌨️ 快捷键说明

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