public ContentResult HoursWorkedsData(HoursWorked filter)
        {
            var hoursWorkeds     = db.HoursWorkeds.Include(h => h.Employee).Include(h => h.Job);
            var hoursWorkedsData = (from hrs in hoursWorkeds
                                    where (hrs.Employee.EmployeeID == filter.EmployeeID || filter.EmployeeID == 0) &&
                                    (hrs.Job.JobID == filter.JobID || filter.JobID == 0) &&
                                    (hrs.ItemNumber == filter.ItemNumber || filter.ItemNumber == null) &&
                                    (hrs.HoursWorkedRT == filter.HoursWorkedRT || filter.HoursWorkedRT == null) &&
                                    (hrs.HoursWorkedOT == filter.HoursWorkedOT || filter.HoursWorkedOT == null) &&
                                    (hrs.JobDescription == filter.JobDescription || filter.JobDescription == null)
                                    select new
            {
                hrs.HoursWorkedID,
                EmployeeID = hrs.Employee.EmployeeID,
                JobID = hrs.Job.JobID,
                hrs.ItemNumber,
                Date = SqlFunctions.DateName("mm", hrs.Date) + " " + SqlFunctions.DateName("day", hrs.Date) + ", " + SqlFunctions.DateName("year", hrs.Date),
                hrs.HoursWorkedRT,
                hrs.HoursWorkedOT,
                hrs.JobDescription
            }).ToList();
            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
            string output = jsonSerializer.Serialize(hoursWorkedsData);

            return(Content(output, "application/json"));
        }
Esempio n. 2
0
        public async Task <HoursWorked> UpdateHoursWorked(int hoursWorkedId, HoursWorked hoursWorked)
        {
            if (hoursWorkedId != hoursWorked.HoursWorkedId)
            {
                throw new HoursWorkedIdsDoNotMatchException();
            }

            if (!await HoursWorkedExists(hoursWorkedId))
            {
                throw new HoursWorkedDoesNotExistException();
            }

            var local = _context.Set <HoursWorked>()
                        .Local
                        .FirstOrDefault(h => h.UserId == hoursWorked.UserId);

            _context.Entry(local).State = EntityState.Detached;

            _context.Entry(hoursWorked).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(hoursWorked);
        }
        public override string ToString()
        {
            return(@$ "  Manager : {NameOfStaff}
===================================
Hourly rate : {managerHourlyRate.ToString()}
Hours worked : {HoursWorked.ToString()}
Allowance : ${Allowance.ToString()}
Esempio n. 4
0
        public void AddNewMonth(AddMonthLocationViewModel addMonthLocationViewModel)
        {
            try
            {
                using (ASJDE context = new ASJDE())
                {
                    var user = Session["user"] as User;


                    HoursWorked hoursWorked = new HoursWorked
                    {
                        CountryID         = addMonthLocationViewModel.CountryID,
                        LocationID        = addMonthLocationViewModel.LocationID,
                        Year              = addMonthLocationViewModel.Year,
                        Month             = addMonthLocationViewModel.Month,
                        CreatedByDate     = DateTime.Now,
                        CreatedBy         = user.LastName + ", " + user.FirstName,
                        CreatedByUserName = user.UserName
                    };
                    context.HoursWorkeds.Add(hoursWorked);

                    context.SaveChanges();
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                logger.Error("Exception", dbEx);
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
        }
Esempio n. 5
0
        public ActionResult HoursWorkedDestroy([DataSourceRequest] DataSourceRequest request,
                                               HoursWorkedViewModel hoursWorkedViewModel)
        {
            try
            {
                if (hoursWorkedViewModel != null)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        HoursWorked hoursWorked = (from hw in context.HoursWorkeds
                                                   where hw.ID == hoursWorkedViewModel.ID
                                                   select hw).FirstOrDefault();

                        context.HoursWorkeds.Remove(hoursWorked);
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }

            return(Json(ModelState.ToDataSourceResult()));
        }
Esempio n. 6
0
        public async Task <IActionResult> Insert([FromBody] HoursWorked hoursworked)
        {
            HoursWorked HoursWorked = hoursworked;

            try
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    try
                    {
                        _context.HoursWorked.Add(HoursWorked);
                        //await _context.SaveChangesAsync();

                        foreach (var item in hoursworked.idhorastrabajadasconstrains)
                        {
                            item.IdHorasTrabajadas = hoursworked.IdHorastrabajadas;
                            _context.HoursWorkedDetail.Add(item);
                        }
                        await _context.SaveChangesAsync();

                        BitacoraWrite _write = new BitacoraWrite(_context, new Bitacora
                        {
                            IdOperacion = HoursWorked.IdHorastrabajadas,
                            DocType     = "HoursWorked",

                            ClaseInicial =
                                Newtonsoft.Json.JsonConvert.SerializeObject(hoursworked, new JsonSerializerSettings {
                                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                            }),
                            ResultadoSerializado = Newtonsoft.Json.JsonConvert.SerializeObject(HoursWorked, new JsonSerializerSettings {
                                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                            }),
                            Accion              = "Insert",
                            FechaCreacion       = DateTime.Now,
                            FechaModificacion   = DateTime.Now,
                            UsuarioCreacion     = HoursWorked.UsuarioCreacion,
                            UsuarioModificacion = HoursWorked.UsuarioModificacion,
                            UsuarioEjecucion    = HoursWorked.UsuarioModificacion,
                        });

                        await _context.SaveChangesAsync();

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        throw ex;
                    }
                }
                // this.UpdateSalesOrder(salesOrder.SalesOrderId);
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(HoursWorked)));
        }
        public ContentResult DeleteHoursWorkedData(HoursWorked hoursWorked)
        {
            var         hoursWorkedsData = db.HoursWorkeds.Include(h => h.Employee).Include(h => h.ItemNumber).Include(h => h.Job);
            HoursWorked removeHrsWorked  = db.HoursWorkeds.Find(hoursWorked.HoursWorkedID);

            ModelState.Clear();
            TryValidateModel(hoursWorked); //Hack to ignore empty employee and job fields
            var isValid = true;            //Work around to resolve error

            if (isValid)
            {
                db.HoursWorkeds.Remove(removeHrsWorked);
                db.SaveChanges();
            }
            else
            {
                string error = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError err in modelState.Errors)
                    {
                        error = error + " \n" + err.ErrorMessage;
                    }
                }
                return(Content("", "application/json"));
            }

            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
            string output = jsonSerializer.Serialize(hoursWorked);

            return(Content(output, "application/json"));
        }
