protected void Page_Load(object sender, EventArgs e) { com.adminLogin(); if (!IsPostBack) { string lbid = pg.request("lbid"); if (lbid == "") { lbid = "0"; } if (lbid != "") { lbname = clsLB.getLbname(lbid); hLbid.Value = lbid; } string act = pg.request("act"); if (act == "top") { //置顶 List <DXProd> prods = (from pro in dbContext.DXProd where pro.lbid == Int32.Parse(lbid) select pro).ToList <DXProd>(); foreach (var item in prods) { item.isTop = false; } dbContext.SubmitChanges(); DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(pg.request("id")) select pro).First <DXProd>(); pro_.isTop = true; dbContext.SubmitChanges(); return; } if (act == "IsIndex") { //置顶 DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(pg.request("id")) select pro).First <DXProd>(); pro_.isIndex = true; dbContext.SubmitChanges(); alert.showAndGo("设置成功", "Prod.aspx?lbid=" + lbid); return; } if (act == "del") { string id = pg.request("id"); DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(pg.request("id")) select pro).First <DXProd>(); //删除图片 FileSys.delFile(pro_.pic); FileSys.delFile(pro_.picSmall); FileSys.delFile(pro_.pic.Replace(".jpg", "_s.jpg")); //删除 dbContext.DXProd.DeleteOnSubmit(dbContext.DXProd.Single(c => c.Id == Int32.Parse(id))); alert.showAndGo("删除成功", "Prod.aspx?lbid=" + lbid); return; } bindGv(); } }
public string setIsIndex(string newsid) { DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(newsid) select pro).First <DXProd>(); string re = ""; if (pro_.isIndex) { re = "<a href='Prod.aspx?act=IsIndex&value=0&lbid=" + hLbid.Value + "&id=" + newsid + "' style='color:red;'>取消首页</a>"; } else { re = "<a href='Prod.aspx?act=IsIndex&value=1&lbid=" + hLbid.Value + "&id=" + newsid + "' style='color:green;'>放到首页</a>"; } return(re); }
public string setTopBtn(string newsid) { lbid = hLbid.Value; DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(newsid) select pro).First <DXProd>(); string re = ""; if (!pro_.isTop) { re = "<a href='Prod.aspx?act=top&pid=" + lbid + "&id=" + newsid + "'>置顶</a>"; } else { re = "已置顶"; } return(re); }
protected void pageInit() { try { DXProd pro_ = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(NewsID) select pro).First <DXProd>(); string title = pro_.Name; string newsBody = pro_.Body; string desc = pro_.Description; string pic = pro_.pic; DateTime?CreateTime = pro_.CreateTime; string picSmall = pro_.picSmall; string addTime = ""; if (CreateTime != null) { addTime = CreateTime.Value.ToString("yyyy-MM-dd hh:mm:ss"); } lbid = pro_.lbid.ToString();; pid = clsLB.getPid(lbid); bindLbList(Int32.Parse(pid)); lbList.SelectedValue = lbid; //lbname = clsLB.getLbname(lbid); hID.Value = NewsID; hPic.Value = pic; hSmallPic.Value = picSmall; txtTitle.Text = title; txtAddTime.Text = addTime; FCKeditor1.Value = newsBody; btnAdd.Text = "修改并保存"; lblOper.Text = "修改" + lbname; } catch (Exception ex) { Response.Write(ex.Message); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { com.adminLogin(); if (!IsPostBack) { string id = pg.request("id"); NewsID = id; pid = pg.request("pid"); if (pid.Length > 0) { pname = clsLB.getLbname(pid); lblPname.Text = pname; hPid.Value = pid; } string act = pg.request("act"); if (act == "delpic") { //由前台的jquery异步调用 string imgsrc = pg.request("imgsrc"); try { DXProd pd = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(id) select pro).First <DXProd>(); pd.pics = pd.pics.Replace(imgsrc, ""); pd.pics = pd.pics.Replace("||", "|"); dbContext.SubmitChanges(); FileSys.delFile(imgsrc); Response.Write("ok"); } catch (Exception ex) { Response.Write("ERROR: " + ex.Message); } Response.End(); } if (id != "") { pageInit(); } else { lbid = pg.request("lbid"); if (lbid == "") { lbid = "0"; } lbname = clsLB.getLbname(lbid); pid = clsLB.getPid(lbid); bindLbList(Int32.Parse(pid)); txtAddTime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); btnAdd.Text = "添加"; lblOper.Text = "添加" + lbname; } //txtStar.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}"); //txtStudentCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}"); //txtStudentTotalCount.Attributes.Add("onchange", "if(/\\D/.test(this.value)){alert('只能输入数字');this.value=''}"); } }
protected void btnAdd_Click(object sender, EventArgs e) { lbid = lbList.SelectedValue; string id = hID.Value; string title = pg.GetSafeString(txtTitle.Text); string oldPic = hPic.Value; string newPic = hPic_new.Value; string oldSmallPic = hSmallPic.Value; //string newsBody = pg.GetSafeString(tbxBody.Text).Replace("\"", "''"); string newsBody = FCKeditor1.Value; string pic, picSmall = hSmallPic_new.Value; string addtime = pg.GetSafeString(txtAddTime.Text); string pid = hPid.Value; pic = oldPic + newPic; pic = pic.Replace("||", "|"); string sql = ""; if (id.Length > 0) { if (picSmall == "") { //未上传小图 picSmall = oldSmallPic; } else { //已上传小图并且原来有图 if (picSmall != "" && oldSmallPic != "") { //删除旧图 FileSys.delFile(oldSmallPic); } } DXProd pd = (from pro in dbContext.DXProd where pro.Id == Int32.Parse(id) select pro).First <DXProd>(); pd.lbid = Int32.Parse(lbid); pd.Name = title; pd.pic = pic; pd.picSmall = picSmall; pd.Body = newsBody; pd.EditorName = Session["AdminName"].ToString(); pd.EditTime = DateTime.Now; dbContext.SubmitChanges(); alert.showAndGo("修改成功", "Prod.aspx?lbid=" + lbid); } else { try { //添加 DXProd pd = new DXProd(); pd.lbid = Int32.Parse(lbid); pd.Name = title; pd.pic = pic; pd.picSmall = picSmall; pd.Body = newsBody; pd.CreateTime = DateTime.Now; pd.EditTime = DateTime.Now; pd.CreatorName = Session["AdminName"].ToString(); pd.EditorName = Session["AdminName"].ToString(); dbContext.DXProd.InsertOnSubmit(pd); dbContext.SubmitChanges(); alert.showAndGo("添加成功", "Prod.aspx?lbid=" + lbid); } catch (Exception ex) { alert.ShowAndBack(Page, "添加失败" + ex.Message); } } }