///<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"); } }
private void FillCustomerTab() { FillCustomerViewsGrid(); if(PatCur==null) { gridCustomerViews.Enabled=false; listCommonProcs.Enabled=false; labelMonth1.Text=""; labelMonth2.Text=""; labelMonth3.Text=""; } else { //Monthly call time breakdown. DateTime startDate=new DateTime(1,1,1); Procedure firstProc=Procedures.GetFirstCompletedProcForFamily(PatCur.Guarantor); if(firstProc!=null) { startDate=firstProc.ProcDate; } DateTime month0=DateTime.Now; DateTime month1=DateTime.Now.AddMonths(-1); DateTime month2=DateTime.Now.AddMonths(-2); DateTime month3=DateTime.Now.AddMonths(-3); //Set the month labels. labelMonth0.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month0.Month); labelMonth1.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month1.Month); labelMonth2.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month2.Month); labelMonth3.Text=CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(month3.Month); List<Commlog> commlogsList=Commlogs.GetTimedCommlogsForPat(PatCur.Guarantor); TimeSpan month0Span=new TimeSpan(); TimeSpan month1Span=new TimeSpan(); TimeSpan month2Span=new TimeSpan(); TimeSpan month3Span=new TimeSpan(); TimeSpan totalSpan=new TimeSpan(); int avgCount=0; bool addToAvg=true; //Add up the length of time each call took within the corresponding month. for(int i=0;i<commlogsList.Count;i++) { DateTime tempDateTime=commlogsList[i].CommDateTime; DateTime tempTimeEnd=commlogsList[i].DateTimeEnd; TimeSpan tempSpan=tempTimeEnd-tempDateTime; if(tempDateTime.Year==month0.Year && tempDateTime.Month==month0.Month) { month0Span=month0Span.Add(tempSpan); addToAvg=false;//Avg should not include this months numbers. } else if(tempDateTime.Year==month1.Year && tempDateTime.Month==month1.Month) { month1Span=month1Span.Add(tempSpan); } else if(tempDateTime.Year==month2.Year && tempDateTime.Month==month2.Month) { month2Span=month2Span.Add(tempSpan); } else if(tempDateTime.Year==month3.Year && tempDateTime.Month==month3.Month) { month3Span=month3Span.Add(tempSpan); } //Take current commlog and see if its greater than or equal to two months after first completed proc date. if(new DateTime(tempDateTime.Year,tempDateTime.Month,1)>=new DateTime(startDate.AddMonths(2).Year,startDate.AddMonths(2).Month,1) && addToAvg) { totalSpan=totalSpan.Add(tempSpan); avgCount++; } addToAvg=true; } if(month0Span.Hours>=3) { textMonth0.BackColor=Color.Red; textMonth0.ForeColor=Color.White; textMonth0.Font=new Font(textMonth1.Font,FontStyle.Bold); } else { textMonth0.ForeColor=Color.Black; textMonth0.BackColor=SystemColors.Control; textMonth0.Font=new Font(textMonth1.Font,FontStyle.Regular); } if(month1Span.Hours>=3) { textMonth1.BackColor=Color.Red; textMonth1.ForeColor=Color.White; textMonth1.Font=new Font(textMonth1.Font,FontStyle.Bold); } else { textMonth1.ForeColor=Color.Black; textMonth1.BackColor=SystemColors.Control; textMonth1.Font=new Font(textMonth1.Font,FontStyle.Regular); } if(month2Span.Hours>=3) { textMonth2.BackColor=Color.Red; textMonth2.ForeColor=Color.White; textMonth2.Font=new Font(textMonth2.Font,FontStyle.Bold); } else { textMonth2.ForeColor=Color.Black; textMonth2.BackColor=SystemColors.Control; textMonth2.Font=new Font(textMonth2.Font,FontStyle.Regular); } if(month3Span.Hours>=3) { textMonth3.BackColor=Color.Red; textMonth3.ForeColor=Color.White; textMonth3.Font=new Font(textMonth3.Font,FontStyle.Bold); } else { textMonth3.ForeColor=Color.Black; textMonth3.BackColor=SystemColors.Control; textMonth3.Font=new Font(textMonth3.Font,FontStyle.Regular); } //Set the text of the boxes. textMonth0.Text=month0Span.ToStringHmm(); textMonth1.Text=month1Span.ToStringHmm(); textMonth2.Text=month2Span.ToStringHmm(); textMonth3.Text=month3Span.ToStringHmm(); if(avgCount>0) { int test=(int)totalSpan.TotalMinutes/avgCount; textMonthAvg.Text=new TimeSpan(0,(int)totalSpan.TotalMinutes/avgCount,0).ToStringHmm(); } else { textMonthAvg.Text=""; } } }
///<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; }
///<summary>-hh:mm or -hh.mm, depending on the pref.TimeCardsUseDecimalInsteadOfColon. Blank if zero.</summary> public static string Format(TimeSpan span) { if(PrefC.GetBool(PrefName.TimeCardsUseDecimalInsteadOfColon)){ if(span==TimeSpan.Zero){ return ""; } return span.TotalHours.ToString("n"); } else{ return span.ToStringHmm();//blank if zero } }