Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Redirecting to another page after form submitsRedirecting to another page after form submits
Previous
 
Next
New Post
7/25/2014 11:56 AM
 
Sacha, it's ascx.
 
New Post
7/25/2014 12:23 PM
 
Thanks for helping me guys, but it's still not working. Here is my original code.

/*
' Copyright (c) 2012  DotNetNuke Corporation
'  All rights reserved.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
*/

using System;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Security;
using DotNetNuke.UI.Utilities;
using DotNetNuke.UI.WebControls;
using DotNetNuke.Web.Client.ClientResourceManagement;
using DotNetNuke.Modules.OnLineOrderForm.Components;
using System.Collections.Generic;
using System.Linq;
using DotNetNuke.Modules.MPUploader;
using Telerik.Web.UI;
using Telerik.Web.UI.Upload;
using DotNetNuke.Entities.Users;
using System.IO;




namespace DotNetNuke.Modules.OnLineOrderForm
{

    /// -----------------------------------------------------------------------------
    /// <summary>
    /// The View class displays the content
    ///
    /// Typically your view control would be used to display content or functionality in your module.
    ///
    /// View may be the only control you have in your project depending on the complexity of your module
    ///
    /// Because the control inherits from OnLineOrderFormModuleBase you have access to any custom properties
    /// defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
    ///
    /// </summary>
    /// -----------------------------------------------------------------------------
    public partial class View : OnLineOrderFormModuleBase, IActionable
    {

