Пример #1
0
 public void BindData()
 {
     if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
     {
         int infoId             = Convert.ToInt32(Request.QueryString["id"]);
         List <Model.Info> list = InfoBll.GetInfobyId(infoId);
         if (list.Count > 0)
         {
             ltlTitle.Text    = list[0].TypeName;
             fck_detail.Value = list[0].Details;
         }
         else
         {
             MessageBox.AlertAndRedirect("您查找的内容不存在!", "right.aspx", Page);
         }
     }
 }
Пример #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Model.News news = new Model.News();
     if (txtTitle.Text == "")
     {
         MessageBox.Alert("标题不能为空!", Page);
         txtTitle.Focus();
     }
     else
     {
         if (dropType.SelectedItem.Text == "--请选择新闻类型--")
         {
             MessageBox.Alert("请选择新闻类型!", Page);
             dropType.Focus();
         }
         else
         {
             news.NewsTypeId = Convert.ToInt32(dropType.SelectedValue);
             if (txtTimer.Value == "")
             {
                 news.CreateTime = DateTime.Now.ToString("yyyy-MM-dd");
             }
             else
             {
                 news.CreateTime = txtTimer.Value;
             }
             if (hfImgUrl.Value == "")
             {
                 news.ImgUrl = txtImgUrl.Text.Trim();
             }
             else
             {
                 news.ImgUrl = hfImgUrl.Value;
             }
             news.Title     = txtTitle.Text;
             news.Intro     = fck_intro.Value;
             news.Details   = fck_detail.Value;
             news.IsShow    = Convert.ToInt32(chkShow.Checked);
             news.IsTop     = Convert.ToInt32(chkTop.Checked);
             news.IndexShow = Convert.ToInt32(chkIndex.Checked);
             if (hfId.Value == "" || hfId.Value == null)
             {
                 try
                 {
                     NewsBll.AddNews(news);
                     MessageBox.AlertAndRedirect("添加成功!", "News.aspx", Page);
                 }
                 catch (Exception)
                 {
                     MessageBox.Alert("添加失败!", Page);
                     /*throw;*/
                 }
             }
             else
             {
                 news.NewsId = Convert.ToInt32(hfId.Value);
                 try
                 {
                     NewsBll.UpdateNews(news);
                     MessageBox.AlertAndRedirect("修改成功!", "News.aspx", Page);
                 }
                 catch (Exception)
                 {
                     MessageBox.Alert("修改失败!", Page);
                     /*throw;*/
                 }
             }
         }
     }
 }
Пример #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.Product pro = new Model.Product();
            if (txtTitle.Text == "")
            {
                MessageBox.Alert("产品名称不能为空!", Page);
                txtTitle.Focus();
            }
            else if (hfId.Value == "" && hftypeId.Value == "")
            {
                Response.Redirect("right.aspx");
            }
            else
            {
                pro.Title     = txtTitle.Text;
                pro.IsShow    = Convert.ToInt32(chkShow.Checked);
                pro.IndexShow = Convert.ToInt32(chkIndex.Checked);
                pro.Intro     = fck_intro.Value;
                pro.Details   = fck_detail.Value;
                if (txtTimer.Value == "")
                {
                    pro.CreateTime = DateTime.Now.ToString("yyy-MM-dd");
                }
                else
                {
                    pro.CreateTime = txtTimer.Value;
                }
                //判断缩略图的值
                if (txtImg.Text == "" && hfImgUrl1.Value == "")
                {
                    pro.ImgUrl = "";
                }
                else if (txtImg.Text != "" && hfImgUrl1.Value == "")
                {
                    pro.ImgUrl = txtImg.Text;
                }
                else if (txtImg.Text == "" && hfImgUrl1.Value != "")
                {
                    pro.ImgUrl = hfImgUrl1.Value;
                }
                else if (txtImg.Text != hfImgUrl1.Value)
                {
                    pro.ImgUrl = hfImgUrl1.Value;
                }
                else
                {
                    pro.ImgUrl = txtImg.Text;
                }
                //判断大图的值
                if (txtBigImg.Text == "" && hfImgUrl.Value == "")
                {
                    pro.BigImgUrl = "";
                }
                else if (txtBigImg.Text != "" && hfImgUrl.Value == "")
                {
                    pro.BigImgUrl = txtBigImg.Text;
                }
                else if (txtBigImg.Text == "" && hfImgUrl.Value != "")
                {
                    pro.BigImgUrl = hfImgUrl.Value;
                }
                else if (txtBigImg.Text != hfImgUrl.Value)
                {
                    pro.BigImgUrl = hfImgUrl.Value;
                }
                else
                {
                    pro.BigImgUrl = txtBigImg.Text;
                }

                //判断产品类型的值
                if (hftypeId.Value != "")
                {
                    pro.ProTypeId = Convert.ToInt32(hftypeId.Value);
                    try
                    {
                        ProductBll.AddProduct(pro);
                        MessageBox.AlertAndRedirect("添加成功!", "Product.aspx?typeId=" + pro.ProTypeId, Page);
                    }
                    catch (Exception)
                    {
                        MessageBox.Alert("添加失败!", Page);
                        throw;
                    }
                }
                else if (hfId.Value != "")
                {
                    int id = Convert.ToInt32(hfId.Value);
                    pro.ProId = id;
                    List <Model.Product> list = ProductBll.GetProductbyId(id);
                    if (list.Count > 0)
                    {
                        pro.ProTypeId = list[0].ProTypeId;
                        try
                        {
                            ProductBll.UpdateProduct(pro);
                            MessageBox.AlertAndRedirect("修改成功!", "Product.aspx?typeId=" + pro.ProTypeId, Page);
                        }
                        catch (Exception)
                        {
                            MessageBox.Alert("修改失败!", Page);
                            /*throw;*/
                        }
                    }
                }
            }
        }
