public void ShowData(string RongYuTypeNo) { WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); DataSet ds = null; if (RongYuTypeNo == "ALL") { ds = bll_RongYu.GetList(""); } else { ds = bll_RongYu.GetList("RongYuTypeNo='" + RongYuTypeNo + "'"); } if (ds.Tables[0].Rows.Count > 0) { this.lblMessage.Visible = false; this.btnDeleteSelect.Visible = true; this.GridView1.Visible = true; this.GridView1.DataSource = ds; this.GridView1.DataBind(); } else { this.lblMessage.Visible = true; this.btnDeleteSelect.Visible = false; this.GridView1.Visible = false; } }
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"); } } }
public void ShowRongYuInfo() { int currentPage = Convert.ToInt32(this.dang.Text); //当前页 WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); DataSet ds = bll_RongYu.GetList(" 1=1 "); this.count.Text = ds.Tables[0].Rows.Count.ToString(); if (ds.Tables[0].Rows.Count != 0) { System.Web.UI.WebControls.PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.AllowPaging = true; pds.PageSize = 6; pds.CurrentPageIndex = currentPage - 1; //当前页面索引,索引号从0开始 this.countpage.Text = pds.PageCount.ToString();//总页数 if (currentPage == 1) { this.shou.Enabled = false; this.shang.Enabled = false; } else { this.shou.Enabled = true; this.shang.Enabled = true; } if (currentPage == pds.PageCount) { this.xia.Enabled = false; this.last.Enabled = false; } else { this.xia.Enabled = true; this.last.Enabled = true; } this.DataList1.DataSource = pds; this.DataList1.DataBind(); } else { this.lblMessage.Visible = true; this.countpage.Text = this.dang.Text; this.shou.Enabled = false; this.shang.Enabled = false; this.xia.Enabled = false; this.last.Enabled = false; } }
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 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; } Boolean fileTypeOK = false; String path = Server.MapPath("~/SysManage/IMG/"); if (txtImgUrl.HasFile == false) { WebProject.Model.BaseData.ZT_COM_RongYu model_RongYu = new WebProject.Model.BaseData.ZT_COM_RongYu(); model_RongYu.Title = this.txtTitle.Text.Trim(); if (this.txtRongYuType.Items.Count > 0) { model_RongYu.RongYuTypeNo = this.txtRongYuType.SelectedValue.ToString(); model_RongYu.RongYuTypeName = this.txtRongYuType.Items[this.txtRongYuType.SelectedIndex].Text.ToString(); } model_RongYu.ImgUrl = "onlinenone.jpg"; model_RongYu.RongYuOrder = Int32.Parse(this.txtRongYuOrder.Text.Trim()); model_RongYu.Body = this.txtBody.Text.Trim(); model_RongYu.CreateBy = SessionUtil.GetAdminSession().AdminNo; model_RongYu.CreateDate = DateTime.Now; WebProject.BLL.BaseData.ZT_COM_RongYu bll_Rongyu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); bll_Rongyu.Add(model_RongYu); MessageBox.ShowAndRedirect(this, "添加信息成功!", "RongYuList.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.Model.BaseData.ZT_COM_RongYu model_RongYu = new WebProject.Model.BaseData.ZT_COM_RongYu(); model_RongYu.Title = this.txtTitle.Text.Trim(); if (this.txtRongYuType.Items.Count > 0) { model_RongYu.RongYuTypeNo = this.txtRongYuType.SelectedValue.ToString(); model_RongYu.RongYuTypeName = this.txtRongYuType.Items[this.txtRongYuType.SelectedIndex].Text.ToString(); } model_RongYu.ImgUrl = SaveFileName; model_RongYu.RongYuOrder = Int32.Parse(this.txtRongYuOrder.Text.Trim()); model_RongYu.Body = this.txtBody.Text.Trim(); model_RongYu.CreateBy = SessionUtil.GetAdminSession().AdminNo; model_RongYu.CreateDate = DateTime.Now; WebProject.BLL.BaseData.ZT_COM_RongYu bll_RongYu = new WebProject.BLL.BaseData.ZT_COM_RongYu(); bll_RongYu.Add(model_RongYu); LogManage.WriteLog(Request.UserHostAddress, "荣誉管理", "添加荣誉", "成功", " 荣誉名称:" + model_RongYu.Title + "操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "添加信息成功!", "RongYuList.aspx"); } catch (Exception) { MessageBox.Show(this, "文件上传失败!"); return; } } } } } }
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()); } } }