private void GetMyRate(DateTime date) { UserRateSchedule URS = new UserRateSchedule(); URS = URS.GetUserScheduleRateByUserIdDate(Id, date); if (URS != null) { startTime = URS.StartTime == "" ? "08:00" : URS.StartTime; endTime = URS.EndTime == "" ? "17:00" : URS.EndTime; currentSalary = URS.GetMySalary(); currentOffDay = URS.OffDay; currentSpecialOffDay = URS.SpecialOffDay; currentOptOffDay1 = URS.OptionalOffDay1 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay1); currentOptOffDay2 = URS.OptionalOffDay2 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay2); currentOptOffDay3 = URS.OptionalOffDay3 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay3); currentOptOffDay4 = URS.OptionalOffDay4 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay4); noOTpay = URS.NoOTPay; currentMinBreak = URS.MinsBreak == null ? 0 : Convert.ToInt32(URS.MinsBreak); isOfficeWorker = URS.IsOfficeWorker == null ? false : Convert.ToBoolean(URS.IsOfficeWorker); currentRateStartDate = URS.StartDate; currentRateCreateDate = URS.CreatedDate == null ? DateTime.Today : Convert.ToDateTime(URS.CreatedDate); usePattern = URS.UsePattern == null ? false : Convert.ToBoolean(URS.UsePattern); offPattern = URS.OffPattern == null ? "" : URS.OffPattern.Trim(); patternStartDate = URS.PatternStartDate == null ? DateTime.Today : Convert.ToDateTime(URS.PatternStartDate); } else { startTime = "08:00"; endTime = "17:00"; currentSalary = 0; currentOffDay = 0; currentSpecialOffDay = 0; currentOptOffDay1 = 0; currentOptOffDay2 = 0; currentOptOffDay3 = 0; currentOptOffDay4 = 0; noOTpay = false; currentMinBreak = 0; isOfficeWorker = false; currentRateStartDate = DateTime.Today; currentRateCreateDate = DateTime.Today; usePattern = false; offPattern = ""; patternStartDate = DateTime.Today; } if (TimeSpan.Parse(startTime) > TimeSpan.Parse(endTime)) { shifting = true; } else { shifting = false; } TimeSpan stime = TimeSpan.Parse(startTime == "" ? "08:00" : startTime); TimeSpan etime = TimeSpan.Parse(endTime == "" ? "17:00" : endTime); if (stime > etime) { minsWorkPerDay = (int)Math.Floor(new TimeSpan(1,0,0,0).TotalMinutes - stime.TotalMinutes); minsWorkPerDay += (int)Math.Floor(etime.TotalMinutes); } else { minsWorkPerDay = (int)Math.Floor(etime.TotalMinutes - stime.TotalMinutes); } minsWorkPerDay -= currentMinBreak; }
private void GetMyRate() { UserRateSchedule URS = new UserRateSchedule(); URS = URS.GetCurrentUserScheduleRateByUserId(Id); if (URS != null) { startTime = URS.StartTime == "" ? "08:00" : URS.StartTime; endTime = URS.EndTime == "" ? "17:00" : URS.EndTime; currentSalary = URS.GetMySalary(); currentOffDay = URS.OffDay; currentSpecialOffDay = URS.SpecialOffDay; currentOptOffDay1 = URS.OptionalOffDay1 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay1); currentOptOffDay2 = URS.OptionalOffDay2 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay2); currentOptOffDay3 = URS.OptionalOffDay3 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay3); currentOptOffDay4 = URS.OptionalOffDay4 == null ? 0 : Convert.ToInt32(URS.OptionalOffDay4); noOTpay = URS.NoOTPay; currentMinBreak = URS.MinsBreak == null ? 0 : Convert.ToInt32(URS.MinsBreak); isOfficeWorker = URS.IsOfficeWorker == null ? false : Convert.ToBoolean(URS.IsOfficeWorker); currentRateStartDate = URS.StartDate; currentRateCreateDate = URS.CreatedDate == null ? DateTime.Today: Convert.ToDateTime(URS.CreatedDate); usePattern = URS.UsePattern == null ? false : Convert.ToBoolean(URS.UsePattern); offPattern = URS.OffPattern == null ? "" : URS.OffPattern.Trim(); patternStartDate = URS.PatternStartDate == null ? DateTime.Today : Convert.ToDateTime(URS.PatternStartDate); } else { startTime = "08:00"; endTime = "17:00"; currentSalary = 0; currentOffDay = 0; currentSpecialOffDay = 0; currentOptOffDay1 = 0; currentOptOffDay2 = 0; currentOptOffDay3 = 0; currentOptOffDay4 = 0; noOTpay = false; currentMinBreak = 0; isOfficeWorker = false; currentRateStartDate = DateTime.Today; currentRateCreateDate = DateTime.Today; usePattern = false; offPattern = ""; patternStartDate = DateTime.Today; } if (TimeSpan.Parse(startTime) > TimeSpan.Parse(endTime)) { shifting = true; } else { shifting = false; } }