在业务逻辑层实现客房信息保存功能
难点分析 -2
public string SaveRoom(Room objRoom)
{
// 返回信息
string message = string.Empty;
// 客房 ID
int roomID;
// 房间编号
string number = string.Empty;
try
{
number = objRoom.Number;
roomID = roomService.GetRoomIDByRoomNumber(number);
if (roomID != 0)
{
// 修改客房信息
roomService.ModifyRoom(objRoom);
message = " 客房信息更新成功! ";
}
else
{
roomID = roomService.AddRoom(objRoom);
if (roomID > 0)
message = " 房间信息录入成功! ";
else
message = " 房间信息录入失败! ";
}
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
return message;
}
public string SaveRoom(Room objRoom)
{
// 返回信息
string message = string.Empty;
// 客房 ID
int roomID;
// 房间编号
string number = string.Empty;
try
{
number = objRoom.Number;
roomID =roomService.GetRoomIDByRoomNumber(number);
if (roomID != 0)
{
// 修改客房信息
roomService.ModifyRoom(objRoom);
message = " 客房信息更新成功! ";
}
else
{
roomID = roomService.AddRoom(objRoom);
if (roomID > 0)
message = " 房间信息录入成功! ";
else
message = " 房间信息录入失败! ";
}
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
return message;
}
判断客房信息是否存在
更新客房信息
新增客房信息