Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            View     view     = inflater.Inflate(Resource.Layout.AddBet, null);
            EditText teamName = view.FindViewById <EditText>(Resource.Id.teamName);
            EditText firstBet = view.FindViewById <EditText>(Resource.Id.firstBet);
            EditText betType  = view.FindViewById <EditText>(Resource.Id.betType);
            Button   saveBet  = view.FindViewById <Button>(Resource.Id.addBetBtn);

            firstBet.FixDigits();


            saveBet.Click += delegate
            {
                if (teamName.Text != string.Empty && firstBet.Text != string.Empty &&
                    betType.Text != string.Empty)
                {
                    Team t = new Team();
                    t.Name        = teamName.Text;
                    t.Bet         = betType.Text;
                    t.Id          = Guid.NewGuid();
                    t.Status      = false;
                    t.Win         = 0;
                    t.BetProvider = ApplicationState.ActiveProvider;


                    if (AWSDataAccess.InsertTeam(t) != Guid.Empty)
                    {
                        BetDetails betDetails = new BetDetails();
                        betDetails.Id       = Guid.NewGuid();
                        betDetails.Quantity = Convert.ToDecimal(firstBet.Text);
                        betDetails.Team_Id  = t.Id;
                        if (AWSDataAccess.InsertBetDetails(betDetails) != Guid.Empty)
                        {
                            Toast.MakeText(Activity, "Bet added", ToastLength.Long).Show();
                            FragmentTransaction ft = FragmentManager.BeginTransaction();
                            ft.Replace(Resource.Id.frameLayout1, new HomeFragment());
                            ft.Commit();
                        }
                        else
                        {
                            Toast.MakeText(Activity, "Error in bet saving", ToastLength.Long).Show();
                        }
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Error in bet saving", ToastLength.Long).Show();
                    }
                }
            };



            return(view);
            //return base.OnCreateView(inflater, container, savedInstanceState);
        }
Esempio n. 2
0
        public static bool DeleteBetDetail(BetDetails betDetail)
        {
            //OUTPUT Inserted.Id
            string sqlQuery = "DELETE from BetDetails Where ID= @id AND quantity=@quantity "
                              + "AND team_id=@teamId;";
            bool result = false;

            using (SqlCommand cmd = new SqlCommand(sqlQuery))
            {
                cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value     = betDetail.Id;
                cmd.Parameters.Add("@quantity", SqlDbType.Decimal).Value        = betDetail.Quantity;
                cmd.Parameters.Add("@teamId", SqlDbType.UniqueIdentifier).Value = betDetail.Team_Id;
                result = Delete(cmd);
            }

            return(result);
        }
Esempio n. 3
0
        public static List <BetDetails> GetBetDetailsByTeamId(Guid teamId)
        {
            List <BetDetails> betDetails = new List <BetDetails>();

            string sqlQuery = "Select * from betdetails where team_id = @teamId " +
                              "order by date, quantity";


            using (SqlCommand cmd = new SqlCommand(sqlQuery))
            {
                cmd.Parameters.Add("@teamId", SqlDbType.UniqueIdentifier).Value = teamId;
                //String.Format("Select * from betdetails where team_id = '{0}' " +
                //"order by date, quantity", teamId.ToString())

                using (SqlConnection connection = new SqlConnection(Initialize().ConnectionString))
                {
                    connection.Open();
                    cmd.Connection = connection;
                    //Select(cmd)
                    using (SqlDataReader dataReader = cmd.ExecuteReader())
                    {
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                BetDetails d = new BetDetails();
                                d.Id       = new Guid(dataReader["Id"].ToString());
                                d.Quantity = Convert.ToDecimal(dataReader["Quantity"]);
                                d.Team_Id  = new Guid(dataReader["Team_Id"].ToString());
                                betDetails.Add(d);
                            }
                        }
                        dataReader.Close();
                    }
                    connection.Close();
                }
            }



            return(betDetails);
        }