Esempio n. 8
0
        public override string ToString()
        {
            return(@$ "  Admin : {NameOfStaff}
==========================================
Hourly rate : {adminHourlyRate.ToString()}
Hours worked : {HoursWorked.ToString()}
Overtime rate : {overtimeRate.ToString()}
Overtime pay : ${Overtime.ToString()}
Esempio n. 9
0
        public ActionResult DeleteConfirmed(int id)
        {
            HoursWorked hoursWorked = db.HoursWorkeds.Find(id);

            db.HoursWorkeds.Remove(hoursWorked);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "hoursWorkedID,positionLocationID,hrsWrkdIDType,hrsWrkdTimeIn,hrsWrkdTimeOut,userAcctID,modifiedOn,hrsWrkedSchedDate,volunteerID,volunteerGroupID,hrsWrkdQty")] HoursWorked hoursWorked)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hoursWorked).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hoursWorked));
 }
Esempio n. 11
0
        public async Task NonExistingPutHoursWorkedShouldReturnBadRequest()
        {
            var fakeHoursWorked = new HoursWorked();

            fakeHoursWorked.UserId = -1;

            var response = await _testHoursWorkedController.PutHoursWorked(-1, fakeHoursWorked);

            response.Should().BeOfType <BadRequestObjectResult>();
        }
