public ActionResult Create(string PRJID = "", string BIDID = "") { int BIDId = 0; int projectHeaderID = 0; var model = new HardCard(); if (!string.IsNullOrWhiteSpace(PRJID) && Int32.TryParse(PRJID, out projectHeaderID)) { Session["PRJID"] = PRJID; model.ProjectHeaderId = projectHeaderID; } if (!string.IsNullOrWhiteSpace(BIDID) && Int32.TryParse(BIDID, out BIDId)) { Session["BIDID"] = BIDId; model.BidItemHeaderid = BIDId; } if (Session["BIDID"] != null && Session["BIDID"] != null) { LookUpHardCardCombos(model); if (model.ProjectHeaderId == 0 || model.BidItemHeaderid == 0) { return(View("create", model)); } var hardCardItem = HardCardDal.getHardCardItem(PRJID, BIDID); if (hardCardItem.Rows.Count == 1) { model.HardCardId = Convert.ToInt32(hardCardItem.Rows[0]["HardCardID"]); HardCardDal.getHardCardDetails(model); } return(View("create", model)); } return(RedirectToAction("error")); }
public FileStreamResult printHardCardDetails(string hid) { string title = string.Empty; title = ""; var model = new HardCard(); model.HardCardId = Convert.ToInt32(hid); HardCardDal.getHardCardDetails(model); HardCardDal.getHardCardLookUpList(model); // Set up the document and the MS to write it to and create the PDF writer instance MemoryStream ms = new MemoryStream(); Document document = new Document(PageSize.A4, 15, 10, 15, 35); PdfWriter writer = PdfWriter.GetInstance(document, ms); writer.PageEvent = new PDFReportEventHelper(title); // Open the PDF document document.Open(); document.Add(PDFUtil.HeaderSection("Job Card")); #region Job Info var jobInfo = PDFUtil.createTableWithHeader("Job Information", new float[] { 2, 2, 2, 2 }); jobInfo.AddCell(PDFUtil.CreateCell("Estimator", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.EstimatorsName, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Job Number", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.Atlas_Job_Number, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Est.Phone #", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(AppUtil.formatPhoneNumber(model.JobInformationDetails.ContractPhoneNumber), PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("BI Number", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.BidItemHeaderId, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Job Name", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.JobName, PDFUtil.spanNormalBlack, colSpan: 3)); jobInfo.AddCell(PDFUtil.CreateCell("Job Address", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.JobAddress, PDFUtil.spanNormalBlack, colSpan: 3)); jobInfo.AddCell(PDFUtil.CreateCell("Job City", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.JobCity, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Job State", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.JobState, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Job Contact", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.JobContact, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Call In Route", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(model.JobInformationDetails.ListJobInfoResponse. FirstOrDefault(i => i.ResponseId.ToString() == model.JobInformationDetails.CallInRoute)?.Response, PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Contact Phone", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(AppUtil.formatPhoneNumber(model.JobInformationDetails.JobPhone), PDFUtil.spanNormalBlack)); jobInfo.AddCell(PDFUtil.CreateCell("Contact Cell", PDFUtil.font_body_bold, 2, false)); jobInfo.AddCell(PDFUtil.CreateCell(AppUtil.formatPhoneNumber(model.JobInformationDetails.JobCell), PDFUtil.spanNormalBlack)); document.Add(jobInfo); #endregion #region ContractorInfo var contractInfo = PDFUtil.createTableWithHeader("Contractor Information", new float[] { 2, 2, 2, 2 }); contractInfo.AddCell(PDFUtil.CreateCell("Contractor Name", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(model.ContractInformationDetails.ContractorName, PDFUtil.spanNormalBlack, colSpan: 3)); contractInfo.AddCell(PDFUtil.CreateCell("Primary Contact Name", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(model.ContractInformationDetails.PrimaryContact, PDFUtil.spanNormalBlack)); contractInfo.AddCell(PDFUtil.CreateCell("Phone", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(AppUtil.formatPhoneNumber(model.ContractInformationDetails.PrimaryPhone), PDFUtil.spanNormalBlack)); contractInfo.AddCell(PDFUtil.CreateCell("Fence Type", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(model.ContractInformationDetails.ListFenceTypes. First(i => i.FenceTypeId.ToString() == model.ContractInformationDetails.FenceType).FenceTypeName, PDFUtil.spanNormalBlack, colSpan: 3)); contractInfo.AddCell(PDFUtil.CreateCell("Special Notes", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(model.ContractInformationDetails.SplNotes, PDFUtil.spanNormalBlack)); contractInfo.AddCell(PDFUtil.CreateCell("Directions", PDFUtil.font_body_bold, 2, false)); contractInfo.AddCell(PDFUtil.CreateCell(model.ContractInformationDetails.Directions, PDFUtil.spanNormalBlack)); document.Add(contractInfo); #endregion #region Installation var installDetails = PDFUtil.createTableWithHeader("Installation", new float[] { 2, 2, 2, 2, 2, 2 }); installDetails.AddCell(PDFUtil.CreateCell("Pre Make Gates", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId.ToString() == model.InstallationDetails.PremakeGate.ToString()).Response, PDFUtil.spanNormalBlack, colSpan: 5)); installDetails.AddCell(PDFUtil.CreateCell("CBYD", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId.ToString() == model.InstallationDetails.CBYD.ToString()).Response, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("CBYD Date", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.CBYDDate, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("CBYD Number", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.CBYDNumber, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Start Date", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.StartDate, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Finish Date", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.FinishDate, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Hard Date", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. FirstOrDefault(i => i.ResponseId.ToString() == model.InstallationDetails.HardDate)?.Response, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Description", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.GateDescription1, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Installation", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListGateInstallation. FirstOrDefault(i => i.GateInstallationID.ToString() == model.InstallationDetails.GateInstallationID1)?.Description, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Gate Description", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.GateDescription2, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Installation", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListGateInstallation. FirstOrDefault(i => i.GateInstallationID.ToString() == model.InstallationDetails.GateInstallationID2)?.Description, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Gate Description", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.GateDescription3, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Installation", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListGateInstallation. FirstOrDefault(i => i.GateInstallationID.ToString() == model.InstallationDetails.GateInstallationID3)?.Description, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Gate Description", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.GateDescription4, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Installation", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListGateInstallation. FirstOrDefault(i => i.GateInstallationID.ToString() == model.InstallationDetails.GateInstallationID4)?.Description, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Gate Description", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.GateDescription5, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Gate Installation", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListGateInstallation. FirstOrDefault(i => i.GateInstallationID.ToString() == model.InstallationDetails.GateInstallationID5)?.Description, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Equipment Required", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId.ToString() == model.InstallationDetails.EquipmentRequired).Response, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Dig Type", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListDigType. First(i => i.DigTypeId == model.InstallationDetails.DigTypeID).DigType, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Water Available", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId.ToString() == model.InstallationDetails.WaterAvailible.ToString()).Response, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Electricity Available", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId == model.InstallationDetails.ElectricityAvailible).Response, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Measure By Installer", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId.ToString() == model.InstallationDetails.MeasureByInstaller.ToString()).Response, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Leave Samples By Installer", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.ListInstallationResponses. First(i => i.ResponseId == model.InstallationDetails.LeaveSamplesByInstaller).Response, PDFUtil.spanNormalBlack, colSpan: 3)); installDetails.AddCell(PDFUtil.CreateCell("Budgeted Install Days", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.BudgetedInstallDays, PDFUtil.spanNormalBlack)); installDetails.AddCell(PDFUtil.CreateCell("Scope", PDFUtil.font_body_bold, 2, false)); installDetails.AddCell(PDFUtil.CreateCell(model.InstallationDetails.Scope, PDFUtil.spanNormalBlack, colSpan: 3)); document.Add(installDetails); #endregion document.NewPage(); #region BuildChecklist var buildList = PDFUtil.createTableWithHeader("Build Checklist", new float[] { 2, 2, 2, 2, 3, 2 }); buildList.AddCell(PDFUtil.CreateCell("Pool Code", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId.ToString() == model.BuildChecklistDetails.PoolCode.ToString()).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Dowelled", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.Dowelled).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Safety Officer Onsite", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.SafetyOfficerOnsite).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Build For Rack", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId.ToString() == model.BuildChecklistDetails.BuildForRack.ToString()).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Morticed", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.Morticed).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Saftey Meeting/Orientation Onsite", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.SafteyMeetingOrintationOnsiteReq).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Stepping Temp", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId.ToString() == model.BuildChecklistDetails.SteppingTemp.ToString()).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Nail On", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.NailOn).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Saftey Inspection Before Job Starts", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.SafteyInspectionReqBeforeJobStarts).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Fence Direction", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListFenceDirection. First(i => i.FenceDirectionID.ToString() == model.BuildChecklistDetails.FenceDirectionID.ToString()).Description, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Single Nailed", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.SingleNailed).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("PPE Required", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.PPERequired).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Fence Install", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListFenceInstall. First(i => i.FenceInstallID.ToString() == model.BuildChecklistDetails.FenceInstallID.ToString()).Description, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Build Full Sections", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.BuildFullSections).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Equipment Operator Certs", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.EquipmentOperatorCertsReq).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Trim In Field", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.TrimInField).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Stain", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.Stain).Response, PDFUtil.spanNormalBlack, colSpan: 3)); buildList.AddCell(PDFUtil.CreateCell("Post Pins", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListBuildResponses. First(i => i.ResponseId == model.BuildChecklistDetails.PostPins).Response, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Stain Color", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.StainColor, PDFUtil.spanNormalBlack, colSpan: 3)); buildList.AddCell(PDFUtil.CreateCell("Tear Out Type", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.ListTearOutType. First(i => i.TearOutTypeID == model.BuildChecklistDetails.TearOutTypeID).Description, PDFUtil.spanNormalBlack)); buildList.AddCell(PDFUtil.CreateCell("Stain Brand", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.StainBrand, PDFUtil.spanNormalBlack, colSpan: 3)); buildList.AddCell(PDFUtil.CreateCell("Other Hazards", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.OtherHazards, PDFUtil.spanNormalBlack, colSpan: 2)); buildList.AddCell(PDFUtil.CreateCell("Notes", PDFUtil.font_body_bold, 2, false)); buildList.AddCell(PDFUtil.CreateCell(model.BuildChecklistDetails.Notes, PDFUtil.spanNormalBlack, colSpan: 3)); document.Add(buildList); #endregion document.Close(); byte[] file = ms.ToArray(); MemoryStream output = new MemoryStream(); output.Write(file, 0, file.Length); output.Position = 0; HttpContext.Response.AddHeader("content-disposition", "inline; filename=HardCard" + hid + ".pdf"); return(File(output, "application/pdf")); }