新聞添加cs頁(yè)面

          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("系統(tǒng)錯(cuò)誤請(qǐng)聯(lián)系管理員", "history.go(-1)");
                      }


                  }
              }
          }

          posted on 2009-06-10 18:15 sanmao 閱讀(122) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 东山县| 眉山市| 洛扎县| 天镇县| 汪清县| 嘉鱼县| 涟水县| 文山县| 全椒县| 日喀则市| 齐河县| 循化| 阳山县| 鹤庆县| 陆良县| 格尔木市| 佛山市| 苍溪县| 佛坪县| 昭平县| 邵阳县| 台山市| 岱山县| 余江县| 曲阳县| 宁强县| 洛阳市| 兴隆县| 波密县| 缙云县| 皋兰县| 呼和浩特市| 清河县| 个旧市| 灯塔市| 稻城县| 宜川县| 汤原县| 蒙阴县| 五指山市| 汉中市|