/// <summary> /// 入住登记 /// </summary> /// <param name="guest"></param> /// <returns></returns> public static int AddCheckinRecord(RoomRecord guest) { if (AddGuest(guest.lsh, guest.khxx) > 0) { string sql = "insert into roomrecord(lsh, lxdh, fjbh, rzzt, rzrq, rzts, rzyj, ldrq) " + "values(@rzbh, @Phone, @RoomId, @ResideId, @ResideDate, @TradeNo, @Deposit, @LeaveDate);" + "update room set fjzt=@RoomStateId where fjbh=@RoomId"; MySqlParameter[] para = { new MySqlParameter("@rzbh", guest.lsh), new MySqlParameter("@Phone", guest.lxdh), new MySqlParameter("@RoomId", guest.fjbh), new MySqlParameter("@ResideId", guest.rzzt), new MySqlParameter("@ResideDate", guest.rzrq), new MySqlParameter("@Deposit", guest.rzyj), new MySqlParameter("@RoomStateId", 1), new MySqlParameter("@TradeNo", guest.rzts), new MySqlParameter("@LeaveDate", guest.tfrq) }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, para)); } else { return(0); } }
public void CreateRoom(string roomName, string description, long userId) { var roomRecord = new RoomRecord(roomName, description, userId); _uow.Rooms.Add(roomRecord); _uow.SaveChanges(); }
private void button1_Click(object sender, EventArgs e) { if (this.cb_rzfj.SelectedIndex == 0) { toolTip1.Show("请选择入住房间类型", this.cb_rzfj, 1000); cb_rzfj.Focus(); return; } if (string.IsNullOrEmpty(txt_lxdh.Text.Trim())) { toolTip1.Show("联系电话不能为空!", this.txt_lxdh, 1000); txt_lxdh.Focus(); return; } RoomRecord record = new RoomRecord(); record.lsh = LshCreate.GetLsh(); record.lxdh = this.txt_lxdh.Text.Trim(); record.fjbh = Bll_Room.GetFreeRoomIdWithFjlx(cb_rzfj.SelectedValue.ToString()).ToString(); record.rzzt = "4"; if (Bll_Guset.AddReserveRecord(record) > 0) { MessageBox.Show("预约成功!房间号:" + record.fjbh, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
// Deletes the specified room public bool DeleteRoom(Room room) { Program app = Program.GetInstance(); Database database = app.GetDatabase(); ChairService chairService = app.GetService <ChairService>("chairs"); ShowService showService = app.GetService <ShowService>("shows"); // Find record RoomRecord record = database.rooms.SingleOrDefault(i => i.id == room.id); if (record == null) { return(false); } // Remove record and related chairs/shows database.rooms.Remove(record); foreach (Chair chair in chairService.GetChairsByRoom(room)) { chairService.DeleteChair(chair); } foreach (Show show in showService.GetShowsByRoom(room)) { showService.DeleteShow(show); } // Try to save database.TryToSave(); return(true); }
public void Remove(RoomRecord room) { using (IDbCommand session = Helpers.OpenSession()) using (IDbTransaction transaction = session.Connection.BeginTransaction()) { session.Connection.Delete(room); transaction.Commit(); } }
private void btn_ok_Click(object sender, EventArgs e) { if (listView1.Items.Count == 0) { toolTip1.Show("客户信息不能为空!", this.listView1, 1000); listView1.Focus(); return; } if (string.IsNullOrEmpty(txt_rzts.Text.Trim())) { toolTip1.Show("入住天数不能为空!", this.txt_rzts, 1000); txt_rzts.Focus(); return; } if (string.IsNullOrEmpty(txt_lxdh.Text.Trim())) { toolTip1.Show("联系电话不能为空!", this.txt_lxdh, 1000); txt_lxdh.Focus(); return; } if (this.cb_rzfj.SelectedIndex == 0) { toolTip1.Show("请选择入住房间类型", this.cb_rzfj, 1000); cb_rzfj.Focus(); return; } RoomRecord record = new RoomRecord(); record.lsh = LshCreate.GetLsh(); record.lxdh = txt_lxdh.Text.Trim(); record.rzyj = txt_rzyj.Text.Trim(); record.fjbh = Bll_Room.GetFreeRoomIdWithFjlx(cb_rzfj.SelectedValue.ToString()).ToString(); record.rzrq = this.dtp_rzsj.Value; record.rzts = this.txt_rzts.Text.Trim(); record.tfrq = record.rzrq.AddDays(Convert.ToInt32(record.rzts)); record.rzzt = "1"; record.khxx = TempGuest.guests; try { if (Bll_Guset.AddCheckinRecord(record) > 0) { MessageBox.Show("入住办理成功!房间号:" + record.fjbh, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MySqlException ex) { MessageBox.Show("数据库异常:" + ex.Message); } catch (Exception ex) { MessageBox.Show("其它异常:" + ex.Message); } }
/// <summary> /// 取消预约 /// </summary> /// <param name="roomRecord"></param> /// <returns></returns> public static int CancelReserveRecord(RoomRecord roomRecord) { string sql = "update roomrecord set rzzt = 0 where lsh = @lsh;update room set fjzt=2 where fjbh=@fjbh"; MySqlParameter[] para = { new MySqlParameter("@lsh", roomRecord.lsh), new MySqlParameter("@fjbh", roomRecord.fjbh) }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, para)); }
public Room RoomRecordToRoom(RoomRecord roomRecord) { return(new Room { Name = roomRecord.Name, DateCreated = roomRecord.DateCreated, Description = roomRecord.Description, Messages = roomRecord.Messages?.Select(MessageRecordToMessage).ToList() ?? new List <Message>(), RoomId = roomRecord.RoomId, UserId = roomRecord.UserId, UserName = roomRecord.User.Name }); }
public void CreateRoomDelegatesToRepository() { var service = CreateService(); var roomViewModel = new RoomViewModel { Name = "Test Room" }; var roomRecord = new RoomRecord("Test Room"); mockRoomViewModelMapper.Setup(mapper => mapper.MapRoomViewModelToRoomRecord(roomViewModel)).Returns(roomRecord); service.CreateRoom(roomViewModel); mockRoomRepository.Verify(repository => repository.CreateRoom(roomRecord.Name)); }
/// <summary> /// 预约登记 /// </summary> /// <param name="guest"></param> /// <returns></returns> public static int AddReserveRecord(RoomRecord guest) { string sql = "insert into roomrecord(lsh, lxdh, fjbh, rzzt) " + "values(@rzbh, @Phone, @RoomId, @ResideId);" + "update room set fjzt=@RoomStateId where fjbh=@RoomId"; MySqlParameter[] para = { new MySqlParameter("@rzbh", guest.lsh), new MySqlParameter("@Phone", guest.lxdh), new MySqlParameter("@RoomId", guest.fjbh), new MySqlParameter("@ResideId", guest.rzzt), new MySqlParameter("@RoomStateId", 4) }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, para)); }
/// <summary> /// 通过手机号查询客户预约信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { string phone = textBox1.Text.Trim(); RoomRecord roomRecord = Bll_Guset.GetReserveRecordByPhone(phone); if (!string.IsNullOrEmpty(roomRecord.lsh)) { textBox5.Text = roomRecord.fjbh; textBox4.Text = roomRecord.lxdh; } else { MessageBox.Show("没有查询到对应的预约信息"); } }
public void GetAllRoomsDelegatesToRoomViewModelMapper() { var service = CreateService(); var roomOne = new RoomRecord("Room one"); var roomTwo = new RoomRecord("Room two"); var roomThree = new RoomRecord("Room three"); var rooms = new List <RoomRecord> { roomOne, roomTwo, roomThree }; mockRoomRepository.Setup(repository => repository.GetAllRooms()).Returns(rooms); service.GetAllRooms(); mockRoomViewModelMapper.Verify(mapper => mapper.MapRoomRecordToRoomViewModel(roomOne)); mockRoomViewModelMapper.Verify(mapper => mapper.MapRoomRecordToRoomViewModel(roomTwo)); mockRoomViewModelMapper.Verify(mapper => mapper.MapRoomRecordToRoomViewModel(roomThree)); }
/// <summary> /// 根据房间编号获取对应预约信息 /// </summary> /// <param name="fjbh"></param> public static RoomRecord GetReserveRecordByFjbh(string fjbh) { RoomRecord roomRecord = new RoomRecord(); string sql = "select lsh, lxdh, fjbh, rzzt from roomrecord where rzzt = 4 and fjbh = @fjbh"; MySqlParameter[] para = { new MySqlParameter("@fjbh", fjbh) }; MySqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, para); reader.Read(); roomRecord.lsh = reader["lsh"].ToString(); roomRecord.lxdh = reader["lxdh"].ToString(); roomRecord.fjbh = reader["fjbh"].ToString(); roomRecord.rzzt = reader["rzzt"].ToString(); return(roomRecord); }
/// <summary> /// 根据手机号获取预约信息 /// </summary> /// <param name="phone"></param> /// <returns></returns> public static RoomRecord GetReserveRecordByPhone(string phone) { RoomRecord roomRecord = new RoomRecord(); string sql = "select t.lsh, t.lxdh, t.fjbh, t.rzzt, t.rzrq, t.rzts, t.rzyj, t.qtxf, t.zjxf, t.ldrq from roomrecord t where t.lxdh = @phone and t.rzzt = 4"; MySqlParameter[] para = { new MySqlParameter("@phone", phone) }; MySqlDataReader dataReader = SqlHelper.ExecuteReader(sql, CommandType.Text, para); if (dataReader.HasRows) { dataReader.Read(); roomRecord.lsh = dataReader["lsh"].ToString(); roomRecord.fjbh = dataReader["fjbh"].ToString(); roomRecord.lxdh = dataReader["lxdh"].ToString(); } return(roomRecord); }
//添加寝室记录 protected void btn_Save_Click(object sender, EventArgs e) { txt_RoomCode.Text = hdRoomCode.Value; lab_Error.Text = ""; RoomRecord model = new RoomRecord(); try { model.RoomCode = txt_RoomCode.Text.Trim(); model.Content = txt_Content.Text.Trim(); model.RcdCate = ddl_RcdCate.SelectedItem.Text; model.RcdDate=Convert.ToDateTime(txt_RcdDate.Text.Trim()); model.IssueDate=Convert.ToDateTime(txt_IssueDate.Text.Trim()); model.HandlerName = txt_HandlerName.Text.Trim(); model.HandlerView = txt_HandlerView.Text.Trim(); model.Save(); Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('添加成功');location.href='RoomRecordList.aspx'",true); } catch (Exception ex) { lab_Error.Text=ex.Message; } }
/// <summary> /// 预约入住确认 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox3.Text)) { toolTip1.Show("入住天数不能为空!", this.textBox3, 1000); textBox3.Focus(); return; } if (listView2.Items.Count == 0) { toolTip1.Show("客户信息不能为空!", this.listView2, 1000); listView2.Focus(); return; } RoomRecord roomRecord = Bll_Guset.GetReserveRecordByPhone(textBox4.Text.Trim()); roomRecord.rzyj = textBox2.Text.Trim(); roomRecord.rzrq = dateTimePicker1.Value; roomRecord.rzts = textBox3.Text.Trim(); roomRecord.tfrq = roomRecord.rzrq.AddDays(Convert.ToInt32(roomRecord.rzts)); roomRecord.rzzt = "1"; roomRecord.khxx = TempGuest.guests; try { if (Bll_Guset.UpdateReserveRecord(roomRecord) > 0) { MessageBox.Show("入住办理成功!房间号:" + roomRecord.fjbh, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (MySqlException ex) { MessageBox.Show("数据库异常:" + ex.Message); } catch (Exception ex) { MessageBox.Show("其它异常:" + ex.Message); } }
// Saves the specified room public bool SaveRoom(Room room) { Program app = Program.GetInstance(); Database database = app.GetDatabase(); ChairService chairService = app.GetService <ChairService>("chairs"); bool isNew = room.id == -1; // Validate and add if valid if (!room.Validate()) { return(false); } // Set id if its a new room if (isNew) { room.id = database.GetNewId("rooms"); } // Find existing record RoomRecord record = database.rooms.SingleOrDefault(i => i.id == room.id); // Add if no record exists if (record == null) { record = new RoomRecord(); database.rooms.Add(record); } // Update record record.id = room.id; record.number = room.number; // Try to save database.TryToSave(); return(true); }
/// <summary> /// 取消预订 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 取消预订ToolStripMenuItem_Click(object sender, EventArgs e) { if (lv_room.SelectedItems.Count == 1 && lv_room.SelectedItems[0].ImageIndex == 3) { string fjbh = lv_room.SelectedItems[0].Text; //根据房间编号获取对应房间的预约信息 RoomRecord roomRecord = Bll_Guset.GetReserveRecordByFjbh(fjbh); //取消对应流水号的预定信息 if (Bll_Guset.CancelReserveRecord(roomRecord) > 0) { FrmMain_Load(null, null); } else { MessageBox.Show("取消预约失败"); } } else { MessageBox.Show("不满足取消预约条件!"); } }
/// <summary> /// 预约入住 /// </summary> /// <param name="roomRecord"></param> public static int UpdateReserveRecord(RoomRecord roomRecord) { if (AddGuest(roomRecord.lsh, roomRecord.khxx) > 0) { string sql = "update roomrecord set rzzt = @rzzt, rzrq = @rzrq, rzts = @rzts, rzyj = @rzyj, ldrq = @ldrq where lsh = @lsh;" + "update room set fjzt=1 where fjbh=@fjbh"; MySqlParameter[] para = { new MySqlParameter("@rzzt", roomRecord.rzzt), new MySqlParameter("@rzrq", roomRecord.rzrq), new MySqlParameter("@rzts", roomRecord.rzts), new MySqlParameter("@rzyj", roomRecord.rzyj), new MySqlParameter("@ldrq", roomRecord.tfrq), new MySqlParameter("@lsh", roomRecord.lsh), new MySqlParameter("@fjbh", roomRecord.fjbh) }; return(SqlHelper.ExecuteNonQuery(sql, CommandType.Text, para)); } else { return(0); } }
private static async Task CreateWorld(RunicMagicDbContext context) { if (!context.Rooms.Any()) { var startingRoom = new RoomRecord(0, "The starting room", @" You are standing in a small room. It is quite nondistinct. It seems like the gods have put a lot of effort into ensuring a world exists at all, and not much into making it look nice. Surely they will do so at a later point in time.".Trim()); var secondRoom = new RoomRecord(0, "The second room", @" You are standing in a small room. It is gray and dark, almost no light penetrates through the solid rock. Frankly, it is amazing the light of the gods reaches here at all. Then again: they are gods.".Trim()); startingRoom.Links.Add(new RoomLinkRecord(startingRoom, secondRoom, Direction.NORTH.Value)); secondRoom.Links.Add(new RoomLinkRecord(secondRoom, startingRoom, Direction.SOUTH.Value)); context.Rooms.Add(startingRoom); context.Rooms.Add(secondRoom); await context.SaveChangesAsync(); } }
private Room Map(RoomRecord roomRecord) { return(new Room(roomRecord.RoomId, roomRecord.Name, roomRecord.RoomDesc)); }
public Room(RoomRecord record) { id = record.id; number = record.number; }
public RoomViewModel MapRoomRecordToRoomViewModel(RoomRecord roomRecord) { return(new RoomViewModel { ID = roomRecord.Id, Name = roomRecord.Name }); }