コード例 #1
0
 private void loadDefaultValues()
 {
     dtpPeriodStart.Value = DateTime.Today;
     dtpPeriodEnd.Value   = DateTime.Today;
     txtMemberID.Text     = ConfigSettings.GetValue("memberid");
     txtStartTime.Text    = ConfigSettings.GetValue("starttime");
     txtEndTime.Text      = ConfigSettings.GetValue("endtime");
     txtAdminCode.Text    = ConfigSettings.GetValue("adminchargecode");
     txtLunch.Text        = ConfigSettings.GetValue("lunchdeduct");
     chkDone.Checked      = ConversionUtils.GetBoolean(ConfigSettings.GetValue("markschedulesdone"));
     firstLogin           = ConversionUtils.GetBoolean(ConfigSettings.GetValue("firstlogin"));
 }
コード例 #2
0
        public void CreateAdminTimeToFillGaps(DateTime startDate, DateTime endDate, string maxStart, string minEnd, string lunchDeduction, List <TimeEntry> timeEntries, string memberID, ChargeTo chargeTo)
        {
            var    currentDate  = startDate.ToLocalTime();
            var    localEndDate = endDate.ToLocalTime();
            var    start        = maxStart.Split(':');
            var    end          = minEnd.Split(':');
            var    lunch        = lunchDeduction.Split(':');
            double lunchDeduct  = Math.Round(ConversionUtils.GetInt(lunch[0]) + ConversionUtils.GetInt(lunch[1]) / 60.00, 2);
            var    startHour    = ConversionUtils.GetInt(start[0]);
            var    startMin     = start.Length > 1 ? ConversionUtils.GetInt(start[1]) : 0;
            var    endHour      = ConversionUtils.GetInt(end[0]);

            if (endHour < 12)
            {
                endHour += 12;
            }
            var endMin = end.Length > 1 ? ConversionUtils.GetInt(end[1]) : 0;

            while (currentDate <= localEndDate)
            {
                var    startTime  = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, startHour, startMin, 0).ToUniversalTime();
                var    endTime    = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, endHour, endMin, 0).ToUniversalTime();
                double totalHours = lunchDeduct;
                var    todayTime  = timeEntries.Where(t => t.TimeStart.Value.ToLocalTime().Date == currentDate.Date).ToList();
                foreach (var timeEntry in todayTime)
                {
                    if (timeEntry.TimeStart.Value < startTime)
                    {
                        startTime = timeEntry.TimeStart.Value;
                    }
                    if (timeEntry.TimeEnd.Value > endTime)
                    {
                        endTime = timeEntry.TimeEnd.Value;
                    }

                    totalHours += timeEntry.ActualHours.Value;
                }

                var maxHours = ConversionUtils.GetDouble(endTime.Subtract(startTime).TotalHours, 2);
                if (totalHours < maxHours)
                {
                    addNewTimeEntry(startTime, endTime, totalHours, memberID, chargeTo);
                }

                currentDate = currentDate.AddDays(1);
            }
        }
コード例 #3
0
        private int getAndCacheChargeCodeId(string adminChargeCode)
        {
            var adminChargeCodeId = ConversionUtils.GetInt(ConfigSettings.GetValue("adminchargecodeid"));

            if (adminChargeCodeId == 0 && !string.IsNullOrEmpty(adminChargeCode))
            {
                raiseProgressEvent("Getting chargecode recid...");
                adminChargeCodeId = api.GetChargeCodeRecIDFromChargeCode(adminChargeCode);
                if (adminChargeCodeId <= 0)
                {
                    throw new ApplicationException("Invalid charge code entered.");
                }

                ConfigSettings.SetValue("adminchargecodeid", adminChargeCodeId.ToString());
                ConfigSettings.Save();
            }

            return(adminChargeCodeId);
        }