protected void Page_Load(object sender, EventArgs e) { if (null != Common.Common.NoHtml(Request.QueryString["action"])) { strAction = Common.Common.NoHtml(Request.QueryString["action"]); } if (null != Common.Common.NoHtml(Request.QueryString["id"])) { strID = Common.Common.NoHtml(Request.QueryString["id"]); } DAL.Product.ProductDAL dal = new DAL.Product.ProductDAL(); switch (strAction) { case "del": if (dal.UpdateProductState(strID)) { strMessage = "删除商品完成!"; } else { strMessage = "删除商品失败!"; } break; default: break; } Response.Write(strMessage); Response.End(); }
/// <summary> /// 加载数据 /// </summary> /// <param name="strWhere">条件</param> void LoadData(string strWhere) { DAL.Product.ProductDAL dal = new DAL.Product.ProductDAL(); DataSet ds = dal.GetProductList(strWhere); DataView dv = ds.Tables[0].DefaultView; AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; Repeater1.DataSource = pds; Repeater1.DataBind(); }
public void ShowProductInfo(string strID) { DAL.Product.ProductDAL dal = new DAL.Product.ProductDAL(); DataSet ds = dal.GetProductDetail(strID); Model.SP.SP_Product model = DataConvert.DataRowToModel <Model.SP.SP_Product>(ds.Tables[0].Rows[0]); this.txtArticleTitle.Text = model.Name; this.ddlCategory.SelectedIndex = this.ddlCategory.Items.IndexOf(this.ddlCategory.Items.FindByValue(model.CatID)); this.txtArticleIsTop.SelectedIndex = this.txtArticleIsTop.Items.IndexOf(this.txtArticleIsTop.Items.FindByValue(model.IsTop == 1 ? "是" : "否")); this.hd_content.Value = model.Desc; this.txtOrder.Text = model.Order.ToString(); this.img0.Src = "../../" + model.Photo; this.txtCredits.Text = model.Credits.ToString(); this.txtNPrice.Text = model.NormalPrice.ToString(); this.txtMPrice.Text = model.MemberPrice.ToString(); this.txtUnit.Text = model.Unit; if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
protected void btnSave_Click(object sender, EventArgs e) { if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"]) { Response.Write("<script language=JavaScript>;parent.location.href='../Login.aspx';</script>"); Response.End(); } //上传图标 string strIconFileName = string.Empty; //图标路径 string strIconSaveFileName = string.Empty; //网址路径 try { if (this.file0.PostedFile.FileName == "") { MessageBox.Show(this, "请选择上传文件!"); } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Photo")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Photo"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/Photo/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/Photo/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())); } string orignalName = this.file0.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName = String.Format(@"{0}Photo/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName); strIconSaveFileName = String.Format(@"Photo/{0}/{1}", Session["strSiteCode"].ToString(), newName); file0.PostedFile.SaveAs(strIconFileName); } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } DAL.Product.ProductDAL dal = new DAL.Product.ProductDAL(); Model.SP.SP_Product modelUpdate = new Model.SP.SP_Product { ID = strID, //文章标题 Name = this.txtArticleTitle.Text, //图标路径 Photo = strIconSaveFileName,//strIconFileName, //文章内容 Desc = this.hd_content.Value, //站点代码 SiteCode = Session["strSiteCode"].ToString(), //类别 CatID = this.ddlCategory.SelectedValue, //积分 Credits = int.Parse(this.txtCredits.Text), //单位 Unit = this.txtUnit.Text, //普通价格 NormalPrice = int.Parse(this.txtNPrice.Text), //会员价格 MemberPrice = int.Parse(this.txtMPrice.Text), //是否置顶 IsTop = this.txtArticleIsTop.Text == "是" ? 1 : 0, //是否删除 State = 0, //创建时间 Pdate = DateTime.Now, //有效开始时间 StartTime = DateTime.Parse("2000-01-01 00:00:00.000"), //有效结束时间 EndTime = DateTime.Parse("2099-01-01 00:00:00.000"), //排序号 Order = int.Parse(this.txtOrder.Text) }; if (dal.UpdateProductData(modelUpdate)) { MessageBox.Show(this, "修改成功!"); } else { MessageBox.Show(this, "修改失败!"); } }