Пример #1
0
        ///<summary>fromDB is set to false when it is refreshing every second so that there will be no extra network traffic.</summary>
        private void FillMain(bool fromDB)
        {
            if (fromDB)
            {
                ClockEventList = ClockEvents.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                     PIn.PDate(textDateStop.Text), false, IsBreaks);
                if (IsBreaks)
                {
                    TimeAdjustList = new TimeAdjust[0];
                }
                else
                {
                    TimeAdjustList = TimeAdjusts.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                         PIn.PDate(textDateStop.Text));
                }
            }
            mergedAL = new ArrayList();
            for (int i = 0; i < ClockEventList.Length; i++)
            {
                mergedAL.Add(ClockEventList[i]);
            }
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                mergedAL.Add(TimeAdjustList[i]);
            }
            IComparer myComparer = new ObjectDateComparer();

            mergedAL.Sort(myComparer);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Date"), 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekday"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Altered"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Status"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "In/Out"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Time"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            if (IsBreaks)
            {
                col = new ODGridColumn(Lan.g(this, "Minutes"), 50, HorizontalAlignment.Right);
            }
            else
            {
                col = new ODGridColumn(Lan.g(this, "Hours"), 50, HorizontalAlignment.Right);
            }
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Overtime"), 55, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Daily"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekly"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Note"), 5);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //TimeSpan weeklyTotalPrevious=
            WeeklyTotals = new TimeSpan[mergedAL.Count];
            TimeSpan   alteredSpan = new TimeSpan(0); //used to display altered times
            TimeSpan   pairSpan    = new TimeSpan(0); //used to sum one pair of clockevents
            ClockEvent pairFirst   = null;            //the first of a pair of clockevents
            TimeSpan   daySpan     = new TimeSpan(0); //used for daily totals.
            TimeSpan   weekSpan    = new TimeSpan(0); //used for weekly totals.

            if (mergedAL.Count > 0)
            {
                weekSpan = ClockEvents.GetWeekTotal(EmployeeCur.EmployeeNum, GetDateForRow(0));
            }
            //MessageBox.Show(weekSpan.TotalHours.ToString());
            TimeSpan         periodSpan   = new TimeSpan(0); //used to add up totals for entire page.
            TimeSpan         otspan       = new TimeSpan(0); //overtime for the entire period
            Calendar         cal          = CultureInfo.CurrentCulture.Calendar;
            CalendarWeekRule rule         = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
            DateTime         curDate      = DateTime.MinValue;
            DateTime         previousDate = DateTime.MinValue;
            Type             type;
            ClockEvent       clock;
            TimeAdjust       adjust;

            for (int i = 0; i < mergedAL.Count; i++)
            {
                row          = new ODGridRow();
                type         = mergedAL[i].GetType();
                row.Tag      = mergedAL[i];
                previousDate = curDate;
                //clock event row---------------------------------------------------------------------------------------------
                if (type == typeof(ClockEvent))
                {
                    clock   = (ClockEvent)mergedAL[i];
                    curDate = clock.TimeDisplayed.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    if (clock.TimeEntered != clock.TimeDisplayed)
                    {
                        alteredSpan = clock.TimeDisplayed - clock.TimeEntered;
                        if (IsBreaks)
                        {
                            row.Cells.Add(alteredSpan.TotalMinutes.ToString("n"));
                        }
                        else
                        {
                            row.Cells.Add(alteredSpan.TotalHours.ToString("n"));
                        }
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //status--------------------------------------
                    row.Cells.Add(clock.ClockStatus.ToString());
                    //in/out------------------------------------------
                    if (clock.ClockIn)
                    {
                        row.Cells.Add(Lan.g(this, "In"));
                    }
                    else
                    {
                        row.Cells.Add(Lan.g(this, "Out"));
                    }
                    //time-----------------------------
                    row.Cells.Add(clock.TimeDisplayed.ToShortTimeString());
                    //minutes or hours-------------------------------
                    if (IsBreaks)                     //breaks
                    {
                        if (!clock.ClockIn)           //clocking out
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking in
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                                //weekSpan+=pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    else                     //regular hours
                    {
                        if (clock.ClockIn)   //clocking in
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking out
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalHours.ToString("n"));
                                daySpan    += pairSpan;
                                weekSpan   += pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    //Overtime------------------------------
                    row.Cells.Add("");
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        if (IsBreaks)
                        {
                            if (!clock.ClockIn)                            //if they have not clocked back in yet from break
                            //display the timespan of pairSpan using current time as the other number.
                            {
                                pairSpan = DateTime.Now - clock.TimeDisplayed + TimeDelta;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                            }
                            else
                            {
                                row.Cells.Add(daySpan.TotalMinutes.ToString("n"));
                            }
                        }
                        else
                        {
                            row.Cells.Add(daySpan.TotalHours.ToString("n"));
                        }
                        daySpan = new TimeSpan(0);
                    }
                    else                     //not the last entry for the day
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(clock.TimeDisplayed.Date, rule, DayOfWeek.Sunday))          //different week of year
                    {
                        row.Cells.Add(weekSpan.TotalHours.ToString("n"));
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(clock.Note);
                }
                //adjustment row--------------------------------------------------------------------------------------
                else if (type == typeof(TimeAdjust))
                {
                    adjust  = (TimeAdjust)mergedAL[i];
                    curDate = adjust.TimeEntry.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    row.Cells.Add("");                    //2
                    //status--------------------------------------
                    row.Cells.Add(Lan.g(this, "Adjust")); //3
                    row.ColorText = Color.Red;
                    //in/out------------------------------------------
                    row.Cells.Add("");                                   //4
                    //time-----------------------------
                    row.Cells.Add(adjust.TimeEntry.ToShortTimeString()); //5
                    //minutes or hours-------------------------------
                    if (adjust.RegHours.TotalHours == 0)
                    {
                        row.Cells.Add("");                        //6
                    }
                    else
                    {
                        daySpan    += adjust.RegHours;                   //might be negative
                        weekSpan   += adjust.RegHours;
                        periodSpan += adjust.RegHours;
                        row.Cells.Add(adjust.RegHours.TotalHours.ToString("n"));                        //6
                    }
                    //Overtime------------------------------
                    if (adjust.OTimeHours.TotalHours != 0)
                    {
                        otspan += adjust.OTimeHours;
                        row.Cells.Add(adjust.OTimeHours.TotalHours.ToString("n"));                        //7
                    }
                    else
                    {
                        row.Cells.Add("");                        //7
                    }
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        row.Cells.Add(daySpan.TotalHours.ToString("n"));         //8
                        daySpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(adjust.TimeEntry.Date, rule, DayOfWeek.Sunday))             //different week of year
                    {
                        ODGridCell cell = new ODGridCell(weekSpan.TotalHours.ToString("n"));
                        cell.ColorText = Color.Black;
                        row.Cells.Add(cell);
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(adjust.Note);
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            if (IsBreaks)
            {
                textTotal.Text = "";
            }
            else
            {
                textTotal.Text    = periodSpan.TotalHours.ToString("n");
                textOvertime.Text = otspan.TotalHours.ToString("n");
            }
        }
Пример #2
0
 ///<summary>fromDB is set to false when it is refreshing every second so that there will be no extra network traffic.</summary>
 private void FillMain(bool fromDB)
 {
     if(fromDB){
         ClockEventList=ClockEvents.Refresh(EmployeeCur.EmployeeNum,PIn.Date(textDateStart.Text),
             PIn.Date(textDateStop.Text),IsBreaks);
         if(IsBreaks){
             TimeAdjustList=new List<TimeAdjust>();
         }
         else{
             TimeAdjustList=TimeAdjusts.Refresh(EmployeeCur.EmployeeNum,PIn.Date(textDateStart.Text),
                 PIn.Date(textDateStop.Text));
         }
     }
     mergedAL=new ArrayList();
     for(int i=0;i<ClockEventList.Count;i++) {
         mergedAL.Add(ClockEventList[i]);
     }
     for(int i=0;i<TimeAdjustList.Count;i++) {
         mergedAL.Add(TimeAdjustList[i]);
     }
     IComparer myComparer=new ObjectDateComparer();
     mergedAL.Sort(myComparer);
     gridMain.BeginUpdate();
     gridMain.Columns.Clear();
     ODGridColumn col=new ODGridColumn(Lan.g(this,"Date"),70);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Weekday"),70);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Altered"),50,HorizontalAlignment.Center);
     gridMain.Columns.Add(col);
     if(IsBreaks){
         col=new ODGridColumn(Lan.g(this,"Out"),60,HorizontalAlignment.Right);
         gridMain.Columns.Add(col);
         col=new ODGridColumn(Lan.g(this,"In"),60,HorizontalAlignment.Right);
         gridMain.Columns.Add(col);
     }
     else{
         col=new ODGridColumn(Lan.g(this,"In"),60,HorizontalAlignment.Right);
         gridMain.Columns.Add(col);
         col=new ODGridColumn(Lan.g(this,"Out"),60,HorizontalAlignment.Right);
         gridMain.Columns.Add(col);
     }
     col=new ODGridColumn(Lan.g(this,"Total"),50,HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Adjust"),55,HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Overtime"),55,HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Daily"),50,HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Weekly"),50,HorizontalAlignment.Right);
     gridMain.Columns.Add(col);
     col=new ODGridColumn(Lan.g(this,"Note"),5);
     gridMain.Columns.Add(col);
     gridMain.Rows.Clear();
     ODGridRow row;
     WeeklyTotals=new TimeSpan[mergedAL.Count];
     TimeSpan alteredSpan=new TimeSpan(0);//used to display altered times
     TimeSpan oneSpan=new TimeSpan(0);//used to sum one pair of clock-in/clock-out
     TimeSpan oneAdj;
     TimeSpan oneOT;
     TimeSpan daySpan=new TimeSpan(0);//used for daily totals.
     TimeSpan weekSpan=new TimeSpan(0);//used for weekly totals.
     if(mergedAL.Count>0){
         weekSpan=ClockEvents.GetWeekTotal(EmployeeCur.EmployeeNum,GetDateForRow(0));
     }
     TimeSpan periodSpan=new TimeSpan(0);//used to add up totals for entire page.
     TimeSpan otspan=new TimeSpan(0);//overtime for the entire period
       Calendar cal=CultureInfo.CurrentCulture.Calendar;
     CalendarWeekRule rule=CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
     DateTime curDate=DateTime.MinValue;
     DateTime previousDate=DateTime.MinValue;
     Type type;
     ClockEvent clock;
     TimeAdjust adjust;
     for(int i=0;i<mergedAL.Count;i++){
         row=new ODGridRow();
         type=mergedAL[i].GetType();
         row.Tag=mergedAL[i];
         previousDate=curDate;
         //clock event row---------------------------------------------------------------------------------------------
         if(type==typeof(ClockEvent)){
             clock=(ClockEvent)mergedAL[i];
             curDate=clock.TimeDisplayed1.Date;
             if(curDate==previousDate){
                 row.Cells.Add("");
                 row.Cells.Add("");
             }
             else{
                 row.Cells.Add(curDate.ToShortDateString());
                 row.Cells.Add(curDate.DayOfWeek.ToString());
             }
             //altered--------------------------------------
             string str="";
             if(clock.TimeEntered1!=clock.TimeDisplayed1){
                 if(IsBreaks){
                     str=Lan.g(this,"out");
                 }
                 else{
                     str=Lan.g(this,"in");
                 }
             }
             if(clock.TimeEntered2!=clock.TimeDisplayed2){
                 if(str!="") {
                     str+="/";
                 }
                 if(IsBreaks){
                     str+=Lan.g(this,"in");
                 }
                 else{
                     str+=Lan.g(this,"out");
                 }
             }
             row.Cells.Add(str);
             //status--------------------------------------
             //row.Cells.Add(clock.ClockStatus.ToString());
             //in------------------------------------------
             row.Cells.Add(clock.TimeDisplayed1.ToShortTimeString());
             //out-----------------------------
             if(clock.TimeDisplayed2.Year<1880){
                 row.Cells.Add("");//not clocked out yet
             }
             else{
                 row.Cells.Add(clock.TimeDisplayed2.ToShortTimeString());
             }
             //total-------------------------------
             if(IsBreaks){ //breaks
                 if(clock.TimeDisplayed2.Year<1880){
                     row.Cells.Add("");
                 }
                 else{
                     oneSpan=clock.TimeDisplayed2-clock.TimeDisplayed1;
                     row.Cells.Add(ClockEvents.Format(oneSpan));
                     daySpan+=oneSpan;
                     periodSpan+=oneSpan;
                 }
             }
             else{//regular hours
                 if(clock.TimeDisplayed2.Year<1880){
                     row.Cells.Add("");
                 }
                 else{
                     oneSpan=clock.TimeDisplayed2-clock.TimeDisplayed1;
                     row.Cells.Add(ClockEvents.Format(oneSpan));
                     daySpan+=oneSpan;
                     weekSpan+=oneSpan;
                     periodSpan+=oneSpan;
                 }
             }
             //Adjust---------------------------------
             oneAdj=TimeSpan.Zero;
             if(clock.AdjustIsOverridden) {
                 oneAdj+=clock.Adjust;
             }
             else {
                 oneAdj+=clock.AdjustAuto;//typically zero
             }
             daySpan+=oneAdj;
             weekSpan+=oneAdj;
             periodSpan+=oneAdj;
             row.Cells.Add(ClockEvents.Format(oneAdj));
             //Overtime------------------------------
             oneOT=TimeSpan.Zero;
             if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
                 oneOT=clock.OTimeHours;
             }
             else {
                 oneOT=clock.OTimeAuto;//typically zero
             }
             otspan+=oneOT;
             daySpan-=oneOT;
             weekSpan-=oneOT;
             periodSpan-=oneOT;
             row.Cells.Add(ClockEvents.Format(oneOT));
             //Daily-----------------------------------
             //if this is the last entry for a given date
             if(i==mergedAL.Count-1//if this is the last row
                 || GetDateForRow(i+1) != curDate)//or the next row is a different date
             {
                 if(IsBreaks){
                     if(clock.TimeDisplayed2.Year<1880){//if they have not clocked back in yet from break
                         //display the timespan of oneSpan using current time as the other number.
                         oneSpan=DateTime.Now-clock.TimeDisplayed1+TimeDelta;
                         row.Cells.Add(oneSpan.ToStringHmmss());
                         daySpan+=oneSpan;
                     }
                     else{
                         row.Cells.Add(ClockEvents.Format(daySpan));
                     }
                 }
                 else{
                     row.Cells.Add(ClockEvents.Format(daySpan));
                 }
                 daySpan=new TimeSpan(0);
             }
             else{//not the last entry for the day
                 row.Cells.Add("");
             }
             //Weekly-------------------------------------
             WeeklyTotals[i]=weekSpan;
             if(IsBreaks){
                 row.Cells.Add("");
             }
             //if this is the last entry for a given week
             else if(i==mergedAL.Count-1//if this is the last row
                 || cal.GetWeekOfYear(GetDateForRow(i+1),rule,DayOfWeek.Sunday)//or the next row has a
                 != cal.GetWeekOfYear(clock.TimeDisplayed1.Date,rule,DayOfWeek.Sunday))//different week of year
             {
                 row.Cells.Add(ClockEvents.Format(weekSpan));
                 weekSpan=new TimeSpan(0);
             }
             else {
                 //row.Cells.Add(ClockEvents.Format(weekSpan));
                 row.Cells.Add("");
             }
             //Note-----------------------------------------
             row.Cells.Add(clock.Note);
         }
         //adjustment row--------------------------------------------------------------------------------------
         else if(type==typeof(TimeAdjust)){
             adjust=(TimeAdjust)mergedAL[i];
             curDate=adjust.TimeEntry.Date;
             if(curDate==previousDate){
                 row.Cells.Add("");
                 row.Cells.Add("");
             }
             else{
                 row.Cells.Add(curDate.ToShortDateString());
                 row.Cells.Add(curDate.DayOfWeek.ToString());
             }
             //altered--------------------------------------
             row.Cells.Add(Lan.g(this,"Adjust"));//2
             row.ColorText=Color.Red;
             //status--------------------------------------
             //row.Cells.Add("");//3
             //in/out------------------------------------------
             row.Cells.Add("");//4
             //time-----------------------------
             row.Cells.Add(adjust.TimeEntry.ToShortTimeString());//5
             //total-------------------------------
             row.Cells.Add("");//
             //Adjust------------------------------
             daySpan+=adjust.RegHours;//might be negative
             weekSpan+=adjust.RegHours;
             periodSpan+=adjust.RegHours;
             row.Cells.Add(ClockEvents.Format(adjust.RegHours));//6
             //Overtime------------------------------
             otspan+=adjust.OTimeHours;
             row.Cells.Add(ClockEvents.Format(adjust.OTimeHours));//7
             //Daily-----------------------------------
             //if this is the last entry for a given date
             if(i==mergedAL.Count-1//if this is the last row
                 || GetDateForRow(i+1) != curDate)//or the next row is a different date
             {
                 row.Cells.Add(ClockEvents.Format(daySpan));//
                 daySpan=new TimeSpan(0);
             }
             else{
                 row.Cells.Add("");
             }
             //Weekly-------------------------------------
             WeeklyTotals[i]=weekSpan;
             if(IsBreaks){
                 row.Cells.Add("");
             }
             //if this is the last entry for a given week
             else if(i==mergedAL.Count-1//if this is the last row
                 || cal.GetWeekOfYear(GetDateForRow(i+1),rule,DayOfWeek.Sunday)//or the next row has a
                 != cal.GetWeekOfYear(adjust.TimeEntry.Date,rule,DayOfWeek.Sunday))//different week of year
             {
                 ODGridCell cell=new ODGridCell(ClockEvents.Format(weekSpan));
                 cell.ColorText=Color.Black;
                 row.Cells.Add(cell);
                 weekSpan=new TimeSpan(0);
             }
             else {
                 row.Cells.Add("");
             }
             //Note-----------------------------------------
             row.Cells.Add(adjust.Note);
         }
         gridMain.Rows.Add(row);
     }
     gridMain.EndUpdate();
     if(IsBreaks){
         textTotal.Text="";
     }
     else{
         textTotal.Text=periodSpan.ToStringHmm();
         textOvertime.Text=otspan.ToStringHmm();
         textTotal2.Text=periodSpan.TotalHours.ToString("n");
         textOvertime2.Text=otspan.TotalHours.ToString("n");
     }
 }
