Пример #1
0
 async void EditButtonClicked(object sender, EventArgs args)
 {
     if (editMode)
     {
         // show the hidden buttons
         EditButton.Text = "Edit Info";
         if (sow.Status == "READY_TO_BREED")
         {
             BreedButton.IsVisible = true;
         }
         if (sow.Status == "DUE")
         {
             FarrowButton.IsVisible = true;
         }
         if (sow.Status == "PENDING_ULTRASOUND")
         {
             UltrasoundButton.IsVisible = true;
         }
         RemoveButton.IsVisible = true;
         // disable the inputs
         KnickName.IsReadOnly      = true;
         SowFarrowedDate.IsEnabled = false;
         SowBredDate.IsEnabled     = false;
         SowDueDate.IsEnabled      = false;
         // save changed data
         sow.KnickName    = KnickName.Text;
         sow.FarrowedDate = SowFarrowedDate.Date;
         sow.BredDate     = SowBredDate.Date;
         sow.DueDate      = SowDueDate.Date;
         sow.Status       = "";
         // determine what the status is after the dates have been modified
         sow.DetermineStatus();
         using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
         {
             conn.Update(sow);
         }
     }
     else
     {
         // hide the buttons
         EditButton.Text            = "Save";
         BreedButton.IsVisible      = false;
         FarrowButton.IsVisible     = false;
         UltrasoundButton.IsVisible = false;
         RemoveButton.IsVisible     = false;
         // enable the inputs
         KnickName.IsReadOnly      = false;
         SowFarrowedDate.IsEnabled = true;
         SowBredDate.IsEnabled     = true;
         SowDueDate.IsEnabled      = true;
     }
     // toggle Edit Mode
     editMode = !editMode;
 }
Пример #2
0
        // Add Sow Button, adds a new sow to the database
        async void AddButtonClicked(object sender, EventArgs args)
        {
            // get user input from the form
            string   sowno     = SowNo.Text;
            string   knickname = KnickName.Text;
            DateTime farrowed  = SowFarrowedDate.Date;
            DateTime bred      = SowBredDate.Date;
            DateTime due       = bred.AddDays(113);
            DateTime usound    = bred.AddDays(27);

            // TODO: determine status
            // if farrowed date > bred date:
            //  status = "READY_TO_BREED"
            // if bred date > farrowed date:
            //  status = "BRED"
            // use sow.update() instead after the sow object has been created

            // create a sow object with the input
            // leav status empty as it will be determined by sow.update()
            Sow sow = new Sow()
            {
                SowNo          = sowno,
                KnickName      = knickname,
                FarrowedDate   = farrowed,
                BredDate       = bred,
                DueDate        = due,
                UltrasoundDate = usound,
            };

            sow.DetermineStatus();

            // insert sow into the database
            using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
            {
                conn.CreateTable <Sow>();
                int rowsAdded = conn.Insert(sow);
            }

            // return to the sows page
            await Navigation.PopAsync();
        }
Пример #3
0
        // temporary method for adding test data
        async void TestDataButtonClicked(object sender, EventArgs args)
        {
            // delete all sows
            using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
            {
                conn.CreateTable <Sow>();
                conn.CreateTable <Litter>();
                conn.CreateTable <Ultrasound>();

                conn.DeleteAll <Sow>();
                conn.DeleteAll <Litter>();
                conn.DeleteAll <Ultrasound>();

                // sows with statuses that need an action
                Sow sow1 = new Sow()
                {
                    SowNo     = "4352",
                    KnickName = "Jim"
                };
                sow1.DetermineStatus();
                Sow sow2 = new Sow()
                {
                    SowNo     = "4356",
                    KnickName = "Jimbo",
                    BredDate  = DateTime.Now.AddDays(-27),
                    Status    = "PENDING_ULTRASOUND"
                };
                Sow sow3 = new Sow()
                {
                    SowNo     = "4354",
                    KnickName = "Jimmy",
                    BredDate  = DateTime.Now.AddDays(-113)
                };
                sow3.DetermineStatus();

                // sows with status's that do not need to be actions
                Sow sow4 = new Sow()
                {
                    SowNo     = "4111",
                    KnickName = "Jarge",
                    BredDate  = DateTime.Now.AddDays(-10)
                };
                sow4.DetermineStatus();
                Sow sow5 = new Sow()
                {
                    SowNo     = "4222",
                    KnickName = "Yorg",
                    BredDate  = DateTime.Now.AddDays(-30)
                };
                sow5.DetermineStatus();
                Sow sow6 = new Sow()
                {
                    SowNo        = "4333",
                    KnickName    = "Gark",
                    BredDate     = DateTime.Now.AddDays(-150),
                    FarrowedDate = DateTime.Now.AddDays(-5)
                };
                sow6.DetermineStatus();

                int rowsAdded;
                rowsAdded = conn.Insert(sow1);
                rowsAdded = conn.Insert(sow2);
                rowsAdded = conn.Insert(sow3);
                rowsAdded = conn.Insert(sow4);
                rowsAdded = conn.Insert(sow5);
                rowsAdded = conn.Insert(sow6);
            }
        }