Esempio n. 12
0
        public async Task ValidGetHoursWorkedByIdReturnsCorrectHoursWorked()
        {
            var response = await _testHoursWorkedController.GetHoursWorked(_testHoursWorked[0].HoursWorkedId);

            var         responseResult = response.Result as OkObjectResult;
            HoursWorked hours          = (HoursWorked)responseResult.Value;

            var compare = hours.Equals(_testHoursWorked[0]);

            hours.Should().Be(_testHoursWorked[0]);
        }
        public ContentResult UpdateHoursWorkedsData(HoursWorked hoursWorked)
        {
            var wageHistoryID = db.WageHistories.Where(x => x.EmployeeID == hoursWorked.EmployeeID && x.IsCurrent == true).Select(x => x.WageHistoryID).FirstOrDefault();

            hoursWorked.WageHistoryID = wageHistoryID;

            if (ModelState.IsValid)
            {
                try
                {
                    db.Entry(hoursWorked).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Content("", "application/json"));
                }
            }
            else
            {
                string error = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError err in modelState.Errors)
                    {
                        error = error + " \n" + err.ErrorMessage;
                    }
                }
                ViewBag.error        = true;
                ViewBag.errorMessage = error;
                return(Content("", "application/json"));
            }

            //Form the hours worked data again for a single row and include the data conversions
            var hoursWorkeds     = db.HoursWorkeds.Include(h => h.Employee).Include(h => h.ItemNumber).Include(h => h.Job);
            var hoursWorkedsData = (from hrs in hoursWorkeds
                                    where hrs.HoursWorkedID == hoursWorked.HoursWorkedID
                                    select new
            {
                hrs.HoursWorkedID,
                EmployeeID = hrs.Employee.EmployeeID,
                JobID = hrs.Job.JobID,
                hrs.ItemNumber,
                Date = SqlFunctions.DateName("mm", hrs.Date) + " " + SqlFunctions.DateName("day", hrs.Date) + ", " + SqlFunctions.DateName("year", hrs.Date),
                hrs.HoursWorkedRT,
                hrs.HoursWorkedOT,
                hrs.JobDescription
            }).SingleOrDefault();

            JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
            string output = jsonSerializer.Serialize(hoursWorkedsData);

            return(Content(output, "application/json"));
        }
        public async Task <ActionResult <HoursWorked> > PostHoursWorked(HoursWorked hoursWorked)
        {
            try
            {
                await _service.AddHoursWorked(hoursWorked);
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(CreatedAtAction("GetHoursWorked", new { id = hoursWorked.HoursWorkedId }, hoursWorked));
        }
Esempio n. 15
0
        // GET: HoursWorked/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HoursWorked hoursWorked = db.HoursWorkeds.Find(id);

            if (hoursWorked == null)
            {
                return(HttpNotFound());
            }
            return(View(hoursWorked));
        }
Esempio n. 16
0
        public void AddNewMonth(AddMonthViewModel addMonthViewModel)
        {
            try
            {
                using (ASJDE context = new ASJDE())
                {
                    var user = Session["user"] as User;

                    List <decimal> locations = (from l in context.Locations
                                                where l.CountryID == addMonthViewModel.CountryID &&
                                                l.LocationStatusID == 1
                                                select l.ID).ToList();

                    List <decimal> existingLocations = (from h in context.HoursWorkeds
                                                        where
                                                        h.CountryID == addMonthViewModel.CountryID &&
                                                        h.Month == addMonthViewModel.Month &&
                                                        h.Year == addMonthViewModel.Year
                                                        select h.LocationID).ToList();

                    var locationsThatNeedAdded = locations.Except(existingLocations);


                    foreach (var location in locationsThatNeedAdded)
                    {
                        HoursWorked hoursWorked = new HoursWorked
                        {
                            CountryID         = addMonthViewModel.CountryID,
                            LocationID        = location,
                            Year              = addMonthViewModel.Year,
                            Month             = addMonthViewModel.Month,
                            CreatedByDate     = DateTime.Now,
                            CreatedBy         = user.LastName + ", " + user.FirstName,
                            CreatedByUserName = user.UserName
                        };
                        context.HoursWorkeds.Add(hoursWorked);
                    }
                    context.SaveChanges();
                }
            }
            catch (DbEntityValidationException dbEx)
            {
                logger.Error("Exception", dbEx);
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
        }
Esempio n. 17
0
        }                                             //  End   public override double CalculateEarnings()

        //************************************************
        //	Overridden ToString()
        //************************************************
        public override string ToString()
        {   //  Begin public override string ToString()
            string outputStr = "";

            outputStr += "Employee Name: " + FirstName + " " +
                         MiddleInit + " " +
                         LastName + "\n";
            outputStr += "Union Status:  " + IsUnion.ToString() + "\n";
            outputStr += "Employee Number: " + EmpNum.ToString() + "\n";
            outputStr += "Hours Worked: " + HoursWorked.ToString("f2") + "\n";
            outputStr += "Hourly Rate: " + HourlyRate.ToString("c") + "\n";
            outputStr += "Gross Pay: " + grossPay.ToString("c") + "\n";

            return(outputStr);
        }   //  End   public override string ToString()
