Esempio n. 1
0
class OrderDaoImpl:
	def __init__(self):
		self.conn = DBUtil().openConnection()

	# save table info, return order_id
	def saveOrder(self, order):

		with self.conn:
			cur = self.conn.cursor()

			sql = " insert into OrderTbl(orderTime,userId,tableId,personNum)values(%s,%s,%s,%s) "
			# set arg
			value = [ order.getOrderTime(),
					order.getUserId(),
					order.getTableId(),
					order.getPersonNum() ]
			# execute
			cur.execute(sql, value);  

			# return order_id
			sql2 = " select max(id) as id from OrderTbl "
			cur.execute(sql2) 

			row = cur.fetchone()
			return row[0]
	
	#save order list
	def saveOrderDetail(self, od):

		with self.conn:
			cur = self.conn.cursor()
			sql = " insert into OrderDetailTbl(orderId,menuId,num,remark)values(%s,%s,%s,%s) "

			value = [ od.getOrderId(),
					od.getMenuId(),
					od.getNum(),
					od.getRemark() ]
			# execute
			cur.execute(sql, value);  
	
	# using: update table status
	def updateTableStatus(self, table_id):

		with self.conn:
			cur = self.conn.cursor()

			sql = " update TableTbl set flag=1 where id = %s "
			cur.execute(sql, table_id)  
		
	
	# empty: update table status
	def updateTableStatus2(self, order_id): 

		 with self.conn:
			cur = self.conn.cursor()

			sql = " update TableTbl set flag = 0 where id = " +\
							" ( select tableId from OrderTbl where id = %s) "
			cur.execute(sql, order_id)  
Esempio n. 2
0
class CheckTableDaoImpl:

	def __init__(self):
		self.conn = DBUtil().openConnection()

	# 获得餐桌列表
	def getTableList(self):
		# 查询SQL语句
		sql =" select num,flag from TableTbl"
		with self.conn:
			cur = self.conn.cursor()

			cur.execute(sql)  

			# 获得预定义语句
			rows = cur.fetchall()
			result = []
			for row in rows:
				num = row[0]
				flag = row[1]

				ct = CheckTable()
				ct.setFlag(flag)
				ct.setNum(num)

				result.append(ct)
			
			return result
		return None
Esempio n. 3
0
class UserDaoImpl:
	
	def __init__(self):
		self.conn = DBUtil().openConnection()

	def login(self, account, password):
		# 查询SQL语句
		sql = " select id,account,password,name,permission,remark "+\
						" from UserTbl "+\
						" where account=%s and password=%s "
		with self.conn:
			cur = self.conn.cursor()

			values = [ account, password ]
			# 执行查询
			cur.execute(sql, values)  

			row = cur.fetchone()

			Id = row[0]
			name = row[3]
			permission = row[4]
			remark = row[5]
			# 封装用户信息
			u = User()
			
			u.setId(Id)
			u.setAccount(account)
			u.setPassword(password)
			u.setName(name)
			u.setPermission(permission)
			u.setRemark(remark)
			
			return u
		return None
Esempio n. 4
0
class UnionTableDaoImpl:
	
	def __init__(self):
		self.conn = DBUtil().openConnection()

	def getTableList(self):
		# 查询SQL语句
		sql =" select id,num from TableTbl where flag = 1 "

		with self.conn:
			cur = self.conn.cursor()
			cur.execute(sql)  

			# 判断订单详细
			result = []
			rows = cur.fetchall()
			for row in rows:
				# 获得菜单信息
				Id = row[0]
				num = row[1]
				
				ut = UnionTable()
				ut.setId(Id)
				ut.setNum(num)
				
				result.append(ut)
			
			return result
		return None
	
	def updateStatus(self, tableId1, tableId2):
		with self.conn:
			cur = self.conn.cursor()

			prepare = "new_proc"
			values = [ tableId1, tableId2 ]

			cur.callproc(prepare, values)
Esempio n. 5
0
class UpdateDaoImpl:

	def __init__(self):
		self.conn = DBUtil().openConnection()

	# 获得菜单列表
	def getMenuList(self):
		# 查询SQL语句
		sql =" select id,type,price,name,pic,remark from MenuTbl "

		with self.conn:
			cur = self.conn.cursor()

			# 执行查询
			cur.execute(sql)  
			# 判断订单详细
			rows = cur.fetchall()
			result = []
			for row in rows:
				# 获得菜单信息
				Id     = row[0]
				typeId = row[1]
				price  = row[2]
				name   = row[3]
				pic    = row[4]
				remark = row[5]
				
				m = Menu()
				m.setId(Id)
				m.setName(name)
				m.setPic(pic)
				m.setPrice(price)
				m.setRemark(remark)
				m.setTypeId(typeId)
				
				result.append(m)
			
			return result
		return None
	
	# 获得餐桌列表
	def getTableList(self):
		# 查询SQL语句
		sql =" select id,num,description from TableTbl "

		with self.conn:
			cur = self.conn.cursor()

			# 执行查询
			cur.execute(sql)  
			# 判断订单详细
			rows = cur.fetchall()
			result = []
			for row in rows:
				# 获得菜单信息
				Id   = row[0]
				num  = row[1]
				desc = row[2]
				
				t = Table()
				t.setId(Id)
				t.setNum(num)
				t.setDesc(desc)
				
				result.append(t)
			
			return result

		return None