protected void submit_Click(object sender, EventArgs e) { using (var db = new SiewebEntities()) { if (uploadWorkPic1() != null) { var data1 = db.pics.FirstOrDefault(a => a.id == 1); string path1 = uploadWorkPic1(); data1.picname = path1; } if (uploadWorkPic2() != null) { string path2 = uploadWorkPic2(); var data2 = db.pics.FirstOrDefault(a => a.id == 2); data2.picname = path2; } if (uploadWorkPic3() != null) { string path3 = uploadWorkPic3(); var data3 = db.pics.FirstOrDefault(a => a.id == 3); data3.picname = path3; } db.SaveChanges(); bindPic(); } }
protected void BtnOk_Click(object sender, EventArgs e) { int tid = -1; try { tid = Convert.ToInt32(Request.QueryString["tid"].ToString()); using (var db = new SiewebEntities()) { string str = Server.HtmlDecode(editor.InnerHtml); var tea = db.teacher.FirstOrDefault(a => a.id == tid); tea.place = TxtPlace.Text.Trim(); tea.tname = TxtName.Text.Trim(); tea.phone = TxtPhone.Text.Replace("\n", "<br/>"); tea.title = TxtTitle.Text.Trim(); tea.body = str; tea.updatetime = DateTime.Now; tea.describe = TxtDes.Text; tea.email = TxtEmail.Text.Trim(); db.SaveChanges(); Response.Write("<script>alert('修改成功');window.location.href='teacherslist.aspx'</script>"); } } catch { Response.Write("<script>alert('修改失败');window.location.href='teacherslist.aspx'</script>"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (TxtNewPassword.Text.Trim() == "" || TxtNewPassword.Text.Trim() == "") { Response.Write("<script>alert('密码不能为空')</script>"); return; } int flag = 0; int id = Convert.ToInt32(Session["adid"]); try { using (var db = new SiewebEntities()) { var ad = from it in db.admins where it.id == id select it; var ad2 = ad.ToList(); for (int i = 0; i < ad2.Count; i++) { if (PasswordHash.PasswordHash.ValidatePassword(TxtOldPassword.Text, ad2[i].password)) { flag = 1; } } } if (flag == 0) { Response.Write("<script>alert('密码错误')</script>"); } else { using (var db2 = new SiewebEntities()) { //var newad = new admins(); admins newad = db2.admins.SingleOrDefault(a => a.id == id); //new newad.password = PasswordHash.PasswordHash.CreateHash(TxtNewPassword.Text); newad.createtime = newad.createtime; newad.updatetime = DateTime.Now; //db2.admins.Add(newad); db2.SaveChanges(); Session.Clear(); Response.Write("<script>alert('修改成功,请重新登录');location='Login.aspx'</script>"); } } } catch (Exception ex) { Response.Redirect("../Login.aspx"); //Response.Write(ex); } }
protected void Rpt_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { using (var db = new SiewebEntities()) { int nid = Convert.ToInt32(e.CommandArgument.ToString()); var ne = db.news.FirstOrDefault(a => a.id == nid); db.news.Remove(ne); db.SaveChanges(); Response.Write("<script>alert('删除成功');window.location.href='newslist.aspx'</script>"); } } }
protected void Rpt_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "del") { int id = Convert.ToInt32(e.CommandArgument); using (var db = new SiewebEntities()) { var fs = db.files.First(a => a.id == id); db.files.Remove(fs); db.SaveChanges(); Response.Write("<script>alert('删除成功');location='files.aspx'</script>"); } } }
protected void BtnOk_Click(object sender, EventArgs e) { using (var db = new SiewebEntities()) { string str = Server.HtmlDecode(editor.InnerHtml); var page = new pages(); page.title = TxtTitle.Text.Trim(); page.body = str; Response.Write("<script>alert('" + str + "');</script>"); page.createtime = DateTime.Now; page.updatetime = DateTime.Now; int belo = Convert.ToInt32(DdlSelect.SelectedValue); page.belong = belo; db.pages.Add(page); db.SaveChanges(); Response.Write("<script>alert('添加成功');</script>"); } }
protected void BtnOk_Click(object sender, EventArgs e) { using (var db = new SiewebEntities()) { var tea = new teacher(); tea.place = TxtPlace.Text.Trim(); tea.tname = TxtName.Text.Trim(); tea.phone = TxtPhone.Text.Replace("\n", "<br/>"); tea.title = TxtTitle.Text.Trim(); tea.body = Server.HtmlDecode(editor.InnerHtml); tea.lang = 1; tea.createtime = DateTime.Now; tea.updatetime = DateTime.Now; tea.describe = TxtDes.Text; tea.email = TxtEmail.Text.Trim(); db.teacher.Add(tea); db.SaveChanges(); Response.Write("<script>alert('添加成功');window.location.href='teacherslist.aspx'</script>"); } }
protected void BtnOk_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string savePath = Server.MapPath("~/admin/upload/");//指定上传文件在服务器上的保存路径 //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } string Extension = Path.GetExtension(FileUpload1.FileName); //获取后缀名 string fname = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //当前时间作为文件名 string finalname = "/admin/upload/" + fname + Extension; //存在数据库中的路径 savePath = savePath + "\\" + fname + Extension; try { FileUpload1.SaveAs(savePath); using (var db = new SiewebEntities()) { var fs = new files(); fs.title = TxtTitle.Text; fs.filename = finalname; fs.lang = 0; fs.createtime = DateTime.Now; fs.viewlevel = Convert.ToInt32(DdlKind.SelectedValue.ToString()); db.files.Add(fs); db.SaveChanges(); Response.Write("<script>alert('添加成功');window.location.href='files.aspx'</script>"); } } catch { Response.Write("<script>alert('添加失败')</script>"); } } else { LabMessage.Text = "你还没有选择上传文件!"; } }
protected void BtnOk_Click(object sender, EventArgs e) { int pageId = 0; try { pageId = Convert.ToInt32(Request.QueryString["pid"].ToString()); using (var db = new SiewebEntities()) { string str = Server.HtmlDecode(editor.InnerHtml); var page = db.pages.First(a => a.id == pageId); page.body = str; page.updatetime = DateTime.Now; db.SaveChanges(); Response.Write("<script>alert('修改成功')</script>"); } } catch { Response.Redirect("index.aspx"); } }
protected void BtnOk_Click(object sender, EventArgs e) { int nid = -1; try { using (var db = new SiewebEntities()) { nid = Convert.ToInt32(Request.QueryString["nid"].ToString()); string str = Server.HtmlDecode(editor.InnerHtml); var page = db.faqs.FirstOrDefault(a => a.id == nid); page.reply = str; page.updatetime = DateTime.Now; page.state = 1; db.SaveChanges(); Response.Write("<script>alert('回复成功');window.location.href='faqs.aspx'</script>"); } } catch { Response.Redirect("faqs.aspx"); } }
protected void BtnOk_Click(object sender, EventArgs e) { int nid = -1; try { using (var db = new SiewebEntities()) { nid = Convert.ToInt32(Request.QueryString["nid"].ToString()); string str = Server.HtmlDecode(editor.InnerHtml); var page = db.news.FirstOrDefault(a => a.id == nid); page.title = TxtTitle.Text.Trim(); page.body = str; page.updatetime = DateTime.Now; int belo = Convert.ToInt32(DdlSelect.SelectedValue); page.newclass = belo; string topName, listName, topPath, listPath; if (filedtop.HasFile) { string savePath = Server.MapPath("~/admin/upload/"); //指定上传文件在服务器上的保存路径 //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } string Extension = Path.GetExtension(filedtop.FileName); //获取后缀名 if (Extension == ".jpg" || Extension == ".png" || Extension == ".gif" || Extension == ".bmp") { string fname = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //当前时间作为文件名 topName = "/admin/upload/" + fname + Extension; //存在数据库中的路径 topPath = savePath + "\\" + fname + Extension; filedtop.SaveAs(topPath); Lbltips1.InnerText = ""; page.toppicture = topName; } else { Lbltips1.InnerText = "图片格式不正确"; return; } } if (filedlist.HasFile) { string savePath = Server.MapPath("~/admin/upload/"); //指定上传文件在服务器上的保存路径 //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } string Extension = Path.GetExtension(filedlist.FileName); //获取后缀名 if (Extension == ".jpg" || Extension == ".png" || Extension == ".gif" || Extension == ".bmp") { string fname = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //当前时间作为文件名 listName = "/admin/upload/" + fname + Extension; //存在数据库中的路径 listPath = savePath + "\\" + fname + Extension; filedlist.SaveAs(listPath); Lbltips2.InnerText = ""; page.listpicture = listName; } else { Lbltips2.InnerText = "图片格式不正确"; return; } } db.SaveChanges(); Response.Write("<script>alert('修改成功');window.location.href='newslist.aspx'</script>"); } } catch { Response.Redirect("newslist.aspx"); } }
protected void BtnOk_Click(object sender, EventArgs e) { using (var db = new SiewebEntities()) { string str = Server.HtmlDecode(editor.InnerHtml); var page = new news(); string topName, listName, topPath, listPath; if (filedtop.HasFile) { string savePath = Server.MapPath("~/admin/upload/"); //指定上传文件在服务器上的保存路径 //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } string Extension = Path.GetExtension(filedtop.FileName); //获取后缀名 if (Extension == ".jpg" || Extension == ".png" || Extension == ".gif" || Extension == ".bmp") { string fname = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //当前时间作为文件名 topName = "/admin/upload/" + fname + Extension; //存在数据库中的路径 topPath = savePath + "\\" + fname + Extension; filedtop.SaveAs(topPath); Lbltips1.InnerText = ""; } else { Lbltips1.InnerText = "图片格式不正确"; return; } } else { topName = ""; } if (filedlist.HasFile) { string savePath = Server.MapPath("~/admin/upload/"); //指定上传文件在服务器上的保存路径 //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } string Extension = Path.GetExtension(filedlist.FileName); //获取后缀名 if (Extension == ".jpg" || Extension == ".png" || Extension == ".gif" || Extension == ".bmp") { string fname = DateTime.Now.ToString("yyyyMMddHHmmssffff"); //当前时间作为文件名 listName = "/admin/upload/" + fname + Extension; //存在数据库中的路径 listPath = savePath + "\\" + fname + Extension; filedlist.SaveAs(listPath); Lbltips2.InnerText = ""; } else { Lbltips2.InnerText = "图片格式不正确"; return; } } else { listName = ""; } page.toppicture = topName; page.listpicture = listName; page.iftop = true; page.title = TxtTitle.Text.Trim(); page.body = str; page.createtime = DateTime.Now; page.updatetime = DateTime.Now; page.lang = 1; int belo = Convert.ToInt32(DdlSelect.SelectedValue); page.newclass = belo; db.news.Add(page); db.SaveChanges(); Response.Write("<script>alert('添加成功');</script>"); } }