Esempio n. 18
0
        public void Calculates_overtime_hours_as_hours_additional_to_contracted()
        {
            var hoursWorked = new Hours(40);
            var contractedHours = new Hours(35);

            // wrap with Micro Types for contextual explicitness
            var hoursWorkedx = new HoursWorked(hoursWorked);
            var contractedHoursx = new ContractedHours(contractedHours);

            var fiveHours = new Hours(5);
            var fiveHoursOvertime = new OvertimeHours(fiveHours);

            var result = new OvertimeCalculator().Calculate(hoursWorkedx, contractedHoursx);
            Assert.AreEqual(fiveHoursOvertime, result);
        }
        public void Calculates_overtime_hours_as_hours_additional_to_contracted()
        {
            var hoursWorked     = new Hours(40);
            var contractedHours = new Hours(35);

            // wrap with Micro Types for contextual explicitness
            var hoursWorkedx     = new HoursWorked(hoursWorked);
            var contractedHoursx = new ContractedHours(contractedHours);

            var fiveHours         = new Hours(5);
            var fiveHoursOvertime = new OvertimeHours(fiveHours);

            var result = new OvertimeCalculator().Calculate(hoursWorkedx, contractedHoursx);

            Assert.AreEqual(fiveHoursOvertime, result);
        }
Esempio n. 20
0
        public async Task <ActionResult <HoursWorked> > GetHoursWorkedById(Int64 IdHorastrabajadas)
        {
            HoursWorked Items = new HoursWorked();

            try
            {
                Items = await _context.HoursWorked.Where(q => q.IdHorastrabajadas == IdHorastrabajadas).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
Esempio n. 21
0
        public async Task <HoursWorked> AddHoursWorked(HoursWorked hoursWorked)
        {
            hoursWorked.Active = true;

            _context.HoursWorked.Add(hoursWorked);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(hoursWorked);
        }
Esempio n. 22
0
        public async Task <IActionResult> Delete([FromBody] HoursWorked _HoursWorked)
        {
            HoursWorked _HoursWorkedq = new HoursWorked();

            try
            {
                _HoursWorkedq = _context.HoursWorked
                                .Where(x => x.IdHorastrabajadas == (Int64)_HoursWorked.IdHorastrabajadas)
                                .FirstOrDefault();

                _context.HoursWorked.Remove(_HoursWorkedq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_HoursWorkedq)));
        }
        public async Task <IActionResult> PutHoursWorked(int id, HoursWorked hoursWorked)
        {
            try
            {
                await _service.UpdateHoursWorked(id, hoursWorked);
            }
            catch (HoursWorkedIdsDoNotMatchException e)
            {
                return(BadRequest(e));
            }
            catch (HoursWorkedDoesNotExistException)
            {
                return(NotFound());
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(NoContent());
        }
Esempio n. 24
0
        public void WriteUser(User user)
        {
            HoursWorked hoursWorked = new HoursWorked()
            {
                hrsWrkdIDType      = user.HoursWorkedType,
                hrsWrkdTimeIn      = user.ClockIn,
                hrsWrkdQty         = user.HoursWorkedQuantity,
                hrsWrkdTimeOut     = user.ClockOut,
                hrsWrkedSchedDate  = user.HoursWorkedDate,
                userAcctID         = user.UserAccount,
                modifiedOn         = user.ModifiedOn,
                volunteerID        = user.UserId,
                volunteerGroupID   = user.GroupId,
                volunteer          = context.Volunteers.Find(user.UserId),
                positionLocation   = context.PositionLocations.Find(user.PositionKey),
                positionLocationID = user.PositionLocationId,
                IsClockedIn        = 1
            };

            context.HoursWorkeds.Add(hoursWorked);
            context.SaveChanges();
        }
Esempio n. 25
0
        public async Task <ActionResult <HoursWorked> > Update([FromBody] HoursWorked _HoursWorked)
        {
            HoursWorked _HoursWorkedq = _HoursWorked;

            try
            {
                _HoursWorkedq = await(from c in _context.HoursWorked
                                      .Where(q => q.IdHorastrabajadas == _HoursWorked.IdHorastrabajadas)
                                      select c
                                      ).FirstOrDefaultAsync();

                _context.Entry(_HoursWorkedq).CurrentValues.SetValues((_HoursWorked));

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_HoursWorkedq)));
        }
