Пример #1
0
        private void FormChooseDate_Load(object sender, EventArgs e)
        {
            if (m_LastDailyStatementTime != null)
            {
                DateTime lastDailyStatementTime = (DateTime)m_LastDailyStatementTime;
                this.txtLastTime.Text = lastDailyStatementTime.ToLongDateString() + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(lastDailyStatementTime.DayOfWeek);
            }
            string dailyTimeInterval = DailyBalanceService.GetInstance().GetDailyStatementTimeInterval();

            if (string.IsNullOrEmpty(dailyTimeInterval))
            {
                MessageBox.Show("未获取到销售数据,请确认后操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                string[] timeArr   = dailyTimeInterval.Split(',');
                DateTime beginTime = DateTime.Parse(timeArr[0]);
                DateTime endTime   = DateTime.Parse(timeArr[1] + " 23:59:59");
                if (endTime < m_LastDailyStatementTime)
                {
                    //Fix 销售时间错误
                    beginTime = (DateTime)m_LastDailyStatementTime;
                    endTime   = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
                }
                DateTime tempDate = beginTime;
                while (tempDate < endTime)
                {
                    comboBox1.Items.Add(tempDate.ToLongDateString() + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(tempDate.DayOfWeek));
                    tempDate = tempDate.AddDays(1);
                }
            }
        }
Пример #2
0
        /// <summary>
        ///  获取一段时间内各个账务日的营业额
        /// </summary>
        public static byte[] GetDailyStatementInDays(byte[] itemBuffer)
        {
            byte[] objRet    = null;
            string beginDate = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, ParamFieldLength.BEGINDATE).Trim('\0');
            string endDate   = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD + ParamFieldLength.BEGINDATE, ParamFieldLength.ENDDATE).Trim('\0');

            IList <DailyStatementInDay> dailyStatementList = DailyBalanceService.GetInstance().GetDailyStatementInDays(DateTime.Parse(beginDate), DateTime.Parse(endDate));

            if (dailyStatementList == null || dailyStatementList.Count == 0)
            {
                //获取单子失败
                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);
            }
            else
            {
                //成功
                string json     = JsonConvert.SerializeObject(dailyStatementList);
                byte[] jsonByte = Encoding.UTF8.GetBytes(json);

                int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + jsonByte.Length;
                objRet = new byte[transCount];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
                Array.Copy(jsonByte, 0, objRet, 2 * BasicTypeLength.INT32, jsonByte.Length);
            }
            return(objRet);
        }
Пример #3
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (this.dateTimePicker2.Value > this.dateTimePicker1.Value)
            {
                string beginDate = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
                string endDate   = this.dateTimePicker2.Value.ToString("yyyy-MM-dd");

                IList <DailyStatementInDay> dailyStatementList = DailyBalanceService.GetInstance().GetDailyStatementInDays(beginDate, endDate);
                if (dailyStatementList != null && dailyStatementList.Count > 0)
                {
                    BindChartColumnData(dailyStatementList);
                }
            }
        }
Пример #4
0
        public static byte[] CheckLastDailyStatement(byte[] itemBuffer)
        {
            byte[] objRet    = null;
            int    breakDays = BitConverter.ToInt32(itemBuffer, ParamFieldLength.PACKAGE_HEAD);
            int    result    = DailyBalanceService.GetInstance().CheckLastDailyStatement(breakDays);

            int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + BasicTypeLength.INT32;

            objRet = new byte[transCount];
            Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(result), 0, objRet, 2 * BasicTypeLength.INT32, BasicTypeLength.INT32);
            return(objRet);
        }
Пример #5
0
        public static byte[] GetDailyStatementTimeInterval()
        {
            byte[] objRet       = null;
            string timeInterval = DailyBalanceService.GetInstance().GetDailyStatementTimeInterval();

            byte[] byteArr    = Encoding.UTF8.GetBytes(timeInterval);
            int    transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + byteArr.Length;

            objRet = new byte[transCount];
            Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            Array.Copy(byteArr, 0, objRet, 2 * BasicTypeLength.INT32, byteArr.Length);
            return(objRet);
        }