Пример #4
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Model.Img img = new Model.Img();
     if (txtTitle.Text == "")
     {
         MessageBox.Alert("标题不能为空!", Page);
         txtTitle.Focus();
     }
     else if (hfId.Value == "" && hfTypeId.Value == "")
     {
         Response.Redirect("right.aspx");
     }
     else
     {
         img.Title   = txtTitle.Text.Trim();
         img.IsShow  = Convert.ToInt32(chkShow.Checked);
         img.LinkUrl = txtLink.Text;
         img.Remark  = "";
         if (txtTimer.Value == "")
         {
             img.CreateTime = DateTime.Now.ToString("yyyy-MM-dd");
         }
         else
         {
             img.CreateTime = txtTimer.Value;
         }
         if (txtRank.Text == "")
         {
             img.Rank = 0;
         }
         else
         {
             try
             {
                 img.Rank = Convert.ToInt32(txtRank.Text);
             }
             catch (Exception)
             {
                 img.Rank = 0;
                 /*throw;*/
             }
         }
         //判断缩略图的值
         if (txtImg.Text == "" && hfImgUrl.Value == "")
         {
             img.ImgUrl = "";
         }
         else if (txtImg.Text != "" && hfImgUrl.Value == "")
         {
             img.ImgUrl = txtImg.Text;
         }
         else if (txtImg.Text == "" && hfImgUrl.Value != "")
         {
             img.ImgUrl = hfImgUrl.Value;
         }
         else if (txtImg.Text != hfImgUrl.Value)
         {
             img.ImgUrl = hfImgUrl.Value;
         }
         else
         {
             img.ImgUrl = txtImg.Text;
         }
         if (hfTypeId.Value != "")
         {
             img.ImgTypeId = Convert.ToInt32(hfTypeId.Value);
             try
             {
                 ImgBll.AddImg(img);
                 MessageBox.AlertAndRedirect("添加成功!", "Img.aspx?typeId=" + img.ImgTypeId, Page);
             }
             catch (Exception)
             {
                 MessageBox.Alert("添加失败!", Page);
                 /*throw;*/
             }
         }
         else if (hfId.Value != "")
         {
             img.ImgId = Convert.ToInt32(hfId.Value);
             List <Model.Img> list = ImgBll.GetImgbyId(img.ImgId);
             if (list.Count > 0)
             {
                 img.ImgTypeId = list[0].ImgTypeId;
                 try
                 {
                     ImgBll.UpdateImg(img);
                     MessageBox.AlertAndRedirect("修改成功!", "Img.aspx?typeId=" + img.ImgTypeId, Page);
                 }
                 catch (Exception)
                 {
                     MessageBox.Alert("修改失败!", Page);
                     /*throw;*/
                 }
             }
         }
     }
 }