/// <summary>GetTimesheetByID
        /// <para>
        /// Input: TimesheetID
        /// Output: Builds TimesheetObject for specified TimesheetID
        /// Return: TimesheetObject with list of TimesheetEnty objects
        /// </para>
        /// </summary>
        public TimesheetObject GetTimesheetByID(string timesheetID)
        {
            TimesheetObject TSO = new TimesheetObject();

            //Foreach string add timesheet info (There should only be one string unless two timesheets have the same ID)
            foreach (string ts in TDA.GetTimesheetDataByID(timesheetID))
            {
                string[] words = ts.Split(';');

                TSO.timesheetID   = words[0].Trim();
                TSO.foremanID     = words[1].Trim();
                TSO.submitted     = words[2].Trim();
                TSO.weekEnding    = words[3].Trim();
                TSO.jobsite       = words[4].Trim();
                TSO.subcontractor = words[5].Trim();
                TSO.signature     = words[6].Trim();
            }

            //Foreach string add Timesheet Entry
            foreach (string ts in TDA.GetTimesheetEntriesByID(timesheetID))
            {
                string[] words = ts.Split(';');

                TimesheetEntry TSE = new TimesheetEntry();

                TSE.entryID        = words[0].Trim();
                TSE.timesheetID    = words[1].Trim();
                TSE.employeeID     = words[2].Trim();
                TSE.employeeName   = words[3].Trim();
                TSE.employeeType   = words[4].Trim();
                TSE.hoursWednesday = words[5].Trim();
                TSE.hoursThursday  = words[6].Trim();
                TSE.hoursFirday    = words[7].Trim();
                TSE.hoursSaturday  = words[8].Trim();
                TSE.hoursSunday    = words[9].Trim();
                TSE.hoursMonday    = words[10].Trim();
                TSE.hoursTuesday   = words[11].Trim();
                TSE.comments       = words[12].Trim();

                TSO.Entries.Add(TSE);
            }
            return(TSO);
        }
        /// <summary>UpdateTimesheet
        /// <para>
        /// Input: Timesheet Object
        /// Output: Updates the timesheet and entries
        /// Return: None
        /// </para>
        /// </summary>
        public void UpdateTimesheet(TimesheetObject Timesheet)
        {
            TDA.UpdateTimesheetInfo(Timesheet.timesheetID, Timesheet.submitted, Timesheet.subcontractor, Timesheet.jobsite, Timesheet.signature);

            foreach (TimesheetEntry Entry in Timesheet.Entries)
            {
                TDA.UpdateTimesheetEntry(Entry.entryID,
                                         Entry.timesheetID,
                                         Entry.employeeID,
                                         Entry.employeeName,
                                         Entry.employeeType,
                                         Entry.hoursWednesday,
                                         Entry.hoursThursday,
                                         Entry.hoursFirday,
                                         Entry.hoursSaturday,
                                         Entry.hoursSunday,
                                         Entry.hoursMonday,
                                         Entry.hoursTuesday,
                                         Entry.comments);
            }
        }
예제 #3
0
        public void SendEmail(TimesheetObject Timesheet)
        {
            //Build the body of the email
            string EmailBody =
                @"<table border=""1"">

                <tr>
                <td>TimesheetID: </td>
                <td>" + Timesheet.timesheetID + @"</td>
                </tr>

                <tr>
                <td>Foreman: </td>
                <td>" + Timesheet.foremanID + @"</td>
                </tr>

                <tr>
                <td>Week Ending: </td>
                <td>" + Timesheet.weekEnding + @"</td>
                </tr>

                <tr>
                <td>Submitted On: </td>
                <td>" + Timesheet.submitted + @"</td>
                </tr>

                <tr>
                <td>Contractor: </td>
                <td>" + Timesheet.subcontractor + @"</td>
                </tr>

                <tr>
                <td>Jobsite: </td>
                <td>" + Timesheet.jobsite + @"</td>
                </tr>

                </table>
                
                <table border=""1"">
                <tr>
                <td>Name</td>
                <td>C/L</td>
                <td>Wed</td>
                <td>Thu</td>
                <td>Fri</td>
                <td>Sat</td>
                <td>Sun</td>
                <td>Mon</td>
                <td>Tue</td>
                <td>Comments</td>
                </tr>
                ";

            foreach (TimesheetEntry TE in Timesheet.Entries)
            {
                EmailBody +=
                    @"
                    <tr>
                    <td>" + TE.employeeName + @"</td>
                    <td>" + TE.employeeType + @"</td>
                    <td>" + TE.hoursWednesday + @"</td>
                    <td>" + TE.hoursThursday + @"</td>
                    <td>" + TE.hoursFirday + @"</td>
                    <td>" + TE.hoursSaturday + @"</td>
                    <td>" + TE.hoursSunday + @"</td>
                    <td>" + TE.hoursMonday + @"</td>
                    <td>" + TE.hoursTuesday + @"</td>
                    <td>" + TE.comments + @"</td>
                    </tr>
                    ";
            }

            EmailBody += @"</table>";

            //create the message
            MailMessage objMail = new MailMessage();

            string[] toEmails = ConfigurationManager.AppSettings["ToEmailAddress"].Split(',');

            foreach (string email in toEmails)
            {
                objMail.To.Add(email);
            }

            objMail.From    = new MailAddress(ConfigurationManager.AppSettings["FromEmailAddress"]);
            objMail.Subject = "Timesheeting: New Timesheet From " + Timesheet.foremanID;
            objMail.Body    = EmailBody;

            objMail.IsBodyHtml = true;
            NetworkCredential objNC   = new NetworkCredential(ConfigurationManager.AppSettings["EmailUsername"], ConfigurationManager.AppSettings["EmailPassword"]);
            SmtpClient        objsmtp = new SmtpClient(ConfigurationManager.AppSettings["EmailSMTPServer"], int.Parse(ConfigurationManager.AppSettings["EmailServerPort"]));

            objsmtp.EnableSsl   = true;
            objsmtp.Credentials = objNC;
            objsmtp.Send(objMail);
        }
        /// <summary>SubmitTimesheet
        /// <para>
        /// Input: None
        /// Output: Gets Employees from Levesys
        /// Return: string list of employees: Firstname Lastname
        /// </para>
        /// </summary>
        public void SubmitTimesheet(TimesheetObject Timesheet)
        {
            TimesheetEmail TE = new TimesheetEmail();

            TE.SendEmail(Timesheet);
        }