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

📄 add_article.aspx.cs

📁 易想商城系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections.Generic;
using Shop.Web.UI;
namespace YXShop.Web.Admin.Article
{
    public partial class Add_Article : System.Web.UI.Page
    {
        public string channelId_temp = "";
        public string classId_temp = "";
        BasePage bp = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!PowerTree.PowerPass.isPass("012001002", PowerTree.PowerPanel.PowerType.add))
            {
                bp = new BasePage();
                bp.PageError("对不起,你没有添加文章的权限!", "../index.aspx");
            }
             if (!Page.IsPostBack)
             { 
                this.channelId_temp = Request["channelID"];
                this.classId_temp = Request["Class_ID"];
                YXShop.Common.WebUtility.WebControlOnblur(title_text);
                YXShop.Common.WebUtility.WebControlOnblur(subtitle_text);
                YXShop.Common.WebUtility.WebControlOnblur(author_text);
                YXShop.Common.WebUtility.WebControlOnblur(artFrom_text);
                YXShop.Common.WebUtility.WebControlOnblur(artUrl_text);
                YXShop.Common.WebUtility.WebControlOnblur(artKeyword_text);
                YXShop.Common.WebUtility.WebControlOnblur(hits_text);
                YXShop.Common.WebUtility.WebControlOnblur(createDate_text);
                YXShop.Common.WebUtility.WebControlOnblur(modiDate_text);
                YXShop.Common.WebUtility.WebControlOnblur(inputerl_text);
                this.classId_droplist.Attributes.Add("onchange", "onChangeVal()");
                this.channelId_droplist.Attributes.Add("onchange", "load(this.options[this.selectedIndex].value)");
                this.hits_text.Attributes.Add("onblur", "isNumber(this.value)");
                this.addArtBtn.Attributes.Add("onclick", "return checkVal();");
                this.createDate_text.Attributes.Add("onblur", "checkDateTime(this)");
                this.modiDate_text.Attributes.Add("onblur", "checkDateTime(this)");
                BindAllData(this.channelId_temp,this.classId_temp);
            
             }
        }
        #region 数据初始绑定
        public void BindAllData(string _channelId,string _classId)
        {


            try
            {
                string str = "SELECT Count(0) FROM YX_InforChannel";
                int channelList = Convert.ToInt32(YXShop.DBUtility.SqlHelper.ExecuteScalar(YXShop.DBUtility.SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, str, null));
                if (channelList == 0)
                {
                    YXShop.Common.alert.showAndGo("对不起!目前暂无任何频道存在,请先添加频道后再添加文章!", "InforChannel/ChannelAnd.aspx");
                }
                else
                {
                    BindDropDownList_Channel();
                    if (_channelId != "")
                    {
                        channelId_droplist.SelectedValue = _channelId;
                    }
                }
                artFrom_text.Text = "网站名称";// new YXJob.BLL.YixiangConfig().GetBasicCofing().webName.ToString();
                hits_text.Text = "0";
                createDate_text.Text = DateTime.Now.ToShortDateString();
                modiDate_text.Text = DateTime.Now.ToShortDateString();
            }
            catch { }
        }
        #endregion

        #region 绑定频道数据 
        public void BindDropDownList_Channel()
        {
            try
            {
                //channelId_droplist.DataSource = new YXJob.BLL.YixiangChannel().GetAllChannelInfo();
                channelId_droplist.DataSource = YXShop.DBUtility.SqlHelper.ExecuteDataSet(YXShop.DBUtility.SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "SELECT * FROM YX_InforChannel where Putout=1", null);
                channelId_droplist.DataTextField = "YX_Name";
                channelId_droplist.DataValueField = "YX_ID";
                channelId_droplist.DataBind();
            }
            catch { }
        }
        #endregion

        #region   添加文章
        protected void addArtBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (FCKeditor1.Value == "")
                {
                    YXShop.Common.alert.show("请输入文章内容!");
                }
                if (channelId_droplist.SelectedValue != "" && classId_droplistVal.Value != "" && artDes_text.Text != "" && artKeyword_text.Text != "" && FCKeditor1.Value != "")
                {
                    //上传缩略图片
                    if (isPic_text.Checked)
                    {
                        if (!string.IsNullOrEmpty(FileUpload1.FileName.ToString()))
                        {
                            string fileStr = YXShop.DBUtility.UploadFile.UploadPicFile(FileUpload1, "ArtUploadPic", "Art", Convert.ToInt32(YXShop.DBUtility.UploadFile.ArticleMaxSize));
                            if (fileStr.IndexOf("error") == -1)
                            {
                                picPath.Text = fileStr;
                            }
                            else
                            {
                                YXShop.Common.alert.show("上传失败!" + fileStr);
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(picPath.Text.ToString()))
                            {
                                YXShop.Common.alert.show("你设置该文章为:包含缩略图片,但你当前尚未选择所要上传的图片或直接在 [缩略图片路径]中输入指定图片路径,请检查!");
                            }
                        }

                    }
                    //----------------

                    YXShop.BLL.YixiangArticle bll = new YXShop.BLL.YixiangArticle();
                    int result = bll.AddArticle(
                        YXShop.Common.WebUtility.InputText(channelId_droplist.SelectedValue.ToString(), channelId_droplist.SelectedValue.ToString().Length),
                        YXShop.Common.WebUtility.InputText(classId_droplistVal.Value.ToString(), classId_droplistVal.Value.ToString().Length),
                        YXShop.Common.WebUtility.InputText(title_text.Text.ToString(), title_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(subtitle_text.Text.ToString(), subtitle_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(author_text.Text.ToString(), author_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(artFrom_text.Text.ToString(), artFrom_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(artUrl_text.Text.ToString(), artUrl_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(inputerl_text.Text.ToString(), inputerl_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(inputerl_text.Text.ToString(), inputerl_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(artKeyword_text.Text.ToString(), artKeyword_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(hits_text.Text.ToString(), hits_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(artDes_text.Text.ToString(), artDes_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(createDate_text.Text.ToString(), createDate_text.Text.ToString().Length),
                        YXShop.Common.WebUtility.InputText(modiDate_text.Text.ToString(), modiDate_text.Text.ToString().Length),
                        isTop_cbox.Checked == true ? "1" : "0",
                        isTj_cbox.Checked == true ? "1" : "0",
                        FCKeditor1.Value.ToString(),
                        isPic_text.Checked == true ? "1" : "0", "0", "0",
                        stateNow_lable.Checked == true ? "1" : "0",
                        isPic_text.Checked == true ? YXShop.Common.WebUtility.InputText(picPath.Text.ToString(), picPath.Text.ToString().Length) : ""
                        );
                    if (result == 1)
                    {
                        YXShop.Common.alert.showAndGo("添加文章成功!", "Add_Article.aspx?channelID=" + this.channelId_temp + "&Class_ID=" + this.classId_temp);
                    }
                    else
                    {
                        YXShop.Common.alert.showAndGo("出现异常!添加文章失败!", "Add_Article.aspx?channelID=" + this.channelId_temp + "&Class_ID=" + this.classId_temp);
                    }
                }
            }
            catch { }
        }
        #endregion
    }
}

⌨️ 快捷键说明

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