コード例 #1
0
 public TimeEntry(TimeEntry toCopy)
     : this(toCopy.Project, toCopy.Task, toCopy.Employer, toCopy.Start, toCopy.Stop, toCopy.Comments, toCopy.WorkLog)
 {
 }
コード例 #2
0
 private void btnStopAtNow_Click(object sender, EventArgs e)
 {
     this.dateTimePickerStop.Value = DateTime.Now;
 }
コード例 #3
0
 public frmTimeEntry(TimeEntry input, bool comment)
     : this(input)
 {
     this.commentFocus = comment;
 }
コード例 #4
0
ファイル: Reports.cs プロジェクト: bethune-bryant/timekeeper
        public static void Export(List <TimeEntry> TimeEntries, string employer, DateTime since, DateTime until, SaveFileDialog saveFileDialogReport)
        {
            List <string> timeEntries = new List <string>();

            timeEntries.Add("Project,Task,Venue,Date,Start,Stop,\"=\"\"Comments  (Month to date: \"\"&ROUND(SUM($K:$K),2)&\"\")\"\"\",Time,H+MM,Gap,DailyTime,=P5,Also Exclude:");

            TimeEntries.Reverse();

            foreach (TimeEntry entry in TimeEntries.Where(item => item.Employer == employer && item.Start >= since && item.Stop <= until && item.Stop != TimeEntry.MIN_DATE))
            {
                string timeEnrty;

                if (entry.Stop != TimeEntry.MIN_DATE)
                {
                    timeEnrty = Quote(entry.Project) + "," + Quote(entry.Task) + ",," + Quote(entry.Start.Date.ToString("d-MMM")) + "," +
                                Quote(entry.Start.ToString("hh:mm tt")) + "," + Quote(entry.Stop.ToString("hh:mm tt")) + "," + Quote(entry.Comments);
                }
                else
                {
                    timeEnrty = Quote(entry.Project) + "," + Quote(entry.Task) + ",," + Quote(entry.Start.Date.ToString("d-MMM")) + "," +
                                Quote(entry.Start.ToString("hh:mm tt")) + ",," + Quote(entry.Comments);
                }

                string time      = "=" + Time;
                string hmm       = "=" + HMM;
                string gap       = "=" + Gap;
                string dailyTime = "=" + DailyTime;

                timeEntries.Add(timeEnrty + "," + Quote(time) + "," + Quote(hmm) + "," + Quote(gap) + "," + Quote(dailyTime));
            }

            TimeEntries.Reverse();

            string dailyHours      = "=" + DailyHours;
            string yesterdaysHours = "=" + YesterdaysHours;
            string weeksHours      = "=" + WeeklyHours;
            string monthsHours     = "=" + MonthlyHours;

            string tableRow = "," + Quote(dailyHours) + "," + Quote(yesterdaysHours) + "," + Quote(weeksHours) + "," + Quote(monthsHours) + "";

            List <string> totalsChart = new List <string>();

            totalsChart.Add(",Week Starts on:,Sat");
            totalsChart.Add("Total" + tableRow);
            totalsChart.Add(",Today,Yesterday,Weekly,Monthly");

            foreach (string project in TimeEntry.ProjectsFor(employer, TimeEntries))
            {
                totalsChart.Add(project + tableRow);
            }

            for (int i = 0; i < 4 - timeEntries.Count; i++)
            {
                timeEntries.Add("");
            }

            for (int i = 0; i < totalsChart.Count; i++)
            {
                if (timeEntries.Count > (i + 3))
                {
                    timeEntries[i + 3] += ",," + totalsChart[i];
                }
                else
                {
                    timeEntries.Add(",,,,,,,,,,,," + totalsChart[i]);
                }
            }

            StringBuilder result = new StringBuilder();

            foreach (string line in timeEntries)
            {
                result.AppendLine(line);
            }

            if (saveFileDialogReport.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    File.WriteAllText(saveFileDialogReport.FileName, result.ToString());
                    System.Diagnostics.Process.Start(saveFileDialogReport.FileName);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }