/// <summary> /// 删除一行时执行 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GuestTable_RowDeleting(object sender, GridViewDeleteEventArgs e) { SqlDataSource1.DeleteCommand = "SELECT * FROM HOTEL WHERE hID='-1'"; GuestManager.DeleteGuest(new Guest { GuestID = e.Values["gID"].ToString().Trim(), GuestName = e.Values["gName"].ToString().Trim(), Username = UsernameLabel.Text }); GuestTable.DataBind(); }
public IHttpActionResult UpdateTable(int id, GuestTable table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _tableManagementService.UpdateTable(id, table); return(Ok()); }
public void UpdateTable(int id, GuestTable table) { //throw new NotImplementedException(); var newTable = _tableManagementRepository.GetGuestTableById(id); newTable.UpdateDate = DateTime.Now; newTable.LastUpdateTime = DateTime.Now; newTable.TableStatus = table.TableStatus; newTable.TableSize = table.TableSize; newTable.MaxSeatsCapacity = table.MaxSeatsCapacity; _tableManagementRepository.UpdateTable(id, newTable); }
public void UpdateTable(int id, GuestTable table) { //throw new NotImplementedException(); context.GuestTables.Attach(table); var entry = context.Entry(table); entry.State = EntityState.Modified; try { context.SaveChanges(); } catch (DbUpdateConcurrencyException dbUpdateConcurrencyException) { var msg = dbUpdateConcurrencyException.Message; } }
public IHttpActionResult AddGuestTable(GuestTable table) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //set default values // table.TableStatus = "Available"; table.CreateDate = DateTime.Now; table.UpdateDate = DateTime.Now; table.LastUpdateTime = DateTime.Now; _tableManagementService.AddTable(table); return(Ok()); }
public void UpdateTableStatus(GuestTable table) { context.GuestTables.Attach(table); var entry = context.Entry(table); entry.State = EntityState.Modified; try { context.SaveChanges(); } catch (DbUpdateConcurrencyException dbUpdateConcurrencyException) { var msg = dbUpdateConcurrencyException.Message; throw; } }
/// <summary> /// 修改一行时执行 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GuestTable_RowUpdating(object sender, GridViewUpdateEventArgs e) { SqlDataSource1.UpdateCommand = "SELECT * FROM HOTEL WHERE hID='-1'"; if (!Regex.IsMatch(e.NewValues["gID"].ToString(), "\\d{14}")) { //身份证号不为14位数字 Response.Write("<script>alert('身份证号不正确!');</script>"); return; } GuestManager.UpdateGuset(new Guest { Username = UsernameLabel.Text, GuestID = e.OldValues["gID"].ToString().Trim(), GuestName = e.OldValues["gName"].ToString() }, new Guest { Username = UsernameLabel.Text, GuestID = e.NewValues["gID"].ToString().Trim(), GuestName = e.NewValues["gName"].ToString() }); GuestTable.DataBind(); }
/// <summary> /// 添加旅客按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void AddButton_OnClick(object sender, EventArgs e) { if (GuestName.Text == "" || GuestID.Text == "" || !Regex.IsMatch(GuestID.Text, "\\d{14}")) { Response.Write("<script>alert('旅客信息不正确!');</script>"); return; } try { GuestManager.AddGuest(new Guest { GuestID = GuestID.Text, GuestName = GuestName.Text.Trim(), Username = UsernameLabel.Text }); } catch { Response.Write("<script>alert('该旅客已存在!');</script>"); } GuestTable.DataBind(); }
public void AddGuestTable(GuestTable table) { context.GuestTables.Add(table); context.SaveChanges(); }
/// <summary> /// 取消修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GuestTable_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GuestTable.EditIndex = -1; GuestTable.DataBind(); }
public void AddTable(GuestTable table) { _tableManagementRepository.AddGuestTable(table); }