Пример #6
0
        private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
            dgvDailyStatement.Rows.Clear();
            DateTime selectedDate = e.Start;
            IList <DailyBalanceTime> dailyBalanceTimeList = DailyBalanceService.GetInstance().GetDailyBalanceTime(selectedDate);

            if (dailyBalanceTimeList != null && dailyBalanceTimeList.Count > 0)
            {
                for (int i = 0; i < dailyBalanceTimeList.Count; i++)
                {
                    int index = dgvDailyStatement.Rows.Add(new DataGridViewRow());
                    dgvDailyStatement.Rows[index].Cells["colOrder"].Value            = i + 1;
                    dgvDailyStatement.Rows[index].Cells["colBeginTime"].Value        = dailyBalanceTimeList[i].MinTime > DateTime.MinValue ? dailyBalanceTimeList[i].MinTime.ToString("yyyy-MM-dd") : "";
                    dgvDailyStatement.Rows[index].Cells["colEndTime"].Value          = dailyBalanceTimeList[i].MaxTime > DateTime.MinValue ? dailyBalanceTimeList[i].MaxTime.ToString("yyyy-MM-dd") : "";
                    dgvDailyStatement.Rows[index].Cells["colDailyStatementNo"].Value = dailyBalanceTimeList[i].DailyStatementNo;
                    dgvDailyStatement.Rows[index].Selected = false;
                }
            }
        }
Пример #7
0
        public static byte[] CreateDailyBalance(byte[] itemBuffer)
        {
            byte[]       objRet       = null;
            string       strReceive   = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, itemBuffer.Length - ParamFieldLength.PACKAGE_HEAD).Trim('\0');
            DailyBalance dailyBalance = JsonConvert.DeserializeObject <DailyBalance>(strReceive);

            string unCheckDeviceNo = string.Empty;  //未结账的设备号
            int    result          = DailyBalanceService.GetInstance().CreateDailyBalance(dailyBalance, out unCheckDeviceNo);

            byte[] strBuffer = Encoding.UTF8.GetBytes(unCheckDeviceNo);

            int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + BasicTypeLength.INT32 + ParamFieldLength.UNCHECK_DEVICE_NO;

            objRet = new byte[transCount];
            Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            Array.Copy(BitConverter.GetBytes(result), 0, objRet, 2 * BasicTypeLength.INT32, BasicTypeLength.INT32);
            Array.Copy(strBuffer, 0, objRet, 3 * BasicTypeLength.INT32, strBuffer.Length);
            return(objRet);
        }
