Here is the code for the submit button function.
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("submit.aspx");
}
|