public static List <labs> SelectList() { List <labs> Listlabs = new List <labs>(); labs lab1 = new labs(); lab1.id = "one"; lab1.name = "two"; lab1.cab = "three"; Listlabs.Add(lab1); return(Listlabs); }
protected void BtnSubmit_Click(object sender, EventArgs e) { string str = Server.HtmlDecode(myEditor.InnerHtml); if (TxtTitle.Text.Trim() == "") { Response.Write("<script>alert('标题不能为空')</script>"); } else if (str.Trim() == "") { Response.Write("<script>alert('文章不能为空')</script>"); } else { try { using (var db = new CstwebEntities()) { labs ne; if (neid == 0) { ne = new labs(); } else { ne = db.labs.First <labs>(a => a.id == neid); } ne.labname = TxtTitle.Text.Trim(); ne.labbody = str.Trim(); ne.addtime = DateTime.Now; if (neid == 0) { db.labs.Add(ne); db.SaveChanges(); Response.Write("<script language=javascript>alert('发布成功');window.location = 'labslist.aspx';</script>"); } else { db.SaveChanges(); Response.Write("<script language=javascript>alert('修改成功');window.location = 'labslist.aspx';</script>"); } } } catch { Response.Write("<script>alert('失败')</script>"); } } }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { int id = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "del") { using (var db = new CstwebEntities()) { try { labs ne = db.labs.FirstOrDefault <labs>(a => a.id == id); db.labs.Remove(ne); db.SaveChanges(); Response.Write("<script>alert('删除成功');window.location = 'labslist.aspx';</script>"); } catch { Response.Write("<script>alert('删除失败')</script>"); } } } }
protected void Page_Load(object sender, EventArgs e) { try { neid = Convert.ToInt32(Request.QueryString["id"]); if (!IsPostBack) { using (var db = new CstwebEntities()) { labs ne = db.labs.First <labs>(a => a.id == neid); TxtTitle.Text = ne.labname; myEditor.InnerHtml = ne.labbody; } } } catch { neid = 0; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { string str = Server.HtmlDecode(myEditor.InnerHtml); if (TxtTitle.Text.Trim() == "") Response.Write("<script>alert('标题不能为空')</script>"); else if (str.Trim() == "") Response.Write("<script>alert('文章不能为空')</script>"); else try { using (var db = new CstwebEntities()) { labs ne; if (neid == 0) ne = new labs(); else ne = db.labs.First<labs>(a => a.id == neid); ne.labname = TxtTitle.Text.Trim(); ne.labbody = str.Trim(); ne.addtime = DateTime.Now; if (neid == 0) { db.labs.Add(ne); db.SaveChanges(); Response.Write("<script language=javascript>alert('发布成功');window.location = 'labslist.aspx';</script>"); } else { db.SaveChanges(); Response.Write("<script language=javascript>alert('修改成功');window.location = 'labslist.aspx';</script>"); } } } catch { Response.Write("<script>alert('失败')</script>"); } }
public labs GetLabDetails(string id) { string userID = GetUserID(); var model = new labs(); //here i am getting the list DocumentReference document = db.Collection("users").Document(userID).Collection("labs").Document(id); DocumentSnapshot snapshot = document.GetSnapshotAsync().GetAwaiter().GetResult(); if (snapshot.Exists) { model.labName = snapshot.GetValue <string>("labName"); model.description = snapshot.GetValue <string>("description"); } else { Console.WriteLine("Document {0} does not exist!", snapshot.Id); } return(model); }