Пример #8
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            //判断程序的配置文件
            if (ConstantValuePool.BizSettingConfig == null)
            {
                MessageBox.Show("找不到程序的配置文件!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }
            if (ConstantValuePool.CurrentShop == null)
            {
                MessageBox.Show("获取不到店铺信息,请检查服务器IP配置或者网络是否正确!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }
            string employeeName = this.txtName.Text.Trim();
            string password     = this.txtPassword.Text.Trim();

            if (string.IsNullOrEmpty(employeeName))
            {
                MessageBox.Show("用户名不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(password))
            {
                MessageBox.Show("密码不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Employee employee = null;
            int      result   = EmployeeService.GetInstance().EmployeeLogin(employeeName, password, ref employee);

            if (result == 1)
            {
                bool haveDailyClose = true;
                if (DateTime.Now.Hour > 5)
                {
                    int breakDays = ConstantValuePool.BizSettingConfig.BreakDays;
                    int status    = DailyBalanceService.GetInstance().CheckLastDailyStatement(breakDays);
                    if (status == 0)
                    {
                        MessageBox.Show("获取最后日结时间出错,请重新登录!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (status == 2)    //未日结
                    {
                        haveDailyClose = false;
                        MessageBox.Show("警告,上次未日结,请联系店长处理!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (status == 3)
                        {
                            MessageBox.Show(string.Format("警告,您已经超过{0}天未营业,请联系店长检查营业日期是否正常!", breakDays), "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                //保存静态池内
                ConstantValuePool.CurrentEmployee = employee;
                //获取基础数据
                SysBasicData sysBasicData = SystemBasicDataService.GetInstance().GetSysBasicData();
                if (sysBasicData != null)
                {
                    ConstantValuePool.NoticeList               = sysBasicData.NoticeList;
                    ConstantValuePool.SysConfig                = sysBasicData.SysConfig;
                    ConstantValuePool.RegionList               = sysBasicData.RegionList;
                    ConstantValuePool.DiscountList             = sysBasicData.DiscountList;
                    ConstantValuePool.PayoffWayList            = sysBasicData.PayoffWayList;
                    ConstantValuePool.ReasonList               = sysBasicData.ReasonList;
                    ConstantValuePool.GoodsGroupList           = sysBasicData.GoodsGroupList;
                    ConstantValuePool.DetailsGroupList         = sysBasicData.DetailsGroupList;
                    ConstantValuePool.GoodsSetMealList         = sysBasicData.GoodsSetMealList;
                    ConstantValuePool.GoodsCronTriggerList     = sysBasicData.GoodsCronTriggerList;
                    ConstantValuePool.ButtonStyleList          = sysBasicData.ButtonStyleList;
                    ConstantValuePool.PromotionList            = sysBasicData.PromotionList;
                    ConstantValuePool.PromotionConditionList   = sysBasicData.PromotionConditionList;
                    ConstantValuePool.PromotionCronTriggerList = sysBasicData.PromotionCronTriggerList;
                    ConstantValuePool.PromotionPresentList     = sysBasicData.PromotionPresentList;

                    IList <GoodsLimitedTimeSale> groupLimitedTimeSaleList = new List <GoodsLimitedTimeSale>();
                    IList <GoodsLimitedTimeSale> goodsLimitedTimeSaleList = new List <GoodsLimitedTimeSale>();
                    if (sysBasicData.TotalLimitedTimeSaleList != null && sysBasicData.TotalLimitedTimeSaleList.Count > 0)
                    {
                        foreach (GoodsLimitedTimeSale item in sysBasicData.TotalLimitedTimeSaleList)
                        {
                            if (item.ItemType == 1) //Group
                            {
                                groupLimitedTimeSaleList.Add(item);
                            }
                            if (item.ItemType == 2) //Item
                            {
                                goodsLimitedTimeSaleList.Add(item);
                            }
                        }
                    }
                    ConstantValuePool.GroupLimitedTimeSaleList = groupLimitedTimeSaleList;
                    ConstantValuePool.GoodsLimitedTimeSaleList = goodsLimitedTimeSaleList;

                    IList <GoodsCombinedSale> groupCombinedSaleList = new List <GoodsCombinedSale>();
                    IList <GoodsCombinedSale> goodsCombinedSaleList = new List <GoodsCombinedSale>();
                    if (sysBasicData.TotalCombinedSaleList != null && sysBasicData.TotalCombinedSaleList.Count > 0)
                    {
                        foreach (GoodsCombinedSale item in sysBasicData.TotalCombinedSaleList)
                        {
                            if (item.ItemType == 1) //Group
                            {
                                groupCombinedSaleList.Add(item);
                            }
                            if (item.ItemType == 2) //Item
                            {
                                goodsCombinedSaleList.Add(item);
                            }
                        }
                    }
                    ConstantValuePool.GroupCombinedSaleList = groupCombinedSaleList;
                    ConstantValuePool.GoodsCombinedSaleList = goodsCombinedSaleList;

                    if (ConstantValuePool.BizSettingConfig.SaleType == ShopSaleType.Takeout)
                    {
                        FormTakeout formTakeout = new FormTakeout(haveDailyClose);
                        formTakeout.VisibleShow = true;
                        formTakeout.ShowDialog();
                    }
                    else
                    {
                        FormDesk deskForm = new FormDesk(haveDailyClose);
                        ConstantValuePool.DeskForm = deskForm;
                        txtPassword.Text           = string.Empty;
                        txtPassword.Focus();
                        deskForm.ShowDialog();
                    }
                }
                else
                {
                    _loginCount++;
                    if (_loginCount == MAX_LOGIN_COUNT)
                    {
                        MessageBox.Show("超出登录次数限制,请重新运行系统!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.DialogResult = DialogResult.Cancel;
                    }
                    else
                    {
                        MessageBox.Show("获取的数据为空,请重新操作!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            else if (result == 2)
            {
                _loginCount++;
                if (_loginCount == MAX_LOGIN_COUNT)
                {
                    MessageBox.Show("超出登录次数限制,请重新运行系统!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.Cancel;
                }
                else
                {
                    MessageBox.Show("您输入的用户名或者密码错误,请重新输入!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                _loginCount++;
                if (_loginCount == MAX_LOGIN_COUNT)
                {
                    MessageBox.Show("超出登录次数限制,请重新运行系统!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = DialogResult.Cancel;
                }
                else
                {
                    MessageBox.Show("数据库操作失败,请重新输入!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #9
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);
                        }
                    }
                }
            }
        }