Example #1
0
 private void FormClockEventEdit_Load(object sender, System.EventArgs e)
 {
     if (!Security.IsAuthorized(Permissions.TimecardDeleteEntry, ClockEventCur.TimeEntered1, true))
     {
         butDelete.Enabled = false;
         butClear.Enabled  = false;
         butNow1.Enabled   = false;
         butNow2.Enabled   = false;
     }
     if (ClockEventCur.ClockStatus == TimeClockStatus.Break)
     {
         groupBox1.Text         = Lan.g(this, "Clock Out Date and Time");
         groupBox2.Text         = Lan.g(this, "Clock In Date and Time");
         groupTimeSpans.Visible = false;
     }
     textTimeEntered1.Text   = ClockEventCur.TimeEntered1.ToString();
     textTimeDisplayed1.Text = ClockEventCur.TimeDisplayed1.ToString();
     if (ClockEventCur.TimeEntered2.Year > 1880)
     {
         textTimeEntered2.Text = ClockEventCur.TimeEntered2.ToString();
     }
     if (ClockEventCur.TimeDisplayed2.Year > 1880)
     {
         textTimeDisplayed2.Text = ClockEventCur.TimeDisplayed2.ToString();
     }
     listStatus.Items.Clear();
     for (int i = 0; i < Enum.GetNames(typeof(TimeClockStatus)).Length; i++)
     {
         listStatus.Items.Add(Lan.g("enumTimeClockStatus", Enum.GetNames(typeof(TimeClockStatus))[i]));
     }
     listStatus.SelectedIndex = (int)ClockEventCur.ClockStatus;          //all clockevents have a status
     textAdjustAuto.Text      = ClockEvents.Format(ClockEventCur.AdjustAuto);
     if (ClockEventCur.AdjustIsOverridden)
     {
         if (ClockEventCur.Adjust == TimeSpan.Zero)
         {
             textAdjust.Text = "0";
         }
         else
         {
             textAdjust.Text = ClockEvents.Format(ClockEventCur.Adjust);
         }
     }
     else
     {
         textAdjust.Text = "";
     }
     textOTimeAuto.Text = ClockEvents.Format(ClockEventCur.OTimeAuto);
     if (ClockEventCur.OTimeHours == TimeSpan.FromHours(-1))           //no override
     {
         textOTimeHours.Text = "";
     }
     else
     {
         textOTimeHours.Text = ClockEvents.Format(ClockEventCur.OTimeHours);
     }
     textNote.Text = ClockEventCur.Note;
 }
Example #2
0
        private void FormTimeAdjustEdit_Load(object sender, System.EventArgs e)
        {
            if (TimeAdjustCur.IsAuto)
            {
                radioAuto.Checked = true;
            }
            else
            {
                radioManual.Checked = true;
            }
            textTimeEntry.Text = TimeAdjustCur.TimeEntry.ToString();
            if (TimeAdjustCur.OTimeHours.TotalHours == 0)
            {
                if (TimeAdjustCur.PtoDefNum == 0)
                {
                    textHours.Text = ClockEvents.Format(TimeAdjustCur.RegHours);
                }
                else                  //Is PTO
                {
                    textHours.Text = ClockEvents.Format(TimeAdjustCur.PtoHours);
                }
            }
            else
            {
                checkOvertime.Checked = true;
                textHours.Text        = ClockEvents.Format(TimeAdjustCur.OTimeHours);
            }
            textNote.Text = TimeAdjustCur.Note;
            comboPTO.Items.Clear();
            comboPTO.Items.Add(Lan.g(this, "None"));
            comboPTO.SelectedIndex = 0;
            List <Def> listPtoTypes = Defs.GetDefsForCategory(DefCat.TimeCardAdjTypes).OrderBy(x => x.ItemName).ToList();

            foreach (Def def in listPtoTypes)
            {
                if (def.IsHidden && def.DefNum == TimeAdjustCur.PtoDefNum)
                {
                    comboPTO.Items.Add(new ODBoxItem <Def>(def.ItemName + " " + Lan.g(this, "(hidden)"), def));
                }
                else if (!def.IsHidden)
                {
                    comboPTO.Items.Add(new ODBoxItem <Def>(def.ItemName, def));
                }
                if (def.DefNum == TimeAdjustCur.PtoDefNum)
                {
                    comboPTO.SelectedIndex = comboPTO.Items.Count - 1;
                }
            }
        }
Example #3
0
 private void FormTimeAdjustEdit_Load(object sender, System.EventArgs e)
 {
     if (TimeAdjustCur.IsAuto)
     {
         radioAuto.Checked = true;
     }
     else
     {
         radioManual.Checked = true;
     }
     textTimeEntry.Text = TimeAdjustCur.TimeEntry.ToString();
     if (TimeAdjustCur.OTimeHours.TotalHours == 0)
     {
         textHours.Text = ClockEvents.Format(TimeAdjustCur.RegHours);
     }
     else
     {
         checkOvertime.Checked = true;
         textHours.Text        = ClockEvents.Format(TimeAdjustCur.OTimeHours);
     }
     textNote.Text = TimeAdjustCur.Note;
 }
Example #4
0
        ///<summary>Does not alter the overrides, but only the auto calc boxes.  Triggered by many things on this form.  It's better to have it be triggered too frequently than to miss something.</summary>
        private void FillTimeSpans()
        {
            if (ClockEventCur.ClockStatus == TimeClockStatus.Break)          //TimeSpans not showing
            {
                return;
            }
            if (textTimeEntered2.Text == "" || textTimeDisplayed2.Text == "")
            {
                textTotalTime.Text = "";
                textRegTime.Text   = "";
                return;
            }
            try{
                DateTime.Parse(textTimeDisplayed1.Text); //because this must always be valid
                DateTime.Parse(textTimeDisplayed2.Text); //this must also be filled in order to calculate timespans
            }
            catch {                                      //an invalid date/time.
                //textTotalTime.Text="";
                //textRegTime.Text="";
                return;
            }
            DateTime dt1 = DateTime.Parse(textTimeDisplayed1.Text);
            DateTime dt2 = DateTime.Parse(textTimeDisplayed2.Text);

            if (dt1 > dt2)
            {
                return;
            }
            TimeSpan totalTime = dt2 - dt1;

            textTotalTime.Text = ClockEvents.Format(totalTime);
            TimeSpan overtime = ClockEventCur.OTimeAuto;

            if (textOTimeHours.Text != "")
            {
                try {
                    if (textOTimeHours.Text.Contains(":"))
                    {
                        overtime = TimeSpan.Parse(textOTimeHours.Text);
                    }
                    else
                    {
                        overtime = TimeSpan.FromHours(Double.Parse(textOTimeHours.Text));
                    }
                }
                catch {
                    return;
                }
            }
            TimeSpan adjust = ClockEventCur.AdjustAuto;

            if (textAdjust.Text != "")
            {
                try {
                    if (textAdjust.Text.Contains(":"))
                    {
                        adjust = TimeSpan.Parse(textAdjust.Text);
                    }
                    else
                    {
                        adjust = TimeSpan.FromHours(Double.Parse(textAdjust.Text));
                    }
                }
                catch {
                    return;
                }
            }
            TimeSpan regTime = totalTime - overtime + adjust;      //adjust is typically a negative value

            if (regTime < TimeSpan.Zero)
            {
                textRegTime.Text = "";
                return;
            }
            textRegTime.Text = ClockEvents.Format(regTime);
        }