コード例 #1
0
        /// <summary>
        /// Check if the params of the fb are correct
        /// </summary>
        /// <param name="type_bet">A new TypeFootballBet object, to save the type on it</param>
        /// <param name="typeBet">The name of the bet type</param>
        /// <param name="type_pay">A new TypePay object, to save the type on it</param>
        /// <param name="typePay">The name of the pay type</param>
        /// <returns>True if the types are correct, false otherwise</returns>
        private bool checkParams(ref TypeFootballBet type_bet, string typeBet, ref TypePay type_pay, string typePay)
        {
            try
            {
                var typeB = _context.TypeFootballBet.Where(t => t.name == typeBet);
                var typeP = _context.TypePay.Where(t => t.name == typePay);

                if (typeB.Count() != 1 || typeP.Count() != 1)
                {
                    return(false);
                }
                if (CheckBetType.typeIsWinner(typeB.First()) && CheckBetType.typeIsCloser(typeB.First()))
                {
                    return(false);
                }

                type_bet = typeB.First();
                type_pay = typeP.First();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
        public static List <CountCurrency> Transform(decimal d, TypePay typePay)
        {
            var result = new List <CountCurrency>();

            var currencys = RepositoryCurrency.Currencys.Where(c => c.TypesPayId == typePay.Id).ToList();

            currencys.Sort((x, y) => decimal.Compare(-x.CurrencyMoney, -y.CurrencyMoney));

            foreach (var c in currencys)
            {
                while (d >= 0)
                {
                    d = d - c.CurrencyMoney;

                    if (d >= 0)
                    {
                        result.Add(new CountCurrency(1, c));
                    }
                    else
                    {
                        d = d + c.CurrencyMoney;
                        break;
                    }
                }
            }

            return(result);
        }
コード例 #3
0
ファイル: NameWinRate.cs プロジェクト: jagolu/TFG-API
 /// <summary>
 /// Initializes the object with a pay type
 /// </summary>
 /// <param name="type">The pay type</param>
 public NameWinRate(TypePay type)
 {
     this.id          = type.id.ToString();
     this.name        = type.name;
     this.description = type.description;
     this.winRate     = type.winRate;
     this.cancelRate  = type.winLoseCancel;
 }
コード例 #4
0
        public static decimal GetMoneyFromType(TypePay typePay)
        {
            if (Document != null)
            {
                var elements = Document.GetXElements("MoneySum", "pay").
                               Where(l => l.GetXAttributeValue("typesPayId").ToInt() == typePay.Id).ToList();

                return(elements.Sum(e => e.GetXAttributeValue("money").ToDecimal()));
            }
            return(-0.0001m);
        }
コード例 #5
0
 public static void Pay(TypePay typesPay, decimal money)
 {
     Document.GetXElement("MoneySum").Add(new XElement("pay",
                                                       new XAttribute("typesPayName", typesPay.CheckName),
                                                       new XAttribute("typesPayCodeCompta", typesPay.CodeCompta.HasValue ? typesPay.CodeCompta.Value.ToString() : string.Empty),
                                                       new XAttribute("typesPayEtat", typesPay.Etat.HasValue ? typesPay.Etat.Value.ToString() : string.Empty),
                                                       new XAttribute("typesPayNameCourt", typesPay.NameCourt),
                                                       new XAttribute("typesPayRendu_Avoir", typesPay.RenduAvoir.HasValue ? typesPay.RenduAvoir.Value.ToString() : string.Empty),
                                                       new XAttribute("typesPayTiroir", typesPay.Tiroir.HasValue ? typesPay.Tiroir.Value.ToString() : string.Empty),
                                                       new XAttribute("typesPayCurMod", typesPay.CurMod.HasValue ? typesPay.CurMod.Value.ToString() : string.Empty),
                                                       new XAttribute("typesPayId", typesPay.Id),
                                                       new XAttribute("money", money)));
 }
コード例 #6
0
ファイル: RepositoryTypePay.cs プロジェクト: SokolSib/FRANCE
        private static void LoadFile()
        {
            if (File.Exists(Path))
            {
                var document = XDocument.Load(Path);

                TypePays.Clear();
                foreach (var tp in document.GetXElements("typesPay", "rec"))
                {
                    TypePays.Add(TypePay.FromXElement(tp));
                }
            }
        }
コード例 #7
0
        public static Elm[,] GridCurrencyPathGetPath(TypePay tp)
        {
            Initialize();

            var r = new Elm[12, 12];

            foreach (var elm in GridCurrencyPath)
            {
                if ((elm[0, 0] != null) && (elm[0, 0].Path == AppDomain.CurrentDomain.BaseDirectory + @"\Data\" + tp.Id + ".xml"))
                {
                    r = elm;
                }
            }
            return(r);
        }
コード例 #8
0
        //ClearInfoWares = Escape
        //AddWaresReceipt = Enter

        void PrintReceipt(TypePay parTypePay)
        {
            switch (Global.GetTypeAccess(CodeEvent.PrintReceipt))
            {
            case TypeAccess.NoErrorAccess:
                ErrorAccess(CodeEvent.PrintReceipt);
                break;

            case TypeAccess.Question:

            case TypeAccess.Yes:
                Clear();
                SetView(ModeInterface.PrintReceipt);
                SetViewPay(parTypePay);
                break;
            }
        }
コード例 #9
0
ファイル: W_Pay_Create.xaml.cs プロジェクト: SokolSib/FRANCE
        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            TypePay        = Owner as WTypePay;
            cb.ItemsSource = RepositoryTypePay.TypePays;

            var name = Sub + "_" + xName.Content + "x" + yName.Content;

            B = (Button)(TypePay.FindName(name));

            if (B != null)
            {
                int indx;
                if (int.TryParse(B.ToolTip == null ? "-1" : B.ToolTip.ToString().Replace("TypesPay", ""), out indx))
                {
                    cb.SelectedItem = RepositoryTypePay.GetById(indx);
                }
            }
        }
コード例 #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            TypePay = this.Owner as W_TypePay;

            cb.ItemsSource = ClassSync.TypesPayDB.t;

            string name = sub + "_" + this.xName.Content + "x" + this.yName.Content;

            b = (Button)(TypePay.FindName(name));

            if (b != null)
            {
                int indx = -1;

                if (int.TryParse(b.ToolTip == null ? "-1" : b.ToolTip.ToString().Replace("TypesPay", ""), out indx))
                {
                    cb.SelectedItem = ClassBond.getTypesPayDBFromId(indx);
                }
            }
        }
コード例 #11
0
ファイル: DBInitializer.cs プロジェクト: jagolu/TFG-API
        /// <summary>
        /// Initializes the pay types
        /// </summary>
        /// <param name="context">The database context</param>
        private static void InitializeTypePay(ApplicationDBContext context)
        {
            var types = new TypePay[]
            {
                new TypePay {
                    name        = CheckBetType.getJackpotExact(), winRate = 0, winLoseCancel = 100,
                    description = "Tiene bote. El bote sera para el participante que acierte el resultado exacto. Si nadie acierta el resultado, todos perderán las monedas apostadas."
                },
                new TypePay {
                    name        = CheckBetType.getJackpotCloser(), winRate = 0, winLoseCancel = 100,
                    description = "Tiene bote. El bote será para el participante que se acerque más al resultado exacto."
                },
                new TypePay {
                    name        = CheckBetType.getSoloExact(), winRate = 1.5, winLoseCancel = 0.2,
                    description = "Cada participante participa el solo. Las apuestas tienen una cuota. Si el participante no gana perderá sus monedas."
                },
            };

            types.Where(t => context.TypePay.All(type => type.name != t.name)).ToList().ForEach(tp => context.Add(tp));
        }
コード例 #12
0
ファイル: RepositoryTypePay.cs プロジェクト: SokolSib/FRANCE
        private static void SaveFile()
        {
            XDocument document;

            if (File.Exists(Path))
            {
                document = XDocument.Load(Path);
                document.GetXElement("typesPay").RemoveAll();
            }
            else
            {
                document = new XDocument();
                document.Add(new XElement("typesPay"));
            }

            foreach (var tp in TypePays)
            {
                document.GetXElement("typesPay").Add(TypePay.ToXElement(tp));
            }

            document.Save(Path);
        }
コード例 #13
0
        /// <summary>
        /// Будує вікно оплати в залежності від вибраного методу.
        /// </summary>
        /// <param name="varTypePay"></param>
        /// <param name="varTypeBonus"></param>
        void SetViewPay(TypePay parTypePay = TypePay.Cash, TypeBonus parTypeBonus = TypeBonus.NonBonus)
        {
            System.Drawing.Font varFontBold   = new Font(PrintHotKeyPos.Font, FontStyle.Bold);
            System.Drawing.Font varFontNormal = new Font(PrintHotKeyPos.Font, FontStyle.Regular);


            if ((parTypePay == TypePay.Partiall || parTypePay == TypePay.Pos) && GlobalVar.varModelPos[0] == -1)
            {
                parTypePay = TypePay.Cash;
            }

            // засткова оплата бонусами і здача тільки в готівковому режимі.
            if (parTypePay != TypePay.Cash && (parTypeBonus != TypeBonus.NonBonus || parTypeBonus != TypeBonus.Bonus))
            {
                parTypeBonus = TypeBonus.NonBonus;
            }

            this.varTypePay   = parTypePay;
            this.varTypeBonus = parTypeBonus;


            this.PrintHotKeyPos.Visible      = (GlobalVar.varModelPos[0] >= 0);
            this.PrintHotKeyNonCash.Visible  = true;
            this.PrintHotKeyPartiall.Visible = false;             // Доробити по прававам чи налаштуванням системи.

            this.PrintHotKeyBonus.Visible            = (varWork.varClient.varSumMoneyBonus > 0);
            this.PrintHotKeyBonusWithOutRest.Visible = (varWork.varClient.varSumMoneyBonus > 0) && (varTypePay == TypePay.Cash);
            this.PrintHotKeyBonusFromRest.Visible    = varWork.varClient.varIsUseBonusFromRest && (varTypePay == TypePay.Cash);
            this.PrintHotKeyBonusToRest.Visible      = varWork.varClient.varIsUseBonusToRest && (varTypePay == TypePay.Cash) && (varWork.varClient.varSumMoneyBonus - Math.Truncate(varWork.varClient.varSumMoneyBonus) <= varWork.varReceipt.varSumReceipt);


            // Виділяємо текучий Режим.
            this.PrintHotKeyCash.Font     = (this.varTypePay == TypePay.Cash)      ? varFontBold:varFontNormal;
            this.PrintHotKeyPos.Font      = (this.varTypePay == TypePay.Pos)       ? varFontBold:varFontNormal;
            this.PrintHotKeyNonCash.Font  = (this.varTypePay == TypePay.NonCash)   ? varFontBold:varFontNormal;
            this.PrintHotKeyPartiall.Font = (this.varTypePay == TypePay.Partiall)  ? varFontBold:varFontNormal;


            // Виділяємо текучий режим списання бонусів.
            this.PrintHotKeyBonus.Font            = (this.varTypeBonus == TypeBonus.Bonus)              ? varFontBold:varFontNormal;
            this.PrintHotKeyBonusWithOutRest.Font = (this.varTypeBonus == TypeBonus.BonusWithOutRest)  ? varFontBold:varFontNormal;
            this.PrintHotKeyBonusToRest.Font      = (this.varTypeBonus == TypeBonus.BonusToRest)    ? varFontBold:varFontNormal;
            this.PrintHotKeyBonusFromRest.Font    = (this.varTypeBonus == TypeBonus.BonusFromRest)  ? varFontBold:varFontNormal;
            varWork.ChangeDataTypeBonys(this.varTypeBonus);


            this.LabelBonus.Text      = this.varTypeBonus == TypeBonus.BonusFromRest ? "На бонусний" : "Вик. Бонусів";
            this.PrintPaySum.Value    = varWork.varReceipt.varSumReceipt - varWork.varReceipt.varSumBonus;
            this.PrintUsedBonus.Value = varWork.varReceipt.varSumBonus;

            this.PrintUsedBonus.Enabled = (this.varTypeBonus == TypeBonus.Bonus);

            this.PrintHotKeyPos.Visible      = (GlobalVar.varModelPos[0] >= 0);
            this.PrintHotKeyQuickPOS.Visible = (GlobalVar.varModelPos[1] >= 0);           //Якщо більше 1пос термінала

            this.LabelPos.Visible  = this.PrintPos.Visible = (GlobalVar.varModelPos[0] >= 0);
            this.LabelSlip.Visible = this.PrintSlip.Visible = (GlobalVar.varModelPos[0] >= 0);

            this.LabelCash.Enabled = this.PrintCash.Enabled = (parTypePay == TypePay.Partiall || parTypePay == TypePay.Cash);
            this.LabelPos.Enabled  = this.PrintPos.Enabled = (parTypePay == TypePay.Partiall);
            this.LabelSlip.Enabled = this.PrintSlip.Enabled = (parTypePay == TypePay.Partiall || parTypePay == TypePay.Pos) && GlobalVar.varModelPos[0] >= 0 && !GlobalVar.varIsPosConnect;
            //this.LabelBonus.Enabled = this.PrintToBonus.Enabled = this.PrintUsedBonus.Enabled = (parTypeBonus==TypeBonus.NonBonus && varClient.varSumMoneyBonus>0) ;

            this.LabelRest.Enabled = this.PrintRest.Enabled = false;
            this.LabelRest.Visible = this.PrintRest.Visible = (parTypePay == TypePay.Partiall || parTypePay == TypePay.Cash);

//			RecalcPrintSum();
            if (parTypePay == TypePay.Cash || parTypePay == TypePay.Partiall)
            {
                this.PrintCash.Focus();
            }
            else if (parTypePay == TypePay.Pos)
            {
                if (GlobalVar.varModelPos[0] >= 0 && GlobalVar.varIsPosConnect)
                {
                    this.ButtonPrintReceipt.Focus();
                }
                else
                {
                    this.PrintSlip.Focus();
                }
            }
        }
コード例 #14
0
 public static void ClearCurrency(TypePay typePay)
 {
     Currencys.RemoveAll(c => c.TypesPayId == typePay.Id);
     CountCurencys.Clear();
 }
コード例 #15
0
        public static void SetDefoultTypesPays()
        {
            var culture = Thread.CurrentThread.CurrentCulture;

            var payCash       = new TypePay(1, true, Resources.TypePayCash, "Cash", 450600, true, true, true);
            var payBankCards  = new TypePay(2, true, Resources.TypePayBankCards, "BankCards", 450601, false, true, false);
            var payBankChecks = new TypePay(3, true, Resources.TypePayBankChecks, "BankChecks", 450602, false, true,
                                            false);
            var payResto     = new TypePay(4, true, Resources.TypePayResto, "Resto", 450603, false, true, false);
            var payBondAchat = new TypePay(5, true, Resources.TypePayBondAchat, "BondAchat", 450604, false, true, false);

            var payCashRep       = RepositoryTypePay.TypePays.FirstOrDefault(tp => tp.NameCourt == payCash.NameCourt);
            var payBankCardsRep  = RepositoryTypePay.TypePays.FirstOrDefault(tp => tp.NameCourt == payBankCards.NameCourt);
            var payBankChecksRep =
                RepositoryTypePay.TypePays.FirstOrDefault(tp => tp.NameCourt == payBankChecks.NameCourt);
            var payRestoRep     = RepositoryTypePay.TypePays.FirstOrDefault(tp => tp.NameCourt == payResto.NameCourt);
            var payBondAchatRep = RepositoryTypePay.TypePays.FirstOrDefault(tp => tp.NameCourt == payBondAchat.NameCourt);

            if (payCashRep == null)
            {
                RepositoryTypePay.TypePays.Add(payCash);
            }
            else
            {
                payCashRep.Name = payCash.Name;
            }

            if (payBankCardsRep == null)
            {
                RepositoryTypePay.TypePays.Add(payBankCards);
            }
            else
            {
                payBankCardsRep.Name = payBankCards.Name;
            }

            if (payBankChecksRep == null)
            {
                RepositoryTypePay.TypePays.Add(payBankChecks);
            }
            else
            {
                payBankChecksRep.Name = payBankChecks.Name;
            }

            if (payRestoRep == null)
            {
                RepositoryTypePay.TypePays.Add(payResto);
            }
            else
            {
                payRestoRep.Name = payResto.Name;
            }

            if (payBondAchatRep == null)
            {
                RepositoryTypePay.TypePays.Add(payBondAchat);
            }
            else
            {
                payBondAchatRep.Name = payBondAchat.Name;
            }

            var checkCulture = new CultureInfo("fr-FR");

            Thread.CurrentThread.CurrentCulture   = checkCulture;
            Thread.CurrentThread.CurrentUICulture = checkCulture;
            Resources.Culture = checkCulture;

            payCashRep       = RepositoryTypePay.TypePays.First(tp => tp.NameCourt == payCash.NameCourt);
            payBankCardsRep  = RepositoryTypePay.TypePays.First(tp => tp.NameCourt == payBankCards.NameCourt);
            payBankChecksRep = RepositoryTypePay.TypePays.First(tp => tp.NameCourt == payBankChecks.NameCourt);
            payRestoRep      = RepositoryTypePay.TypePays.First(tp => tp.NameCourt == payResto.NameCourt);
            payBondAchatRep  = RepositoryTypePay.TypePays.First(tp => tp.NameCourt == payBondAchat.NameCourt);

            payCashRep.CheckName       = Resources.TypePayCash;
            payBankCardsRep.CheckName  = Resources.TypePayBankCards;
            payBankChecksRep.CheckName = Resources.TypePayBankChecks;
            payRestoRep.CheckName      = Resources.TypePayResto;
            payBondAchatRep.CheckName  = Resources.TypePayBondAchat;

            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            Resources.Culture = culture;
        }
コード例 #16
0
        /// <summary>
        /// Launchs a new fb
        /// </summary>
        /// <param name="order">The info to launch a new fb</param>
        /// See <see cref="Areas.Bet.Models.LaunchFootballBet"/> to know the param structure
        /// <returns>IActionResult of the launch fb action</returns>
        /// See <see cref="Areas.GroupManage.Models.GroupPage"/> to know the response structure
        public IActionResult launchBet([FromBody] LaunchFootballBet order)
        {
            User caller = TokenUserManager.getUserFromToken(HttpContext, _context);

            if (!caller.open)
            {
                return(BadRequest(new { error = "YoureBanned" }));
            }
            if (AdminPolicy.isAdmin(caller, _context))
            {
                return(BadRequest("notAllowed"));
            }
            Group           group   = new Group();
            MatchDay        match   = new MatchDay();
            TypeFootballBet typeBet = new TypeFootballBet();
            TypePay         typePay = new TypePay();

            if (!GroupMakerFuncionlities.checkFuncionality(caller, ref group, order.groupName, GroupMakerFuncionality.STARTCREATE_FOOTBALL_BET, _context))
            {
                return(BadRequest());
            }
            if (!getMatchDay(ref match, order.matchday))
            {
                return(BadRequest());
            }
            if (!checkMaxBetAllowed(group))
            {
                return(BadRequest());
            }
            if (!checkParams(ref typeBet, order.typeBet, ref typePay, order.typePay))
            {
                return(BadRequest());
            }
            if (order.lastBetTime > match.date)
            {
                return(BadRequest());
            }
            if (!checkMaxMin(order.minBet, order.maxBet))
            {
                return(BadRequest());
            }
            try
            {
                FootballBet fb = new FootballBet
                {
                    MatchDay    = match,
                    Group       = group,
                    type        = typeBet,
                    typePay     = typePay,
                    minBet      = order.minBet,
                    maxBet      = order.maxBet,
                    winRate     = typeBet.winRate + typePay.winRate,
                    dateLastBet = order.lastBetTime,
                    dateEnded   = match.date
                };
                _context.Add(fb);
                _context.SaveChanges();

                launchNews(caller, group, fb);

                return(Ok(GroupPageManager.GetPage(caller, group, _context)));
            }
            catch (Exception)
            {
                return(StatusCode(500));
            }
        }
コード例 #17
0
ファイル: PrintTypePay.cs プロジェクト: SokolSib/FRANCE
 public PrintTypePay(TypePay type, decimal money)
 {
     Type  = type;
     Money = money;
 }
コード例 #18
0
ファイル: NET_MainForm.cs プロジェクト: OlehR/UniCS.TM
        //ClearInfoWares = Escape
        //AddWaresReceipt = Enter

        void PrintReceipt(TypePay parTypePay)
        {
            Clear();
            SwitchMainPrint(false);
            SetViewPay(parTypePay);
        }