        #region Event Handlers

        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);

        }

        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);

        }
        public static string datePatt = "yyyyMMdd";


        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, System.EventArgs e)
        {
            Azshops az = new Azshops();
            string foldername = System.String.Empty;
            int lastId = 0;
            try
            {
                if (!IsPostBack)
                {
                    DotNetNuke.Framework.jQuery.RequestDnnPluginsRegistration();
                    //set defaults
                    rdoReqOpt.Items[0].Selected = true;
                    rdoCopyRightClearance.Items[0].Selected = true;
                    //rdoOkToSubmit.Items[1].Selected = true;
                    rdoPaginationRequired.Items[0].Selected = true;
                    rdoProofCopy.Items[0].Selected = true;
                   // rdoPrintingStyle.Items[0].Selected = true;
                    rdoRequireQuote.Items[0].Selected = true;
                    rdoTOC.Items[0].Selected = true;
                    rdoRequireCopyRightQuote.Items[0].Selected = true;

                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }

        #endregion

        #region Optional Interfaces

        public ModuleActionCollection ModuleActions
        {
            get
            {
                ModuleActionCollection Actions = new ModuleActionCollection();
                Actions.Add(GetNextActionID(), Localization.GetString("EditModule", this.LocalResourceFile), "", "", "", EditUrl(), false, SecurityAccessLevel.Edit, true, false);
                return Actions;
            }
        }

        #endregion

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Azshops az = new Azshops();
            string foldername = System.String.Empty;
            DateTime nowdate = DateTime.Now;
            foldername = nowdate.ToString(datePatt);

            makeFolder(string.Format("{0}{1}", az.MpPath, foldername));

            RadUpload1.TargetPhysicalFolder = string.Format("{0}{1}", az.MpPath, foldername);

            var dt1 = filldate( DateNeeded.SelectedDate);
            var dt2 = filldate(DeskCopyDateNeeded.SelectedDate);

            UploadedFile file;

            MPOrderForm m;
            m = new MPOrderForm
            {
                AssignedUserId = UserId
               ,
                CreatedByUserId = UserId
               ,
                CreatedOnDate = DateTime.Now
               ,
                FirstName = txtFirstName.Text.Trim()
               ,
                LastName = txtLastName.Text.Trim()
               ,
                Email = txtEmail.Text.Trim()
               ,
                Campus = txtCampus.Text.Trim()
               ,
                Department = txtDepartment.Text.Trim()
               ,
                OfficePhone = txtOfficePhone.Text.Trim()
               ,
                HomePhone = txtHomePhone.Text.Trim()
               ,
                Author = txtAuthor.Text.Trim()
               ,
                Title = txtTitle.Text.Trim()
               ,
                Semester = txtSemester.Text.Trim()
               ,
                DateNeeded = dt1
               ,
                Course = txtCourse.Text.Trim()
               ,
                SectionNumbers = txtSectionNumbers.Text.Trim()
               ,
                EstEnrollment = fillInt(txtEstEnrollment.Text)
               ,
                ReqOpt = fillBool(rdoReqOpt.Items[0])
               ,
                ProductIs = myProductIs.Value
               ,
                CopyRightClearance = fillBool(rdoCopyRightClearance.Items[0])
               ,
                RequireCopyRightQuote = fillBool(rdoRequireCopyRightQuote.Items[0])
               ,
                DeskCopyQty = txtDeskCopyQty.Text.Trim()
               ,
                DeskCopyDateNeeded =dt2
             
               ,
                ProofCopy = fillBool(rdoProofCopy.Items[0])
               ,
                PrintingStyle = myPrintingStyle.Value
               ,
                CoverColor = myCoverColor.Value
               ,
                CustomCover = myCustomCover.Value
               ,
                //BindingOption = ddlBindingOptions.SelectedValue
                BindingOption =myBindingOption.Value
               ,
                PaginationRequired = fillBool(rdoPaginationRequired.Items[0])
               ,
                TOC = fillBool(rdoTOC.Items[0])
               ,
                AdditionalSupplies = txtAdditionalSupplies.Text.Trim()
               ,
                SpecialInstructions = txtSpecialInstructions.Text.Trim()
               ,
                Attachments = formHasAttachments(RadUpload1.UploadedFiles.Count)
               ,
                OkToSubmit = true
            };

           m.OnlineFormId= OnlineOrderFormController.SaveOnlineForm(m, this.PortalId, this.ModuleId, this.TabId);
          
            string fname = System.String.Empty;
            string lname = System.String.Empty;
            string campus = System.String.Empty;
            string dept = System.String.Empty;
            //Firstname
            if (m.FirstName.Length >= 1)
            {
                fname = m.FirstName.Substring(0, 1);
            }
            else
            {
                fname = "f";
            }

            //Lastname
            if (m.LastName.Length >= 3)
            {
                lname = m.LastName.Substring(0, 3);
            }
            else if (m.LastName.Length >= 2)
            {
                lname = m.LastName.Substring(0,2);
            }
            else if (m.LastName.Length >= 1)
            {
                lname = m.LastName.Substring(0, 1);
            }
            else
            {
                lname = "l";
            }

            //Campus
            if (m.Campus.Length >= 4)
            {
                campus = m.Campus.Substring(0, 4);
            }
            else if (m.Campus.Length >= 2)
            {
                campus = m.Campus.Substring(0, 2);
            }
            else if (m.Campus.Length >= 1)
            {
                campus = m.Campus.Substring(0, 1);
            }
            else
            {
                campus = "c";
            }
           

            //Dept
            if (m.Department.Length >= 3)
            {
                dept = m.Department.Substring(0, 3);
            }
            else if (m.Department.Length >= 2)
            {
                dept = m.Department.Substring(0, 2);
            }
            else if (m.Department.Length >= 1)
            {
                dept = m.Department.Substring(0, 1);
            }
            else
            {
                dept = "d";
            }
        
           
            foldername = string.Format("{0}{1}{2}{3}",fname,lname,campus,dept);

           

           


            RadProgressContext progress = RadProgressContext.Current;

            RadProgressArea1.ProgressIndicators = RadProgressArea1.ProgressIndicators | ~ProgressIndicators.SelectedFilesCount;
            RadProgressArea1.Localization.UploadedFiles = "Processed";
            RadProgressArea1.Localization.TotalFiles = "";
            RadProgressArea1.Localization.CurrentFileName = "File: ";



            progress.SecondaryPercent = "0";
            progress.SecondaryValue = "0";
            progress.SecondaryTotal = "0";

           
            //rename the uploaded file to suffix to aid in locating files
            foreach (UploadedFile f in RadUpload1.UploadedFiles)
            {
                string targetfolder = string.Format(@"{0}\{1}\",RadUpload1.TargetPhysicalFolder,foldername);
               
               
                makeFolder(string.Format("{0}", targetfolder));
                string filename = string.Format("{0}{1}", targetfolder, f.FileName);
                f.SaveAs(filename, true);
                if (f.ContentLength > 0)
                {
                    LooongMethodWhichUpdatesTheProgressContext(f);
                }
            }

          
            if (RadUpload1.UploadedFiles.Count > 0)
            {
                labelNoResults.Visible = false;
                repeaterResults.Visible = true;
                repeaterResults.DataSource = RadUpload1.UploadedFiles;
                repeaterResults.DataBind();
            }
            else
            {
                labelNoResults.Visible = true;
                repeaterResults.Visible = false;
            }

          

          

            sndEmail(m, RadUpload1.UploadedFiles.Count);

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());   

        }

        private void makeFolder(string p)
        {
            DirectoryInfo dirInfo = new DirectoryInfo(p);
            if (!dirInfo.Exists)
            {
                Directory.CreateDirectory(p);
            }
        }

        private bool formHasAttachments(int count)
        {
            if (count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private bool fillBool(System.Web.UI.WebControls.ListItem listItem)
        {
            if (listItem.Selected == true)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        private int fillInt(string p)
        {
            if (p.Length == 0)
            { return 0; }
            else
            { return Convert.ToInt32(p); }
        }

        private DateTime filldate(DateTime? nullable)
        {
            DateTime defaultdate = DateTime.Parse("1/1/1908");
            if (nullable.HasValue)
            {
                if ((nullable.Value >= DateTime.Parse("1/1/1753 12:00:00 AM")) || (nullable.Value <= DateTime.Parse("12/31/9999 11:59:59 PM")))
                {
                    return nullable.Value;
                }
                else
                {
                    return DateTime.Parse("1/1/1908");
                }
            }
            else
            {
                return defaultdate;
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }

        private void LooongMethodWhichUpdatesTheProgressContext(UploadedFile file)
        {
            const int total = 100;
            RadProgressContext progress = RadProgressContext.Current;
            for (int i = 0; i < total - 1; i++)
            {
                progress.SecondaryTotal = RadUpload1.UploadedFiles.Count.ToString();
                progress.SecondaryPercent = i.ToString();
                progress.CurrentOperationText = string.Format("{0} is being processed...", file.GetName());

                if (!Response.IsClientConnected)
                {
                    //Cancel button was clicked or the browser was closed, so stop processing
                    break;
                }

                //Stall the current thread for 0.1 seconds
                System.Threading.Thread.Sleep(25);
            }
           
        }

        private void sndEmail(MPOrderForm m, int count)
        {
            string sndEmail = m.Email.ToString();

            Azshops az = new Azshops();

           

          
          

           

            try
            {
                string strBody = string.Format("{0} {1} has submitted a form.\n\n", m.FirstName, m.LastName);
                strBody += string.Format("{0}\n\n", new String('-', 40));
                strBody += string.Format("First Name: {0}\n", m.FirstName.ToString());
                strBody += string.Format("Last Name: {0}\n", m.LastName.ToString());
                strBody += string.Format("Email: {0}\n", m.Email.ToString());
                strBody += string.Format("Campus: {0}\n", m.Campus.ToString());
                strBody += string.Format("Department: {0}\n", m.Department.ToString());
                strBody += string.Format("Office Phone: {0}\n", m.OfficePhone.ToString());
                strBody += string.Format("Home Phone: {0}\n", m.HomePhone.ToString());
                strBody += string.Format("{0}\n\n", new String('-', 40));
                strBody += string.Format("Author: {0}\n", m.Author.ToString());
                strBody += string.Format("Title: {0}\n", m.Title.ToString());
                strBody += string.Format("Semester needed: {0}\n", m.Semester.ToString());
                strBody += string.Format("Date needed: {0}\n", m.DateNeeded.ToString());
                strBody += string.Format("Course: {0}\n", m.Course.ToString());
                strBody += string.Format("Section numbers: {0}\n", m.SectionNumbers.ToString());
                strBody += string.Format("Estimated enrollment: {0}\n", m.EstEnrollment.ToString());
                strBody += string.Format("This product will be required: {0}\n", m.ReqOpt.ToString());
                strBody += string.Format("This product is: {0}\n", m.ProductIs.ToString());
                strBody += string.Format("{0}\n\n", new String('-', 40));
                strBody += string.Format("Require copyright clearance?: {0}\n", m.CopyRightClearance.ToString());
                strBody += string.Format("Require quote?: {0}\n", m.RequireCopyRightQuote.ToString());
                strBody += string.Format("{0}\n\n", new String('-', 40));
                strBody += string.Format("Desk copy qty: {0}\n", m.DeskCopyQty.ToString());
                strBody += string.Format("Desk copy date needed: {0}\n\n", m.DeskCopyDateNeeded.ToString());
                strBody += string.Format("Proof copy: {0}\n", m.ProofCopy.ToString());
                strBody += string.Format("Printing style: {0}\n", m.PrintingStyle.ToString());
                strBody += string.Format("Color of cover: {0}\n", m.CoverColor.ToString());
                strBody += string.Format("Custom covers: {0}\n", m.CustomCover.ToString());
                strBody += string.Format("Binding Options: {0}\n", m.BindingOption.ToString());
                strBody += string.Format("Pagination required: {0}\n", m.PaginationRequired.ToString());
                strBody += string.Format("Table of contents required: {0}\n", m.TOC.ToString());
                strBody += string.Format("Additional Supplies: {0}\n", m.AdditionalSupplies.ToString());
                strBody += string.Format("Special Instructions: {0}\n", m.SpecialInstructions.ToString());
                strBody += string.Format("{0}\n\n", new String('-', 40));


                for (int i = 0; i <= count - 1; i++)
                {
                    strBody += string.Format("[{0}] {1}\n", i + 1, RadUpload1.UploadedFiles[i].GetName().ToString());

                }
                // DotNetNuke.Services.Mail.Mail.SendEmail(az.From, p.Email, "Thesis Upload", strBody);
                DotNetNuke.Services.Mail.Mail.SendMail(az.From, m.Email, az.bcc, az.subject, strBody, "", "", "", "", "", "");
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 
    }

}
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Redirecting to another page after form submitsRedirecting to another page after form submits


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out