/// <summary> /// 删除房间 /// </summary> /// <param name="id">房间ID</param> /// <returns>是否删除成功</returns> public bool DeleteRoom(string id) { string sql = string.Format(@"DELETE Room WHERE RoomId='{0}'", id); return((Convert.ToInt32(DBHerper.NonQuery(sql)) != 0)? true : false); }
/// <summary> /// 修改房间信息 /// </summary> /// <param name="room">房间信息对象</param> /// <returns>是否修改成功</returns> public bool UpdateRoomInfo(Room room) { string sql = string.Format(@"UPDATE [dbo].[Room] SET [RoomTypeId]='{0}', [RoomStateId]='{1}' WHERE [RoomId]='{2}'", room.RoomTypeId, room.RoomStateId, room.RoomId); return((DBHerper.NonQuery(sql) == 1) ? true : false); }
/// <summary> /// 修改房间类型 /// </summary> /// <param name="type">type</param> /// <returns>是否修改成功</returns> public bool UpdateType(RoomType type) { string sql = string.Format(@"UPDATE [dbo].[RoomType] SET [TypeName]='{0}',[TypeWindow]='{1}',[BedNum]='{2}',[TypePrice]='{3}' WHERE [TypeId]='{4}'", type.TypeName, type.TypeWindow, type.BedNum, type.TypePrice, type.TypeId); return((DBHerper.NonQuery(sql) == 1) ? true : false); }
/// <summary> /// 删除房间类型 /// </summary> /// <param name="id">id</param> /// <returns>是否删除成功</returns> public bool DeleteType(string id) { string sql = string.Format(@"DELETE [dbo].[RoomType] WHERE [TypeId]='{0}'", id); object judge = DBHerper.NonQuery(sql); return((Convert.ToInt32(judge) != 0) ? true : false); }
/// <summary> /// 增加订单 /// </summary> /// <param name="guest">客户记录对象</param> public void AddOrder(GuestRecord guest) { string sql = string.Format(@"INSERT [dbo].[GuestRecord] ( [GuestID], [Deposit], [ArrivalDate], [RoomId]) VALUES ('{0}','{1}','{2}','{3}') UPDATE [dbo].[Room] SET [RoomStateId]=1 WHERE [RoomId]='{3}'", guest.GuestID, guest.Deposit, guest.ArrivalDateStr, guest.RoomId); DBHerper.NonQuery(sql); }
/// <summary> /// 单个退房 /// </summary> /// <param name="RoomTotal">房款</param> /// <param name="FoodTotal">消费</param> /// <param name="id">房间号</param> public void SCheckOut(string RoomTotal, string FoodTotal, string id) { string sql = string.Format(@"UPDATE [dbo].[GuestRecord] SET [LeaveDate]=GETDATE(),[RoomTotal]='{0}',[FoodTotal]='{1}' WHERE [RoomId]='{2}' UPDATE [dbo].[Room] SET [RoomStateId]=2 WHERE [RoomId]='{2}'", RoomTotal, FoodTotal, id); DBHerper.NonQuery(sql); }
/// <summary> /// 删除食品 /// </summary> /// <param name="id">商品ID</param> /// <returns>是否删除成功</returns> public bool DeleteFoods(string id) { string sql = string.Format(@"DELETE [dbo].[FoodList] WHERE [FoodId]='{0}'", id); int judge = DBHerper.NonQuery(sql); if (judge == 0) { return(false); } else { return(true); } }
/// <summary> /// 修改商品 /// </summary> /// <param name="food">商品对象</param> /// <returns>是否修改成功</returns> public bool UpdateFoods(FoodList food) { string sql = string.Format(@"UPDATE [dbo].[FoodList] SET [FoodName]='{0}',[Unit]='{1}',[Price]='{2}' WHERE [FoodId]='{3}'", food.FoodName, food.Unit, food.Price, food.FoodId); int judge = Convert.ToInt32(DBHerper.NonQuery(sql)); if (judge != 0) { return(true); } else { return(false); } }
/// <summary> /// 增加房间信息 /// </summary> /// <param name="room">房间对象</param> /// <returns>是否增加成功</returns> public bool AddRoom(Room room) { string sql = string.Format(@"SELECT count(*) FROM Room WHERE RoomId='{0}'", room.RoomId); if (Convert.ToInt32(DBHerper.Scalar(sql)) != 0) { return(false); } else { sql = string.Format(@"INSERT Room VALUES ('{0}','{1}','{2}')", room.RoomId, room.RoomTypeId, room.RoomStateId); return((Convert.ToInt32(DBHerper.NonQuery(sql)) == 1) ? true : false); } }
/// <summary> /// 修改房间信息 /// </summary> /// <param name="room">房间对象</param> /// <param name="id">要修改的id</param> /// <returns>是否修改成功</returns> public bool UpdateRoom(Room room, string id) { string sql = string.Format(@"SELECT count(*) FROM Room WHERE RoomId !='{0}' and RoomId='{1}'", id, room.RoomId); if (Convert.ToInt32(DBHerper.Scalar(sql)) != 0) { return(false); } else { sql = string.Format(@"UPDATE Room SET RoomId='{0}',RoomTypeId='{1}',RoomStateId='{2}' WHERE RoomId='{3}'", room.RoomId, room.RoomTypeId, room.RoomStateId, id); return((Convert.ToInt32(DBHerper.NonQuery(sql)) == 1) ? true : false); } }
/// <summary> /// 修改密码 /// </summary> /// <param name="admin">管理员对象</param> /// <returns>修改是否成功</returns> public bool UpadtePwd(Admin admin) { Encrypt encrypt = new Encrypt(); string pwd = encrypt.EncryotPwd(admin.Pwd); string sql = string.Format(@"UPDATE [dbo].[Admin] SET [Pwd]='{0}' WHERE [Admins]='{1}'", pwd, admin.Admins); try { int judge = DBHerper.NonQuery(sql); return((judge == 1) ? true : false); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); return(false); } }