Exemplo n.º 1
0
        public bool CreateHandover(HandoverInfo handover)
        {
            string json = JsonConvert.SerializeObject(handover);

            byte[] jsonByte = Encoding.UTF8.GetBytes(json);

            int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length;

            byte[] sendByte   = new byte[cByte];
            int    byteOffset = 0;

            Array.Copy(BitConverter.GetBytes((int)Command.ID_CREATE_HANDOVER), sendByte, BasicTypeLength.INT32);
            byteOffset = BasicTypeLength.INT32;
            Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32);
            byteOffset += BasicTypeLength.INT32;
            Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length);
            byteOffset += jsonByte.Length;

            bool result = false;

            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32  operCode    = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    result = true;
                }
                socket.Close();
            }
            return(result);
        }
Exemplo n.º 2
0
        public bool CreateHandover(HandoverInfo handover)
        {
            bool returnValue = false;

            _daoManager.BeginTransaction();
            try
            {
                //日结号
                string dailyStatementNo = _dailyStatementDao.GetCurrentDailyStatementNo();
                if (!string.IsNullOrEmpty(dailyStatementNo))
                {
                    //交班记录
                    HandoverRecord handoverRecord = handover.handoverRecord;
                    handoverRecord.DailyStatementNo = dailyStatementNo;
                    _handoverRecord.CreateHandoverRecord(handoverRecord);
                    //交班金额列表
                    if (handover.handoverTurnoverList != null && handover.handoverTurnoverList.Count > 0)
                    {
                        foreach (HandoverTurnover item in handover.handoverTurnoverList)
                        {
                            item.DailyStatementNo = dailyStatementNo;
                            _handoverTurnover.CreateHandoverTurnover(item);
                        }
                    }
                    returnValue = true;
                }
                _daoManager.CommitTransaction();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[CreateHandover]参数:handover_{0}", JsonConvert.SerializeObject(handover)), exception);
                _daoManager.RollBackTransaction();
                returnValue = false;
            }
            return(returnValue);
        }
Exemplo n.º 3
0
        public static byte[] CreateHandover(byte[] itemBuffer)
        {
            byte[]       objRet     = null;
            string       strReceive = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0');
            HandoverInfo handover   = JsonConvert.DeserializeObject <HandoverInfo>(strReceive);

            bool result = HandoverService.GetInstance().CreateHandover(handover);

            if (result)
            {
                //交班成功
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            else
            {
                //交班失败
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            return(objRet);
        }
Exemplo n.º 4
0
        private void btnSalesReport_Click(object sender, EventArgs e)
        {
            if (bizReport != null && bizReport.BillTotalQty > 0)
            {
                if (m_ModelType == 1)
                {
                    //判断是否存在退款失败的账单
                    CardRefundPayService refundPayService  = new CardRefundPayService();
                    List <CardRefundPay> cardRefundPayList = refundPayService.GetCardRefundPayList();
                    if (cardRefundPayList != null && cardRefundPayList.Count > 0)
                    {
                        FormVIPCardRefundPay refundPayForm = new FormVIPCardRefundPay(cardRefundPayList);
                        refundPayForm.ShowDialog();
                    }
                    Guid           handoverRecordId = Guid.NewGuid();
                    HandoverRecord handoverRecord   = new HandoverRecord();
                    handoverRecord.HandoverRecordID = handoverRecordId;
                    handoverRecord.DeviceNo         = ConstantValuePool.BizSettingConfig.DeviceNo;
                    handoverRecord.EmployeeID       = ConstantValuePool.CurrentEmployee.EmployeeID;
                    IList <HandoverTurnover> handoverTurnoverList = new List <HandoverTurnover>();
                    foreach (OrderPayoffSum item in bizReport.orderPayoffSumList)
                    {
                        HandoverTurnover handoverTurnover = new HandoverTurnover();
                        handoverTurnover.HandoverRecordID = handoverRecordId;
                        handoverTurnover.PayoffID         = item.PayoffID;
                        handoverTurnover.SalesTurnover    = item.PayoffMoney;
                        handoverTurnoverList.Add(handoverTurnover);
                    }

                    HandoverInfo handover = new HandoverInfo();
                    handover.handoverRecord       = handoverRecord;
                    handover.handoverTurnoverList = handoverTurnoverList;
                    bool result = HandoverService.GetInstance().CreateHandover(handover);
                    if (result)
                    {
                        MessageBox.Show("交班成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        m_HandleSuccess = true;
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("出现异常错误,请重新交班!");
                    }
                }
                else if (m_ModelType == 2)
                {
                    //判断是否存在退款失败的账单
                    CardRefundPayService refundPayService  = new CardRefundPayService();
                    List <CardRefundPay> cardRefundPayList = refundPayService.GetCardRefundPayList();
                    if (cardRefundPayList != null && cardRefundPayList.Count > 0)
                    {
                        FormVIPCardRefundPay refundPayForm = new FormVIPCardRefundPay(cardRefundPayList);
                        refundPayForm.ShowDialog();
                    }
                    FormChooseDate form = new FormChooseDate(bizReport.LastDailyStatementTime);
                    form.ShowDialog();
                    if (form.DailyStatementDate != null)
                    {
                        string weather = this.cmbWeather.Text;
                        if (string.IsNullOrEmpty(weather))
                        {
                            MessageBox.Show("请先选择当天天气情况!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        DateTime       belongToDate   = (DateTime)form.DailyStatementDate;
                        DailyStatement dailyStatement = new DailyStatement();
                        dailyStatement.DeviceNo     = ConstantValuePool.BizSettingConfig.DeviceNo;
                        dailyStatement.BelongToDate = belongToDate;
                        dailyStatement.Weather      = weather;
                        dailyStatement.EmployeeID   = ConstantValuePool.CurrentEmployee.EmployeeID;
                        DailyTurnover dailyTurnover = new DailyTurnover();
                        dailyTurnover.TotalRevenue       = bizReport.TotalRevenue;
                        dailyTurnover.CutOffTotalPrice   = bizReport.CutOffTotalPrice;
                        dailyTurnover.DiscountTotalPrice = bizReport.DiscountTotalPrice;
                        dailyTurnover.ActualTotalIncome  = bizReport.ActualTotalIncome;
                        dailyTurnover.TotalServiceFee    = bizReport.TotalServiceFee;
                        dailyTurnover.StoredTotalPrice   = 0;

                        DailyBalance dailyBalance = new DailyBalance();
                        dailyBalance.dailyStatement = dailyStatement;
                        dailyBalance.dailyTurnover  = dailyTurnover;
                        string unCheckDeviceNo;  //未结账的设备号
                        int    result = DailyBalanceService.GetInstance().CreateDailyBalance(dailyBalance, out unCheckDeviceNo);
                        if (result == 1)
                        {
                            MessageBox.Show("日结成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            m_HandleSuccess = true;
                            this.Close();
                        }
                        else if (result == 2)
                        {
                            MessageBox.Show("存在未结账单据,请先结完账!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else if (result == 3)
                        {
                            if (string.IsNullOrEmpty(unCheckDeviceNo))
                            {
                                MessageBox.Show("存在未交班的POS,请先交班!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            else
                            {
                                if (unCheckDeviceNo.IndexOf(',') == -1 && unCheckDeviceNo.IndexOf(ConstantValuePool.BizSettingConfig.DeviceNo) >= 0)
                                {
                                    MessageBox.Show("当前设备未交班,请交班后进行日结!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else
                                {
                                    MessageBox.Show(string.Format("设备【{0}】未交班,请先交班!", unCheckDeviceNo), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("出现异常错误,请重新日结!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }