コード例 #1
0
ファイル: AddImg.aspx.cs プロジェクト: liuyim93/yohome
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["typeId"] != null && Request.QueryString["typeId"] != "")
         {
             int imgTypeId = Convert.ToInt32(Request.QueryString["typeId"]);
             hfTypeId.Value       = imgTypeId.ToString();
             hlnkList.NavigateUrl = "Img.aspx?typeId=" + imgTypeId;
             txtTimer.Value       = DateTime.Now.ToString("yyyy-MM-dd");
             List <ImgType> list = ImgTypeBll.GetImgTypebyId(imgTypeId);
             if (list.Count > 0)
             {
                 lblType.Text  = list[0].TypeName;
                 ltlTitle.Text = "添加" + list[0].TypeName;
                 hlnkList.Text = "查看" + list[0].TypeName + "列表";
             }
             else
             {
                 lblType.Text  = "";
                 ltlTitle.Text = "添加图片";
                 hlnkList.Text = "查看图片列表";
             }
         }
         else if (Request.QueryString["id"] != null && Request.QueryString["id"] != "")
         {
             int id = Convert.ToInt32(Request.QueryString["id"]);
             hfId.Value = id.ToString();
             List <Model.Img> list = ImgBll.GetImgbyId(id);
             if (list.Count > 0)
             {
                 txtTitle.Text   = list[0].Title;
                 txtImg.Text     = list[0].ImgUrl;
                 txtLink.Text    = list[0].LinkUrl;
                 txtRank.Text    = list[0].Rank.ToString();
                 txtTimer.Value  = list[0].CreateTime;
                 chkShow.Checked = Convert.ToBoolean(list[0].IsShow);
                 List <ImgType> list_imgType = ImgTypeBll.GetImgTypebyId(list[0].ImgTypeId);
                 if (list_imgType.Count > 0)
                 {
                     lblType.Text  = list_imgType[0].TypeName;
                     ltlTitle.Text = "添加" + list_imgType[0].TypeName;
                     hlnkList.Text = "查看" + list_imgType[0].TypeName + "列表";
                 }
                 else
                 {
                     lblType.Text = "";
                 }
                 hlnkList.NavigateUrl = "Img.aspx?typeId=" + list[0].ImgTypeId;
             }
         }
     }
 }
コード例 #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (hfImgId.Value != "")
     {
         int    imgId  = Convert.ToInt32(hfImgId.Value);
         string imgUrl = hfImgUrl.Value;
         try
         {
             ImgBll.UpdateImgUrl(imgId, imgUrl);
             MessageBox.Alert("保存成功!", Page);
             Bind();
         }
         catch (Exception)
         {
             MessageBox.Alert("保存失败!", Page);
         }
     }
     else
     {
         Img img = new Img();
         img.Title  = "首页盛大开幕图片";
         img.Rank   = 1;
         img.ImgUrl = hfImgUrl.Value;
         string         typeName = "盛大开幕图片";
         List <ImgType> list     = ImgTypeBll.GetImgTypebyName(typeName);
         if (list.Count > 0)
         {
             img.ImgTypeId = list[0].ImgTypeId;
         }
         else
         {
             img.ImgTypeId = 3;
         }
         img.IsShow     = 1;
         img.LinkUrl    = "#";
         img.Remark     = "";
         img.CreateTime = DateTime.Now.ToString("yyyy-MM-dd");
         try
         {
             ImgBll.AddImg(img);
             Bind();
             MessageBox.Alert("保存成功!", Page);
         }
         catch (Exception)
         {
             MessageBox.Alert("保存失败!", Page);
         }
     }
 }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["typeId"] == null || Request.QueryString["typeId"] == "")
         {
             Response.Redirect("right.aspx");
         }
         else
         {
             int imgTypeId = Convert.ToInt32(Request.QueryString["typeId"]);
             hfTypeId.Value = imgTypeId.ToString();
             List <ImgType> list = ImgTypeBll.GetImgTypebyId(imgTypeId);
             if (list.Count > 0)
             {
                 ltlTitle.Text = list[0].TypeName + "管理";
             }
             hlnkAdd.NavigateUrl = "AddImg.aspx?typeId=" + imgTypeId;
             BindData();
         }
     }
 }