zoukankan      html  css  js  c++  java
  • 新闻添加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;

    namespace domain.UI.images.News
    {
        public partial class NewsEdit :domain.BLL.AdminPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    this.LoadType(this.DdlType, this.Db.GetTable("select * from NewsSort where Column_Depth=1"));
                    BindUpdateData();
                }
             
            }
            public void LoadType(DropDownList ddl, DataTable dt)
            {
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ddl.Items.Add(new ListItem(GetSpace(Convert.ToInt32(dt.Rows[i]["Column_Depth"]) - 1) + Convert.ToString(dt.Rows[i]["Column_Name"]), Convert.ToString(dt.Rows[i]["Column_ID"])));
                            DataTable dtTemp = this.Db.GetTable("select * from NewsSort where Parent_ID=@Parent_ID",new System.Data.SqlClient.SqlParameter("@Parent_ID",Convert.ToString(dt.Rows[i]["Column_ID"])));
                            if (dtTemp != null)
                            {
                                if (dtTemp.Rows.Count > 0)
                                {
                                    LoadType(DdlType,dtTemp);
                                }
                            }
                        }
                          
                    }
                }
            }
            public string GetSpace(int tempint)
            {
                string s = "";
                for (int i = 0; i < tempint; i++)
                {
                    s += "";
                }
                return s;
            }
            public void BindUpdateData()
            {
                string Gid = this.GetRequest("Gid");
                if(Gid.Length>0)
                {
                    domain.SQLDB.News news = new domain.SQLDB.News();
                    news.Gid = Gid;

                    news = news.SelectById();
                    this.DdlType.SelectedIndex = this.DdlType.Items.IndexOf(this.DdlType.Items.FindByValue(news.TypeId));
                    this.TbTitle.Text = news.Title;
                    this.TbKeyword.Text = news.Keyword;
                    this.TbComeFrom.Text = news.ComeFrom;
                    this.TbAuthor.Text = news.Author;
                    this.TbContent.Text = news.Content;
                    this.Cbcommand.Checked=news.IsCommand=="1"?(true):(false);
                    this.cbTop.Checked    = news.IsTop=="1"?(true):(false);
                    this.idPic.ImageUrl = "/upload/admin/news/"+news.Pic;

                }
              
            }
            protected void BtEdit_Click(object sender, EventArgs e)
            {
                domain.UI.cs.Util.UploadFile uf = new domain.UI.cs.Util.UploadFile();
                domain.SQLDB.News news = new domain.SQLDB.News();
                news.Gid = GetRequest("Gid").Length>0?(GetRequest("Gid")):("-1200");
                news.TypeId = this.DdlType.SelectedValue.Trim();
                news.Title = this.TbTitle.Text.Trim();
                news.Keyword = this.TbKeyword.Text.Trim();
                news.ComeFrom = this.TbComeFrom.Text.Trim();
                news.Author = this.TbAuthor.Text.Trim();
                news.Content = this.TbContent.Text.Trim();
                news.Pic = uf.GetSqlFile("admin/news",120,240);
                news.IsCommand=this.Cbcommand.Checked?("1"):("0");
                news.commandTime = DateTime.Now.ToString("yyyy-MM-dd");
                news.IsTop      =this.cbTop.Checked?("1"):("0");
                news.topTime    = DateTime.Now.ToString("yyyy-MM-dd");
                news.AddTime = DateTime.Now.ToString("yyyy-MM-dd");
                if (news.Update())
                {
                    this.ShowMessage("成功编辑新闻!","history.go(-1)");
                }
                else
                {
                    this.ShowMessage("系统错误请联系管理员", "history.go(-1)");
                }


            }
        }
    }

  • 相关阅读:
    IOS Charles(代理服务器软件,可以用来拦截网络请求)
    Javascript中addEventListener和attachEvent的区别
    MVC中实现Area几种方法
    Entity Framework Code First 中使用 Fluent API 笔记。
    自定义JsonResult解决 序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用
    序列化类型 System.Data.Entity.DynamicProxies 的对象时检测到循环引用
    An entity object cannot be referenced by multiple instances of IEntityChangeTracker 的解决方案
    Code First :使用Entity. Framework编程(8) ----转发 收藏
    Code First :使用Entity. Framework编程(6) ----转发 收藏
    Code First :使用Entity. Framework编程(5) ----转发 收藏
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835602.html
Copyright © 2011-2022 走看看