private void SortRecursiveTable(ref string output, ref MainDataSet.ArticleDataTable input, Guid?parentArticleId) { OrderedEnumerableRowCollection <MainDataSet.ArticleRow> query = null; if (parentArticleId.HasValue) { query = input.Where(w => w.IsParentArticleGuidNull() ? false : w.ParentArticleGuid.Equals(parentArticleId.Value)).OrderBy(o => o.Subject); } else { query = input.Where(w => w.IsParentArticleGuidNull()).OrderBy(o => o.Subject); } int cnt = query.Count(); if (cnt > 0) { output += "<ul>"; } foreach (MainDataSet.ArticleRow row in query) { output += string.Format(CultureInfo.CurrentCulture, "<li><a style=\"vertical-align:top\" href=\"Default.aspx?i={0}&t={1}\">{2}</a>", this.InstanceGuid.ToString("N"), row.ArticleGuid.ToString("N"), row.Subject); SortRecursiveTable(ref output, ref input, row.ArticleGuid); } if (cnt > 0) { output += "</ul>"; } }
private void ProcessDataChitiet(ref DataTable m_dtReport) { try { var lstAdded = new List <DataRow>(); int startDate = Utility.Int32Dbnull(Utility.GetYYYYMMDD(dtFromDate.Value), 0); int EndDate = Utility.Int32Dbnull(Utility.GetYYYYMMDD(dtToDate.Value), 0); int iFound = 0; int idx = 0; foreach (DataRow dr in m_dtReport.Rows) { DateTime _ngaybiendong = Convert.ToDateTime(dr[TBiendongThuoc.Columns.NgayBiendong]); long _myId = Utility.Int64Dbnull(dr[TBiendongThuoc.Columns.IdBiendong], 0); iFound++; if (iFound == 1) //Tính tồn cuối dòng đầu tiên tìm thấy { dr["Toncuoi"] = Utility.Int32Dbnull(dr["Tondau"], 0) + Utility.Int32Dbnull(dr["SoLuongNhap"], 0) - Utility.Int32Dbnull(dr["SoLuongXuat"], 0); } else { OrderedEnumerableRowCollection <DataRow> q = from p in m_dtReport.AsEnumerable() where Convert.ToDateTime( p[TBiendongThuoc.Columns.NgayBiendong]) <= _ngaybiendong && Utility.Int64Dbnull( p[TBiendongThuoc.Columns.IdBiendong], 0) != _myId && Utility.Int32Dbnull(p["processed"], 0) > 0 orderby Utility.Int32Dbnull(p["processed"], 0) descending //Convert.ToDateTime(p[TBiendongThuoc.Columns.NgayBiendong]) descending select p; if (q.Count() > 0) { DataRow drPrevious = q.FirstOrDefault(); dr["Tondau"] = Utility.Int32Dbnull(drPrevious["Toncuoi"], 0); dr["Toncuoi"] = Utility.Int32Dbnull(dr["Tondau"], 0) + Utility.Int32Dbnull(dr["SoLuongNhap"], 0) - Utility.Int32Dbnull(dr["SoLuongXuat"], 0); } } idx++; dr["processed"] = idx; m_dtReport.AcceptChanges(); } } catch { } }
private void ProcessDataThethuoc(ref DataTable m_dtReport) { DataTable dtTemp = m_dtReport.Clone(); try { var lstAdded = new List <DataRow>(); int startDate = Utility.Int32Dbnull(Utility.GetYYYYMMDD(dtFromDate.Value), 0); int EndDate = Utility.Int32Dbnull(Utility.GetYYYYMMDD(dtToDate.Value), 0); if (m_dtReport.Rows.Count == 1 && Utility.sDbnull(m_dtReport.Rows[0]["YYYYMMDD"], "") == "") { m_dtReport.Rows[0]["YYYYMMDD"] = startDate.ToString(); m_dtReport.Rows[0][TBiendongThuoc.Columns.NgayBiendong] = dtFromDate.Value.Date.ToString("dd/MM/yyyy"); } int iFound = 0; DataRow rowdata = m_dtReport.Rows[0]; DateTime _dtmStartDate = dtFromDate.Value.Date;// Utility.FromYYYYMMDD2Datetime(startDate.ToString()); if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_THETHUOC_TUDONGTHEMDULIEU_TUONGLAI", "0", false) == "1") { while (_dtmStartDate <= dtToDate.Value.Date) { DataRow[] arrDr = m_dtReport.Select("YYYYMMDD=" + Utility.GetYYYYMMDD(_dtmStartDate)); if (arrDr.Length > 0) { dtTemp.ImportRow(arrDr[0]); } else { DataRow newDr = dtTemp.NewRow(); Utility.CopyData(rowdata, ref newDr); newDr["YYYYMMDD"] = Utility.GetYYYYMMDD(_dtmStartDate); newDr[TBiendongThuoc.Columns.NgayBiendong] = _dtmStartDate.ToString("dd/MM/yyyy"); newDr["Xuat"] = 0; newDr["Tondau"] = 0; newDr["Toncuoi"] = 0; newDr["Nhap"] = 0; dtTemp.Rows.Add(newDr); } _dtmStartDate = _dtmStartDate.AddDays(1); } } else { dtTemp = m_dtReport.Copy(); } _dtmStartDate = dtFromDate.Value.Date; while (_dtmStartDate <= dtToDate.Value.Date) { DataRow[] arrDr = dtTemp.Select("YYYYMMDD=" + Utility.GetYYYYMMDD(_dtmStartDate)); if (arrDr.Length > 0) { iFound++; if (iFound == 1) //Tính tồn cuối dòng đầu tiên tìm thấy { arrDr[0]["Toncuoi"] = Utility.Int32Dbnull(arrDr[0]["Tondau"], 0) + Utility.Int32Dbnull(arrDr[0]["Nhap"], 0) - Utility.Int32Dbnull(arrDr[0]["Xuat"], 0); } else { OrderedEnumerableRowCollection <DataRow> q = from p in dtTemp.AsEnumerable() where Utility.Int32Dbnull(p["YYYYMMDD"], 0) < Utility.Int32Dbnull(Utility.GetYYYYMMDD(_dtmStartDate)) orderby p["YYYYMMDD"] descending select p; if (q.Count() > 0) { DataRow drPrevious = q.FirstOrDefault(); arrDr[0]["Tondau"] = Utility.Int32Dbnull(drPrevious["Toncuoi"], 0); arrDr[0]["Toncuoi"] = Utility.Int32Dbnull(arrDr[0]["Tondau"], 0) + Utility.Int32Dbnull(arrDr[0]["Nhap"], 0) - Utility.Int32Dbnull(arrDr[0]["Xuat"], 0); } } dtTemp.AcceptChanges(); } else { } _dtmStartDate = _dtmStartDate.AddDays(1); } } catch (Exception ex) { //Utility.CatchException(ex); } finally{ m_dtReport = dtTemp.Copy(); } }
public int GetCurves(string primID, int crvSeqNo, string worklistID, int worklistNumber) { ResultDataSet.Tables.Clear(); OrderedEnumerableRowCollection <DataRow> selectedRows = null; if (crvSeqNo > 0) { //var condition = new ParadoxCondition.Compare(ParadoxCompareOperator.Equal, mainTestID, 8, 0); //QueryArgs q = new QueryArgs("HRRuns", condition, "CrvSeqNum", ""); //return GetSimpleRowInfos(q, false); } if (!String.IsNullOrEmpty(primID) && worklistNumber > 0) { selectedRows = from qs in _dataSet.Tables["HRRuns"].AsEnumerable() where qs.Field <string>("PrimID") == primID && qs.Field <int>("WrkLstNum") == worklistNumber orderby qs.Field <int>("ChnlNum") ascending select qs; } if (!String.IsNullOrEmpty(worklistID) && worklistNumber > 0) { selectedRows = from qs in _dataSet.Tables["HRRuns"].AsEnumerable() where qs.Field <int>("WrkLstNum") == worklistNumber && qs.Field <string>("WrkLstID") == worklistID orderby qs.Field <int>("ChnlNum") ascending select qs; } if (selectedRows != null && selectedRows.Count() > 0) { // 创建结果报告集 DataTable reportTable = CreateReportTable(); ResultDataSet.Tables.Add(reportTable); // 创建病人信息结果集 DataTable patientTable = CreatePatientTable(); ResultDataSet.Tables.Add(patientTable); foreach (var sr in selectedRows) { // 创建曲线点信息 int lblChnNum = sr.Field <int>("ChnlNum") + 1; string label = "Channel " + lblChnNum.ToString(); AggRamCurve crv = new AggRamCurve( label, (int)sr["InitialMax"], (int)sr["InitialMin"], (int)sr["ScaleSet1Rd"], (int)sr["MaxPCPoint"], (double)sr["ScaleSetResult"], (int)sr["DataPoints"], (byte[])sr["Data"]); // Add Curve if (OnAddCurve != null) { OnAddCurve(label, crv); //OnAddCurve(label, CreateCurve((int)rdr["DataPoints"], (byte[])rdr["Data"])); } int selectedProcTag = sr.Field <int>("ProcTag"); var procs = from qs in _dataSet.Tables["HRTestParms"].AsEnumerable() where qs.Field <int>("ProcTag") == selectedProcTag select qs; // Add Report Row DataRow reportRow = reportTable.NewRow(); reportRow["ChnlNum"] = lblChnNum; reportRow["StartTime"] = sr.Field <DateTime>("StartTime"); if (procs.Count() > 0) { var procInfo = procs.First(); reportRow["ProcID"] = procInfo.Field <string>("ProcID"); reportRow["Abbrev"] = procInfo.Field <string>("Abbrev"); } reportRow["Unit"] = sr.Field <string>("Unit"); reportRow["Conc"] = sr.Field <double>("Conc"); reportRow["PRP"] = FloatPS(crv.PRP, 3); reportRow["PPP"] = FloatPS(crv.PPP, 3); reportRow["MaxPercent"] = FloatPS(crv.MaxPercent * 100, 1); reportRow["MaxPCTime"] = FloatPS((double)sr.Field <int>("MaxPCTime") / 1000.0, 0); reportRow["LagTime"] = FloatPS((double)sr.Field <int>("LagTime") / 1000.0, 1); reportRow["Slope"] = FloatPS(sr.Field <double>("Slope"), 1); reportTable.Rows.Add(reportRow); // Add Patient Row DataRow row = patientTable.NewRow(); row[0] = lblChnNum; string selectedPrimID = sr.Field <string>("PrimID"); var patientInfos = from qs in _dataSet.Tables["Patients"].AsEnumerable() where qs.Field <string>("PrimID") == selectedPrimID select qs; if (patientInfos.Count() > 0) { var patientInfo = patientInfos.First(); object[] array = (patientInfo.ItemArray.Take(patientTable.Columns.Count - 1)).ToArray(); for (int i = 0; i < patientTable.Columns.Count - 1; i++) { row[i + 1] = array[i]; } } else { row[1] = selectedPrimID; } patientTable.Rows.Add(row); } return(selectedRows.Count()); } return(0); }