Esempio n. 26
0
        public ActionResult HoursWorkedUpdate([DataSourceRequest] DataSourceRequest dataSourceRequest, HoursWorkedViewModel hoursWorkedViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (ASJDE context = new ASJDE())
                    {
                        var user = Session["user"] as User;

                        HoursWorked hoursWorked = (from hw in context.HoursWorkeds
                                                   where hw.ID == hoursWorkedViewModel.ID
                                                   select hw).FirstOrDefault();

                        hoursWorked.Hours            = hoursWorkedViewModel.Hours;
                        hoursWorked.EntityID         = hoursWorkedViewModel.EntityID;
                        hoursWorked.EditedByUserName = user.UserName;
                        hoursWorked.EditedByDate     = DateTime.Now;
                        hoursWorked.EditedByName     = user.LastName + ", " + user.FirstName;

                        context.SaveChanges();

                        hoursWorkedViewModel.EditedBy = user.LastName + ", " + user.FirstName;
                    }
                }
            }
            catch (DbEntityValidationException)
            {
                return(null);
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
            return(Json(new[] { hoursWorkedViewModel }.ToDataSourceResult(dataSourceRequest, ModelState)));
        }
Esempio n. 27
0
 public string GetDisplayText()
 {
     // string c = Code; //using the get
     return(EmployeeName + ", " + EmployeeNumber + ", " + HoursWorked.ToString() + ", " + WeeklyPay.ToString("c"));
 }
Esempio n. 28
0
 public OvertimeHours Calculate(HoursWorked worked, ContractedHours contracted)
 {
     var overtimeHours = worked.Hours - contracted.Hours;
     return new OvertimeHours(overtimeHours);
 }
        public OvertimeHours Calculate(HoursWorked worked, ContractedHours contracted)
        {
            var overtimeHours = worked.Hours - contracted.Hours;

            return(new OvertimeHours(overtimeHours));
        }
