예제 #1
0
        protected void LoadXmlDocument(string fileName)
        {
            XElement root = XElement.Load(fileName);

            // Note: No need to perform the below.  this.TimesheetMonth is
            // updated prior to calling this member.
            //int year = Convert.ToInt32(root.Attribute("timesheetYear").Value);
            //int month = Convert.ToInt32(root.Attribute("timesheetMonth").Value);
            //this.TimesheetMonth = new TimesheetMonth(year, month);
            // _PRIORITY_: This is new 2011-02-15!!!
            int invoiceNumber = Convert.ToInt32(root.Attribute("invoiceNumber").Value);

            if (invoiceNumber == 0)
            {
                // Get our invoice number to use.
                invoiceNumber = MonthlyTimesheets.GetPreviousInvoiceNumberOrDefault(new DateTime(this.TimesheetMonth.Year, this.TimesheetMonth.Month, 1).AddMonths(-1));
                ++invoiceNumber;
            }
            this.InvoiceNumber = invoiceNumber;

            foreach (XElement timesheetElement in root.XPathSelectElements("./timesheet"))
            {
                Timesheet timesheet = new Timesheet(this, timesheetElement);
                this.Add(timesheet);
            }
        }
예제 #2
0
        protected void CreateXmlDocument(string fileName)
        {
            int year  = this.TimesheetMonth.Year;
            int month = this.TimesheetMonth.Month;

            DateTime startDate = new DateTime(year, month, 1);
            DateTime endDate   = new DateTime(year, month, DateTime.DaysInMonth(year, month));

            TimesheetMonth timesheetMonth = new TimesheetMonth(startDate.Year, startDate.Month);

            // Get our invoice number to use.
            int invoiceNumber = MonthlyTimesheets.GetPreviousInvoiceNumberOrDefault(new DateTime(year, month, 1).AddMonths(-1));

            this.InvoiceNumber = ++invoiceNumber;

            // Capture the day of week...
            DayOfWeek dayOfWeek = startDate.DayOfWeek;

            // If the day of week is not a Monday, we need to calculate backwards or
            // forwards to get to the Monday we want...
            if (dayOfWeek != DayOfWeek.Monday)
            {
                double daysToAdd = 0;

                if (dayOfWeek < DayOfWeek.Monday)
                {
                    daysToAdd = Convert.ToDouble(DayOfWeek.Monday - dayOfWeek);
                }
                else if (startDate.DayOfWeek > DayOfWeek.Monday)
                {
                    daysToAdd = -Convert.ToDouble(dayOfWeek - DayOfWeek.Monday);
                }

                startDate = startDate.AddDays(daysToAdd);
            }

            DateTime monday = startDate;

            for (int i = 0; monday <= endDate; i++)
            {
                DateTime mondayPlus6 = monday.AddDays(6);

                if (!Timesheet.WouldTimesheetSplit(timesheetMonth, monday, mondayPlus6))
                {
                    this.Add(monday, mondayPlus6, i);
                }
                else
                {
                    this.Add(monday, mondayPlus6, i, 0);
                    this.Add(monday, mondayPlus6, i, 1);
                }

                monday = monday.AddDays(7);                     // see if we can get the next Monday...
            }

            // Save the changes.
            XElement root = new XElement(this.ToXml());

            root.Save(fileName);
        }
 public MonthlyTimesheetChangedEventArgs(MonthlyTimesheets monthlyTimesheets)
 {
     this.MonthlyTimesheets = monthlyTimesheets;
 }
예제 #4
0
        protected virtual void Add(TimesheetMonth timesheetMonth)
        {
            MonthlyTimesheets monthlyTimesheets = new MonthlyTimesheets(timesheetMonth);

            this.MonthlyTimesheets.Add(monthlyTimesheets);
        }