private bool Save()
        {
            // Validate the user is trying to send something either existing talent files or uploaded files
             var bSendingSomething = false;
             foreach (GridDataItem oDataItem in m_grdTalentFiles.Items)
             {
            if (oDataItem["Send"] != null)
            {
               var chkSend = oDataItem["Send"].Controls[0] as CheckBox;
               if (chkSend.Checked)
               {
                  bSendingSomething = true;
                  break;
               }
            }
             }

             if (m_oUpload.UploadedFiles.Count > 0)
             {
            bSendingSomething = true;
             }

             if (!bSendingSomething)
             {
            SetMessage("Please select or upload files to send to the customer.", MessageTone.Negative);
            return false;
             }

             // Process
             var oIARequestProduction = new IARequestProduction();
             oIARequestProduction.IARequestID = m_oIAJob.IARequestID;
             oIARequestProduction.IAJobID = m_oIAJob.IAJobID;
             oIARequestProduction.MPUserID = MemberProtect.CurrentUser.UserID;
             oIARequestProduction.Notes = m_txtNotes.Text;
             oIARequestProduction.CreatedDateTime = DateTime.Now;
             oIARequestProduction.HasRecutBeenRequested = false;
             oIARequestProduction.RecutRequestDateTime = DateTime.Now;
             oIARequestProduction.RecutNotes = string.Empty;
             DataAccess.IARequestProductions.InsertOnSubmit(oIARequestProduction);
             DataAccess.SubmitChanges();

             foreach (GridDataItem oDataItem in m_grdTalentFiles.Items)
             {
            if (oDataItem["Send"] != null)
            {
               var chkSend = oDataItem["Send"].Controls[0] as CheckBox;
               if (chkSend.Checked)
               {
                  // Create a copy of the talent file and then attach it to a new request production
                  var iIASpotFileID = MemberProtect.Utility.ValidateInteger(oDataItem["IASpotFileID"].Text);
                  var oIASpotFile = DataAccess.IASpotFiles.SingleOrDefault(row => row.IASpotFileID == iIASpotFileID);
                  if (oIASpotFile != null)
                  {
                     var txtNewFilename = oDataItem["NewFilename"].FindControl("m_txtNewFilename") as RadTextBox;

                     var sExtension = string.Empty;
                     var iIndex = txtNewFilename.Text.LastIndexOf(".");
                     if (iIndex > 0)
                     {
                        sExtension = txtNewFilename.Text.Substring(iIndex, txtNewFilename.Text.Length - iIndex);
                     }

                     var sFilename = string.Format("{0}{1}", Guid.NewGuid(), sExtension);

                     // Copy files
                     File.Copy(string.Format("{0}{1}", ApplicationContext.UploadPath, oIASpotFile.FilenameUnique),
                               string.Format("{0}{1}", ApplicationContext.UploadPath, sFilename));
                     if (File.Exists(string.Format("{0}{1}", ApplicationContext.UploadPath, sFilename)))
                     {
                        var oIARequestProductionFile = new IARequestProductionFile();
                        oIARequestProductionFile.IARequestProductionID = oIARequestProduction.IARequestProductionID;
                        oIARequestProductionFile.Filename = txtNewFilename.Text;
                        oIARequestProductionFile.FilenameUnique = sFilename;
                        oIARequestProductionFile.FileSize = oIASpotFile.FileSize;
                        oIARequestProductionFile.CreatedDateTime = DateTime.Now;

                        oIARequestProduction.IARequestProductionFiles.Add(oIARequestProductionFile);
                        DataAccess.SubmitChanges();
                     }
                  }
               }
            }
             }

             ProcessUploadedFiles(oIARequestProduction);

             // Send email to customer
             var sName = string.Format("{0} {1}", MemberProtect.User.GetDataItem(oIARequestProduction.IARequest.MPUserID, "FirstName"),
                                   MemberProtect.User.GetDataItem(oIARequestProduction.IARequest.MPUserID, "LastName"));
             var sOrgName = MemberProtect.Organization.GetName(ApplicationContext.GetOrgID(oIARequestProduction.IARequest.MPUserID));
             var fileUrl = string.Empty;

             var oSB = new StringBuilder();
             oSB.AppendLine("<html><body>");
             oSB.AppendLine("Hello,<br/>");
             oSB.AppendLine("<br/>");
             oSB.AppendLine(string.Format("Files have been delivered for {0} of {1}.<br/>", sName, sOrgName));
             oSB.AppendLine(string.Format("Request #{0}<br/>", oIARequestProduction.IARequest.RequestIdForDisplay));
             oSB.AppendLine("<br/>");
             oSB.AppendLine("You may download the files by clicking the link(s) below:<br/>");
             foreach (var oIARequestProductionFile in oIARequestProduction.IARequestProductionFiles)
             {
            fileUrl = string.Format("{0}/{1}/{2}/{3}", ApplicationContext.GetRootUrl(this, "/delivery"),
                                    oIARequestProductionFile.IARequestProductionID.ToString().Replace("-", ""),
                                    oIARequestProductionFile.IARequestProductionFileID.ToString().Replace("-", ""), oIARequestProductionFile.Filename);
            oSB.AppendLine(string.Format("* {0} - <a href=\"{1}\">{1}</a><br />", oIARequestProductionFile.Filename, fileUrl));
             }
             oSB.AppendLine("<br/>");
             oSB.AppendLine(string.Format("NOTE: {0}", oIARequestProduction.Notes.Replace(Environment.NewLine, "<br/>")));
             oSB.AppendLine("<br/>");
             oSB.AppendLine("<br/>");
             oSB.AppendLine("<br/>");
             oSB.AppendLine(string.Format("<a href='{0}?rid={1}'>View Request Details</a> [login required]<br/>",
                                      ApplicationContext.GetRootUrl(this, "order-details.aspx"), oIARequestProduction.IARequest.IARequestID));
             oSB.AppendLine("<br/>");
             oSB.AppendLine("<br/>");
             oSB.AppendLine("Thank you,<br/>");
             oSB.AppendLine("<a href='http://www.speedyspots.com'>SpeedySpots.com</a><br/>");
             oSB.AppendLine("<a href='mailto:[email protected]'>[email protected]</a><br/>");
             oSB.AppendLine("(734) 475-9327");
             oSB.AppendLine("</body></html>");

             var subject = string.Format("Files Delivered - #{0}", oIARequestProduction.IARequest.RequestIdForDisplay);
             var alsoContacts = oIARequestProduction.IARequest.NotificationEmails.Split(',').ToList();
             EmailCommunicationService.JobPackageDeliveryNoticeToJobContacts(oSB, subject, oIARequestProduction.IARequest.MPUser.Username, alsoContacts);

             return true;
        }
        private bool ProcessUploadedFiles(IARequestProduction oIARequestProduction)
        {
            if (m_oUpload.UploadedFiles.Count > 0)
             {
            foreach (UploadedFile oFile in (m_oUpload.UploadedFiles))
            {
               // Create file record
               var oIARequestProductionFile = new IARequestProductionFile();
               oIARequestProductionFile.IARequestProductionID = oIARequestProduction.IARequestProductionID;
               oIARequestProductionFile.Filename = oFile.GetName();
               oIARequestProductionFile.FilenameUnique = string.Format("{0}{1}", Guid.NewGuid(), oFile.GetExtension());
               oIARequestProductionFile.FileSize = oFile.ContentLength;
               oIARequestProductionFile.CreatedDateTime = DateTime.Now;
               oIARequestProduction.IARequestProductionFiles.Add(oIARequestProductionFile);
               DataAccess.SubmitChanges();

               // Save physical file under a new name
               oFile.SaveAs(string.Format("{0}{1}", ApplicationContext.UploadPath, oIARequestProductionFile.FilenameUnique));
            }

            return true;
             }
             else
             {
            return false;
             }
        }