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 UI.images.Expro
          {
              public partial class NewsEdit :BLL.AdminPage
              {
              
                  protected void Page_Load(object sender, EventArgs e)
                  {
                      if (!Page.IsPostBack)
                      {
                          BindSortData();
                          UpdateBindData();
                          BindData();             

                      }
                  }
                  public void UpdateBindData()
                  {
                      string Gid = this.GetRequest("Gid");
                      if (Gid.Length > 0)
                      {
                         SQLDB.Expro_news Expro_news = new SQLDB.Expro_news();
                          Expro_news.Gid = Gid;
                          Expro_news = Expro_news.SelectById();
                          this.DdlGTypeId.SelectedIndex = this.DdlGTypeId.Items.IndexOf(this.DdlGTypeId.Items.FindByValue(Expro_news.GTypeId));
                          this.TbGTitle.Text=Expro_news.GTitle;
                          this.TbGKeyWord.Text=Expro_news.GKeyWord;
                          this.TbGDescription.Text=Expro_news.GDescription;
                          this.TbGContent.Text=Expro_news.GContent;
                          TbGAddTime.Text=Expro_news.GAddTime;
                          CbGRecommend.Checked=Expro_news.GRecommmend=="1"?(true):(false);
                      }
                  }
                  public void BindData()
                  {
           
                  }
                  public void BindSortData()
                  {
                      DataTable dt = this.Db.GetTable("select Column_ID,Column_Name,Column_Depth from Expro_NewsType where Column_Depth=1");
                      SortList(dt,"0");
                  }
                  public void SortList(DataTable dt,string parentId)
                  {
                   
                      if (dt != null)
                      {
                          DataRow dr = null;
                          string tempColumnId = "";
                          string tempColumn_Name = "";
                          int tempColumn_Depth = 0;

                          if (dt.Rows.Count > 0)
                          {

                

                              for (int i = 0; i < dt.Rows.Count; i++)
                              {
                                  dr = dt.Rows[i];
                                  tempColumnId = Convert.ToString(dr["Column_ID"] ?? "");
                                  tempColumn_Name = Convert.ToString(dr["Column_Name"] ?? "");
                                  tempColumn_Depth = int.Parse(Convert.ToString(dr["Column_Depth"] ?? ""));

                                  DataTable dtTemp = this.Db.GetTable("select Column_ID,Column_Name,Column_Depth from Expro_NewsType where Parent_ID=@Parent_ID", new System.Data.SqlClient.SqlParameter("@Parent_ID", tempColumnId));
                                  if (dtTemp != null && dtTemp.Rows.Count>0)
                                  {
                                      string tempGe = "";
                                      for (int j = 0; j < tempColumn_Depth - 1; j++)
                                      {
                                          tempGe += "";
                                      }
                                      this.DdlGTypeId.Items.Add(new ListItem(tempGe + tempColumn_Name, tempColumnId));
                                      SortList(dtTemp, tempColumnId);
                                  }
                                  else
                                  {

                                      string tempGe = "";
                                      for (int j = 0; j < tempColumn_Depth-1; j++)
                                      {
                                          tempGe += "";
                                      }
                                      this.DdlGTypeId.Items.Add(new ListItem(tempGe+tempColumn_Name, tempColumnId));
                                  }


                              }
                          }
               
                      }
                     
                  }


                  protected void BtEdit_Click(object sender, EventArgs e)
                  {
                      UI.cs.Util.UploadFile uf = new UI.cs.Util.UploadFile();
                      string tempGPic = uf.GetSqlFile("Expro/News", 600, 360);

                        SQLDB.Expro_news Expro_news = new SQLDB.Expro_news();
                        Expro_news.GTypeId = this.DdlGTypeId.SelectedValue.ToString();
                        Expro_news.GTitle = this.TbGTitle.Text;
                        Expro_news.GKeyWord = this.TbGKeyWord.Text;
                        Expro_news.GDescription = this.TbGDescription.Text;
                        Expro_news.GContent = this.TbGContent.Text;
                        Expro_news.GAddTime = this.TbGAddTime.Text;
                        Expro_news.GPic = tempGPic;
                        Expro_news.GRecommmend=CbGRecommend.Checked?("1"):("0");

                      

                        string Gid = this.GetRequest("Gid");
                        Expro_news.Gid = Gid.Length>0?(Gid):("");
                     
                        if (Expro_news.Update())
                        {
                            this.JSMessage = "成功編輯新聞!";
                            this.JSScript = "document.location=document.location";
                        }
                        else
                        {
                            this.JSMessage = "更新數(shù)據(jù)時(shí)發(fā)生錯(cuò)誤!";
                            this.JSScript = "history.go(-1)";
                        }
                        this.ShowMessage(JSMessage, JSScript);

           

                  }

               

              
              }
          }

          posted on 2009-03-13 18:19 sanmao 閱讀(82) 評(píng)論(0)  編輯  收藏

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


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

          常用鏈接

          留言簿(5)

          隨筆分類(lèi)

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 双城市| 都匀市| 新丰县| 桂平市| 台前县| 获嘉县| 临江市| 琼结县| 准格尔旗| 龙陵县| 普陀区| 临洮县| 修水县| 宁波市| 新兴县| 修文县| 东安县| 黄石市| 宿州市| 柳河县| 紫阳县| 始兴县| 大石桥市| 厦门市| 襄汾县| 久治县| 大新县| 方正县| 昂仁县| 海宁市| 静海县| 防城港市| 崇义县| 合阳县| 丽水市| 平果县| 新和县| 镇赉县| 永修县| 商丘市| 鄂州市|