public void Save(object sender, EventArgs e)
        {
            try
            {
                string dpPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3");
                var    db     = new SQLiteConnection(dpPath);
                db.CreateTable <PitsTable>();
                PitsTable pits = new PitsTable();

                int number = Int32.Parse(teamNumber.Text);
                pits.Team = number;

                pits.RobotWeight = robotWeight.Text;

                if (mech.Checked)
                {
                    pits.Drivetrain = "Mechanum";
                }
                else if (holo.Checked)
                {
                    pits.Drivetrain = "Holonomic";
                }
                else if (tank.Checked)
                {
                    pits.Drivetrain = "Tank";
                }
                else if (swerve.Checked)
                {
                    pits.Drivetrain = "Swerve";
                }
                else if (slide.Checked)
                {
                    pits.Drivetrain = "Slide";
                }
                else
                {
                    Toast.MakeText(this, "Please Select a Drivetrain", ToastLength.Long).Show();
                }

                string dimensions = (dLength.Text + "x" + dWidth.Text + "x" + dHeight.Text);
                pits.Dimensions = dimensions;

                pits.Auto = autoS.Text;

                if (e1.Checked)
                {
                    pits.Electronics = "1";
                }
                else if (e2.Checked)
                {
                    pits.Electronics = "2";
                }
                else if (e3.Checked)
                {
                    pits.Electronics = "3";
                }
                else if (e4.Checked)
                {
                    pits.Electronics = "4";
                }
                else if (e5.Checked)
                {
                    pits.Electronics = "5";
                }
                else
                {
                    Toast.MakeText(this, "Please Select an Electronics Grade", ToastLength.Long).Show();
                }

                if (d1.Checked)
                {
                    pits.Chassis = "1";
                }
                else if (d2.Checked)
                {
                    pits.Chassis = "2";
                }
                else if (d3.Checked)
                {
                    pits.Chassis = "3";
                }
                else if (d4.Checked)
                {
                    pits.Chassis = "4";
                }
                else if (d5.Checked)
                {
                    pits.Chassis = "5";
                }
                else
                {
                    Toast.MakeText(this, "Please Select a Chassis Grade", ToastLength.Long).Show();
                }

                if (q1.Checked)
                {
                    pits.Build = "1";
                }
                else if (q2.Checked)
                {
                    pits.Build = "2";
                }
                else if (q3.Checked)
                {
                    pits.Build = "3";
                }
                else if (q4.Checked)
                {
                    pits.Build = "4";
                }
                else if (q5.Checked)
                {
                    pits.Build = "5";
                }
                else
                {
                    Toast.MakeText(this, "Please Select an Overall Build Grade", ToastLength.Long).Show();
                }

                if (sy.Checked)
                {
                    pits.Spinner = "Yes";
                }
                else if (sn.Checked)
                {
                    pits.Spinner = "No";
                }
                else
                {
                    Toast.MakeText(this, "Select if Spinner Can Be Used", ToastLength.Long).Show();
                }

                if (cy.Checked)
                {
                    pits.Cameras = "Yes";
                }
                else if (cn.Checked)
                {
                    pits.Cameras = "No";
                }
                else
                {
                    Toast.MakeText(this, "Select if Robot has Driver Cameras", ToastLength.Long).Show();
                }

                if (cLy.Checked)
                {
                    pits.Climb = "Yes";
                }
                else if (cLn.Checked)
                {
                    pits.Climb = "No";
                }
                else
                {
                    Toast.MakeText(this, "Select if Robot Can Climb", ToastLength.Long).Show();
                }

                pits.Notes = notes.Text;

                db.Insert(pits);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
            }
        }
Пример #2
0
        public void ShowClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            try
            {
                string dpPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ScoutingApp.db3");
                var    db     = new SQLiteConnection(dpPath);
                db.CreateTable <PitsTable>();
                PitsTable        pits = new PitsTable();
                List <PitsTable> pts  = new List <PitsTable>();

                string tnd = ad.GetItem(e.Position);
                SetContentView(Resource.Layout.team_display);
                var tn             = FindViewById <TextView>(Resource.Id.textViewtd1);
                var txtWeight      = FindViewById <TextView>(Resource.Id.txtView_Weight);
                var txtDrive       = FindViewById <TextView>(Resource.Id.txtView_Drive);
                var txtDimensions  = FindViewById <TextView>(Resource.Id.txtView_DimensionsL);
                var txtAuto        = FindViewById <TextView>(Resource.Id.txtView_Auto);
                var txtBuild       = FindViewById <TextView>(Resource.Id.txtView_Build);
                var txtElectronics = FindViewById <TextView>(Resource.Id.txtView_Electronics);
                var txtChassis     = FindViewById <TextView>(Resource.Id.Chassis);
                var txtSpinner     = FindViewById <TextView>(Resource.Id.txtView_Spinner);
                var txtCameras     = FindViewById <TextView>(Resource.Id.txtView_Cameras);
                var txtClimb       = FindViewById <TextView>(Resource.Id.txtView_Climb);
                var txtNotes       = FindViewById <TextView>(Resource.Id.txtView_Notes);

                var    pt    = new PitsTable();
                string teams = pits.Team.ToString();
                tn.Text = tnd;
                int num = Int32.Parse(tnd);
                // var query = "FROM p in pts WHERE p.Team.ToString() == tnd.ToString() SELECT p.Team";
                var query  = db.Query <PitsTable>("SELECT * FROM PitsTable WHERE Team ==" + num);
                var queryP = db.Query <ImageTable>("SELECT * FROM ImageTable WHERE Team ==" + num);
                // db.Execute(query);
                foreach (var p in queryP)
                {
                    var          gridview1 = FindViewById <GridView>(Resource.Id.gridViewtd1);
                    ImageAdapter adap      = new ImageAdapter(this, queryP);
                    gridview1.Adapter    = adap;
                    gridview1.ItemClick += delegate
                    {
                        SetContentView(Resource.Layout.image_expand);
                        ImageView expandable        = FindViewById <ImageView>(Resource.Id.ImageViewE);
                        Android.Graphics.Bitmap bmp = BitmapFactory.DecodeByteArray(p.Image, 0, p.Image.Length);
                        expandable.SetImageBitmap(bmp);
                    };
                }

                // Toast.MakeText(this, query.ToString(), ToastLength.Long).Show();
                foreach (var t in query)
                {
                    txtWeight.Text      = "Weight: " + t.RobotWeight;
                    txtDrive.Text       = "Drivetrain: " + t.Drivetrain;
                    txtDimensions.Text  = "Dimensions: " + t.Dimensions;
                    txtAuto.Text        = "Auto Strategy: " + t.Auto;
                    txtBuild.Text       = "Build Quality: " + t.Build;
                    txtElectronics.Text = "Electronics Reliability: " + t.Electronics;
                    txtChassis.Text     = "Chassis Durability: " + t.Chassis;
                    txtSpinner.Text     = "Spinner: " + t.Spinner;
                    txtCameras.Text     = "Driver Cameras: " + t.Cameras;
                    txtClimb.Text       = "Climb: " + t.Climb;
                    txtNotes.Text       = "Notes: " + t.Notes;
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show();
            }
        }