Пример #3
0
		///<summary>This is a modified version of FormTimeCard.FillMain().  It fills one time card per employee.</summary>
		private ODGrid GetGridForPrinting(Employee emp) {
			ODGrid gridTimeCard=new ODGrid();
			List<ClockEvent> clockEventList=ClockEvents.Refresh(emp.EmployeeNum,PIn.Date(textDateStart.Text),PIn.Date(textDateStop.Text),false);
			List<TimeAdjust> timeAdjustList=TimeAdjusts.Refresh(emp.EmployeeNum,PIn.Date(textDateStart.Text),PIn.Date(textDateStop.Text));
			ArrayList mergedAL=new ArrayList();
			for(int i=0;i<clockEventList.Count;i++) {
				mergedAL.Add(clockEventList[i]);
			}
			for(int i=0;i<timeAdjustList.Count;i++) {
				mergedAL.Add(timeAdjustList[i]);
			}
			IComparer myComparer=new ObjectDateComparer();
			mergedAL.Sort(myComparer);
			gridTimeCard.BeginUpdate();
			gridTimeCard.Columns.Clear();
			ODGridColumn col=new ODGridColumn(Lan.g(this,"Date"),70);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Weekday"),70);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"In"),60,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Out"),60,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Total"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Adjust"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Rate2"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Overtime"),55,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Daily"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Weekly"),50,HorizontalAlignment.Right);
			gridTimeCard.Columns.Add(col);
			col=new ODGridColumn(Lan.g(this,"Note"),5);
			gridTimeCard.Columns.Add(col);
			gridTimeCard.Rows.Clear();
			ODGridRow row;
			TimeSpan[] weeklyTotals=new TimeSpan[mergedAL.Count];
			TimeSpan alteredSpan=new TimeSpan(0);//used to display altered times
			TimeSpan oneSpan=new TimeSpan(0);//used to sum one pair of clock-in/clock-out
			TimeSpan oneAdj;
			TimeSpan oneOT;
			TimeSpan daySpan=new TimeSpan(0);//used for daily totals.
			TimeSpan weekSpan=new TimeSpan(0);//used for weekly totals.
			if(mergedAL.Count>0){
				weekSpan=ClockEvents.GetWeekTotal(emp.EmployeeNum,GetDateForRow(0,mergedAL));
			}
			TimeSpan periodSpan=new TimeSpan(0);//used to add up totals for entire page.
			TimeSpan otspan=new TimeSpan(0);//overtime for the entire period
			TimeSpan rate2span=new TimeSpan(0);//rate2 hours total
			Calendar cal=CultureInfo.CurrentCulture.Calendar;
			CalendarWeekRule rule=CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
			DateTime curDate=DateTime.MinValue;
			DateTime previousDate=DateTime.MinValue;
			Type type;
			ClockEvent clock;
			TimeAdjust adjust;
			for(int i=0;i<mergedAL.Count;i++){
				row=new ODGridRow();
				type=mergedAL[i].GetType();
				row.Tag=mergedAL[i];
				previousDate=curDate;
				//clock event row---------------------------------------------------------------------------------------------
				if(type==typeof(ClockEvent)){
					clock=(ClockEvent)mergedAL[i];
					curDate=clock.TimeDisplayed1.Date;
					if(curDate==previousDate){
						row.Cells.Add("");
						row.Cells.Add("");
					}
					else{
						row.Cells.Add(curDate.ToShortDateString());
						row.Cells.Add(curDate.DayOfWeek.ToString());
					}
					//altered--------------------------------------
					//deprecated
					//status--------------------------------------
					//row.Cells.Add(clock.ClockStatus.ToString());
					//in------------------------------------------
					row.Cells.Add(clock.TimeDisplayed1.ToShortTimeString());
					if(clock.TimeEntered1!=clock.TimeDisplayed1){
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//out-----------------------------
					if(clock.TimeDisplayed2.Year<1880){
						row.Cells.Add("");//not clocked out yet
					}
					else{
						row.Cells.Add(clock.TimeDisplayed2.ToShortTimeString());
						if (clock.TimeEntered2!=clock.TimeDisplayed2)
						{
							row.Cells[row.Cells.Count-1].ColorText = Color.Red;
						}
					}
					//total-------------------------------
					if(clock.TimeDisplayed2.Year<1880){
						row.Cells.Add("");
					}
					else{
						oneSpan=clock.TimeDisplayed2-clock.TimeDisplayed1;
						row.Cells.Add(ClockEvents.Format(oneSpan));
						daySpan+=oneSpan;
						weekSpan+=oneSpan;
						periodSpan+=oneSpan;
					}
					//Adjust---------------------------------
					oneAdj=TimeSpan.Zero;
					if(clock.AdjustIsOverridden) {
						oneAdj+=clock.Adjust;
					}
					else {
						oneAdj+=clock.AdjustAuto;//typically zero
					}
					daySpan+=oneAdj;
					weekSpan+=oneAdj;
					periodSpan+=oneAdj;
					row.Cells.Add(ClockEvents.Format(oneAdj));
					if(clock.AdjustIsOverridden) {
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//Rate2---------------------------------
					if(clock.Rate2Hours!=TimeSpan.FromHours(-1)) {
						rate2span+=clock.Rate2Hours;
						row.Cells.Add(ClockEvents.Format(clock.Rate2Hours));
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					else {
						rate2span+=clock.Rate2Auto;
						row.Cells.Add(ClockEvents.Format(clock.Rate2Auto));
					}
					//Overtime------------------------------
					oneOT=TimeSpan.Zero;
					if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
						oneOT=clock.OTimeHours;
					}
					else {
						oneOT=clock.OTimeAuto;//typically zero
					}
					otspan+=oneOT;
					daySpan-=oneOT;
					weekSpan-=oneOT;
					periodSpan-=oneOT;
					row.Cells.Add(ClockEvents.Format(oneOT));
					if(clock.OTimeHours!=TimeSpan.FromHours(-1)) {//overridden
						row.Cells[row.Cells.Count-1].ColorText = Color.Red;
					}
					//Daily-----------------------------------
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));
						daySpan=new TimeSpan(0);
					}
					else{//not the last entry for the day
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(clock.TimeDisplayed1.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						row.Cells.Add(ClockEvents.Format(weekSpan));
						weekSpan=new TimeSpan(0);
					}
					else {
						//row.Cells.Add(ClockEvents.Format(weekSpan));
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add(clock.Note);
				}
				//adjustment row--------------------------------------------------------------------------------------
				else if(type==typeof(TimeAdjust)){
					adjust=(TimeAdjust)mergedAL[i];
					curDate=adjust.TimeEntry.Date;
					if(curDate==previousDate){
						row.Cells.Add("");
						row.Cells.Add("");
					}
					else{
						row.Cells.Add(curDate.ToShortDateString());
						row.Cells.Add(curDate.DayOfWeek.ToString());
					}
					//altered--------------------------------------
					//Deprecated
					//status--------------------------------------
					//row.Cells.Add("");//3
					//in/out------------------------------------------
					row.Cells.Add("");//4
					//time-----------------------------
					row.Cells.Add(adjust.TimeEntry.ToShortTimeString());//5
					//total-------------------------------
					row.Cells.Add("");//
					//Adjust------------------------------
					daySpan+=adjust.RegHours;//might be negative
					weekSpan+=adjust.RegHours;
					periodSpan+=adjust.RegHours;
					row.Cells.Add(ClockEvents.Format(adjust.RegHours));//6
					//Rate2-------------------------------
					row.Cells.Add("");//
					//Overtime------------------------------
					otspan+=adjust.OTimeHours;
					row.Cells.Add(ClockEvents.Format(adjust.OTimeHours));//7
					//Daily-----------------------------------
					//if this is the last entry for a given date
					if(i==mergedAL.Count-1//if this is the last row
						|| GetDateForRow(i+1,mergedAL) != curDate)//or the next row is a different date
					{
						row.Cells.Add(ClockEvents.Format(daySpan));//
						daySpan=new TimeSpan(0);
					}
					else{
						row.Cells.Add("");
					}
					//Weekly-------------------------------------
					weeklyTotals[i]=weekSpan;
					//if this is the last entry for a given week
					if(i==mergedAL.Count-1//if this is the last row 
						|| cal.GetWeekOfYear(GetDateForRow(i+1,mergedAL),rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek))//or the next row has a
						!= cal.GetWeekOfYear(adjust.TimeEntry.Date,rule,(DayOfWeek)PrefC.GetInt(PrefName.TimeCardOvertimeFirstDayOfWeek)))//different week of year
					{
						ODGridCell cell=new ODGridCell(ClockEvents.Format(weekSpan));
						cell.ColorText=Color.Black;
						row.Cells.Add(cell);
						weekSpan=new TimeSpan(0);
					}
					else {
						row.Cells.Add("");
					}
					//Note-----------------------------------------
					row.Cells.Add("(Adjust)"+adjust.Note);//used to indicate adjust rows.
					row.Cells[row.Cells.Count-1].ColorText=Color.Red;
				}
				gridTimeCard.Rows.Add(row);
			}
			gridTimeCard.EndUpdate();
			totalTime=periodSpan.ToStringHmm();
			overTime=otspan.ToStringHmm();
			rate2Time=rate2span.ToStringHmm();
			totalTime2=periodSpan.TotalHours.ToString("n");
			overTime2=otspan.TotalHours.ToString("n");
			rate2Time2=rate2span.TotalHours.ToString("n");
			return gridTimeCard;
		}