代码
Imports
Wireless.Entities
Imports Wireless.Printer.RemotingConnection
Imports Wireless.Common
Imports Dsdt.CasinoManager.BusinessRule
Imports HNA.PubClass.DishModel
Namespace DishInterface
Public Delegate Sub PrintBillDeletate( ByVal IsLaress As Boolean , ByVal machineNumber As String , ByVal data As List( Of BillList), ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Public Class OrderDishesImpl
Private Shared _currentTable As Table
Private Shared uStatus As Wireless.Entities.LoginUserStatus
' 种数(本次点菜)
Private Shared _orderKindCount As Decimal
' 份数(本次点菜)
Private Shared _copiesCount As Decimal
''' <summary>
''' 点菜 (入单)
''' </summary>
''' <param name="argOrderDishes"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function OrderDishes( ByVal argOrderDishes As Entities.OrderDishes()) As String
If argOrderDishes Is Nothing OrElse argOrderDishes.Length < 1 Then
Throw New Exception( " 获取菜单数据异常! " )
End If
Dim message As String = String .Empty
Dim result As String = String .Format( " {0} {1}{2} " , MobilFormatUtil.FormatString(argOrderDishes( 0 ).TypeCode, 4 ), _
MobilFormatUtil.FormatString(argOrderDishes( 0 ).MachineNumber, 3 ), _
vbCrLf)
uStatus = GlobalDataProvider.GetLoginUserStatusByMachineNo(argOrderDishes( 0 ).MachineNumber)
If uStatus Is Nothing Then
Return String .Concat(result, " 请先登录! " )
End If
' 将手持设备的台号(nWireTableId)映射为原有的桌号(cCode)
For i As Integer = 0 To argOrderDishes.Length - 1
argOrderDishes(i).TabelNoBillNo = TableCollection.All.GetCodeByWirlessId(argOrderDishes(i).TabelNoBillNo)
Next
If argOrderDishes( 0 ).TabelNoBillNo Is Nothing Then
Return String .Concat(result, " 台不存在! " )
End If
' 取得台对象
_currentTable = TableCollection.All.GetTableByCode(argOrderDishes( 0 ).TabelNoBillNo.Trim)
_currentTable = TableCollection.All.GetOneTables(_currentTable.ID)
If _currentTable Is Nothing Then
Return String .Concat(result, " 台不存在! " )
End If
' 取得当前台所有开台
Dim _currentOpentTables As OpenTableCollection = _currentTable.GetOpenTables()
If _currentOpentTables Is Nothing OrElse _currentOpentTables.Count < 1 Then
Return String .Concat(result, " 当前台未开! " )
End If
' NOTE :取得当前开台对象
Dim _openTable As Dsdt.CasinoManager.BusinessRule.OpenTable = _currentOpentTables( 0 )
' 判断当前台的账单状态
If _openTable.CurrentBillState = BillState.Printed Then
Return String .Concat(result, " 本单已预结,请先解冻! " )
Else
Try
' 执行入单操作
' 本次点菜种数和份数
_orderKindCount = 0
_copiesCount = 0
If ExecInsertBillList(argOrderDishes, False , - 1 ) Then
' 取得累计点菜种类和份数
Dim billLists As BillListCollection = _openTable.GetBillLists
Dim _totalOrderKindCount As Decimal = billLists.Count
Dim _totalCopiesCount As Decimal
For Each item As BillList In billLists
_totalCopiesCount += item.Count
Next
message = String .Format( " 点菜成功 " )
' message = String.Format("点菜成功!" + vbCrLf, _
' "{0} 本次点菜:{1}种/{2}份 累计点菜:{3}种/{4}份", _
' argOrderDishes(0).TabelNoBillNo, _
' _orderKindCount, _copiesCount, _
' _totalOrderKindCount, _totalCopiesCount _
' )
Else
message = " 点菜失败! "
End If
Catch ex As Exception
message = " 点菜失败! "
End Try
End If
Return String .Concat(result, message)
End Function
''' <summary>
''' 执行入单操作
''' </summary>
''' <param name="argOrderDishes"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function ExecInsertBillList( ByVal argOrderDishes As Entities.OrderDishes(), ByVal IsLaress As Boolean , ByVal nLargessManId As Integer ) As Boolean
Dim result As Boolean
If argOrderDishes.Length > 0 Then
' 菜单List
Dim data As New List( Of BillList)
' 将数据封装到BillList列表中
For Each item As Entities.OrderDishes In argOrderDishes
data.Add(InsertDataToBillList(item, IsLaress, nLargessManId))
_orderKindCount += 1
Next
If data.Count > 0 Then
'
' If _currentTable.GetOpenTables()(0).InsertBillList(data, argOrderDishes(0).MachineNumber, argOrderDishes(0).MachineNumber) Then
If _currentTable.GetOpenTables()( 0 ).InsertBillList(data, uStatus.UserId, argOrderDishes( 0 ).MachineNumber) Then
' Print
Dim printDelegate As PrintBillDeletate = New PrintBillDeletate( AddressOf PrintBill)
printDelegate.BeginInvoke(IsLaress, argOrderDishes( 0 ).MachineNumber, data, _currentTable, uStatus, Nothing , Nothing )
result = True
Else
result = False
End If
End If
End If
Return result
End Function
Private Shared Sub PrintBill( ByVal IsLaress As Boolean , ByVal machineNumber As String , ByVal data As List( Of BillList), ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Try
PrintBillListDoc(IsLaress, data, machineNumber, currenttable, userStatus) ' 打印小票
PrintDoc(data, machineNumber, currenttable, userStatus) ' 打印总单
Catch ex As Exception
' note 打印日志
End Try
End Sub
''' <summary>
''' 将数据追加到BillList中
''' </summary>
''' <param name="orderDish"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertDataToBillList( ByVal orderDish As Entities.OrderDishes, ByVal IsLaress As Boolean , ByVal nLargessManId As Integer ) As BillList
' 菜品 套餐号为空则是菜品否则为套餐
If String .IsNullOrEmpty(orderDish.ComboNumber.Trim) Then
Return InsertDishToList(orderDish, IsLaress, nLargessManId)
End If
' 套餐
Return InsertSuitToList(orderDish, IsLaress, nLargessManId)
End Function
''' <summary>
''' 将套餐子类数据追加到BillList对象中
''' </summary>
''' <param name="suitMenu"></param>
''' <param name="cookState"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertSuitMenuToList( ByVal suitMenu As SuitMenu, _
ByVal cookState As String , _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer )
If suitMenu Is Nothing Then
Return Nothing
End If
' 消费菜式状态
Dim curCookState As String = cookState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' 名称
Dim name As String = suitMenu.Name
' 数量
Dim count As Decimal = suitMenu.Count
' 价格
Dim price As Decimal = suitMenu.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = suitMenu.UnitId
Dim UnitName As String = suitMenu.UnitName
' 厨房
Dim CookRoomId As Integer = suitMenu.CookRoomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = False
Dim IsAgio = False
' M:菜品
Dim Id As Integer = suitMenu.ID
Dim IdSource As String = " SM "
Dim result As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
Return result
End Function
''' <summary>
''' 将套餐数据追加到BillList对象中
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertSuitToList( ByVal orderDish As Entities.OrderDishes, ByVal IsLaress As Boolean , ByVal nLargessManId As Integer )
' 消费菜式状态
Dim curCookState As String = orderDish.WaitState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' NOTE 根据CODE取得套餐对象
Dim suit As Suit = GlobalDataProvider.Menus.GetSuitByCode(orderDish.ComboNumber.Trim)
If suit Is Nothing Then
Return Nothing
End If
' 名称
Dim name As String = suit.Name
' 数量
Dim count As Decimal = orderDish.Count
' 价格
Dim price As Decimal = suit.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = suit.UnitId
Dim UnitName As String = suit.UnitName
' 厨房
Dim CookRoomId As Integer = suit.CookRoomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = suit.IsServerFee
Dim IsAgio = suit.IsAgio
' S:套餐
Dim Id As Integer = suit.ID
Dim IdSource As String = " S "
Dim result As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
' 取得套餐子类
Dim lstSuitMenu As List( Of SuitMenu) = GlobalDataProvider.Menus.GetMenusFromSuit(orderDish.ComboNumber.Trim)
If Not lstSuitMenu Is Nothing AndAlso lstSuitMenu.Count > 0 Then
For Each item As SuitMenu In lstSuitMenu
result.Items.Add(InsertSuitMenuToList(item, orderDish.WaitState.Trim, IsLaress, nLargessManId))
Next
End If
Return result
End Function
''' <summary>
''' 将菜品数据追加到BillList对象中
''' </summary>
''' <param name="orderDish"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertDishToList( ByVal orderDish As Entities.OrderDishes, _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer ) As BillList
' 消费菜式状态
Dim curCookState As String = orderDish.WaitState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
' If Not String.IsNullOrEmpty(curCookState) Then
' ckState = curCookState
' curCookStateName = BusinessUtil.GetCookStateName(ckState)
' End If
' NOTE 手持机无法输入消费菜式状态 默认为"即起"
ckState = EnumCookState.Checked
curCookStateName = BusinessUtil.GetCookStateName(ckState)
' Note NULL 取得菜对象
Dim menu As Menu = GlobalDataProvider.Menus.GetMenuByCode(orderDish.MenuId.Trim)
' 菜名
Dim name As String = menu.Name
' 数量
Dim count As Decimal = orderDish.Count
' 总份数统计
_copiesCount += count
' 价格
Dim price As Decimal = menu.Price
' 备注
Dim remark As String = menu.Remark
' 单价
Dim UnitId As Integer = menu.UnitId
Dim UnitName As String = menu.UnitName
' 厨房
Dim CookRoomId As Integer = menu.CookroomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = menu.IsServerFee
Dim IsAgio = menu.IsAgio
' M:菜品
Dim Id As Integer = menu.ID
Dim IdSource As String = " M "
Dim dish As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
' 如果有做法,则追加做法对象
If Not String .IsNullOrEmpty(orderDish.MakeWay.Trim) Then
' 制作方法中的任何一位不是数字,则认为输入的是内容而不是制作法的编号。
If IsNumeric (orderDish.MakeWay.Trim) Then
' Feihu Huang 2009/12/29
' 去做法的时候,3位取法优先,如果不是3位不是做法,则跳1位,取下三位,取到为止
Dim s As String
s = orderDish.MakeWay.Trim
Dim threeBytes As String
Dim i As Integer
Try
For i = 0 To s.Length - 2
threeBytes = s.Substring(i, 3 )
If Wireless.Common.MenusClass.IsAFunction(threeBytes) = True Then
System.Console.WriteLine(threeBytes)
' '根据CODE取得菜品做法对象
' orderDish.WaitState.Trim, _
Dim makeWayItem As BillList = SetDataToMakeWay(threeBytes, _
" 1 " , _
IsLaress, _
nLargessManId)
If Not makeWayItem Is Nothing Then
dish.Items.Add(makeWayItem)
dish.MenuRemark += makeWayItem.MenuName + " , "
End If
i = i + 2
End If
Next
If Not dish.MenuRemark Is Nothing AndAlso dish.MenuRemark.Length > 0 Then
dish.MenuRemark = dish.MenuRemark.Substring( 0 , dish.MenuRemark.Length - 1 )
End If
Catch ex As Exception
End Try
' '每3位为一做法的Code
' Dim functionCodes() As String = MobilFormatUtil.SplitStringByLenth(orderDish.MakeWay.Trim, 3)
' For Each code As String In functionCodes
' '根据CODE取得菜品做法对象
' Dim makeWayItem As BillList = SetDataToMakeWay(code, _
' orderDish.WaitState.Trim, _
' IsLaress, _
' nLargessManId)
' If Not makeWayItem Is Nothing Then
' dish.Items.Add(makeWayItem)
' End If
' Next
End If
End If
Return dish
End Function
''' <summary>
''' 将做法数据追加到BillList对象中
''' </summary>
''' <param name="makeWayCode"></param>
''' <param name="waitState"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function SetDataToMakeWay( ByVal makeWayCode As String , _
ByVal waitState As String , _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer ) As BillList
' 消费菜式状态
Dim curCookState As String = waitState
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' NOTE 根据CODE取得菜品做法对象
Dim makeWay As MenuFunction = GlobalDataProvider.Menus.GetFunctionById(makeWayCode)
If makeWay Is Nothing Then
Return Nothing
End If
' 名称
Dim name As String = makeWay.Name
' 数量
Dim count As Decimal = 1
' 价格
Dim price As Decimal = makeWay.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = makeWay.UnitId
Dim UnitName As String = makeWay.UnitName
' 厨房
Dim CookRoomId As Integer = - 1
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = makeWay.IsServerFee
Dim IsAgio = makeWay.IsAgio
' M:菜品
Dim Id As Integer = makeWay.ID
Dim IdSource As String = " F "
Dim makeWayItem As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
Return makeWayItem
End Function
#Region "打印小票"
Private Shared Sub PrintBillListDoc( ByVal IsLaress As Boolean , ByVal data As List( Of BillList), ByVal machineCode As String , ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
' TODO 手持设备的用户名
' Dim currentUserName As String = machineCode
Dim currentUserName As String = userStatus.UserName
Dim BLCol As New BillListCollection
For Each l As BillList In data
If l.IsPrintB() Then
BLCol.Add(l)
End If
Next
If BLCol.Count > 0 Then
For Each BL As BillList In BLCol
If IsPrintPassPrintCenter Then
Dim L As New SystemLicenseRule( True )
Dim P As New RemotingConnection
Dim C As CookRoom = CType (CookRoomCollection.GetOneCookRooms(BL.CookRoomId)( 0 ), CookRoom)
Dim BillListDoc As New PrintBillListRpt( IIf (IsLaress, " 赠送 " , BL.CurrentCookStateName), currenttable.Name, _
currentUserName, Now.ToString, BL.MenuName, BL.Count, BL.UnitName, BL.Price, _
BL.Count * BL.Price, BL.MenuRemark, C.PrintAreaCode, _
L.CurLicense.name, currenttable.DepartmentName, currenttable.HallName, _
currenttable.ServerFee, 0 , 0 , 0 , 0 , 0 )
P.LoadBillListPiaoRpt(BillListDoc)
Else
End If
Next
' Dim doc As New Doc_TolBill(cols, Me._checkedTbl.Name, AppConfig.CurrentUser.cName, IIf(cols(0).ListState = BillListState.Natural, "总单", "赠送"))
' doc.PrintController = New System.Drawing.Printing.StandardPrintController()
' doc.PrintDoc()
End If
End Sub
''' <summary>
''' 是否用打印中心来打印账单
''' </summary>
''' <remarks></remarks>
Public Shared ReadOnly Property IsPrintPassPrintCenter() As Boolean
Get
Dim p As New SystemParamsRule( True )
Return p.IsPrintPassPrintCenter
End Get
' 'Get
' ' Return _IsPrintPassPrintCenter
' 'End Get
' 'Set(ByVal value As Boolean)
' ' Dim p As New SystemParamsRule(True)
' ' _IsPrintPassPrintCenter = p.IsPrintPassPrintCenter
' 'End Set
End Property
#End Region
#Region "打印总单"
Private Shared Sub PrintDoc( ByVal data As List( Of BillList), ByVal machineCode As String , ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Dim Plsts As New BillListCollection
For Each l As BillList In data
If l.IsPrintA() Then
Plsts.Add(l)
End If
Next
If Plsts.Count > 0 Then
Dim L As New SystemLicenseRule( True )
' 'If AppConfig.IsPrintPassPrintCenter Then
' ' ''用C1REPORT来打印
' ' Dim BLdata As PrintBillListData = New PrintBillListData("zongdan")
' ' For Each BL As BillList In Plsts
' ' BLdata.AddOneRow(BL)
' ' Next
' ' Dim P As New RemotingConnection
' ' 'Dim C As CookRoom = CType(CookRoomCollection.GetOneCookRooms(lst.CookRoomId)(0), CookRoom)
' ' Dim pbr As New PrintBillListRpt("总单", Me._checkedTbl.Name, AppConfig.CurrentUser.cName, _
' ' Now.ToString, "", 0, "", 0, _
' ' 0, "", _PrintArea, _
' ' L.CurLicense.name, _checkedTbl.DepartmentName, _checkedTbl.HallName, _
' ' Me._checkedTbl.ServerFee, Plsts.TolServerFeeMoney(Me._checkedTbl.ServerFee), 0, 0, Plsts.TolNaturalMoney, Plsts.TolLargessMoney) 'C.PrintAreaCode)
' ' P.LoadBillListZongRpt(BLdata._BillListData, pbr)
' ' ''用C1REPORT来打印
' 'Else
' '用画的PrintDocument来打印()
Dim msg As New CashBillMsg
msg.title = IIf (Plsts( 0 ).ListState = BillListState.Natural, " 总单 " , " 赠送 " )
msg.HotelName = L.CurLicense.name
msg.DprtName = currenttable.DepartmentName
msg.HallName = currenttable.HallName
msg.TableCode = currenttable.Code
msg.TableName = currenttable.Name
msg.PrintCount = 0
msg.BillCode = ""
' TODO 手持设备的用户名
msg.UserCode = userStatus.UserCode
msg.UserName = userStatus.UserName
msg.GuestCount = currenttable.GetOpenTables( 0 ).GuestCount
msg.MenuInTime = Now
msg.ServerFeeRate = currenttable.ServerFee
msg.ServerFee = Plsts.TolServerFeeMoney(currenttable.ServerFee)
msg.AgioRate = 0
msg.Agio = 0
msg.MenuMoney = Plsts.TolAllMoney
msg.TolMoney = Plsts.TolAllMoney + Plsts.TolServerFeeMoney(currenttable.ServerFee)
' Dim doc As New Doc_TolBill(cols, Me._checkedTbl.Name, AppConfig.CurrentUser.cName, IIf(cols(0).ListState = BillListState.Natural, "总单", "赠送"))
Dim doc As New Doc_TolBill(Plsts, msg)
doc.PrintController = New System.Drawing.Printing.StandardPrintController()
doc.PrintDoc()
' '用画的PrintDocument来打印
' 'End If
End If
End Sub
#End Region
End Class
End Namespace
Imports Wireless.Printer.RemotingConnection
Imports Wireless.Common
Imports Dsdt.CasinoManager.BusinessRule
Imports HNA.PubClass.DishModel
Namespace DishInterface
Public Delegate Sub PrintBillDeletate( ByVal IsLaress As Boolean , ByVal machineNumber As String , ByVal data As List( Of BillList), ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Public Class OrderDishesImpl
Private Shared _currentTable As Table
Private Shared uStatus As Wireless.Entities.LoginUserStatus
' 种数(本次点菜)
Private Shared _orderKindCount As Decimal
' 份数(本次点菜)
Private Shared _copiesCount As Decimal
''' <summary>
''' 点菜 (入单)
''' </summary>
''' <param name="argOrderDishes"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function OrderDishes( ByVal argOrderDishes As Entities.OrderDishes()) As String
If argOrderDishes Is Nothing OrElse argOrderDishes.Length < 1 Then
Throw New Exception( " 获取菜单数据异常! " )
End If
Dim message As String = String .Empty
Dim result As String = String .Format( " {0} {1}{2} " , MobilFormatUtil.FormatString(argOrderDishes( 0 ).TypeCode, 4 ), _
MobilFormatUtil.FormatString(argOrderDishes( 0 ).MachineNumber, 3 ), _
vbCrLf)
uStatus = GlobalDataProvider.GetLoginUserStatusByMachineNo(argOrderDishes( 0 ).MachineNumber)
If uStatus Is Nothing Then
Return String .Concat(result, " 请先登录! " )
End If
' 将手持设备的台号(nWireTableId)映射为原有的桌号(cCode)
For i As Integer = 0 To argOrderDishes.Length - 1
argOrderDishes(i).TabelNoBillNo = TableCollection.All.GetCodeByWirlessId(argOrderDishes(i).TabelNoBillNo)
Next
If argOrderDishes( 0 ).TabelNoBillNo Is Nothing Then
Return String .Concat(result, " 台不存在! " )
End If
' 取得台对象
_currentTable = TableCollection.All.GetTableByCode(argOrderDishes( 0 ).TabelNoBillNo.Trim)
_currentTable = TableCollection.All.GetOneTables(_currentTable.ID)
If _currentTable Is Nothing Then
Return String .Concat(result, " 台不存在! " )
End If
' 取得当前台所有开台
Dim _currentOpentTables As OpenTableCollection = _currentTable.GetOpenTables()
If _currentOpentTables Is Nothing OrElse _currentOpentTables.Count < 1 Then
Return String .Concat(result, " 当前台未开! " )
End If
' NOTE :取得当前开台对象
Dim _openTable As Dsdt.CasinoManager.BusinessRule.OpenTable = _currentOpentTables( 0 )
' 判断当前台的账单状态
If _openTable.CurrentBillState = BillState.Printed Then
Return String .Concat(result, " 本单已预结,请先解冻! " )
Else
Try
' 执行入单操作
' 本次点菜种数和份数
_orderKindCount = 0
_copiesCount = 0
If ExecInsertBillList(argOrderDishes, False , - 1 ) Then
' 取得累计点菜种类和份数
Dim billLists As BillListCollection = _openTable.GetBillLists
Dim _totalOrderKindCount As Decimal = billLists.Count
Dim _totalCopiesCount As Decimal
For Each item As BillList In billLists
_totalCopiesCount += item.Count
Next
message = String .Format( " 点菜成功 " )
' message = String.Format("点菜成功!" + vbCrLf, _
' "{0} 本次点菜:{1}种/{2}份 累计点菜:{3}种/{4}份", _
' argOrderDishes(0).TabelNoBillNo, _
' _orderKindCount, _copiesCount, _
' _totalOrderKindCount, _totalCopiesCount _
' )
Else
message = " 点菜失败! "
End If
Catch ex As Exception
message = " 点菜失败! "
End Try
End If
Return String .Concat(result, message)
End Function
''' <summary>
''' 执行入单操作
''' </summary>
''' <param name="argOrderDishes"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function ExecInsertBillList( ByVal argOrderDishes As Entities.OrderDishes(), ByVal IsLaress As Boolean , ByVal nLargessManId As Integer ) As Boolean
Dim result As Boolean
If argOrderDishes.Length > 0 Then
' 菜单List
Dim data As New List( Of BillList)
' 将数据封装到BillList列表中
For Each item As Entities.OrderDishes In argOrderDishes
data.Add(InsertDataToBillList(item, IsLaress, nLargessManId))
_orderKindCount += 1
Next
If data.Count > 0 Then
'
' If _currentTable.GetOpenTables()(0).InsertBillList(data, argOrderDishes(0).MachineNumber, argOrderDishes(0).MachineNumber) Then
If _currentTable.GetOpenTables()( 0 ).InsertBillList(data, uStatus.UserId, argOrderDishes( 0 ).MachineNumber) Then
Dim printDelegate As PrintBillDeletate = New PrintBillDeletate( AddressOf PrintBill)
printDelegate.BeginInvoke(IsLaress, argOrderDishes( 0 ).MachineNumber, data, _currentTable, uStatus, Nothing , Nothing )
result = True
Else
result = False
End If
End If
End If
Return result
End Function
Private Shared Sub PrintBill( ByVal IsLaress As Boolean , ByVal machineNumber As String , ByVal data As List( Of BillList), ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Try
PrintBillListDoc(IsLaress, data, machineNumber, currenttable, userStatus) ' 打印小票
PrintDoc(data, machineNumber, currenttable, userStatus) ' 打印总单
Catch ex As Exception
' note 打印日志
End Try
End Sub
''' <summary>
''' 将数据追加到BillList中
''' </summary>
''' <param name="orderDish"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertDataToBillList( ByVal orderDish As Entities.OrderDishes, ByVal IsLaress As Boolean , ByVal nLargessManId As Integer ) As BillList
' 菜品 套餐号为空则是菜品否则为套餐
If String .IsNullOrEmpty(orderDish.ComboNumber.Trim) Then
Return InsertDishToList(orderDish, IsLaress, nLargessManId)
End If
' 套餐
Return InsertSuitToList(orderDish, IsLaress, nLargessManId)
End Function
''' <summary>
''' 将套餐子类数据追加到BillList对象中
''' </summary>
''' <param name="suitMenu"></param>
''' <param name="cookState"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertSuitMenuToList( ByVal suitMenu As SuitMenu, _
ByVal cookState As String , _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer )
If suitMenu Is Nothing Then
Return Nothing
End If
' 消费菜式状态
Dim curCookState As String = cookState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' 名称
Dim name As String = suitMenu.Name
' 数量
Dim count As Decimal = suitMenu.Count
' 价格
Dim price As Decimal = suitMenu.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = suitMenu.UnitId
Dim UnitName As String = suitMenu.UnitName
' 厨房
Dim CookRoomId As Integer = suitMenu.CookRoomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = False
Dim IsAgio = False
' M:菜品
Dim Id As Integer = suitMenu.ID
Dim IdSource As String = " SM "
Dim result As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
Return result
End Function
''' <summary>
''' 将套餐数据追加到BillList对象中
''' </summary>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertSuitToList( ByVal orderDish As Entities.OrderDishes, ByVal IsLaress As Boolean , ByVal nLargessManId As Integer )
' 消费菜式状态
Dim curCookState As String = orderDish.WaitState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' NOTE 根据CODE取得套餐对象
Dim suit As Suit = GlobalDataProvider.Menus.GetSuitByCode(orderDish.ComboNumber.Trim)
If suit Is Nothing Then
Return Nothing
End If
' 名称
Dim name As String = suit.Name
' 数量
Dim count As Decimal = orderDish.Count
' 价格
Dim price As Decimal = suit.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = suit.UnitId
Dim UnitName As String = suit.UnitName
' 厨房
Dim CookRoomId As Integer = suit.CookRoomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = suit.IsServerFee
Dim IsAgio = suit.IsAgio
' S:套餐
Dim Id As Integer = suit.ID
Dim IdSource As String = " S "
Dim result As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
' 取得套餐子类
Dim lstSuitMenu As List( Of SuitMenu) = GlobalDataProvider.Menus.GetMenusFromSuit(orderDish.ComboNumber.Trim)
If Not lstSuitMenu Is Nothing AndAlso lstSuitMenu.Count > 0 Then
For Each item As SuitMenu In lstSuitMenu
result.Items.Add(InsertSuitMenuToList(item, orderDish.WaitState.Trim, IsLaress, nLargessManId))
Next
End If
Return result
End Function
''' <summary>
''' 将菜品数据追加到BillList对象中
''' </summary>
''' <param name="orderDish"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function InsertDishToList( ByVal orderDish As Entities.OrderDishes, _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer ) As BillList
' 消费菜式状态
Dim curCookState As String = orderDish.WaitState.Trim
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
' If Not String.IsNullOrEmpty(curCookState) Then
' ckState = curCookState
' curCookStateName = BusinessUtil.GetCookStateName(ckState)
' End If
' NOTE 手持机无法输入消费菜式状态 默认为"即起"
ckState = EnumCookState.Checked
curCookStateName = BusinessUtil.GetCookStateName(ckState)
' Note NULL 取得菜对象
Dim menu As Menu = GlobalDataProvider.Menus.GetMenuByCode(orderDish.MenuId.Trim)
' 菜名
Dim name As String = menu.Name
' 数量
Dim count As Decimal = orderDish.Count
' 总份数统计
_copiesCount += count
' 价格
Dim price As Decimal = menu.Price
' 备注
Dim remark As String = menu.Remark
' 单价
Dim UnitId As Integer = menu.UnitId
Dim UnitName As String = menu.UnitName
' 厨房
Dim CookRoomId As Integer = menu.CookroomId
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = menu.IsServerFee
Dim IsAgio = menu.IsAgio
' M:菜品
Dim Id As Integer = menu.ID
Dim IdSource As String = " M "
Dim dish As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
' 如果有做法,则追加做法对象
If Not String .IsNullOrEmpty(orderDish.MakeWay.Trim) Then
' 制作方法中的任何一位不是数字,则认为输入的是内容而不是制作法的编号。
If IsNumeric (orderDish.MakeWay.Trim) Then
' Feihu Huang 2009/12/29
' 去做法的时候,3位取法优先,如果不是3位不是做法,则跳1位,取下三位,取到为止
Dim s As String
s = orderDish.MakeWay.Trim
Dim threeBytes As String
Dim i As Integer
Try
For i = 0 To s.Length - 2
threeBytes = s.Substring(i, 3 )
If Wireless.Common.MenusClass.IsAFunction(threeBytes) = True Then
System.Console.WriteLine(threeBytes)
' '根据CODE取得菜品做法对象
' orderDish.WaitState.Trim, _
Dim makeWayItem As BillList = SetDataToMakeWay(threeBytes, _
" 1 " , _
IsLaress, _
nLargessManId)
If Not makeWayItem Is Nothing Then
dish.Items.Add(makeWayItem)
dish.MenuRemark += makeWayItem.MenuName + " , "
End If
i = i + 2
End If
Next
If Not dish.MenuRemark Is Nothing AndAlso dish.MenuRemark.Length > 0 Then
dish.MenuRemark = dish.MenuRemark.Substring( 0 , dish.MenuRemark.Length - 1 )
End If
Catch ex As Exception
End Try
' '每3位为一做法的Code
' Dim functionCodes() As String = MobilFormatUtil.SplitStringByLenth(orderDish.MakeWay.Trim, 3)
' For Each code As String In functionCodes
' '根据CODE取得菜品做法对象
' Dim makeWayItem As BillList = SetDataToMakeWay(code, _
' orderDish.WaitState.Trim, _
' IsLaress, _
' nLargessManId)
' If Not makeWayItem Is Nothing Then
' dish.Items.Add(makeWayItem)
' End If
' Next
End If
End If
Return dish
End Function
''' <summary>
''' 将做法数据追加到BillList对象中
''' </summary>
''' <param name="makeWayCode"></param>
''' <param name="waitState"></param>
''' <param name="IsLaress"></param>
''' <param name="nLargessManId"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Shared Function SetDataToMakeWay( ByVal makeWayCode As String , _
ByVal waitState As String , _
ByVal IsLaress As Boolean , _
ByVal nLargessManId As Integer ) As BillList
' 消费菜式状态
Dim curCookState As String = waitState
Dim curCookStateName As String = String .Empty
Dim ckState As EnumCookState
If Not String .IsNullOrEmpty(curCookState) Then
ckState = curCookState
curCookStateName = BusinessUtil.GetCookStateName(ckState)
End If
' NOTE 根据CODE取得菜品做法对象
Dim makeWay As MenuFunction = GlobalDataProvider.Menus.GetFunctionById(makeWayCode)
If makeWay Is Nothing Then
Return Nothing
End If
' 名称
Dim name As String = makeWay.Name
' 数量
Dim count As Decimal = 1
' 价格
Dim price As Decimal = makeWay.Price
' 备注
Dim remark As String = String .Empty
' 单价
Dim UnitId As Integer = makeWay.UnitId
Dim UnitName As String = makeWay.UnitName
' 厨房
Dim CookRoomId As Integer = - 1
' 帐单明细状态
Dim listState As BillListState = IIf (IsLaress, BillListState.Largess, BillListState.Natural)
' 是否收服务费
Dim IsServerFee = makeWay.IsServerFee
Dim IsAgio = makeWay.IsAgio
' M:菜品
Dim Id As Integer = makeWay.ID
Dim IdSource As String = " F "
Dim makeWayItem As BillList = New BillList(Id, name, listState, ckState, curCookStateName, CookRoomId, count, price, remark, _
IdSource, UnitId, UnitName, nLargessManId, IsServerFee, IsAgio)
Return makeWayItem
End Function
#Region "打印小票"
Private Shared Sub PrintBillListDoc( ByVal IsLaress As Boolean , ByVal data As List( Of BillList), ByVal machineCode As String , ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
' TODO 手持设备的用户名
' Dim currentUserName As String = machineCode
Dim currentUserName As String = userStatus.UserName
Dim BLCol As New BillListCollection
For Each l As BillList In data
If l.IsPrintB() Then
BLCol.Add(l)
End If
Next
If BLCol.Count > 0 Then
For Each BL As BillList In BLCol
If IsPrintPassPrintCenter Then
Dim L As New SystemLicenseRule( True )
Dim P As New RemotingConnection
Dim C As CookRoom = CType (CookRoomCollection.GetOneCookRooms(BL.CookRoomId)( 0 ), CookRoom)
Dim BillListDoc As New PrintBillListRpt( IIf (IsLaress, " 赠送 " , BL.CurrentCookStateName), currenttable.Name, _
currentUserName, Now.ToString, BL.MenuName, BL.Count, BL.UnitName, BL.Price, _
BL.Count * BL.Price, BL.MenuRemark, C.PrintAreaCode, _
L.CurLicense.name, currenttable.DepartmentName, currenttable.HallName, _
currenttable.ServerFee, 0 , 0 , 0 , 0 , 0 )
P.LoadBillListPiaoRpt(BillListDoc)
Else
End If
Next
' Dim doc As New Doc_TolBill(cols, Me._checkedTbl.Name, AppConfig.CurrentUser.cName, IIf(cols(0).ListState = BillListState.Natural, "总单", "赠送"))
' doc.PrintController = New System.Drawing.Printing.StandardPrintController()
' doc.PrintDoc()
End If
End Sub
''' <summary>
''' 是否用打印中心来打印账单
''' </summary>
''' <remarks></remarks>
Public Shared ReadOnly Property IsPrintPassPrintCenter() As Boolean
Get
Dim p As New SystemParamsRule( True )
Return p.IsPrintPassPrintCenter
End Get
' 'Get
' ' Return _IsPrintPassPrintCenter
' 'End Get
' 'Set(ByVal value As Boolean)
' ' Dim p As New SystemParamsRule(True)
' ' _IsPrintPassPrintCenter = p.IsPrintPassPrintCenter
' 'End Set
End Property
#End Region
#Region "打印总单"
Private Shared Sub PrintDoc( ByVal data As List( Of BillList), ByVal machineCode As String , ByVal currenttable As Table, ByVal userStatus As LoginUserStatus)
Dim Plsts As New BillListCollection
For Each l As BillList In data
If l.IsPrintA() Then
Plsts.Add(l)
End If
Next
If Plsts.Count > 0 Then
Dim L As New SystemLicenseRule( True )
' 'If AppConfig.IsPrintPassPrintCenter Then
' ' ''用C1REPORT来打印
' ' Dim BLdata As PrintBillListData = New PrintBillListData("zongdan")
' ' For Each BL As BillList In Plsts
' ' BLdata.AddOneRow(BL)
' ' Next
' ' Dim P As New RemotingConnection
' ' 'Dim C As CookRoom = CType(CookRoomCollection.GetOneCookRooms(lst.CookRoomId)(0), CookRoom)
' ' Dim pbr As New PrintBillListRpt("总单", Me._checkedTbl.Name, AppConfig.CurrentUser.cName, _
' ' Now.ToString, "", 0, "", 0, _
' ' 0, "", _PrintArea, _
' ' L.CurLicense.name, _checkedTbl.DepartmentName, _checkedTbl.HallName, _
' ' Me._checkedTbl.ServerFee, Plsts.TolServerFeeMoney(Me._checkedTbl.ServerFee), 0, 0, Plsts.TolNaturalMoney, Plsts.TolLargessMoney) 'C.PrintAreaCode)
' ' P.LoadBillListZongRpt(BLdata._BillListData, pbr)
' ' ''用C1REPORT来打印
' 'Else
' '用画的PrintDocument来打印()
Dim msg As New CashBillMsg
msg.title = IIf (Plsts( 0 ).ListState = BillListState.Natural, " 总单 " , " 赠送 " )
msg.HotelName = L.CurLicense.name
msg.DprtName = currenttable.DepartmentName
msg.HallName = currenttable.HallName
msg.TableCode = currenttable.Code
msg.TableName = currenttable.Name
msg.PrintCount = 0
msg.BillCode = ""
' TODO 手持设备的用户名
msg.UserCode = userStatus.UserCode
msg.UserName = userStatus.UserName
msg.GuestCount = currenttable.GetOpenTables( 0 ).GuestCount
msg.MenuInTime = Now
msg.ServerFeeRate = currenttable.ServerFee
msg.ServerFee = Plsts.TolServerFeeMoney(currenttable.ServerFee)
msg.AgioRate = 0
msg.Agio = 0
msg.MenuMoney = Plsts.TolAllMoney
msg.TolMoney = Plsts.TolAllMoney + Plsts.TolServerFeeMoney(currenttable.ServerFee)
' Dim doc As New Doc_TolBill(cols, Me._checkedTbl.Name, AppConfig.CurrentUser.cName, IIf(cols(0).ListState = BillListState.Natural, "总单", "赠送"))
Dim doc As New Doc_TolBill(Plsts, msg)
doc.PrintController = New System.Drawing.Printing.StandardPrintController()
doc.PrintDoc()
' '用画的PrintDocument来打印
' 'End If
End If
End Sub
#End Region
End Class
End Namespace