0
나는 데이터베이스에서 가져온 항목 목록을 가지고 있으며 동시에 사용자가 발급 된 수량을 입력하기를 원합니다.텍스트 상자를 사용하여 데이터베이스 테이블에 값 입력 Asp.net MVC
내 문제는 내가 발행 수량에 대한 데이터베이스에있는 버튼 인쇄/문제에게 양을 클릭 한 후 내가 값을 입력 할 수있는 사용자에 대한 텍스트 상자를 추가 한 0
것입니다. 내가 여기있는 것이 바르게 행해졌는지 확실하지 않습니다.
@Html.TextBoxFor(model => model.item.quantityI, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.item.quantityI, "", new { @class = "text-danger" })
보기
if (@Model.items.Count > 0)
{
foreach (var issueditem in @Model.items)
{
<tr>
<td class="col-md-4">@issueditem.itemNumber</td>
<td class="col-md-4">@issueditem.description</td>
<td class="col-md-4">@issueditem.expense_account.getDescription</td>
<td class="col-md-2">@issueditem.quantity.ToString()</td>
<td class="col-md-5">
@*@Html.LabelFor(model => model.item.quantityI, htmlAttributes: new { @class = "col-md-3" })*@
@Html.TextBoxFor(model => model.item.quantityI, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.item.quantityI, "", new { @class = "text-danger" })
</td>
<td class="col-md-1">@issueditem.selecteduomtext </td>
<td class="col-md-1">@issueditem.price.ToString()</td>
</tr>
}
}
컨트롤러
public ActionResult ReceiptPrint(Issue issue)
{
IssueDAO dbdata = new IssueDAO();
dbdata.connectionString = ConfigurationManager.ConnectionStrings["TWCL_OPERATIONSConnectionString"].ConnectionString;
getIssue.transactionDate = DateTime.Now; //Sets the transaction date to current date
getIssue.status = -1;
getIssue.docType = "Issue";
ViewBag.StoresReps =dbdata.SelectEmployeesByDept("Stores");
getIssue.employeeDetails.employeeNum = issue.employeeDetails.employeeNum;
getIssue.processedbyDetails.employeeNum = issue.processedbyDetails.employeeNum;
getIssue.inventory_acccount=5520;
Item item = new Item();
try
{
dbdata.createIssue(getIssue, item);//Creates the issue in the database
}
catch (Exception ex)
{
LogWrite logWriter = new LogWrite(ex.ToString());
ViewBag.errorMessage = "Unable to complete the Issue. Please see Log file for more Information";
return View("IssueItem", getIssue);
}
DataSet ds = dbdata.GetReceipt(getIssue.requisitionNumber);
LocalReport localreport = new LocalReport();
localreport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Reports\Reciept.rdlc";
localreport.DataSources.Add(new ReportDataSource("Receipt_Data", ds.Tables[0]));
localreport.SetParameters(new ReportParameter("Req_num", getIssue.requisitionNumber));
string reporttype = "PDF";
string mimeType;
string encoding;
string fileNameExtension = "pdf";
string deviceInfo = @"<DeviceInfo>
<OutputFormat>PDF</OutputFormat>
<PageWidth>8.5in</PageWidth>
<PageHeight>11in</PageHeight>
<MarginTop>0.25in</MarginTop>
<MarginLeft>0.45in</MarginLeft>
<MarginRight>0.45in</MarginRight>
<MarginBottom>0.25in</MarginBottom></DeviceInfo>";
Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localreport.Render(
reporttype, deviceInfo, out mimeType, out encoding, out fileNameExtension,
out streams, out warnings);
var doc = new iTextSharp.text.Document();
var reader = new PdfReader(renderedBytes);
using (FileStream fs = new FileStream(Server.MapPath("~/Receipt" +
Convert.ToString(Session["CurrentUserName"]) + ".pdf"), FileMode.Create))
{
PdfStamper stamper = new PdfStamper(reader, fs);
string Printer = "Xerox Phaser 3635MFP PCL6";
// This is the script for automatically printing the pdf in acrobat viewer
stamper.JavaScript = "var pp = getPrintParams();pp.interactive =pp.constants.interactionLevel.automatic; pp.printerName = " +
Printer + ";print(pp);\r";
stamper.Close();
}
reader.Close();
FileStream fss = new FileStream(Server.MapPath("~/Receipt.pdf"), FileMode.Open);
byte[] bytes = new byte[fss.Length];
fss.Read(bytes, 0, Convert.ToInt32(fss.Length));
fss.Close();
System.IO.File.Delete(Server.MapPath("~/Receipt.pdf"));
return File(bytes, "application/pdf", "receipt.pdf");
}
여기 전체 과정이 명확하지 않습니다. 보기의 단편에는 양식이 없습니다. 게시 내용은 무엇입니까? 그런 다음 @ 존 믹첼 (JohnMitchell)은 당신이 어디에서나 수량 (quantity)을 사용하지 않는다고 말합니다. 그래서 그것이 발급 된 금액이라면, 당신은 그것을 설정하지 않습니다. 데이터를 데이터베이스에 저장하고있는 유일한 부분은'dbdata.createIssue (getIssue, item)'을 사용하는 곳이며, 당신은 어쨌든 그 메소드에 quantityI를 전달하지 않는 것 같습니다. – Dzyann