Ejemplo n.º 1
0
        public List <int> GetTotalHours(LønPeriode valgteLønPeriode)
        {
            var records = database.FåRecordsByPeriode(valgteLønPeriode);

            if (records != null)
            {
                int WorkHours   = 0;
                int WorkMinutes = 0;
                foreach (var item in records)
                {
                    WorkHours += item.EndTime.Subtract(item.StartTime).Hours;

                    WorkMinutes += item.EndTime.Subtract(item.StartTime).Minutes;
                    if (WorkMinutes > 60)
                    {
                        double a          = (WorkMinutes / 60.0);
                        int    hoursToAdd = (int)a;
                        WorkMinutes = WorkMinutes - (hoursToAdd * 60);
                        WorkHours  += hoursToAdd;
                    }
                }

                return(new List <int> {
                    WorkHours, WorkMinutes
                });
            }
            else
            {
                return(new List <int> {
                    0, 0
                });
            }
        }
Ejemplo n.º 2
0
 public Record FindesDerRecordForDagsDato(LønPeriode lønperiode, DateTime TodaysDate)
 {
     try
     {
         if (database.Table <Record>() != null)
         {
             var records = database.Table <Record>().Where(n => n.LønPeriodeID == lønperiode.LønPeriodeID);
             foreach (var item in records)
             {
                 if (item.LoggedDate.Day == TodaysDate.Day && item.LoggedDate.Month == TodaysDate.Month && item.LoggedDate.Year == TodaysDate.Year)
                 {
                     return(item);
                 }
             }
             return(null);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(null);
     }
 }
Ejemplo n.º 3
0
        private void ListOfPeriods_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            ListView    view       = sender as ListView;
            PeriodeView periode    = (PeriodeView)view.SelectedItem;
            LønPeriode  lønPeriode = database.GetLønPeriode(periode.Periode.LønPeriodeID);

            Navigation.PushAsync(new SeeOldRecords(lønPeriode));
        }
Ejemplo n.º 4
0
 public ViewLogModal(RecordView record)
 {
     BindingContext = this;
     CurrentCompany = database.GetVariables().CurrentCompany;
     CurrentPeriode = database.GetCompany(CurrentCompany).HasCurrentPeriode();
     this.Record    = record;
     GetDataOnSpecificRecord();
     InitializeComponent();
 }
Ejemplo n.º 5
0
 public SeeOldRecords(LønPeriode selectedItem)
 {
     BindingContext      = this;
     this.LønPeriode     = selectedItem;
     PeriodeLabel        = LønPeriode.Periode + ", " + this.LønPeriode.Year;
     PeriodeFraLabel     = this.LønPeriode.From.ToString("dd-MM-yyyy");
     PeriodeTilLabel     = this.LønPeriode.To.ToString("dd-MM-yyyy");
     this.LønPeriodeName = selectedItem.Periode;
     this.ListOfRecords  = GetRecords();
     SetTotalHoursAndBreaks();
     InitializeComponent();
 }
Ejemplo n.º 6
0
        public SeLønSeddel(LønPeriode lønPeriode)
        {
            BindingContext = this;
            arbejdsplads   = "Arbejdsplads: " + lønPeriode.CompanyName;
            periode        = "Periode: " + lønPeriode.Periode;
            antalVagter    = "Antal vagter: " + database.FåRecordsByPeriode(lønPeriode).Count.ToString();
            var hours   = cal.GetTotalHours(lønPeriode);
            var minutes = cal.GetTotalBreak(lønPeriode);

            antalTimer     = "Antal timer: " + hours[0].ToString() + "t " + hours[1].ToString() + "m";
            pauseIMinutter = "Pause i minutter: " + minutes[0].ToString() + "t " + minutes[1].ToString() + "m";
            InitializeComponent();
        }
