Пример #1
0
        /// <summary>
        /// 新增房间类型
        /// </summary>
        /// <param name="type">房间类型对象</param>
        /// <returns>新增的类型编号</returns>
        public object AddType(RoomType type)
        {
            string sql = string.Format(@"INSERT [dbo].[RoomType] ([TypeName], [TypeWindow], [BedNum], [TypePrice])
                VALUES('{0}','{1}','{2}','{3}') SELECT @@IDENTITY", type.TypeName, type.TypeWindow, type.BedNum, type.TypePrice);
            object obj = DBHerper.Scalar(sql);

            return(obj);
        }
Пример #2
0
        /// <summary>
        /// 增加商品
        /// </summary>
        /// <param name="food">商品对象</param>
        /// <returns>增加的商品编号</returns>
        public object AddFoods(FoodList food)
        {
            string sql   = string.Format(@"INSERT [dbo].[FoodList] ([FoodName], [Unit], [Price])
                VALUES('{0}','{1}','{2}') SELECT @@IDENTITY", food.FoodName, food.Unit, food.Price);
            object judge = DBHerper.Scalar(sql);

            return(judge);
        }
Пример #3
0
        /// <summary>
        /// 判断该房间是有有未结账的订单
        /// </summary>
        /// <param name="id">房间ID</param>
        /// <returns>是否有</returns>
        public bool JudgeRoom(string id)
        {
            string sql = string.Format(@"SELECT count(*)
                FROM GuestRecord
                WHERE RoomId='{0}'", id);

            return((Convert.ToInt32(DBHerper.Scalar(sql)) != 0) ? true : false);
        }
        /// <summary>
        /// 获取房间状态
        /// </summary>
        /// <param name="roomId">房间编号</param>
        /// <returns>房间状态</returns>
        public int GetStatistics(string roomId)
        {
            string sql   = string.Format(@"SELECT [RoomStateId]
                FROM [dbo].[Room]
                WHERE [RoomId]='{0}'", roomId);
            int    judge = Convert.ToInt32(DBHerper.Scalar(sql));

            return(judge);
        }
Пример #5
0
        /// <summary>
        /// 增加客户信息
        /// </summary>
        /// <param name="info">客户信息</param>
        /// <returns>客户编号</returns>
        public string AddGuestInfo(GuestInfo info)
        {
            string sql     = string.Format(@"INSERT [dbo].[GuestInfo]([Name], [CardNo], [Phone], [Sex])
                VALUES ('{0}','{1}','{2}','{3}')
                SELECT @@IDENTITY", info.Name, info.CardNo, info.Phone, info.Sex);
            string guestId = DBHerper.Scalar(sql).ToString();

            return(guestId);
        }
Пример #6
0
        /// <summary>
        /// 判断类型的房间是否存在
        /// </summary>
        /// <param name="id">类型ID</param>
        /// <returns>是否存在</returns>
        public bool JudgeTypeId(string id)
        {
            string sql   = string.Format(@"SELECT COUNT(*)
                FROM [dbo].[Room]
                WHERE [RoomTypeId] ='{0}'", id);
            object judge = DBHerper.Scalar(sql);

            return((Convert.ToInt32(judge) != 0) ? true : false);
        }
Пример #7
0
        /// <summary>
        /// 修改客户信息
        /// </summary>
        /// <param name="info">客户信息</param>
        /// <returns>客户编号</returns>
        public string UpdateGuestInfo(GuestInfo info)
        {
            string sql     = string.Format(@"UPDATE [dbo].[GuestInfo]
                SET [Name]='{0}',[Phone]='{1}',[Sex]='{2}'
                WHERE [CardNo]='{3}'
                SELECT [ID]
                FROM [dbo].[GuestInfo]
                WHERE [CardNo]='{3}'", info.Name, info.Phone, info.Sex, info.CardNo);
            string guestId = DBHerper.Scalar(sql).ToString();

            return(guestId);
        }
Пример #8
0
        /// <summary>
        /// 判断此食品ID是否有订单
        /// </summary>
        /// <param name="id">商品ID</param>
        /// <returns>是否有订单</returns>
        public bool JudgeFoodsOrders(string id)
        {
            string sql   = string.Format(@"SELECT COUNT(*)
                FROM [dbo].[FoodOrder]
                WHERE [FoodId]='{0}'", id);
            int    judge = Convert.ToInt32(DBHerper.Scalar(sql));

            if (judge != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #9
0
        /// <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);
            }
        }
Пример #10
0
        /// <summary>
        /// 通过身份证判断客户是否存在
        /// </summary>
        /// <param name="id">身份证</param>
        /// <returns>是否存在</returns>
        public bool CheckExist(string id)
        {
            string sql   = string.Format(@"SELECT COUNT(*)
                FROM [dbo].[GuestInfo]
                WHERE [CardNo]='{0}'", id);
            int    judge = Convert.ToInt32(DBHerper.Scalar(sql));

            if (judge != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #11
0
        /// <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);
            }
        }
Пример #12
0
        /// <summary>
        /// 检查用户名和密码是否正确
        /// </summary>
        /// <param name="admin">管理员对象</param>
        /// <returns>是否正确</returns>
        public bool Check(Admin admin)
        {
            Encrypt encrypt = new Encrypt();
            string  pwd     = encrypt.EncryotPwd(admin.Pwd);
            string  sql     = string.Format(@"SELECT COUNT(*)
                FROM [dbo].[Admin]
                WHERE [Admins]='{0}' AND [Pwd]='{1}'", admin.Admins, pwd);

            try
            {
                int judge = Convert.ToInt32(DBHerper.Scalar(sql));
                return((judge == 1) ? true : false);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                return(false);
            }
        }