コード例 #1
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);
                }
            }
        }
コード例 #2
0
ファイル: FormLogin.cs プロジェクト: hpbaotho/top4ever-pos
        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);
                }
            }
        }