Esempio n. 4
0
        public static Guid InsertBetDetails(BetDetails details)
        {
            //String.Format(  '{0}', '{1}', '{2}', GETDATE() , details.Id, details.Quantity, details.Team_Id
            string sqlQuery = "Insert into BetDetails (Id,Quantity,Team_Id,Date) OUTPUT Inserted.Id "
                              + "Values (@id, @quantity, @team_id, @date);";

            Guid result = Guid.Empty;

            using (SqlCommand cmd = new SqlCommand(sqlQuery))
            {
                cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value      = details.Id;
                cmd.Parameters.Add("@quantity", SqlDbType.Decimal).Value         = details.Quantity;
                cmd.Parameters.Add("@team_id", SqlDbType.UniqueIdentifier).Value = details.Team_Id;
                cmd.Parameters.Add("@date", SqlDbType.DateTime).Value            = DateTime.Now;
                //cmd.Connection= new SqlConnection(Initialize().ConnectionString);
                result = Insert(cmd);
            }
            //Guid result = Insert(sqlQuery);
            return(result);
        }
Esempio n. 5
0
        public static Guid UpdateBetTeamDetail(BetDetails betTeamDetail)
        {
            string sqlQuery = "Update BetDetails SET ID = @id, Quantity=@quantity,team_id=@teamId"
                              + ",date=@date OUTPUT Inserted.Id "
                              + "Where ID=@id ; ";
            Guid result = Guid.Empty;

            using (SqlCommand cmd = new SqlCommand(sqlQuery))
            {
                cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier).Value     = betTeamDetail.Id;
                cmd.Parameters.Add("@quantity", SqlDbType.Decimal).Value        = betTeamDetail.Quantity;
                cmd.Parameters.Add("@teamId", SqlDbType.UniqueIdentifier).Value = betTeamDetail.Team_Id;
                cmd.Parameters.Add("@date", SqlDbType.DateTime).Value           = DateTime.Now;
                //cmd.Parameters.Add("@bet", SqlDbType.NChar).Value = t.Bet;
                //SqlParameter win = new SqlParameter("@win",SqlDbType.Money);
                //win.Va


                //cmd.Connection= new SqlConnection(Initialize().ConnectionString);
                result = Insert(cmd);
            }

            return(result);
        }
Esempio n. 6
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            View view = inflater.Inflate(Resource.Layout.CalculateBet, null);

            List <BetDetails> betDetails = AWSDataAccess.GetBetDetailsByTeamId(TeamId);
            string            history    = string.Empty;

            foreach (var item in betDetails)
            {
                int temp = (int)item.Quantity;
                history += temp + ",";
            }

            history = history.Substring(0, history.LastIndexOf(','));

            view.FindViewById <EditText>(Resource.Id.History).Text = history;

            view.FindViewById <EditText>(Resource.Id.Quote).FixDigits();
            Button   calculateBtn = view.FindViewById <Button>(Resource.Id.Calculate);
            EditText historyTxt   = view.FindViewById <EditText>(Resource.Id.History);
            EditText quote        = view.FindViewById <EditText>(Resource.Id.Quote);
            EditText nextbet      = view.FindViewById <EditText>(Resource.Id.NextBet);
            EditText profit       = view.FindViewById <EditText>(Resource.Id.Profit);
            EditText offset       = view.FindViewById <EditText>(Resource.Id.Offset);
            Button   saveBetBtn   = view.FindViewById <Button>(Resource.Id.SaveBet);


            saveBetBtn.Click += delegate
            {
                if (nextbet.Text != String.Empty)
                {
                    BetDetails newBet = new BetDetails()
                    {
                        Id       = Guid.NewGuid(),
                        Quantity = Decimal.Parse(nextbet.Text),
                        Team_Id  = TeamId
                    };

                    if (AWSDataAccess.InsertBetDetails(newBet) != Guid.Empty)
                    {
                        Toast.MakeText(Activity, "Bet saved", ToastLength.Long).Show();
                        FragmentTransaction ft = FragmentManager.BeginTransaction();
                        ft.Replace(Resource.Id.frameLayout1, new ActiveBetFragment());
                        ft.Commit();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Error in bet saving", ToastLength.Long).Show();
                    }
                }
                else
                {
                    return;
                }
            };

            calculateBtn.Click += delegate
            {
                InputMethodManager inputManager = (InputMethodManager)Activity.GetSystemService(Context.InputMethodService);

                //inputManager.HideSoftInputFromWindow(Activity.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways);
                if (Activity.CurrentFocus != null)
                {
                    inputManager.HideSoftInputFromWindow(Activity.CurrentFocus.WindowToken, HideSoftInputFlags.NotAlways);
                }

                //&& offset.Text != string.Empty
                if (historyTxt.Text != string.Empty && quote.Text != string.Empty)
                {
                    BettingPerding result = new BettingPerding();

                    int offsetVal = 0;
                    if (offset.Text != string.Empty)
                    {
                        Int32.Parse(offset.Text);
                    }

                    result = BetCalculator.Calculate(historyTxt.Text,
                                                     Double.Parse(quote.Text), 0, offsetVal);

                    //nextbet.SetText(ciccio.ToString(),TextView.BufferType.Normal);
                    profit.Text  = "" + result.Profit;
                    nextbet.Text = "" + result.NextBet;
                }
                else
                {
                    quote.Error = "Requested";
                    //offset.Error = "Requested";
                }
            };

            nextbet.TextChanged += delegate
            {
                //&& offset.Text != string.Empty

                if (historyTxt.Text != string.Empty && quote.Text != string.Empty)
                {
                    BettingPerding result      = new BettingPerding();
                    int            offsetValue = 0;
                    if (offset.Text != string.Empty)
                    {
                        offsetValue = Int32.Parse(offset.Text);
                    }

                    double next = 0;
                    if (!String.IsNullOrEmpty(nextbet.Text))
                    {
                        next = Double.Parse(nextbet.Text);
                    }
                    result = BetCalculator.Calculate(historyTxt.Text,
                                                     Double.Parse(quote.Text), next, offsetValue);


                    profit.Text = "" + result.Profit;
                }
            };

            return(view);
        }
