Beispiel #1
0
        public static byte[] GetSysBasicData()
        {
            byte[]       objRet       = null;
            SysBasicData sysBasicData = SysBasicDataService.GetInstance().GetSysBasicData();

            if (sysBasicData == null)
            {
                //数据获取失败
                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(sysBasicData);
                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);
        }
Beispiel #2
0
        public SysBasicData GetSysBasicData()
        {
            int cByte = ParamFieldLength.PACKAGE_HEAD;

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

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

            SysBasicData sysBasicData = null;

            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)
                {
                    string strReceive = Encoding.UTF8.GetString(receiveData, ParamFieldLength.PACKAGE_HEAD, receiveData.Length - ParamFieldLength.PACKAGE_HEAD);
                    sysBasicData = JsonConvert.DeserializeObject <SysBasicData>(strReceive);
                }
                socket.Close();
            }
            return(sysBasicData);
        }
Beispiel #3
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);
                }
            }
        }
Beispiel #4
0
        public SysBasicData GetSysBasicData()
        {
            SysBasicData basicData = null;

            try
            {
                _daoManager.OpenConnection();
                basicData = new SysBasicData();
                // region
                IList <BizRegion> regionList = _regionDao.GetAllBizRegion();
                if (regionList != null && regionList.Count > 0)
                {
                    IList <BizDesk> deskList = _deskDao.GetAllBizDesks();
                    if (deskList != null && deskList.Count > 0)
                    {
                        foreach (BizRegion region in regionList)
                        {
                            IList <BizDesk> desks = deskList.Where(desk => desk.RegionID.Equals(region.RegionID)).ToList();
                            if (desks.Count > 0)
                            {
                                region.BizDeskList = desks;
                            }
                        }
                    }
                }
                // goodsGroup
                IList <GoodsGroup> goodsGroupList = _goodsGroupDao.GetAllGoodsGroup();
                if (goodsGroupList != null && goodsGroupList.Count > 0)
                {
                    foreach (GoodsGroup item in goodsGroupList)
                    {
                        IList <Goods> goodsList = _goodsDao.GetGoodsListInGroup(item.GoodsGroupID);
                        if (goodsList != null && goodsList.Count > 0)
                        {
                            IList <GoodsDetailsGroup> goodsDetailsGroupList = _goodsDao.GetDetailsGroupIdsInGoods();
                            if (goodsDetailsGroupList != null && goodsDetailsGroupList.Count > 0)
                            {
                                foreach (Goods goods in goodsList)
                                {
                                    IList <Guid> detailsGroupIds = goodsDetailsGroupList.Where(detail => detail.GoodsID.Equals(goods.GoodsID)).Select(detail => detail.DetailsGroupID).ToList();
                                    if (detailsGroupIds.Count > 0)
                                    {
                                        goods.DetailsGroupIDList = detailsGroupIds;
                                    }
                                }
                            }
                        }
                        item.GoodsList = goodsList;
                    }
                }
                // detailsGroup
                IList <DetailsGroup> detailsGroupList = _detailsGroupDao.GetAllDetailsGroup();
                if (detailsGroupList != null && detailsGroupList.Count > 0)
                {
                    IList <Details> detailsInfoList = _detailsDao.GetAllDetails();
                    if (detailsInfoList != null && detailsInfoList.Count > 0)
                    {
                        foreach (DetailsGroup item in detailsGroupList)
                        {
                            IList <Details> detailsList = detailsInfoList.Where(detail => detail.DetailsGroupID.Equals(item.DetailsGroupID)).ToList();
                            if (detailsList.Count > 0)
                            {
                                IList <DetailsDetailsGroup> detailsDetailsGroups = _detailsDao.GetDetailsGroupIdsInDetails();
                                if (detailsDetailsGroups != null && detailsDetailsGroups.Count > 0)
                                {
                                    foreach (Details details in detailsList)
                                    {
                                        IList <Guid> detailsGroupIdList = detailsDetailsGroups.Where(ddg => ddg.DetailsID.Equals(details.DetailsID)).Select(ddg => ddg.DetailsGroupID).ToList();
                                        if (detailsGroupIdList.Count > 0)
                                        {
                                            details.DetailsGroupIDList = detailsGroupIdList;
                                        }
                                    }
                                }
                                item.DetailsList = detailsList;
                            }
                        }
                    }
                }
                // SysBasicData
                basicData.NoticeList               = _noticeDao.GetAllNotice();
                basicData.RegionList               = regionList;
                basicData.DiscountList             = _discountDao.GetAllDiscount();
                basicData.PayoffWayList            = _payoffWayDao.GetAllPayoffWay();
                basicData.ReasonList               = _reasonDao.GetAllReason();
                basicData.GoodsGroupList           = goodsGroupList;
                basicData.DetailsGroupList         = detailsGroupList;
                basicData.GoodsSetMealList         = _goodsSetMealDao.GetAllGoodsSetMeal();
                basicData.GoodsCronTriggerList     = _goodsGroupDao.GetAllGoodsCronTrigger();
                basicData.ButtonStyleList          = _buttonStyleDao.GetButtonStyleList();
                basicData.SysConfig                = _sysConfigDao.GetSystemConfigInfo();
                basicData.PromotionList            = _promotionDao.GetPromotionList();
                basicData.PromotionConditionList   = _promotionDao.GetPromotionConditionList();
                basicData.PromotionCronTriggerList = _promotionDao.GetPromotionCronTriggerList();
                basicData.PromotionPresentList     = _promotionDao.GetPromotionPresentList();
                //限时特价
                basicData.TotalLimitedTimeSaleList = _goodsGroupDao.GetAllGoodsLimitedTimeSale();
                //组合销售
                basicData.TotalCombinedSaleList = _goodsGroupDao.GetAllGoodsCombinedSale();
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error("[GetSysBasicData]", exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(basicData);
        }