Example #1
0
        //sets checkin entry in preparation for saving a time entry to the database
        //inserts a soll entry to the database (overwrites if one already exists on that day)
        public void checkin(object sender, EventArgs e)
        {
            var ce = new CheckinEntry(DateTime.Now.TimeOfDay);

            ce.comment = comment.Text;


            string check = type.SelectedItem.ToString(); // save

            switch (check)                               // save
            {
            case "Notfall":
                ce.type = "NF";
                break;

            case "Meeting":
                ce.type = "M";
                break;

            case "Wiiterbildig":
                ce.type = "WB";
                break;

            default:
                ce.type = " ";
                break;
            }

            var se = new SollEntry(SollZeit.Time, DateTime.Now);

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_Path))
            {
                conn.CreateTable <CheckinEntry>();
                conn.InsertOrReplace(ce);

                conn.CreateTable <SollEntry>();
                conn.InsertOrReplace(se);
            }

            check_out.IsEnabled = true;
            check_in.IsEnabled  = false;
        }
Example #2
0
        // same as delete of time entry
        async void delete(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }
            answer = await DisplayAlert("Eintrag Löschen", "Wetsch de Iitrag würkli lösche", "Ja", "Nei");

            if (answer)
            {
                int       Index             = e.SelectedItemIndex;
                SollEntry selectedSollEntry = sollEntries[Index];
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_Path))
                {
                    conn.Delete <SollEntry>(selectedSollEntry.Date);
                }
                OnAppearing();
                answer = false;
            }
        }
Example #3
0
        // thanks to https://www.youtube.com/watch?v=JhWwBOoqXQ8&t=1801s&ab_channel=AltexSoft
        public async void enterToDB(object sender, EventArgs e)
        {
            TimeSpan TimeIn  = TimeInPicked.Time;
            TimeSpan TimeOut = TimeOutPicked.Time;

            /*
             * if (TimeIn > TimeOut)
             * {
             *  Debug.WriteLine("------");
             *  bool answer = await DisplayAlert("Obacht!", "Hesch würkli über Mitternach gschaffet oder dich vertippt", "stimmt scho so", "ups...");
             *
             *  if(!answer)
             *  {
             *      return;
             *  }
             * }
             */
            string Type;
            string Comment = comment.Text;
            string check   = type.SelectedItem.ToString();

            switch (check)
            {
            case "Notfall":
                Type = "NF";
                break;

            case "Meeting":
                Type = "M";
                break;

            case "Wiiterbiudig":
                Type = "WB";
                break;

            default:
                Type = " ";
                break;
            }
            TimeEntry manualEntry = new TimeEntry(DatePicked.Date, TimeIn, TimeOut, Comment);

            manualEntry.Type = Type;

            var se = new SollEntry(SollTimePicked.Time, DatePicked.Date);

            using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_Path))
            {
                conn.CreateTable <TimeEntry>();
                conn.Insert(manualEntry);
                if (Type != "NF")
                {
                    conn.CreateTable <SollEntry>();
                    conn.InsertOrReplace(se);
                }
            }

            if (changeEntry)
            {
                this.SendBackButtonPressed();
            }
        }