public void ShowData() { if (Request["ProductID"] + "" == "") { Response.Redirect("RightsWarn.aspx"); } else { try { WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); WebProject.Model.BaseData.ZT_COM_Product model_Product = bll_Product.GetModel(Int32.Parse(Request["ProductID"].ToString())); if (model_Product.TypeNo.ToString() != "") { this.txtProductType.SelectedValue = model_Product.TypeNo.ToString(); } this.txtProductInfo.Text = model_Product.ProductInfo.ToString(); this.txtProductName.Text = model_Product.ProductName.ToString(); this.txtProductOrder.Text = model_Product.ProductOrder.ToString(); } catch { Response.Redirect("RightsWarn.aspx"); } } }
protected void btnSetNoImg_Click(object sender, EventArgs e) { if (Request["ProductID"] + "" == "") { Response.Redirect("RightsWarn.aspx"); } else { try { WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); WebProject.Model.BaseData.ZT_COM_Product model_Product = bll_Product.GetModel(Int32.Parse(Request["ProductID"].ToString())); if (model_Product.ProductImgUrl.ToString() != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + model_Product.ProductImgUrl.ToString())); model_Product.ProductImgUrl = "onlinenone.jpg"; model_Product.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo; model_Product.LastUpdateDate = DateTime.Now; bll_Product.Update(model_Product); } LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除图片", "成功", "产品名称:" + model_Product.ProductName + ", 修改人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.Show(this, "删除原图片成功!"); } catch { Response.Redirect("RightsWarn.aspx"); } } }
public void ShowData() { WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DataSet ds = null; if (this.txtProductType.SelectedValue == "ALL") { ds = bll_Product.GetList(" 1=1 "); } else { ds = bll_Product.GetList(" TypeNo='" + this.txtProductType.SelectedValue + "'"); } if (ds.Tables[0].Rows.Count > 0) { this.GridView1.Visible = true; this.btnDeleteSelect.Visible = true; this.lblMessage.Visible = false; this.GridView1.DataSource = ds; this.GridView1.DataBind(); } else { this.lblMessage.Visible = true; this.btnDeleteSelect.Visible = false; this.GridView1.Visible = false; } }
public void ShowProductInfo() { WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DataSet ds = bll_Product.GetList(" 1=1 "); this.RPProduct.DataSource = ds; this.RPProduct.DataBind(); }
public void ShowProduct() { int currentPage = Convert.ToInt32(this.dang.Text); //当前页 WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DataSet ds = bll_Product.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("ProductDelete.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("lblProductID"); int ProductID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DeleteTitle += bll_Product.GetModel(ProductID).ProductName + ","; bll_Product.Delete(ProductID); //删除文件夹的图片 Label l2 = (Label)gr.Cells[0].FindControl("lblProductImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } } } LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品信息", "成功", "产品名称:" + DeleteTitle.TrimEnd(',') + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); ShowData(); } } }
public void ShowProductInfo() { if (Request["ProductID"] + "" == "") { Response.Redirect("ErrorPage.aspx"); } else { try { int ProductID = Convert.ToInt32(Request.QueryString["ProductID"].ToString()); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); WebProject.Model.BaseData.ZT_COM_Product model_Product = bll_Product.GetModel(ProductID); this.ProductImgUrl.ImageUrl = "SysManage/IMG/" + model_Product.ProductImgUrl.ToString(); this.lblProductName.Text = model_Product.ProductName.ToString(); this.lblProductInfo.Text = model_Product.ProductInfo.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.txtProductName.Text.Trim() == "") { MessageBox.Show(this, "请输入产品名称!"); return; } if (this.txtProductInfo.Text.Trim() == "") { MessageBox.Show(this, "请输入信息内容!"); return; } int ProductOrder; if (this.txtProductOrder.Text.Trim() == "") { ProductOrder = 1000; } else { double u; if (!double.TryParse(this.txtProductOrder.Text.Trim(), out u)) { MessageBox.Show(this, "排序必须为数字!"); return; } else { ProductOrder = Convert.ToInt32(this.txtProductOrder.Text.Trim()); } } Boolean fileTypeOK = false; String path = Server.MapPath("~/SysManage/IMG/"); if (txtProductImgUrl.HasFile == false) { try { WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); WebProject.Model.BaseData.ZT_COM_Product model_Product = bll_Product.GetModel(Int32.Parse(Request["ProductID"].ToString())); model_Product.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo; model_Product.LastUpdateDate = DateTime.Now; if (this.txtProductType.Items.Count > 0) { model_Product.TypeName = this.txtProductType.Items[this.txtProductType.SelectedIndex].Text.ToString(); model_Product.TypeNo = this.txtProductType.SelectedValue.ToString(); } model_Product.ProductInfo = this.txtProductInfo.Text.Trim(); model_Product.ProductName = this.txtProductName.Text.Trim(); model_Product.ProductOrder = ProductOrder; bll_Product.Update(model_Product); LogManage.WriteLog(Request.UserHostAddress, "产品管理", "修改产品信息", "成功", "产品名称:" + model_Product.ProductName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "修改信息成功!", "ProductList.aspx"); } catch { Response.Redirect("RightsWarn.aspx"); } } if (txtProductImgUrl.HasFile == true) { String fileExtension = System.IO.Path.GetExtension(txtProductImgUrl.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 (txtProductImgUrl.PostedFile.ContentLength > 10240000) { MessageBox.Show(this, "你选择上传的文件不能大于10M,请重新选择!"); return; } if (txtProductImgUrl.PostedFile.ContentLength <= 10240000) { try { string SaveFileName = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + fileExtension; txtProductImgUrl.PostedFile.SaveAs(path + SaveFileName); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); WebProject.Model.BaseData.ZT_COM_Product model_Product = bll_Product.GetModel(Int32.Parse(Request["ProductID"].ToString())); model_Product.LastUpdateBy = SessionUtil.GetAdminSession().AdminNo; model_Product.LastUpdateDate = DateTime.Now; if (this.txtProductType.Items.Count > 0) { model_Product.TypeName = this.txtProductType.Items[this.txtProductType.SelectedIndex].Text.ToString(); model_Product.TypeNo = this.txtProductType.SelectedValue.ToString(); } model_Product.ProductImgUrl = SaveFileName; model_Product.ProductInfo = this.txtProductInfo.Text.Trim(); model_Product.ProductName = this.txtProductName.Text.Trim(); model_Product.ProductOrder = ProductOrder; bll_Product.Update(model_Product); LogManage.WriteLog(Request.UserHostAddress, "产品管理", "修改产品信息", "成功", "产品名称:" + model_Product.ProductName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); MessageBox.ShowAndRedirect(this, "修改信息成功!", "ProductList.aspx"); } catch (Exception) { MessageBox.Show(this, "文件上传失败!"); return; } } } } } }
public void ProductView() { if (Request["TypeID"] + "" == "") { Response.Redirect("ErrorPage.aspx"); } else { try { int TypeID = Convert.ToInt32(Request.QueryString["TypeID"].ToString()); WebProject.BLL.BaseData.ZT_COM_ProductType bll_ProductType = new WebProject.BLL.BaseData.ZT_COM_ProductType(); WebProject.Model.BaseData.ZT_COM_ProductType model_ProductType = bll_ProductType.GetModel(TypeID); int currentPage = Convert.ToInt32(this.dang.Text); //当前页 WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); DataSet ds = bll_Product.GetList(" TypeNo='" + model_ProductType.TypeNo + "'"); 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; } } 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("ProductDelete.aspx")) { Response.Redirect("RightsWarn.aspx"); } else { //删除数据库的信息 Label ll = (Label)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("lblProductID"); int ProductID = Convert.ToInt32(ll.Text); WebProject.BLL.BaseData.ZT_COM_Product bll_Product = new WebProject.BLL.BaseData.ZT_COM_Product(); LogManage.WriteLog(Request.UserHostAddress, "产品管理", "删除产品信息", "成功", "产品名称:" + bll_Product.GetModel(ProductID).ProductName + ", 操作人:" + SessionUtil.GetAdminSession().AdminNo); bll_Product.Delete(ProductID); //删除文件夹的图片 Label l2 = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblProductImgUrl"); if (l2.Text != "onlinenone.jpg") { System.IO.File.Delete(Server.MapPath("IMG/" + l2.Text)); } //重新加载信息 ShowData(); } } }