/// <summary> /// 房屋租赁 列表 /// </summary> public ActionResult roomList(tb_room model) { int count = 0; ViewBag.roomList = droom.GetList(model, ref count); ViewBag.page = Utils.ShowPage(count, model.PageSize, model.PageIndex, 5); return(View()); }
public async Task <ActionResult> DeleteConfirmed(int id) { tb_room tb_room = await db.tb_room.FindAsync(id); db.tb_room.Remove(tb_room); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(short id) { tb_room tb_room = db.tb_room.Find(id); db.tb_room.Remove(tb_room); db.tb_seat.RemoveRange(db.tb_seat.Where(m => m.room == id)); db.tb_seat_student.RemoveRange(db.tb_seat_student.Where(m => m.room == tb_room.no)); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "IDX,roomID,type,ispriced,personID,remark,isused")] tb_room tb_room) { if (ModelState.IsValid) { db.Entry(tb_room).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tb_room)); }
public async Task <ActionResult> Create([Bind(Include = "IDX,roomID,type,ispriced,personID,remark,isused")] tb_room tb_room) { if (ModelState.IsValid) { db.tb_room.Add(tb_room); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tb_room)); }
public async Task <ActionResult> DetailsConfirmed(int id) { tb_room tb_room = await db.tb_room.FindAsync(id); tb_room.ispriced = "false"; tb_room.personID = null; tb_room.isused = "false"; db.Entry(tb_room).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
/// <summary> /// 得到一个对象实体 /// </summary> public tb_room GetInfo(tb_room model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from tb_room"); strSql.Append(" where id=@id "); using (IDbConnection conn = DapperHelper.OpenConnection()) { model = conn.Query <tb_room>(strSql.ToString(), model)?.FirstOrDefault(); } return(model); }
public ActionResult Reset(short id) { tb_room room = db.tb_room.Find(id); room.cur = room.total; room.after15min = room.total; room.book = room.total; db.Entry(room).State = EntityState.Modified; db.Database.ExecuteSqlCommand("update tb_seat set anyone=0,available=1 where room=@p0", id); db.Database.ExecuteSqlCommand("delete from tb_seat_student where room=@p0", id); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: tb_room/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_room tb_room = await db.tb_room.FindAsync(id); if (tb_room == null) { return(HttpNotFound()); } return(View(tb_room)); }
// GET: Admin/Room/Edit/5 public ActionResult Edit(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tb_room tb_room = db.tb_room.Find(id); if (tb_room == null) { return(HttpNotFound()); } return(View(tb_room)); }
/// <summary> /// 房屋租赁 保存 /// </summary> public JsonResult roomSave(tb_room model) { if (model == null) { return(ResultTool.jsonResult(false, "参数错误!")); } if (!String.IsNullOrEmpty(model.id)) { bool boolResult = droom.Update(model); return(ResultTool.jsonResult(boolResult, boolResult ? "成功!" : "更新失败!")); } else { model.id = Guid.NewGuid().ToString("N"); bool boolResult = droom.Add(model); return(ResultTool.jsonResult(boolResult, boolResult ? "成功!" : "添加失败!")); } }
public ActionResult Create([Bind(Include = "no,name,tables,cur,after15min")] tb_room tb_room) { if (ModelState.IsValid) { db.tb_room.Add(tb_room); for (int i = 0; i < tb_room.tables * 4; i++) { tb_seat seat = new tb_seat() { no = i, anyone = false, available = true, room = tb_room.no, seat = (short)(i % 4), desk = i / 4 }; db.tb_seat.Add(seat); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_room)); }
/// <summary> /// 是否存在该记录 /// </summary> public bool Exists(tb_room model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(1) from tb_room"); strSql.Append(" where id=@id "); using (IDbConnection conn = DapperHelper.OpenConnection()) { int count = conn.Execute(strSql.ToString(), model); if (count > 0) { return(true); } else { return(false); } } }
protected void Unnamed_Click(object sender, EventArgs e) { if (Page.IsValid) { using (dbDataContext db = new dbDataContext()) { tb_dosen user = Session["user"] as tb_dosen; tb_room model = new tb_room(); model.tgl_room = DateTime.Parse(t2.Text.Trim()); model.id_proposal = Int32.Parse(t1.SelectedValue); model.id_mahasiswa = (from c in db.tb_proposals where c.id_proposal == model.id_proposal select c.id_mahasiswa).FirstOrDefault(); model.id_pembimbing = user.id_dosen; db.tb_rooms.InsertOnSubmit(model); db.SubmitChanges(); Response.Redirect("bimbingan.aspx"); } } }
public async Task <ActionResult> DetailsConfirmed(int id) { tb_reserve tb_reserve = await db.tb_reserve.FindAsync(id); db.tb_reserve.Remove(tb_reserve); await db.SaveChangesAsync(); //tb_room更新预定为false 使用为true string room_ID = tb_reserve.roomID; tb_room tb_room = await db.tb_room.Where(room => room.roomID == room_ID).FirstAsync(); tb_room.ispriced = "false"; tb_room.personID = tb_reserve.cardID; tb_room.isused = "true"; db.Entry(tb_room).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "no,name,tables,cur,after15min")] tb_room tb_room) { if (ModelState.IsValid) { db.Entry(tb_room).State = EntityState.Modified; db.tb_seat_student.RemoveRange(db.tb_seat_student.Where(m => m.room == tb_room.no)); db.tb_seat.RemoveRange(db.tb_seat.Where(m => m.room == tb_room.no)); for (int i = 0; i < tb_room.tables * 4; i++) { tb_seat seat = new tb_seat() { no = i, anyone = false, available = true, room = tb_room.no, seat = (short)(i % 4), desk = i / 4 }; db.tb_seat.Add(seat); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tb_room)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(tb_room model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_room("); strSql.Append("id,buildingid,floor,roomnumber,roomtype,hold,housetype,direction,space,fee,status,isopen,isdel,sortnum,addtime)"); strSql.Append(" values ("); strSql.Append("@id,@buildingid,@floor,@roomnumber,@roomtype,@hold,@housetype,@direction,@space,@fee,@status,@isopen,@isdel,@sortnum,@addtime)"); using (IDbConnection conn = DapperHelper.OpenConnection()) { int count = conn.Execute(strSql.ToString(), model); if (count > 0) { return(true); } else { return(false); } } }
/// <summary> /// 获得数据列表 /// </summary> public List <tb_room> GetList(tb_room model, ref int total) { List <tb_room> list; StringBuilder strSql = new StringBuilder(); StringBuilder whereSql = new StringBuilder(" where 1 = 1 "); strSql.Append(" select ROW_NUMBER() OVER(ORDER BY id desc) AS RID, * from tb_room "); if (!String.IsNullOrEmpty(model.buildingid)) { whereSql.Append(" and buildingid=@buildingid"); } if (!String.IsNullOrEmpty(model.floor)) { whereSql.Append(" and floor=@floor"); } if (!String.IsNullOrEmpty(model.roomnumber)) { whereSql.Append(" and roomnumber=@roomnumber"); } if (model.roomtype != null) { whereSql.Append(" and roomtype=@roomtype"); } if (!String.IsNullOrEmpty(model.hold)) { whereSql.Append(" and hold=@hold"); } if (!String.IsNullOrEmpty(model.housetype)) { whereSql.Append(" and housetype=@housetype"); } if (!String.IsNullOrEmpty(model.direction)) { whereSql.Append(" and direction=@direction"); } if (!String.IsNullOrEmpty(model.space)) { whereSql.Append(" and space=@space"); } if (!String.IsNullOrEmpty(model.fee)) { whereSql.Append(" and fee=@fee"); } if (model.status != null) { whereSql.Append(" and status=@status"); } if (model.isopen != null) { whereSql.Append(" and isopen=@isopen"); } if (model.isdel) { whereSql.Append(" and isdel=@isdel"); } if (model.sortnum != null) { whereSql.Append(" and sortnum=@sortnum"); } if (model.addtime != null) { whereSql.Append(" and addtime=@addtime"); } strSql.Append(whereSql); string CountSql = "SELECT COUNT(1) as RowsCount FROM (" + strSql.ToString() + ") AS CountList"; string pageSqlStr = "select * from ( " + strSql.ToString() + " ) as Temp_PageData where Temp_PageData.RID BETWEEN {0} AND {1}"; pageSqlStr = string.Format(pageSqlStr, (model.PageSize * (model.PageIndex - 1) + 1).ToString(), (model.PageSize * model.PageIndex).ToString()); using (IDbConnection conn = DapperHelper.OpenConnection()) { list = conn.Query <tb_room>(pageSqlStr, model)?.ToList(); total = conn.ExecuteScalar <int>(CountSql, model); } return(list); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(tb_room model) { StringBuilder strSql = new StringBuilder(); StringBuilder setSql = new StringBuilder(); strSql.Append("update tb_room set "); if (!String.IsNullOrEmpty(model.buildingid)) { setSql.Append("buildingid=@buildingid,"); } if (!String.IsNullOrEmpty(model.floor)) { setSql.Append("floor=@floor,"); } if (!String.IsNullOrEmpty(model.roomnumber)) { setSql.Append("roomnumber=@roomnumber,"); } if (model.roomtype != null) { setSql.Append("roomtype=@roomtype,"); } if (!String.IsNullOrEmpty(model.hold)) { setSql.Append("hold=@hold,"); } if (!String.IsNullOrEmpty(model.housetype)) { setSql.Append("housetype=@housetype,"); } if (!String.IsNullOrEmpty(model.direction)) { setSql.Append("direction=@direction,"); } if (!String.IsNullOrEmpty(model.space)) { setSql.Append("space=@space,"); } if (!String.IsNullOrEmpty(model.fee)) { setSql.Append("fee=@fee,"); } if (model.status != null) { setSql.Append("status=@status,"); } if (model.isopen != null) { setSql.Append("isopen=@isopen,"); } if (model.isdel) { setSql.Append("isdel=@isdel,"); } if (model.sortnum != null) { setSql.Append("sortnum=@sortnum,"); } if (model.addtime != null) { setSql.Append("addtime=@addtime,"); } strSql.Append(setSql.ToString().TrimEnd(',')); strSql.Append(" where id=@id "); using (IDbConnection conn = DapperHelper.OpenConnection()) { int count = conn.Execute(strSql.ToString(), model); if (count > 0) { return(true); } else { return(false); } } }
/// <summary> /// 房屋租赁 删除 /// </summary> public JsonResult roomDelete(tb_room model) { bool boolResult = droom.Delete(model); return(ResultTool.jsonResult(boolResult, boolResult ? "成功!" : "删除失败!")); }
/// <summary> /// 房屋租赁 详情 /// </summary> public ActionResult roomInfo(tb_room model) { model = droom.GetInfo(model); return(View(model ?? new tb_room())); }