public void populateGRV() { DataTable dt = new DataTable(); dt = pRequest.getunapprovedPRs(new Guid(Session["UserGuid"].ToString())); PRApproval.DataSource = dt; PRApproval.DataBind(); }
[Authorize(Roles = SD.Role_Admin_Modify + "," + SD.Role_Admin_View + "," + SD.Role_Employee_Modify)]// Add authorization Level public IActionResult Upsert(PRApprovalVM prapprovalVM) { if (ModelState.IsValid) { // to pass parameters to sql procedrues var parameter = new DynamicParameters(); parameter.Add("@PRApprovalId", prapprovalVM.PRApproval.PRApprovalId); parameter.Add("@PRApprovalTitle ", prapprovalVM.PRApproval.PRApprovalTitle); parameter.Add("@PRApprovalDescription ", prapprovalVM.PRApproval.PRApprovalDescription); parameter.Add("@WorkOrder ", prapprovalVM.PRApproval.WorkOrder); parameter.Add("@CMOA", prapprovalVM.PRApproval.CMOA); parameter.Add("@MatCorVer ", prapprovalVM.PRApproval.MatCorVer); parameter.Add("@Warranty ", prapprovalVM.PRApproval.Warranty); parameter.Add("@WorkDurationSiteDays ", prapprovalVM.PRApproval.WorkDurationSiteDays); parameter.Add("@RateSheet ", prapprovalVM.PRApproval.RateSheet); parameter.Add("@GateAccess ", prapprovalVM.PRApproval.GateAccess); parameter.Add("@RentalPeriodDays ", prapprovalVM.PRApproval.RentalPeriodDays); parameter.Add("@EquipmentTireEngine ", prapprovalVM.PRApproval.EquipmentTireEngine); parameter.Add("@JustificationVendor ", prapprovalVM.PRApproval.JustificationVendor); parameter.Add("@VendorId", prapprovalVM.PRApproval.VendorId); parameter.Add("@PurchaseTypeId", prapprovalVM.PRApproval.PurchaseTypeId); parameter.Add("@SourcedBy", prapprovalVM.PRApproval.SourcedBy); parameter.Add("@ProjectId", prapprovalVM.PRApproval.ProjectId); // File operation started string webRootPath = _hostEnvironment.WebRootPath; PRApproval objFromDB = _unitOfWork.PRApproval.Get(prapprovalVM.PRApproval.Id); //testing now for delete the old files if ((objFromDB != null) && (objFromDB.ExcelFileUrl != null)) // //testing now for delete the old files { // this is an edit and we need to remove old image // var quotePath = Path.Combine(webRootPath, quoteVM.Quote.PdfUrl.TrimStart('\\')); var excelPath = Path.Combine(webRootPath, objFromDB.ExcelFileUrl.TrimStart('\\')); if (System.IO.File.Exists(excelPath)) { System.IO.File.Delete(excelPath); } } // Start check case if edit or new to create the ID if (prapprovalVM.PRApproval.Id == 0) { prapprovalVM.PRApproval.PRApprovalId = GetNextPRID(); } else { prapprovalVM.PRApproval.PRApprovalId = _unitOfWork.PRApproval.Get(prapprovalVM.PRApproval.Id).PRApprovalId; } // End check case if edit or new to create the ID // Adding operation to create an excel file var ExcelFileUrlName = CreateEmptyExcelPRA(prapprovalVM.PRApproval.PRApprovalId.ToString(), _unitOfWork.Vendor.Get(prapprovalVM.PRApproval.VendorId).VendorName, prapprovalVM.PRApproval.PRApprovalTitle, _unitOfWork.PurchaseType.Get(prapprovalVM.PRApproval.PurchaseTypeId).PurcahseCode.ToString(), "0"); parameter.Add("@ExcelFileUrl", ExcelFileUrlName); prapprovalVM.PRApproval.ExcelFileUrl = ExcelFileUrlName; // File Operation Ended if (prapprovalVM.PRApproval.Id == 0) // create case whenever no ID posted { //prapprovalVM.PRApproval.PRApprovalId = GetNextPRID(); // Get next ID _unitOfWork.PRApproval.Add(prapprovalVM.PRApproval); // to allow sql procedrues // _unitOfWork.SP_Call.Execute(SD.Proc_PRApproval_Create, parameter); } else { parameter.Add("@Id", prapprovalVM.PRApproval.Id); // _unitOfWork.SP_Call.Execute(SD.Proc_PRApproval_Update, parameter); _unitOfWork.PRApproval.Update(prapprovalVM.PRApproval); } _unitOfWork.Save(); EditExcelPRA(_unitOfWork.PRApproval.Get(prapprovalVM.PRApproval.Id).ExcelFileUrl, prapprovalVM.PRApproval); return(RedirectToAction(nameof(Index))); // if any mistake the name is gotted } return(View(prapprovalVM)); }
public string EditExcelPRA(string excelpath, PRApproval prapproval) { string webRootPath = _hostEnvironment.WebRootPath; byte[] fileContents; //using (ExcelPackage package = new ExcelPackage(new FileInfo(excelpath.TrimStart('\\')))) // string excelpathTrimed = excelpath.Replace(@"\\", @"\"); string excelpathTrimed = Path.Combine(webRootPath, excelpath.TrimStart('\\')); using (ExcelPackage package = new ExcelPackage(new FileInfo(excelpathTrimed))) { ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"]; ExcelWorksheet worksheetcover = package.Workbook.Worksheets["Cover Page"]; worksheet.Cells["F5"].Value = prapproval.PRApprovalId; // Setting the ID // Setup Area Code and Request Type worksheet.Cells["F6"].Value = _unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode; // Setting the Area Code worksheet.Cells["F7"].Value = _unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurchaseTypeAppr; // Setting the Area Code worksheet.Cells["C8"].Value = prapproval.PRApprovalTitle.ToString(); worksheet.Cells["C10"].Value = prapproval.PRApprovalDescription; // Check the data type and fill the code if (_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 17) { worksheet.Cells["D11"].Value = prapproval.RentalPeriodDays; worksheet.Cells["D12"].Value = prapproval.EquipmentTireEngine; worksheet.Cells["F11"].Value = prapproval.GateAccess; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 18)) { worksheet.Cells["D11"].Value = prapproval.CMOA == true ? "Yes" : "No"; worksheet.Cells["D12"].Value = prapproval.MatCorVer == true ? "Yes" : "No"; worksheet.Cells["F11"].Value = prapproval.Warranty == true ? "Yes" : "No"; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 19)) { worksheet.Cells["D11"].Value = prapproval.WorkDurationSiteDays; worksheet.Cells["D12"].Value = prapproval.GateAccess == true? "Yes":"No"; worksheet.Cells["F11"].Value = prapproval.RateSheet == true ? "Yes" : "No"; } else { worksheet.Cells["D11"].Value = null; worksheet.Cells["D12"].Value = null; worksheet.Cells["F11"].Value = null; } worksheet.Cells["F12"].Value = prapproval.WorkOrder; // Set the work order worksheet.Cells["C30"].Value = prapproval.JustificationVendor; // Set the Justificaiton for the vendor worksheet.Cells["D31"].Value = _unitOfWork.Vendor.Get(prapproval.VendorId).VendorName; // Set the Justificaiton for the vendor worksheet.Cells["D60"].Value = _unitOfWork.Employee.Get(prapproval.SourcedBy).EmployeeName; // Set the Submitted by in the Database // Arrange for cover page worksheetcover.Cells["B6"].Value = "Contract No. " + _unitOfWork.Project.Get(prapproval.ProjectId).ContractNo.ToString(); worksheetcover.Cells["B7"].Value = "WPI " + _unitOfWork.Project.Get(prapproval.ProjectId).WorkPackageIn.ToString() + ": Site Services & Maintenance"; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; // package.Save(); // file could be saved using the file stream // One way to save file is to save it as abinary file fileContents = package.GetAsByteArray(); System.IO.File.WriteAllBytes(excelpathTrimed, fileContents); // file could be saved using save as method //fileContents = null; //FileInfo fi = new FileInfo(excelpathTrimed); //package.SaveAs(fi); //package.SaveAs(FileInfo(excelpathTrimed)); Response.Clear(); // Response.End(); // Response.BinaryWrite(package.GetAsByteArray()); //Response.End(); // clear the work area // Response.Clear(); //Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx"); //Response.BinaryWrite(package.GetAsByteArray()); } if (fileContents == null || fileContents.Length == 0) { return(null); } File( fileContents: fileContents, contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); /* * return File( * fileContents: fileContents, * contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", * fileDownloadName: "StudinetList.xlsx"); * */ return("hi"); }
// Adding function for editing the excel file public string EditExcelPRAQuote(string excelpath, PRAQuote praquote) { string webRootPath = _hostEnvironment.WebRootPath; byte[] fileContents; PRApproval prapproval = _unitOfWork.PRApproval.Get(praquote.PRAId); //using (ExcelPackage package = new ExcelPackage(new FileInfo(excelpath.TrimStart('\\')))) // string excelpathTrimed = excelpath.Replace(@"\\", @"\"); string excelpathTrimed = Path.Combine(webRootPath, excelpath.TrimStart('\\')); using (ExcelPackage package = new ExcelPackage(new FileInfo(excelpathTrimed))) { // Configure the work sheets ExcelWorksheet worksheet = package.Workbook.Worksheets["Sheet1"]; ExcelWorksheet worksheetcover = package.Workbook.Worksheets["Cover Page"]; // Setting the main PR Area worksheet.Cells["F5"].Value = prapproval.PRApprovalId; // Setting the ID // Setup Area Code and Request Type worksheet.Cells["F6"].Value = _unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode; // Setting the Area Code worksheet.Cells["F7"].Value = _unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurchaseTypeAppr; // Setting the Area Code worksheet.Cells["C8"].Value = prapproval.PRApprovalTitle.ToString(); worksheet.Cells["C10"].Value = prapproval.PRApprovalDescription; // Check the data type and fill the code if (_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 17) { worksheet.Cells["D11"].Value = prapproval.RentalPeriodDays; worksheet.Cells["D12"].Value = prapproval.EquipmentTireEngine; worksheet.Cells["F11"].Value = prapproval.GateAccess; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 18)) { worksheet.Cells["D11"].Value = prapproval.CMOA == true ? "Yes" : "No"; worksheet.Cells["D12"].Value = prapproval.MatCorVer == true ? "Yes" : "No"; worksheet.Cells["F11"].Value = prapproval.Warranty == true ? "Yes" : "No"; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 19)) { worksheet.Cells["D11"].Value = prapproval.WorkDurationSiteDays; worksheet.Cells["D12"].Value = prapproval.GateAccess == true ? "Yes" : "No"; worksheet.Cells["F11"].Value = prapproval.RateSheet == true ? "Yes" : "No"; } else { worksheet.Cells["D11"].Value = null; worksheet.Cells["D12"].Value = null; worksheet.Cells["F11"].Value = null; } worksheet.Cells["F12"].Value = prapproval.WorkOrder; // Set the work order worksheet.Cells["C30"].Value = prapproval.JustificationVendor; // Set the Justificaiton for the vendor worksheet.Cells["D31"].Value = _unitOfWork.Vendor.Get(prapproval.VendorId).VendorName; // Set the Justificaiton for the vendor worksheet.Cells["D60"].Value = _unitOfWork.Employee.Get(prapproval.SourcedBy).EmployeeName; // Set the Submitted by in the Database // Arrrange PR Quote Area worksheet.Cells["D6"].Value = praquote.PRAQuoteDate.Date; worksheet.Cells["D7"].Value = praquote.PRARevision; worksheet.Cells["C14"].Value = praquote.JustificationRev; worksheet.Cells["D19"].Value = praquote.EstimatedPrice; // Check the data type and fill the code switch (praquote.PRARevision) { case 0: if (_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 17) { worksheet.Cells["D20"].Value = praquote.RentalInsurance; worksheet.Cells["D21"].Value = praquote.Mobilization; worksheet.Cells["D22"].Value = praquote.EquipmentDisinfection; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 18)) { worksheet.Cells["D20"].Value = praquote.AddWarCost; worksheet.Cells["D21"].Value = praquote.FreightCost; worksheet.Cells["D22"].Value = praquote.EnvFees; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 19)) { worksheet.Cells["D20"].Value = praquote.PSTCost; worksheet.Cells["D21"].Value = praquote.Mobilization; worksheet.Cells["D22"].Value = praquote.SiteOrientation; } else { worksheet.Cells["D20"].Value = null; worksheet.Cells["D21"].Value = null; worksheet.Cells["D22"].Value = null; } break; case 1: if (_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 17) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).RentalInsurance; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).Mobilization; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).EquipmentDisinfection; worksheet.Cells["E20"].Value = praquote.RentalInsurance; worksheet.Cells["E21"].Value = praquote.Mobilization; worksheet.Cells["E22"].Value = praquote.EquipmentDisinfection; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 18)) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).AddWarCost; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).FreightCost; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).EnvFees; worksheet.Cells["E20"].Value = praquote.AddWarCost; worksheet.Cells["E21"].Value = praquote.FreightCost; worksheet.Cells["E22"].Value = praquote.EnvFees; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 19)) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).PSTCost; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).Mobilization; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).SiteOrientation; worksheet.Cells["E20"].Value = praquote.PSTCost; worksheet.Cells["E21"].Value = praquote.Mobilization; worksheet.Cells["E22"].Value = praquote.SiteOrientation; } else { worksheet.Cells["D20"].Value = null; worksheet.Cells["D21"].Value = null; worksheet.Cells["D22"].Value = null; worksheet.Cells["E20"].Value = null; worksheet.Cells["E21"].Value = null; worksheet.Cells["E22"].Value = null; } break; case 2: if (_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 17) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).RentalInsurance; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).Mobilization; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).EquipmentDisinfection; worksheet.Cells["E20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).RentalInsurance; worksheet.Cells["E21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).Mobilization; worksheet.Cells["E22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).EquipmentDisinfection; worksheet.Cells["F20"].Value = praquote.RentalInsurance; worksheet.Cells["F21"].Value = praquote.Mobilization; worksheet.Cells["F22"].Value = praquote.EquipmentDisinfection; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 18)) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).AddWarCost; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).FreightCost; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).EnvFees; worksheet.Cells["E20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).AddWarCost; worksheet.Cells["E21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).FreightCost; worksheet.Cells["E22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).EnvFees; worksheet.Cells["F20"].Value = praquote.AddWarCost; worksheet.Cells["F21"].Value = praquote.FreightCost; worksheet.Cells["F22"].Value = praquote.EnvFees; } else if ((_unitOfWork.PurchaseType.Get((prapproval.PurchaseTypeId)).PurcahseCode == 19)) { worksheet.Cells["D20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).PSTCost; worksheet.Cells["D21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).Mobilization; worksheet.Cells["D22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 0).SiteOrientation; worksheet.Cells["E20"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).PSTCost; worksheet.Cells["E21"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).Mobilization; worksheet.Cells["E22"].Value = _unitOfWork.PRAQuote.GetFirstOrDefault(a => a.PRAId == praquote.PRAId && a.PRARevision == 1).SiteOrientation; worksheet.Cells["F20"].Value = praquote.PSTCost; worksheet.Cells["F21"].Value = praquote.Mobilization; worksheet.Cells["F22"].Value = praquote.SiteOrientation; } else { worksheet.Cells["D20"].Value = null; worksheet.Cells["D21"].Value = null; worksheet.Cells["D22"].Value = null; worksheet.Cells["E20"].Value = null; worksheet.Cells["E21"].Value = null; worksheet.Cells["E22"].Value = null; worksheet.Cells["F20"].Value = null; worksheet.Cells["F21"].Value = null; worksheet.Cells["F22"].Value = null; } break; default: break; } worksheet.Cells["D23"].Value = praquote.CarbonTax; //worksheet.Cells["D24"].Value = praquote.CarbonTax; worksheet.Cells["D25"].Value = praquote.ContingencyPercentage; //worksheet.Cells["D26"].Value = praquote.ContingencyAmount; // worksheet.Cells["D23"].Value = praquote.Total; worksheet.Cells["D32"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).QuoteAmount; worksheet.Cells["D33"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).SiteCompliant == true?"Yes": "N/A"; worksheet.Cells["D34"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).Less3K == true? "Yes":"No"; worksheet.Cells["D35"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).SoleProvider == true ? "Yes" : "No"; worksheet.Cells["D36"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).OEM == true ? "Yes" : "No"; worksheet.Cells["D37"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).ScheduleDrivenPur == true ? "Yes" : "No"; worksheet.Cells["F33"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).Commonality == true ? "Yes" : "No"; worksheet.Cells["F34"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).FirstNation == true ? "Yes" : "No"; worksheet.Cells["F35"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).Metis == true ? "Yes" : "No"; worksheet.Cells["F36"].Value = _unitOfWork.Quote.Get(praquote.QuoteId).LocalVendor == true ? "Yes" : "No"; worksheet.Cells["D38"].Value = _unitOfWork.VendorContact.Get(_unitOfWork.Quote.Get(praquote.QuoteId).VendorContactId).Name; worksheet.Cells["E38"].Value = _unitOfWork.VendorContact.Get(_unitOfWork.Quote.Get(praquote.QuoteId).VendorContactId).Email; // Data for Alternate qutoe1 if (praquote.QuoteAl1Id != null) { worksheet.Cells["D43"].Value = _unitOfWork.Vendor.Get((_unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).VendorId)).VendorName; worksheet.Cells["D44"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).QuoteAmount; worksheet.Cells["D45"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).SiteCompliant == true ? "Yes" : "N/A"; worksheet.Cells["D46"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).Less3K == true ? "Yes" : "No"; worksheet.Cells["D47"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).SoleProvider == true ? "Yes" : "No"; worksheet.Cells["D48"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).OEM == true ? "Yes" : "No"; worksheet.Cells["D49"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).ScheduleDrivenPur == true ? "Yes" : "No"; worksheet.Cells["F45"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).Commonality == true ? "Yes" : "No"; worksheet.Cells["F46"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).FirstNation == true ? "Yes" : "No"; worksheet.Cells["F47"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).Metis == true ? "Yes" : "No"; worksheet.Cells["F48"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl1Id).LocalVendor == true ? "Yes" : "No"; } else { worksheet.Cells["D43"].Value = null; worksheet.Cells["D44"].Value = null; worksheet.Cells["D45"].Value = null; worksheet.Cells["D46"].Value = null; worksheet.Cells["D47"].Value = null; worksheet.Cells["D48"].Value = null; worksheet.Cells["D49"].Value = null; worksheet.Cells["F45"].Value = null; worksheet.Cells["F46"].Value = null; worksheet.Cells["F47"].Value = null; worksheet.Cells["F48"].Value = null; } // Data for Alternate qutoe2 if (praquote.QuoteAl2Id != null) { worksheet.Cells["D51"].Value = _unitOfWork.Vendor.Get((_unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).VendorId)).VendorName; worksheet.Cells["D52"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).QuoteAmount; worksheet.Cells["D53"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).SiteCompliant == true ? "Yes" : "N/A"; worksheet.Cells["D54"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).Less3K == true ? "Yes" : "No"; worksheet.Cells["D55"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).SoleProvider == true ? "Yes" : "No"; worksheet.Cells["D56"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).OEM == true ? "Yes" : "No"; worksheet.Cells["D57"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).ScheduleDrivenPur == true ? "Yes" : "No"; worksheet.Cells["F53"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).Commonality == true ? "Yes" : "No"; worksheet.Cells["F54"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).FirstNation == true ? "Yes" : "No"; worksheet.Cells["F55"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).Metis == true ? "Yes" : "No"; worksheet.Cells["F56"].Value = _unitOfWork.Quote.Get((int)praquote.QuoteAl2Id).LocalVendor == true ? "Yes" : "No"; } else { worksheet.Cells["D51"].Value = null; worksheet.Cells["D52"].Value = null; worksheet.Cells["D53"].Value = null; worksheet.Cells["D54"].Value = null; worksheet.Cells["D55"].Value = null; worksheet.Cells["D56"].Value = null; worksheet.Cells["D57"].Value = null; worksheet.Cells["F53"].Value = null; worksheet.Cells["F54"].Value = null; worksheet.Cells["F55"].Value = null; worksheet.Cells["F56"].Value = null; } worksheet.Cells["D59"].Value = _unitOfWork.Employee.Get(praquote.SubmittedBy).EmployeeName; // Set the Submitted by in the Database // Arrange for cover page worksheetcover.Cells["B6"].Value = "Contract No. " + _unitOfWork.Project.Get(prapproval.ProjectId).ContractNo.ToString(); worksheetcover.Cells["B7"].Value = "WPI " + _unitOfWork.Project.Get(prapproval.ProjectId).WorkPackageIn.ToString() + ": Site Services & Maintenance"; package.Save(); fileContents = package.GetAsByteArray(); //package.SaveAs(FileInfo(excelpathTrimed)); Response.Clear(); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; //Response.BinaryWrite(package.GetAsByteArray()); // send the file // Response.End(); // Response.BinaryWrite(package.GetAsByteArray()); //Response.End(); // clear the work area // Response.Clear(); //Response.AddHeader("content-disposition", "attachment; filename=ExcelDemo.xlsx"); //Response.BinaryWrite(package.GetAsByteArray()); } if (fileContents == null || fileContents.Length == 0) { return(null); } File( fileContents: fileContents, contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); /* * return File( * fileContents: fileContents, * contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", * fileDownloadName: "StudinetList.xlsx"); * */ return("hi"); }