diff --git a/Labtracker/AddUpdate.cs b/Labtracker/AddUpdate.cs index 1939dac..338704a 100644 --- a/Labtracker/AddUpdate.cs +++ b/Labtracker/AddUpdate.cs @@ -402,21 +402,24 @@ public bool AddUpdate(string dater,string repDate, string SaId, string week, str //Overload for DnaExtraction - public bool AddUpdater(DateTime? dater, string PaId, string purity, string ndConc, string qubConc,string remark , string labInitial) + public bool AddDnaExtract(string dater, string PaId, string purity, string ndConc, string qubConc,string remark , string labInitial, string tubeLabel, string goodQQ,string sampleType, string assayReagent) { var tbgdnaextractupdates = new Dnaextract(); tbgdnaextractupdates.PatientId = PaId; //tbgdstupdates.DstID = Convert.ToInt32(ResuId); tbgdnaextractupdates.Initial = labInitial; - tbgdnaextractupdates.Purity = Convert.ToDecimal(purity); - tbgdnaextractupdates.NDConc = Convert.ToDecimal(ndConc); - tbgdnaextractupdates.QubitConc = Convert.ToDecimal(qubConc); - - - tbgdnaextractupdates.ExtractDate = Convert.ToDateTime(dater); + tbgdnaextractupdates.Purity = string.IsNullOrWhiteSpace(purity)? (decimal?)null : Convert.ToDecimal(purity); + tbgdnaextractupdates.NDConc = string.IsNullOrWhiteSpace(ndConc)? (decimal?)null : Convert.ToDecimal(ndConc); + tbgdnaextractupdates.QubitConc = qubConc; + tbgdnaextractupdates.ExtractDate = string.IsNullOrEmpty(dater)? (DateTime?)null : Convert.ToDateTime(dater); tbgdnaextractupdates.Remark = remark; + tbgdnaextractupdates.GoodQQ = goodQQ; + tbgdnaextractupdates.TubeLabel = tubeLabel; + tbgdnaextractupdates.SampleType = sampleType; + tbgdnaextractupdates.AssayReagent = assayReagent; + using (SampleContext _db = new SampleContext()) { diff --git a/Labtracker/Controllers/DnaExtractExcelController.cs b/Labtracker/Controllers/DnaExtractExcelController.cs new file mode 100644 index 0000000..e79e3ee --- /dev/null +++ b/Labtracker/Controllers/DnaExtractExcelController.cs @@ -0,0 +1,176 @@ +using ExcelDataReader; +using Labtracker.Models; +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace Labtracker.Controllers +{ + public class DnaExtractExcelController : Controller + { + // GET: DnaExtractExcel + public ActionResult Index() + { + DataTable dt = new DataTable(); + try + { + dt = (DataTable)Session["tmpdata"]; + } + catch (Exception) + { + throw; + } + + return View(dt); + } + + + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Index(HttpPostedFileBase upload) + { + + if (ModelState.IsValid) + { + + if (upload != null && upload.ContentLength > 0) + { + // ExcelDataReader works with the binary Excel file, so it needs a FileStream + // to get started. This is how we avoid dependencies on ACE or Interop: + Stream stream = upload.InputStream; + + // We return the interface, so that + IExcelDataReader reader = null; + + + if (upload.FileName.EndsWith(".xls")) + { + reader = ExcelReaderFactory.CreateBinaryReader(stream); + } + else if (upload.FileName.EndsWith(".xlsx")) + { + reader = ExcelReaderFactory.CreateOpenXmlReader(stream); + } + else + { + ModelState.AddModelError("File", "This file format is not supported"); + return View(); + } + int fieldcount = reader.FieldCount; + int rowcount = reader.RowCount; + + + DataTable dt = new DataTable(); + //dt.Columns.Add("UserName"); + //dt.Columns.Add("Adddress"); + DataRow row; + + + DataTable dt_ = new DataTable(); + string err1 = "", err2 = ""; + try + { + + dt_ = reader.AsDataSet().Tables[0]; + + string ret = ""; + + for (int i = 0; i < dt_.Columns.Count; i++) + { + dt.Columns.Add(dt_.Rows[0][i].ToString()); + } + + int rowcounter = 0; + for (int row_ = 1; row_ < dt_.Rows.Count; row_++) + { + row = dt.NewRow(); + + for (int col = 0; col < dt_.Columns.Count; col++) + { + + row[col] = dt_.Rows[row_][col].ToString(); + rowcounter++; + } + dt.Rows.Add(row); + + err1 = row[9].ToString(); + err2 = row[10].ToString(); + //db insert + try + { + using (var context = new SampleContext()) + + { + + + + var tbgdnaextractupdates = new Dnaextract(); + + tbgdnaextractupdates.PatientId = row[0].ToString(); + tbgdnaextractupdates.TubeLabel = row[1].ToString(); + tbgdnaextractupdates.GoodQQ = row[2].ToString(); + tbgdnaextractupdates.NDConc = string.IsNullOrWhiteSpace(row[3].ToString()) ? (decimal?)null : Convert.ToDecimal(row[3].ToString()); + tbgdnaextractupdates.Purity = string.IsNullOrWhiteSpace(row[5].ToString()) ? (decimal?)null : Convert.ToDecimal(row[5].ToString()); + tbgdnaextractupdates.SampleType = row[6].ToString(); + tbgdnaextractupdates.QubitConc = row[7].ToString(); + + tbgdnaextractupdates.AssayReagent = row[9].ToString(); + tbgdnaextractupdates.ExtractDate = string.IsNullOrEmpty(row[10].ToString()) ? (DateTime?)null : Convert.ToDateTime(row[10].ToString()); + + //tbgdnaextractupdates.Initial = labInitial; + //tbgdnaextractupdates.Remark = remark; + + context.Dnaextracts.Add(tbgdnaextractupdates); + context.SaveChanges(); + + + } + } + catch (Exception ex1) + { + throw ex1; + + } + + } + + } + catch (Exception ex) + { + + ModelState.AddModelError("File", ex.ToString() + err1 + err2 + "Unable to Upload file! Info: Data Validation Error, Invalid data entry."); + + return View(); + } + + DataSet result = new DataSet();//reader.AsDataSet(); + result.Tables.Add(dt); + string minutes_ID = ""; + + reader.Close(); + reader.Dispose(); + // return View(); + // return View(result.Tables[0]); + + DataTable ddd = result.Tables[0]; + + Session["tmpdata"] = ddd; + + return RedirectToAction("Index"); + + } + else + { + ModelState.AddModelError("File", "Please Choose Your file to Upload"); + } + } + return View(); + } + + } +} \ No newline at end of file diff --git a/Labtracker/Labtracker.csproj b/Labtracker/Labtracker.csproj index 26cf77c..e99bd34 100644 --- a/Labtracker/Labtracker.csproj +++ b/Labtracker/Labtracker.csproj @@ -2278,6 +2278,7 @@ Contact.aspx + @@ -2493,6 +2494,7 @@ + Web.config diff --git a/Labtracker/Models/Dnaextract.cs b/Labtracker/Models/Dnaextract.cs index f9446ab..4b7562d 100644 --- a/Labtracker/Models/Dnaextract.cs +++ b/Labtracker/Models/Dnaextract.cs @@ -16,13 +16,13 @@ public class Dnaextract public string PatientId { get; set; } [Display(Name = "ND Conc")] - public decimal NDConc { get; set; } + public Nullable NDConc { get; set; } [Display(Name = "Qubit Conc")] - public decimal QubitConc { get; set; } + public string QubitConc { get; set; } [Display(Name = "Purity")] - public decimal Purity { get; set; } + public Nullable Purity { get; set; } [Display(Name = "Extract Date")] public Nullable ExtractDate { get; set; } @@ -32,6 +32,11 @@ public class Dnaextract [Display(Name = "Initial")] public string Initial { get; set; } + public string TubeLabel { get; set; } + + public string GoodQQ { get; set; } + public string SampleType { get; set; } + public string AssayReagent { get; set; } } } \ No newline at end of file diff --git a/Labtracker/Views/DnaExtractExcel/Index.cshtml b/Labtracker/Views/DnaExtractExcel/Index.cshtml new file mode 100644 index 0000000..0896981 --- /dev/null +++ b/Labtracker/Views/DnaExtractExcel/Index.cshtml @@ -0,0 +1,119 @@ + + +@{ + ViewBag.Title = "DNA Extract Excel Upload"; +} + +@model System.Data.DataTable +@using System.Data; + + + + + + + + +@using (Html.BeginForm("Index", "DnaExtractExcel", null, FormMethod.Post, new { enctype = "multipart/form-data" })) +{ +
+

DnaExtract Excel File Upload

+ @Html.AntiForgeryToken() + +
+ +
+
+ + @**@ + + @**@ + +
+
+ @**@ + +
+ +
+ + @**@ +
+ + +
+ @Html.ValidationSummary() + @* asdasd*@ +
+ + + +
+ if (Model != null) + { + + + + @foreach (DataColumn col in Model.Columns) + { + + } + + + + @foreach (DataRow row in Model.Rows) + { + + @foreach (DataColumn col in Model.Columns) + { + + } + + } + +
@col.ColumnName
@row[col.ColumnName]
+ } +} + + + + diff --git a/Labtracker/addsequencing.aspx b/Labtracker/addsequencing.aspx index 6f4a253..9e29f9f 100644 --- a/Labtracker/addsequencing.aspx +++ b/Labtracker/addsequencing.aspx @@ -81,13 +81,15 @@
+ + Good Quality & Quantity: - Good for library Prep - Failed-Repeat Extraction - Failed-Discard + Yes + No + @@ -99,12 +101,12 @@
- +

- +

@@ -128,7 +130,7 @@
Average Size - +
Average Size Percent @@ -347,23 +349,42 @@