/// <summary> /// 根据二级列表元素的ID /// 查找其上级元素的ID /// 然后找出一级元素下的所有的二级元素 /// </summary> /// <param name="sonId"></param> /// <returns></returns> private List <Entity.Son> getSonList(Guid sonId) { DboUtils db = new DboUtils(); String sql1 = "select up_item from top_sub where id='" + sonId + "'"; DataSet ds1 = db.query(sql1); if (ds1.Tables[0].Rows.Count > 0) { Guid parentId = (Guid)ds1.Tables[0].Rows[0]["up_item"]; String sql = "select * from top_sub where up_item='" + parentId + "' order by position"; DataSet ds = db.query(sql); List <Entity.Son> list = new List <Entity.Son>(); foreach (DataRow mDr in ds.Tables[0].Rows) { Entity.Son son = new Entity.Son() { id = (Guid)mDr["id"], title = mDr["title"].ToString(), up_item = (Guid)mDr["up_item"], position = (int)mDr["position"], pageType = mDr["pagetype"].ToString() }; list.Add(son); } return(list); } else { return(new List <Entity.Son>()); } }
private List <Entity.Nav> getList() { DboUtils db = new DboUtils(); String sql = "select top_sum.id ,top_sum.position,top_sum.title,top_sum.nov_type,top_sub.id sonid,top_sub.position sonposition,up_item,createtime,top_sub.title sontitle,top_sub.pagetype from top_sum left join top_sub on top_sum.id = top_sub.up_item order by top_sum.position,top_sub.position"; DataSet ds = db.query(sql); List <Entity.Nav> list = new List <Entity.Nav>(); foreach (DataRow mDr in ds.Tables[0].Rows) { Guid id = (Guid)mDr["id"]; if (list.Where(t => t.id == id).Count() == 0) { Entity.Nav nav = new Entity.Nav(); nav.id = id; nav.title = mDr["title"].ToString(); nav.position = (int)mDr["position"]; nav.novType = (Boolean)mDr["nov_type"]; nav.sonList = new List <Entity.Son>(); list.Add(nav); if (nav.novType) { AddSon(nav, mDr); } } else { var nav = list.Where(t => t.id == id).FirstOrDefault(); AddSon(nav, mDr); } } return(list); }
public ActionResult Register(String username, String password, String realname, String email, String phone, String gender, String wx) { DboUtils db = new DboUtils(); String sql0 = "select * from user_info where username='******'"; DataSet ds = db.query(sql0); String errorMessage = ""; if (ds.Tables[0].Rows.Count > 0) { errorMessage = "用户名已经被注册!!!"; return(Redirect("/Register/Index?" + errorMessage)); } else { String sql = "INSERT INTO user_info(realname, username, pwd, email, sex, wx, phonenum) VALUES('" + realname + "','" + username + "','" + password + "','" + email + "','" + gender + "','" + wx + "','" + phone + "')"; DboUtils db1 = new DboUtils(); int i = db1.insert(sql); if (i > 0) { return(Redirect("/Login/Index")); } else { errorMessage = "用户名已经被注册!!!"; return(Redirect("/Register/Index?" + errorMessage)); } } }
public ActionResult getNav() { String sql = "select * from nav ORDER by id"; DataSet ds = dbo.query(sql); List <nav> navList = new List <nav>(); foreach (DataRow dr in ds.Tables[0].Rows) { nav nav = new nav() { id = (int)dr["id"], name = dr["name"].ToString(), href = dr["href"].ToString() }; navList.Add(nav); } return(Json(navList)); }
public ActionResult ModifyNav(int id) { DboUtils db = new DboUtils(); String sql = "select * from Nav where id = '" + id + "'"; DataSet ds = db.query(sql); DataRow dr = ds.Tables[0].Rows[0]; nav nav = new nav() { id = (int)dr["id"], name = dr["name"].ToString(), href = dr["href"].ToString() }; ViewBag.g = nav; return(View()); }
// GET: Admin public ActionResult Login(String username, String password) { String sql = "select * from admin where username='******'and pwd='" + password + "'"; DboUtils db = new DboUtils(); DataSet ds = db.query(sql); if (ds.Tables[0].Rows.Count > 0) { return(Redirect("/Modify/Index")); } else { ViewBag.errorMessage = "用户名或密码错误"; return(View()); } }
public ActionResult GetAdminList() { DboUtils db = new DboUtils(); String sql = "select * from admin"; DataSet ds = db.query(sql); List <Entity.Admin> list = new List <Entity.Admin>(); foreach (DataRow mDr in ds.Tables[0].Rows) { Entity.Admin ad = new Entity.Admin(); ad.username = mDr["username"].ToString(); ad.pwd = mDr["pwd"].ToString(); list.Add(ad); } ViewBag.adminList = list; return(View()); }
private List <LvDu.Entity.Admin> getAdminListByName(String username) { DboUtils db = new DboUtils(); String sql = "select * from admin where username='******'"; DataSet ds = db.query(sql); List <Entity.Admin> list = new List <Entity.Admin>(); foreach (DataRow mDr in ds.Tables[0].Rows) { Entity.Admin ad = new Entity.Admin() { username = mDr["username"].ToString(), pwd = mDr["pwd"].ToString() }; list.Add(ad); } return(list); }
public ActionResult Modify(Guid id) { DboUtils db = new DboUtils(); String sql = "select * from good where id = '" + id + "'"; DataSet ds = db.query(sql); DataRow dr = ds.Tables[0].Rows[0]; good g = new good() { id = (Guid)dr["id"], img = dr["img"].ToString(), info = dr["info"].ToString(), price = (double)dr["price"], upitem = (int)dr["upitem"], name = dr["name"].ToString() }; ViewBag.g = g; return(View()); }
public ActionResult getGood() { DboUtils dbo = new DboUtils(); String sql = "select * from good ORDER by upitem"; DataSet ds = dbo.query(sql); List <good> navList = new List <good>(); foreach (DataRow dr in ds.Tables[0].Rows) { good info = new good() { id = (Guid)dr["id"], img = dr["img"].ToString(), info = dr["info"].ToString(), price = (double)dr["price"], upitem = (int)dr["upitem"], name = dr["name"].ToString() }; navList.Add(info); } return(Json(navList)); }
public ActionResult getOrdering() { String sql = "select * from orderList where orderingState = 'false' ORDER by id"; DataSet ds = dbo.query(sql); List <ordering> navList = new List <ordering>(); foreach (DataRow dr in ds.Tables[0].Rows) { ordering nav = new ordering() { id = (Guid)dr["id"], roomID = dr["roomID"].ToString(), order = dr["ordering"].ToString(), orderID = dr["orderingID"].ToString(), orderState = (Boolean)dr["orderingState"], note = dr["note"].ToString(), createtime = (DateTime)dr["createtime"], total = dr["total"].ToString() }; navList.Add(nav); } return(Json(navList)); }
private List <Entity.Info> getInfo(Guid id) { DboUtils db = new DboUtils(); String sql = "select * from top_info where id='" + id + "'"; DataSet ds = db.query(sql); List <Entity.Info> list = new List <Entity.Info>(); foreach (DataRow mDr in ds.Tables[0].Rows) { Entity.Info son = new Entity.Info() { id = (Guid)mDr["id"], title = mDr["title"].ToString(), up_item = (Guid)mDr["up_item"], position = (int)mDr["position"], info = mDr["info"].ToString(), img_b = mDr["img_b"].ToString(), img_s = mDr["img_s"].ToString(), video = mDr["video"].ToString() }; list.Add(son); } return(list); }