Esempio n. 7
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            View view = inflater.Inflate(Resource.Layout.ModifyBet, container, false);

            //Button saveMod = view.FindViewById<Button>(Resource.Id.modSave);
            //Button deleteMod = view.FindViewById<Button>(Resource.Id.modDelete);
            //Button deleteAllMod = view.FindViewById<Button>(Resource.Id.modDeleteAll);


            this.progressDialog = ProgressDialog.Show(Activity, "", "Loading bet", true);
            progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);

            progressDialog.Show();


            this.lastBet = view.FindViewById <EditText>(Resource.Id.modLastBet);
            this.betType = view.FindViewById <EditText>(Resource.Id.modBetType);
            lastBet.FixDigits();
            Spinner betTeamsSpinner = view.FindViewById <Spinner>(Resource.Id.modTeamName);



            Thread mainThread = new Thread(new ThreadStart(delegate
            {
                //List<Team> activeBetTeams = new List<Team>();

                activeBetTeams = AWSDataAccess.GetBetTeam(0);

                Activity.RunOnUiThread(() => { betTeamsSpinner.Adapter =
                                                   new SpinnerTeamAdapter(Activity, activeBetTeams); });

                //if (activeBetTeams.Count > 0)
                //{
                //    List<BetDetails> betDetails = AWSDataAccess.GetBetDetailsByTeamId(
                //        activeBetTeams[0].Id);
                //    if (betDetails.Count > 0)
                //    {
                //        Activity.RunOnUiThread(() =>
                //        {
                //            lastBet.Text = AWSDataAccess.DoFormat(betDetails
                //                [betDetails.Count - 1].Quantity);
                //        });

                //        Activity.RunOnUiThread(() => { betType.Text = activeBetTeams[0].Bet; });
                //    }
                //}

                //});

                //betList.AddHeaderView(header, null, false);
                //betList.Adapter = new TeamListAdapter(Activity, this.teams);
                //betList.ItemClick += ActiveBetFragment_ItemClick;

                Thread.Sleep(10);
                progressDialog.Dismiss();
                running = 0;
            }));

            mainThread.Name = "ModifyMain";
            mainThread.Start();


            #region Button click

            //saveMod.Click += delegate
            //{
            //    if (lastBet.Text != string.Empty)
            //    {
            //        BetDetails modifiedTeamDetail = new BetDetails()
            //        {
            //            Id = betDetails[betDetails.Count - 1].Id,
            //            Quantity = Decimal.Parse(lastBet.Text),
            //            Team_Id = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
            //        };
            //        if (AWSDataAccess.UpdateBetTeamDetail(modifiedTeamDetail)!=Guid.Empty)
            //        {
            //            Toast.MakeText(Activity, "Bet updated", ToastLength.Long).Show();
            //            BackHome();
            //        }
            //        else
            //        {
            //            Toast.MakeText(Activity, "Error in bet updating", ToastLength.Long).Show();
            //        }
            //    }
            //    else
            //    {
            //        lastBet.Error = "Required!";
            //    }


            //};

            //deleteMod.Click += delegate
            // {
            //     if (lastBet.Text != string.Empty)
            //     {
            //         BetDetails modifiedTeamDetail = new BetDetails()
            //         {
            //             Id = betDetails[betDetails.Count - 1].Id,
            //             Quantity = Decimal.Parse(lastBet.Text),
            //             Team_Id = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
            //         };
            //         if (AWSDataAccess.DeleteBetDetail(modifiedTeamDetail))
            //         {
            //             Toast.MakeText(Activity, "Bet deleted", ToastLength.Long).Show();
            //             BackHome();
            //         }
            //         else
            //         {
            //             Toast.MakeText(Activity, "Error in bet deleting", ToastLength.Long).Show();
            //         }
            //     }
            //     else
            //     {
            //         lastBet.Error = "Required!";
            //     }
            // };

            //deleteAllMod.Click += delegate
            //{
            //    Team t = new Team()
            //    {
            //        Id = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
            //    };

            //    if (AWSDataAccess.DeleteAllBetTeam(t))
            //    {
            //        Toast.MakeText(Activity, "All team bet deleted", ToastLength.Long).Show();
            //        BackHome();
            //    }
            //    else
            //    {
            //        Toast.MakeText(Activity, "Error in team bet deleting", ToastLength.Long).Show();
            //    }
            //};

            #endregion

            var editToolbar = view.FindViewById <Toolbar>(Resource.Id.modifyBetToolbar);
            //editToolbar.Title = "Editing";
            editToolbar.InflateMenu(Resource.Menu.modifyBet_menus);
            //Spinner betProviders= editToolbar.FindViewById<Spinner>(Resource.Id.providerSpinnerToolbar);
            //var providers = new List<BetProvider>() { BetProvider.PaddyPower, BetProvider.Bet365 };
            //betProviders.Adapter = new ArrayAdapter<BetProvider>(Activity,
            //    Android.Resource.Layout.SimpleDropDownItem1Line, providers);

            //betProviders.ItemSelected += delegate
            //{
            //    ApplicationState.ActiveProvider = providers[betProviders.SelectedItemPosition];

            //};

            //Spinner providerSpinner = (Spinner) editToolbar.FindViewById<Resource.Id.sp
            editToolbar.MenuItemClick += (sender, e) =>
            {
                switch (e.Item.ItemId)
                {
                case Resource.Id.menu_save:
                    if (lastBet.Text != string.Empty)
                    {
                        BetDetails modifiedTeamDetail = new BetDetails()
                        {
                            Id       = betDetails[betDetails.Count - 1].Id,
                            Quantity = Decimal.Parse(lastBet.Text),
                            Team_Id  = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
                        };
                        if (AWSDataAccess.UpdateBetTeamDetail(modifiedTeamDetail) != Guid.Empty)
                        {
                            Toast.MakeText(Activity, "Bet updated", ToastLength.Long).Show();
                            BackHome();
                        }
                        else
                        {
                            Toast.MakeText(Activity, "Error in bet updating", ToastLength.Long).Show();
                        }
                    }
                    else
                    {
                        lastBet.Error = "Required!";
                    }
                    break;

                case Resource.Id.menu_delete:
                    if (lastBet.Text != string.Empty)
                    {
                        BetDetails modifiedTeamDetail = new BetDetails()
                        {
                            Id       = betDetails[betDetails.Count - 1].Id,
                            Quantity = Decimal.Parse(lastBet.Text),
                            Team_Id  = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
                        };
                        if (AWSDataAccess.DeleteBetDetail(modifiedTeamDetail))
                        {
                            Toast.MakeText(Activity, "Bet deleted", ToastLength.Long).Show();
                            BackHome();
                        }
                        else
                        {
                            Toast.MakeText(Activity, "Error in bet deleting", ToastLength.Long).Show();
                        }
                    }
                    else
                    {
                        lastBet.Error = "Required!";
                    }

                    break;

                case Resource.Id.menu_deleteAll:
                    Team t = new Team()
                    {
                        Id = activeBetTeams[betTeamsSpinner.SelectedItemPosition].Id,
                    };

                    if (AWSDataAccess.DeleteAllBetTeam(t))
                    {
                        Toast.MakeText(Activity, "All team bet deleted", ToastLength.Long).Show();
                        BackHome();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Error in team bet deleting", ToastLength.Long).Show();
                    }
                    break;

                default:
                    break;
                }
            };

            betTeamsSpinner.ItemSelected += BetTeamsSpinner_ItemSelected;



            return(view);
        }