protected void btnSetNoImg_Click(object sender, EventArgs e)
 {
     if (Request["RongYuID"] + "" == "")
     {
         Response.Redirect("RightsWarn.aspx");
     }
     else
     {
         try
         {
             WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
             WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = bll_RongYu.GetModel(Int32.Parse(Request["RongYuID"].ToString()));
             if (model_RongYu.ImgUrl.ToString() != "onlinenone.jpg")
             {
                 System.IO.File.Delete(Server.MapPath("IMG/" + model_RongYu.ImgUrl.ToString()));
                 model_RongYu.ImgUrl = "onlinenone.jpg";
                 model_RongYu.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo;
                 model_RongYu.LastUpdateDate = DateTime.Now;
                 bll_RongYu.Update(model_RongYu);
             }
             LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "删除图片", "成功", " 荣誉名称:" + model_RongYu.Title + "操作人:" + SessionUtil.GetAdminSession().AdminNo);
             MessageBox.Show(this, "删除原图片成功!");
         }
         catch
         {
             Response.Redirect("RightsWarn.aspx");
         }
     }
 }
 public void ShowData()
 {
     if (Request["RongYuID"] + "" == "")
     {
         Response.Redirect("RightsWarn.aspx");
     }
     else
     {
         try
         {
             WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
             WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = bll_RongYu.GetModel(Int32.Parse(Request["RongYuID"].ToString()));
             this.txtTitle.Text = model_RongYu.Title.ToString();
             if (model_RongYu.RongYuTypeNo.ToString() != "")
             {
                 this.txtRongYuType.SelectedValue = model_RongYu.RongYuTypeNo.ToString();
             }
             this.txtRongYuOrder.Text = model_RongYu.RongYuOrder.ToString();
             this.txtBody.Text = model_RongYu.Body.ToString();
         }
         catch
         {
             Response.Redirect("RightsWarn.aspx");
         }
     }
 }
    protected void btnDeleteSelect_Click(object sender, EventArgs e)
    {
        if (Session["ZT_ADMIN"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (!Communal.CheckQx("RongYuDelete.aspx"))
            {
                Response.Redirect("RightsWarn.aspx");
            }
            else
            {
                string DeleteTitle = "";
                foreach (GridViewRow gr in this.GridView1.Rows)
                {
                    CheckBox cb = (CheckBox)gr.Cells[1].FindControl("Select");
                    if (cb.Checked)
                    {
                        //删除数据库信息
                        Label ll = (Label)gr.Cells[1].FindControl("lblRongYuID");
                        int RongYuID = Convert.ToInt32(ll.Text);
                        WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
                        DeleteTitle += bll_RongYu.GetModel(RongYuID).Title + ",";
                        bll_RongYu.Delete(RongYuID);

                        //删除文件夹的图片
                        Label l2 = (Label)gr.Cells[0].FindControl("lblImgUrl");

                        if (l2.Text != "onlinenone.jpg")
                        {
                            System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text));
                        }
                    }
                }
                LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "删除荣誉", "成功", "荣誉标题:" + DeleteTitle.TrimEnd(',') + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo);
                ShowData(txtRongYuType.SelectedValue.ToString());
            }
        }
    }
 public void ShowRongYuInfo()
 {
     if (Request["RongYuID"] + "" == "")
     {
         Response.Redirect("ErrorPage.aspx");
     }
     else
     {
         try
         {
             int RongYuID = Convert.ToInt32(Request.QueryString["RongYuID"].ToString());
             WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
             WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = bll_RongYu.GetModel(RongYuID);
             this.ImgUrl.ImageUrl = "SysManage/IMG/" + model_RongYu.ImgUrl.ToString();
             this.lblTitle.Text = model_RongYu.Title.ToString();
             this.lblBody.Text = model_RongYu.Body.ToString();
         }
         catch
         {
             Response.Redirect("ErrorPage.aspx");
         }
     }
 }
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     if (Session["ZT_ADMIN"] == null)
     {
         Response.Redirect("Login.aspx");
     }
     else
     {
         if (!Communal.CheckQx("RongYuDelete.aspx"))
         {
             Response.Redirect("RightsWarn.aspx");
         }
         else
         {
             //删除数据库的信息
             Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblRongYuID");
             int RongYuID = Convert.ToInt32(ll.Text);
             WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
             LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "删除荣誉", "成功", "荣誉标题:" + bll_RongYu.GetModel(RongYuID).Title + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo);
             bll_RongYu.Delete(RongYuID);
             //删除文件夹的图片
             Label l2 = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblImgUrl");
             if (l2.Text != "onlinenone.jpg")
             {
                 System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text));
             }
             //重新加载信息
             ShowData(txtRongYuType.SelectedValue.ToString());
         }
     }
 }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Session["ZT_ADMIN"] == null)
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            if (this.txtTitle.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入荣誉标题!");
                return;
            }
            int RongYuOrder;
            if (this.txtRongYuOrder.Text.Trim() == "")
            {
                RongYuOrder = 1000;
            }
            else
            {
                double u;
                if (!double.TryParse(this.txtRongYuOrder.Text.Trim(), out u))
                {
                    MessageBox.Show(this, "排序必须为数字!");
                    return;
                }
                else
                {
                    RongYuOrder = Convert.ToInt32(this.txtRongYuOrder.Text.Trim());
                }
            }
            if (this.txtBody.Text.Trim() == "")
            {
                MessageBox.Show(this, "请输入荣誉内容!");
                return;
            }
            if (Request["RongYuID"] + "" == "")
            {
                Response.Redirect("RightsWarn.aspx");
            }
            else
            {
                Boolean fileTypeOK = false;
                String path = Server.MapPath("~/SysManage/IMG/");
                if (txtImgUrl.HasFile == false)
                {
                    try
                    {
                        WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
                        WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = bll_RongYu.GetModel(Int32.Parse(Request["RongYuID"].ToString()));

                        model_RongYu.Body = this.txtBody.Text.Trim();
                        if (this.txtRongYuType.Items.Count > 0)
                        {
                            model_RongYu.RongYuTypeName = this.txtRongYuType.Items[this.txtRongYuType.SelectedIndex].Text.ToString();
                            model_RongYu.RongYuTypeNo = this.txtRongYuType.SelectedValue.ToString();
                        }
                        model_RongYu.RongYuOrder = Int32.Parse(this.txtRongYuOrder.Text.Trim());
                        model_RongYu.Title = this.txtTitle.Text.Trim();
                        model_RongYu.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo;
                        model_RongYu.LastUpdateDate = DateTime.Now;

                        bll_RongYu.Update(model_RongYu);
                        LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "修改荣誉", "成功", " 荣誉名称:" + model_RongYu.Title + "操作人:" + SessionUtil.GetAdminSession().AdminNo);
                        MessageBox.ShowAndRedirect(this, "修改信息成功!", "RongYuList.aspx");
                    }
                    catch
                    {
                        Response.Redirect("RightsWarn.aspx");
                    }
                }
                if (txtImgUrl.HasFile == true)
                {
                    String fileExtension = System.IO.Path.GetExtension(txtImgUrl.FileName).ToLower();
                    String[] allowedExtensions = { ".bmp", ".jpg", ".jpeg", ".png", ".gif" };
                    for (int i = 0; i < allowedExtensions.Length; i++)
                    {
                        if (fileExtension == allowedExtensions[i])
                        {
                            fileTypeOK = true;
                            break;
                        }
                    }
                    if (fileTypeOK == false)
                    {
                        MessageBox.Show(this, "你要上传的文件类型不符合要求!");
                        return;
                    }
                    if (fileTypeOK == true)
                    {
                        if (txtImgUrl.PostedFile.ContentLength > 10240000)
                        {
                            MessageBox.Show(this, "你选择上传的文件不能大于10M,请重新选择!");
                            return;
                        }
                        if (txtImgUrl.PostedFile.ContentLength <= 10240000)
                        {
                            try
                            {
                                string SaveFileName = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + fileExtension;
                                txtImgUrl.PostedFile.SaveAs(path + SaveFileName);
                                WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu();
                                WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = bll_RongYu.GetModel(Int32.Parse(Request["RongYuID"].ToString()));

                                model_RongYu.Body = this.txtBody.Text.Trim();
                                if (this.txtRongYuType.Items.Count > 0)
                                {
                                    model_RongYu.RongYuTypeName = this.txtRongYuType.Items[this.txtRongYuType.SelectedIndex].Text.ToString();
                                    model_RongYu.RongYuTypeNo = this.txtRongYuType.SelectedValue.ToString();
                                }
                                model_RongYu.RongYuOrder = RongYuOrder;
                                model_RongYu.Title = this.txtTitle.Text.Trim();
                                model_RongYu.ImgUrl = SaveFileName;
                                model_RongYu.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo;
                                model_RongYu.LastUpdateDate = DateTime.Now;

                                bll_RongYu.Update(model_RongYu);
                                LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "修改荣誉", "成功", " 荣誉名称:" + model_RongYu.Title + "操作人:" + SessionUtil.GetAdminSession().AdminNo);
                                MessageBox.ShowAndRedirect(this, "修改信息成功!", "RongYuList.aspx");
                            }
                            catch (Exception)
                            {
                                MessageBox.Show(this, "文件上传失败!");
                                return;
                            }
                        }
                    }
                }
            }
        }
    }