Ejemplo n.º 7
0
        // Controllers for TABLE: Records
        public List <Record> FåRecords(string chosenCompany, LønPeriode valgteLønPeriode)
        {
            try
            {
                List <Record> list = new List <Record>();
                foreach (var item in database.Table <Record>().Where(n => n.LønPeriodeID == valgteLønPeriode.LønPeriodeID))
                {
                    list.Add(item);
                }

                return(list);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returner en list med alle records for den givende lønperiode.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        internal List <Record> FåRecordsByPeriode(LønPeriode item)
        {
            try
            {
                var           records = database.Table <Record>().Where(n => n.LønPeriodeID == item.LønPeriodeID);
                List <Record> list    = new List <Record>();
                foreach (var record in records)
                {
                    list.Add(record);
                }

                return(list);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 9
0
        internal Record FåRecordByLoggedDate(DateTime SelectedRecordLoggedDate, LønPeriode valgteLønPeriode)
        {
            List <Record> list = new List <Record>();

            foreach (var item in database.Table <Record>().Where(n => n.LønPeriodeID == valgteLønPeriode.LønPeriodeID))
            {
                list.Add(item);
            }
            foreach (var record in list)
            {
                String time1 = SelectedRecordLoggedDate.ToString("hh/mm/ss");
                String time2 = record.LoggedDate.ToString("hh/mm/ss");
                if (time1 == time2)
                {
                    return(record);
                }
            }
            return(null);
        }
Ejemplo n.º 10
0
        private void TilføjLønPeriode()
        {
            LønPeriode lønPeriode;

            // Hvis løn perioden starter på dagen eller først er om et par dage.
            // Opret en løn periode bagud.
            if (company.LønPeriode_FraDato >= current.Day)
            {
                lønPeriode = new LønPeriode
                {
                    From        = new DateTime(current.Year, current.Month - 1, company.LønPeriode_FraDato),
                    To          = new DateTime(current.Year, (current.Month), company.LønPeriode_TilDato),
                    Year        = current.Year,
                    CompanyName = company.CompanyName,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM") + " - " + current.ToString("MMMM"),
                };
            }
            else
            {
                lønPeriode = new LønPeriode
                {
                    From        = new DateTime(current.Year, current.Month, company.LønPeriode_FraDato),
                    To          = new DateTime(current.Year, (current.Month + 1), company.LønPeriode_TilDato),
                    Year        = current.Year,
                    CompanyName = company.CompanyName,
                    Periode     = current.ToString("MMMM") + " - " + current.AddMonths(1).ToString("MMMM"),
                };
                ;
            }
            // Tilføjer lønperiode
            try
            {
                FromDate = company.LønPeriode_FraDato + "/" + (current.Month - 1) + "/" + current.Year;
                ToDate   = company.LønPeriode_TilDato + "/" + current.Month + "/" + current.Year;
                App.Database.TilføjLønPeriode(lønPeriode);
                App.Database.Commit();
            }
            catch (Exception)
            {
                DisplayAlert("ERROR", "Der er sket en fejl ved oprettelse af din lønperiode, prøv venligst igen", "Ok");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Tjekker om det er oprettet en record for dags dato og returner record. Hvis ikke nogen record er fundet bliver null returned.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        internal bool FåRecordForIdag(LønPeriode item)
        {
            try
            {
                var recordsForPeriod = database.Table <Record>().Where(n => n.LønPeriodeID == item.LønPeriodeID).ToList();
                foreach (var record in recordsForPeriod)
                {
                    if (record.LoggedDate.ToString("dd-MM-yyyy").Equals(DateTime.Now.Date.ToString("dd-MM-yyyy")))
                    {
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            return(false);
        }
Ejemplo n.º 12
0
        public List <int> GetTotalBreak(LønPeriode valgteLønPeriode)
        {
            var records = database.FåRecordsByPeriode(valgteLønPeriode);

            if (records != null)
            {
                int minutes = 0;
                foreach (var item in records)
                {
                    minutes += int.Parse(item.Pause);
                }
                TimeSpan time = TimeSpan.FromMinutes(minutes);
                return(new List <int> {
                    time.Hours, time.Minutes
                });
            }
            else
            {
                return(new List <int> {
                    0, 0
                });
            }
        }
Ejemplo n.º 13
0
 public int TilføjLønPeriode(LønPeriode lønPeriode)
 {
     return(database.Insert(lønPeriode));
 }
Ejemplo n.º 14
0
        private void OpretLønPerioder()
        {
            DateTime   current = System.DateTime.Now;
            LønPeriode lønPeriode_Elgiganten_1;
            LønPeriode lønPeriode_Elgiganten_2;
            LønPeriode lønPeriode_Elgiganten_3;
            LønPeriode lønPeriode_THansen_2;
            LønPeriode lønPeriode_Kinorama_3;

            // Hvis TestData ikke virker ændre denne. Det er pga. dagsdato.
            if (15 >= current.Day)
            {
                lønPeriode_Elgiganten_1 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, current.Month - 1, 15),
                    To          = new DateTime(current.Year, (current.Month), 16),
                    Year        = 2019,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_THansen_2 = new LønPeriode
                {
                    CompanyName = "T-Hansen A/S",
                    From        = new DateTime(current.Year, current.Month - 1, 8),
                    To          = new DateTime(current.Year, (current.Month), 9),
                    Year        = 2019,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Kinorama_3 = new LønPeriode
                {
                    CompanyName = "Kinorama A/S",
                    From        = new DateTime(current.Year, current.Month - 1, 10),
                    To          = new DateTime(current.Year, (current.Month), 11),
                    Year        = 2019,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Elgiganten_2 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, 2, 15),
                    To          = new DateTime(current.Year, 3, 16),
                    Year        = 2019,
                    Periode     = new DateTime(2019, 2, 15).ToString("MMMM", new CultureInfo("da-DK")) + " - " + new DateTime(2019, 3, 16).ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Elgiganten_3 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, 1, 15),
                    To          = new DateTime(current.Year, 2, 16),
                    Year        = 2018,
                    Periode     = new DateTime(2018, 1, 15).ToString("MMMM", new CultureInfo("da-DK")) + " - " + new DateTime(2018, 2, 16).ToString("MMMM", new CultureInfo("da-DK")),
                };
            }
            else
            {
                lønPeriode_Elgiganten_1 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, current.Month, 15),
                    To          = new DateTime(current.Year, (current.Month + 1), 16),
                    Year        = current.Year,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };

                lønPeriode_THansen_2 = new LønPeriode
                {
                    CompanyName = "T-Hansen A/S",
                    From        = new DateTime(current.Year, current.Month, 8),
                    To          = new DateTime(current.Year, (current.Month + 1), 9),
                    Year        = 2019,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Kinorama_3 = new LønPeriode
                {
                    CompanyName = "Kinorama A/S",
                    From        = new DateTime(current.Year, current.Month, 10),
                    To          = new DateTime(current.Year, (current.Month + 1), 11),
                    Year        = 2019,
                    Periode     = new DateTime(current.Year, (DateTime.Now.Month - 1), current.Day).ToString("MMMM", new CultureInfo("da-DK")) + " - " + current.ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Elgiganten_2 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, 2, 15),
                    To          = new DateTime(current.Year, 3, 16),
                    Year        = current.Year,
                    Periode     = new DateTime(2019, 2, 15).ToString("MMMM", new CultureInfo("da-DK")) + " - " + new DateTime(2019, 3, 16).ToString("MMMM", new CultureInfo("da-DK")),
                };
                lønPeriode_Elgiganten_3 = new LønPeriode
                {
                    CompanyName = "Elgiganten A/S",
                    From        = new DateTime(current.Year, 2, 15),
                    To          = new DateTime(current.Year, 3, 16),
                    Year        = 2018,
                    Periode     = new DateTime(2018, 2, 15).ToString("MMMM", new CultureInfo("da-DK")) + " - " + new DateTime(2018, 3, 16).ToString("MMMM", new CultureInfo("da-DK")),
                };
            }

            database.TilføjLønPeriode(lønPeriode_Elgiganten_1);
            App.Database.Commit();
            App.Database.Commit();
            database.TilføjLønPeriode(lønPeriode_THansen_2);
            App.Database.Commit();
            database.TilføjLønPeriode(lønPeriode_Kinorama_3);
            App.Database.Commit();
            database.TilføjLønPeriode(lønPeriode_Elgiganten_2);
            App.Database.Commit();
            database.TilføjLønPeriode(lønPeriode_Elgiganten_3);
        }
Ejemplo n.º 15
0
 private void SletLønPeriode(LønPeriode lønperiode)
 {
     database.Delete(lønperiode);
 }
Ejemplo n.º 16
0
 public PeriodeView(LønPeriode periode, string color)
 {
     this.Color           = color;
     this.Periode         = periode;
     this.PeriodeAsString = periode.Periode;
 }
Ejemplo n.º 17
0
 public void DeleteMonth(LønPeriode month)
 {
     database.Delete(month);
 }
Ejemplo n.º 18
0
 public int UpdateMonth(LønPeriode month)
 {
     return(database.Update(month));
 }
Ejemplo n.º 19
0
 public int AddMonth(LønPeriode month)
 {
     return(database.Insert(month));
 }