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); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment Dialog.SetTitle("You Win!!!"); View view = inflater.Inflate(Resource.Layout.CloseBetDialog, container, false); EditText win = view.FindViewById <EditText>(Resource.Id.win); win.FixDigits(); Button saveWin = view.FindViewById <Button>(Resource.Id.saveWin); //Button closeWin = view.FindViewById<Button>(Resource.Id.cancelWin); Spinner activeBetTeamsSpinner = view.FindViewById <Spinner>(Resource.Id.activeTeamsSpinner); activeBetTeams = AWSDataAccess.GetBetTeam(0); SpinnerTeamAdapter cba = new SpinnerTeamAdapter(Activity, activeBetTeams); activeBetTeamsSpinner.Adapter = cba; //activeBetTeamsSpinner.ItemSelected += ActiveBetTeamsSpinner_ItemSelected; saveWin.Click += delegate { if (win.Text != string.Empty) { //salvataggio e chiusura dialog SelectedTeam = activeBetTeams[activeBetTeamsSpinner.SelectedItemPosition]; SelectedTeam.Win = Convert.ToDecimal(win.Text); SelectedTeam.Status = true; if (AWSDataAccess.UpdateCloseWin(SelectedTeam) != Guid.Empty) { Toast.MakeText(Activity, "Win saved", ToastLength.Long).Show(); //FragmentTransaction ft = FragmentManager.BeginTransaction(); //ft.Replace(Resource.Id.frameLayout1, new HomeFragment()); //ft.Commit(); this.Dismiss(); } else { Toast.MakeText(Activity, "Error in bet saving", ToastLength.Long).Show(); } } }; //closeWin.Click += delegate //{ // this.Dismiss(); //}; return(view); }
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); }