Esempio n. 30
0
        public void AddNewMonth(AddMonthViewModel addMonthViewModel)
        {
            try
            {
                using (ASJDE context = new ASJDE())
                {
                    var user = Session["user"] as User;

                    List<decimal> locations = (from l in context.Locations
                                               where l.CountryID == addMonthViewModel.CountryID
                                               && l.LocationStatusID == 1
                                               select l.ID).ToList();

                    List<decimal> existingLocations = (from h in context.HoursWorkeds
                                                       where
                                                           h.CountryID == addMonthViewModel.CountryID &&
                                                           h.Month == addMonthViewModel.Month &&
                                                           h.Year == addMonthViewModel.Year
                                                       select h.LocationID).ToList();

                    var locationsThatNeedAdded = locations.Except(existingLocations);

                    foreach (var location in locationsThatNeedAdded)
                    {
                        HoursWorked hoursWorked = new HoursWorked
                            {
                                CountryID = addMonthViewModel.CountryID,
                                LocationID = location,
                                Year = addMonthViewModel.Year,
                                Month = addMonthViewModel.Month,
                                CreatedByDate = DateTime.Now,
                                CreatedBy = user.LastName + ", " + user.FirstName,
                                CreatedByUserName = user.UserName
                            };
                        context.HoursWorkeds.Add(hoursWorked);
                    }
                    context.SaveChanges();

                }
            }
            catch (DbEntityValidationException dbEx)
            {
                logger.Error("Exception", dbEx);
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
        }
Esempio n. 31
0
        public void AddNewMonth(AddMonthLocationViewModel addMonthLocationViewModel)
        {
            try
            {
                using (ASJDE context = new ASJDE())
                {
                    var user = Session["user"] as User;

                    HoursWorked hoursWorked = new HoursWorked
                        {
                            CountryID = addMonthLocationViewModel.CountryID,
                            LocationID = addMonthLocationViewModel.LocationID,
                            Year = addMonthLocationViewModel.Year,
                            Month = addMonthLocationViewModel.Month,
                            CreatedByDate = DateTime.Now,
                            CreatedBy = user.LastName + ", " + user.FirstName,
                            CreatedByUserName = user.UserName
                        };
                    context.HoursWorkeds.Add(hoursWorked);

                    context.SaveChanges();

                }
            }
            catch (DbEntityValidationException dbEx)
            {
                logger.Error("Exception", dbEx);
            }
            catch (Exception e)
            {
                logger.Error("Exception", e);
            }
        }
 public bool GetObjectNeedsUpate(PersonFollowUp checkUpdateFrom)
 {
     if (!FollowUpDate.Equals(checkUpdateFrom.FollowUpDate))
     {
         return(true);
     }
     if (!HaveJobReturningTo.Equals(checkUpdateFrom.HaveJobReturningTo))
     {
         return(true);
     }
     if (!HoursWorked.Equals(checkUpdateFrom.HoursWorked))
     {
         return(true);
     }
     if (!HouseWorkedOnHousework.Equals(checkUpdateFrom.HouseWorkedOnHousework))
     {
         return(true);
     }
     if (!EnrolledInSchool.Equals(checkUpdateFrom.EnrolledInSchool))
     {
         return(true);
     }
     if (!GpsLatitude.Equals(checkUpdateFrom.GpsLatitude))
     {
         return(true);
     }
     if (!GpsLongitude.Equals(checkUpdateFrom.GpsLongitude))
     {
         return(true);
     }
     if (!GpsPositionAccuracy.Equals(checkUpdateFrom.GpsPositionAccuracy))
     {
         return(true);
     }
     if (!GpsAltitude.Equals(checkUpdateFrom.GpsAltitude))
     {
         return(true);
     }
     if (!GpsAltitudeAccuracy.Equals(checkUpdateFrom.GpsAltitudeAccuracy))
     {
         return(true);
     }
     if (!GpsHeading.Equals(checkUpdateFrom.GpsHeading))
     {
         return(true);
     }
     if (!GpsSpeed.Equals(checkUpdateFrom.GpsSpeed))
     {
         return(true);
     }
     if (!GpsPositionTime.Equals(checkUpdateFrom.GpsPositionTime))
     {
         return(true);
     }
     if (!PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(checkUpdateFrom.PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition)))
     {
         return(true);
     }
     if (!PeopleFollowUpWorkActivities.Select(a => a.WorkActivity).SequenceEqual(checkUpdateFrom.PeopleFollowUpWorkActivities.Select(a => a.WorkActivity)))
     {
         return(true);
     }
     if (!PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(checkUpdateFrom.PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask)))
     {
         return(true);
     }
     if (!ExternalParentId.Equals(checkUpdateFrom.ExternalParentId))
     {
         return(true);
     }
     return(false);
 }
        public string GenerateUpdateJsonFromObject(PersonFollowUp updateFrom)
        {
            // form the json (determine the fields that need to be updated)
            var sb     = new StringBuilder();
            var sw     = new StringWriter(sb);
            var writer = new JsonTextWriter(sw)
            {
                Formatting = Formatting.None
            };

            writer.WriteStartObject();
            writer.WritePropertyName(@"follow_up");
            writer.WriteStartObject();

            if (!FollowUpDate.Equals(updateFrom.FollowUpDate))
            {
                writer.WritePropertyName("follow_date");
                writer.WriteValue(updateFrom.FollowUpDate);
            }

            if (!HaveJobReturningTo.Equals(updateFrom.HaveJobReturningTo))
            {
                writer.WritePropertyName("have_job_returning_to");
                writer.WriteValue(updateFrom.HaveJobReturningTo);
            }

            if (!HoursWorked.Equals(updateFrom.HoursWorked))
            {
                writer.WritePropertyName("hours_worked");
                writer.WriteValue(updateFrom.HoursWorked);
            }

            if (!HouseWorkedOnHousework.Equals(updateFrom.HouseWorkedOnHousework))
            {
                writer.WritePropertyName("hours_worked_on_housework");
                writer.WriteValue(updateFrom.HouseWorkedOnHousework);
            }

            if (!EnrolledInSchool.Equals(updateFrom.EnrolledInSchool))
            {
                writer.WritePropertyName("enrolled_in_school");
                writer.WriteValue(updateFrom.EnrolledInSchool);
            }

            if (!GpsLatitude.Equals(updateFrom.GpsLatitude))
            {
                writer.WritePropertyName("latitude");
                writer.WriteValue(updateFrom.GpsLatitude);
            }

            if (!GpsLongitude.Equals(updateFrom.GpsLongitude))
            {
                writer.WritePropertyName("longitude");
                writer.WriteValue(updateFrom.GpsLongitude);
            }

            if (!GpsPositionAccuracy.Equals(updateFrom.GpsPositionAccuracy))
            {
                writer.WritePropertyName("position_accuracy");
                writer.WriteValue(updateFrom.GpsPositionAccuracy);
            }

            if (!GpsAltitude.Equals(updateFrom.GpsAltitude))
            {
                writer.WritePropertyName("altitude");
                writer.WriteValue(updateFrom.GpsAltitude);
            }

            if (!GpsAltitudeAccuracy.Equals(updateFrom.GpsAltitudeAccuracy))
            {
                writer.WritePropertyName("altitude_accuracy");
                writer.WriteValue(updateFrom.GpsAltitudeAccuracy);
            }

            if (!GpsHeading.Equals(updateFrom.GpsHeading))
            {
                writer.WritePropertyName("heading");
                writer.WriteValue(updateFrom.GpsHeading);
            }

            if (!GpsSpeed.Equals(updateFrom.GpsSpeed))
            {
                writer.WritePropertyName("speed");
                writer.WriteValue(updateFrom.GpsSpeed);
            }

            if (!GpsPositionTime.Equals(updateFrom.GpsPositionTime))
            {
                writer.WritePropertyName("gps_recorded_at");
                writer.WriteValue(updateFrom.GpsPositionTime);
            }

            if (!PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition).SequenceEqual(updateFrom.PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition)))
            {
                writer.WritePropertyName("hazardous_condition_ids");
                writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpHazardousConditions.Select(a => a.HazardousCondition)));
            }

            if (!PeopleFollowUpWorkActivities.Select(a => a.WorkActivity).SequenceEqual(updateFrom.PeopleFollowUpWorkActivities.Select(a => a.WorkActivity)))
            {
                writer.WritePropertyName("work_activity_ids");
                writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpWorkActivities.Select(a => a.WorkActivity)));
            }

            if (!PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask).SequenceEqual(updateFrom.PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask)))
            {
                writer.WritePropertyName("household_task_ids");
                writer.WriteRawValue(GetStatusArrayAsJsonString(PeopleFollowUpHouseholdTasks.Select(a => a.HouseholdTask)));
            }

            if (!ExternalParentId.Equals(updateFrom.ExternalParentId))
            {
                writer.WritePropertyName("person_id");
                writer.WriteValue(updateFrom.ExternalParentId);
            }

            writer.WriteEndObject();
            writer.WriteEndObject();
            return(sw.ToString());
        }
        private void CalcButton_Click(object sender, EventArgs e)
        {
            hours = (int)HoursWorked.Value;
            week  = (int)WeekChooser.Value;
            lates = (int)latechooser.Value;
            EmptyError.Hide();
            EmptyError1.Hide();
            totweekhour         = (int)WeekChooser.Value * 40;
            latefee             = Pay / 60 * (int)latechooser.Value;
            OTrate              = Pay * 1.25;
            totOT               = OTrate * hours;
            grosspay            = Pay * totweekhour;
            GrossPayText.Text   = "₱ " + grosspay.ToString();
            deduc               = grosspay * 0.20 + latefee;
            finalpay            = grosspay - deduc + totOT;
            DeductionsText.Text = "₱ " + deduc.ToString();
            NetPayText.Text     = "₱ " + finalpay.ToString();
            otPaytxt.Text       = "₱ " + totOT.ToString();
            totallatetxt.Text   = "₱ " + latefee.ToString();
            totWeektxt.Text     = week.ToString();
            totlatetxt.Text     = lates.ToString();
            totOTtxt.Text       = hours.ToString();
            GenInvoice.Enabled  = true;

            //(EmployeeNameText.TextLength >= 1 && empidtxt.TextLength >= 1 && WeekChooser.Minimum >= 1 && HoursWorked.Minimum >= 1)

            if (string.IsNullOrWhiteSpace(empidtxt.Text) || string.IsNullOrWhiteSpace(EmployeeNameText.Text) || WeekChooser.Minimum >= 1 && HoursWorked.Minimum >= 1)
            {
                var result = MessageBox.Show("Opps! Something went wrong!", "Please Provide Details!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                EmptyError.Show();
                EmptyError1.Show();
                //MessageBox.Show("There are still unsaved changes." + Environment.NewLine + "are you sure you want to continue?", "Textbox has been filled!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    empidtxt.Focus();
                    EmployeeNameText.Focus();
                    WeekChooser.Focus();
                    HoursWorked.Focus();
                }
            }
            else
            {
                string       action = "Add Employee Record";
                string       table  = "employee";
                string       eid    = "N/A";
                string       today  = DateTime.Now.ToString("dd/MM/yyyy h:mm tt");
                const string sql1   = "insert into audittrail (adminname,[action],[tablename],eid,[accesstime]) values (@adminname,@action,@tablename,@eid,@accesstime)";
                cmd1 = new OleDbCommand(sql1, con);
                cmd1.Parameters.AddWithValue("@adminname", adminlabel.Text);
                cmd1.Parameters.AddWithValue("[@action]", action);
                cmd1.Parameters.AddWithValue("[@tablename]", table);
                cmd1.Parameters.AddWithValue("[@eid]", eid);
                cmd1.Parameters.AddWithValue("[@accesstime]", today);

                const string sql = "insert into employee(empid,empname,deptid,dept) values (@empid,@empname,@deptid,@dept)";
                cmd = new OleDbCommand(sql, con);
                cmd.Parameters.AddWithValue("@empid", empidtxt.Text);
                cmd.Parameters.AddWithValue("@empname", EmployeeNameText.Text);
                cmd.Parameters.AddWithValue("@deptid", DepartmentText.SelectedValue);
                cmd.Parameters.AddWithValue("@dept", DepartmentText.Text);

                con.Open();
                int result = cmd.ExecuteNonQuery();
                cmd1.ExecuteNonQuery();

                if (result > 0)
                {
                    MessageBox.Show("Record Saved Successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    con.Close();
                }
                else
                {
                    MessageBox.Show("It seems that the record does not saved successfully", "Opps! Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    con.Close();
                }
            }


            /*
             * if (!string.IsNullOrWhiteSpace(empidtxt.Text) && !string.IsNullOrWhiteSpace(EmployeeNameText.Text) && WeekChooser.Minimum >= 1 && HoursWorked.Minimum >= 1)
             * {
             *  empidtxt.Focus();
             *  MessageBox.Show("Opps! Something went wrong!", "Please Provide Details!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  EmptyError.Show();
             *  EmptyError1.Show();
             * }
             * else
             * {
             *  const string sql = "insert into employee(empid,empname,deptid,dept) values (@empid,@empname,@deptid,@dept)";
             *  cmd = new OleDbCommand(sql, con);
             *  con.Open();
             *  cmd.Parameters.AddWithValue("@empid", empidtxt.Text);
             *  cmd.Parameters.AddWithValue("@empname", EmployeeNameText.Text);
             *  cmd.Parameters.AddWithValue("@deptid", DepartmentText.SelectedValue);
             *  cmd.Parameters.AddWithValue("@dept", DepartmentText.Text);
             *  int result = cmd.ExecuteNonQuery();
             *
             *  if (result > 0)
             *  {
             *      MessageBox.Show("Record Saved Successfully!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *      con.Close();
             *  }
             *  else
             *  {
             *      MessageBox.Show("Opps! Something went wrong!", "Please Provide Details!!!!!!!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *      con.Close();
             *  }
             * }
             * else if (string.IsNullOrWhiteSpace(EmployeeNameText.Text) || string.IsNullOrWhiteSpace(empidtxt.Text) || WeekChooser.Minimum == 0 || HoursWorked.Minimum == 0)
             * {
             *  empidtxt.Focus();
             *  MessageBox.Show("Opps! Something went wrong!", "Please Provide Details!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  EmptyError.Show();
             *  EmptyError1.Show();
             * }*/
        }