Beispiel #1
0
        /// <summary>
        /// 顾客登记
        /// </summary>
        /// <param name="guest"></param>
        /// <returns></returns>
        public static bool AddGuest(GuestInsert guest)
        {
            string sql = "Insert GuestRecord(IdentityID,GuestName,RoomID,ResideID,ResideDate,Deposit) Values(@IdCard,@Name,@RoomId,(Select ResideId From ResideState Where ResideName = '未结账'),@ResideDate,@Deposit)";

            SqlParameter [] paras =
            {
                new SqlParameter("@IdCard",     guest.IdentityId),
                new SqlParameter("@Name",       guest.GuestName),
                new SqlParameter("@RoomId",     guest.RoomId),
                new SqlParameter("@ResideDate", guest.ResideDate),
                new SqlParameter("@Deposit",    guest.Deposit)
            };
            try
            {
                if (!SqlHelper.Execute(sql, paras))
                {
                    return(false);
                }
                //更新房间入住人数
                RoomService.UpdateRoomGuestNum(guest.RoomId);
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 退房(Sql语句)
        /// </summary>
        /// <param name="guest"></param>
        /// <returns></returns>
        public static bool CheckOutRoomBySql(GuestSeach guest)
        {
            //先更改顾客状态、退房日期、总金额
            string sql = "Update GuestRecord Set ResideID = (Select ResideId From ResideState Where ResideName = '已结账'),LeaveDate = @LeaveDate,TotalMoney = @TotalMoney Where GuestID = @GuestID";

            SqlParameter[] paras =
            {
                new SqlParameter("@LeaveDate",  guest.LeaveDate),
                new SqlParameter("@TotalMoney", guest.TotalMoney),
                new SqlParameter("@GuestID",    guest.GuestId)
            };
            try
            {
                if (!SqlHelper.ExecuteWithTran(sql, paras))
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            //再把房间的客人数量减一
            try
            {
                if (!RoomService.UpdateRoomGuestNumByCheckOutRoom(guest.Room.RoomId))
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
            //判断当前房间入住人数是否小于等于0
            try
            {
                if (RoomService.GetRoomGuestNumByCheckOutRoom(guest.Room.RoomId) <= 0)
                {
                    //如果这个房间当前入住人数小于等于0,把状态改为空闲
                    try
                    {
                        if (!RoomService.UpdateRoomRoomStateByCheckOutRoom(guest.Room.RoomId))
                        {
                            return(false);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(true);
        }