/// <summary> /// 初始化表格 /// </summary> private void InitGridSource(MedGridView control, Dictionary <string, System.Data.DataTable> dataSources) { List <MED_QIXIE_QINGDIAN> dataTable = new ModelHandler <MED_QIXIE_QINGDIAN>().FillModel(dataSources["MED_QIXIE_QINGDIAN"]); List <MED_QIXIE_QINGDIAN> qiXierows = null; if (dataTable != null && dataTable.Count > 0) { qiXierows = dataTable.Where(x => x.TABLETAG == control.Name).ToList();; } if (qiXierows == null || qiXierows.Count == 0) { if (string.IsNullOrEmpty(control.DefaultDatas)) { return; } if (dataTable == null) { dataTable = CareDocService.ClientInstance.GetOperCheckList(ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID, ExtendAppContext.Current.PatientInformationExtend.VISIT_ID, ExtendAppContext.Current.PatientInformationExtend.OPER_ID); } string defaultDatas = control.DefaultDatas; string[] rows = defaultDatas.Split(new string[] { "{}" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < rows.Length; i++) { string[] rowdatas = rows[i].Split(new string[] { "[]" }, StringSplitOptions.None); for (int j = 0; j < rowdatas.Length; j++) { try { if (string.IsNullOrEmpty(rowdatas[j])) { continue; } MED_QIXIE_QINGDIAN row = new MED_QIXIE_QINGDIAN(); row.PATIENT_ID = ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID; row.VISIT_ID = ExtendAppContext.Current.PatientInformationExtend.VISIT_ID; row.OPER_ID = ExtendAppContext.Current.PatientInformationExtend.OPER_ID; row.X_POSITION = j; row.Y_POSITION = i; row.POSITION_VALUE = rowdatas[j]; row.TABLETAG = control.Name; dataTable.Add(row); } catch (Exception ex) { ExceptionHandler.Handle(ex); } } } dataSources["MED_QIXIE_QINGDIAN"] = new ModelHandler <MED_QIXIE_QINGDIAN>().FillDataTable(dataTable); } }
protected override void OnSaveData(Dictionary <string, DataTable> dataSource) { #region 手术清点单添加多表格功能 List <MED_QIXIE_QINGDIAN> dataTable = ModelHelper <MED_QIXIE_QINGDIAN> .ConvertDataTableToList(dataSource["MED_QIXIE_QINGDIAN"]); MED_QIXIE_QINGDIAN row = null; string patientID = ExtendApplicationContext.Current.PatientContextExtend.PatientID; int visitID = ExtendApplicationContext.Current.PatientContextExtend.VisitID; int operID = ExtendApplicationContext.Current.PatientContextExtend.OperID; if (dataTable == null) { dataTable = operationInfoRepository.GetOperCheckList(patientID, visitID, operID).Data; } List <MedGridView> grids = base.GetControls <MedGridView>(); foreach (MedGridView grid in grids) { for (int i = 0; i < grid.RowCount; i++) { for (int j = 0; j < grid.ColumnCount; j++) { DataGridViewCell cell = grid[j, i]; List <MED_QIXIE_QINGDIAN> rows = null; rows = dataTable.Where(x => x.PATIENT_ID == patientID && x.VISIT_ID == visitID && x.OPER_ID == operID && x.X_POSITION == j && x.Y_POSITION == i && x.TABLETAG == grid.Name).ToList(); if (rows != null && rows.Count > 0) { row = rows[0]; } else { row = null; } string celltext = string.Empty; if (cell.Value != null && !string.IsNullOrEmpty(cell.Value.ToString().Trim())) { celltext = cell.Value.ToString().Trim(); } if (string.IsNullOrEmpty(celltext)) { if (row != null) { row.POSITION_VALUE = ""; } } else { if (row == null) { row = new MED_QIXIE_QINGDIAN(); row.PATIENT_ID = patientID; row.VISIT_ID = visitID; row.OPER_ID = operID; row.X_POSITION = j; row.Y_POSITION = i; row.TABLETAG = grid.Name; dataTable.Add(row); } row.POSITION_VALUE = celltext; } } } } #endregion List <MED_OPERATION_MASTER> operMasterList = ModelHelper <MED_OPERATION_MASTER> .ConvertDataTableToList(dataSource["MED_OPERATION_MASTER"]); MED_OPERATION_MASTER operMaster = null; if (operMasterList != null && operMasterList.Count > 0) { operMaster = operMasterList[0]; } List <MED_PAT_MASTER_INDEX> patIndexList = ModelHelper <MED_PAT_MASTER_INDEX> .ConvertDataTableToList(dataSource["MED_PAT_MASTER_INDEX"]); MED_PAT_MASTER_INDEX patMasterIndex = null; if (patIndexList != null && patIndexList.Count > 0) { patMasterIndex = patIndexList[0]; } List <MED_PAT_VISIT> patVisitList = ModelHelper <MED_PAT_VISIT> .ConvertDataTableToList(dataSource["MED_PAT_VISIT"]); MED_PAT_VISIT patVisit = null; if (patVisitList != null && patVisitList.Count > 0) { patVisit = patVisitList[0]; } List <MED_OPERATION_EXTENDED> operExtended = ModelHelper <MED_OPERATION_EXTENDED> .ConvertDataTableToList(dataSource["MED_OPERATION_EXTENDED"]); List <MED_POSTOPERATIVE_EXTENDED> postExtended = ModelHelper <MED_POSTOPERATIVE_EXTENDED> .ConvertDataTableToList(dataSource["MED_POSTOPERATIVE_EXTENDED"]); List <MED_PREOPERATIVE_EXPANSION> preExpansion = ModelHelper <MED_PREOPERATIVE_EXPANSION> .ConvertDataTableToList(dataSource["MED_POSTOPERATIVE_EXTENDED"]); List <MED_QIXIE_QINGDIAN> operCheck = dataTable; if (operCheck != null) { operationInfoRepository.SaveOperCheckList(operCheck); } //OperationInfoService.SaveMedicalBasicDoc(operMaster, patIndex, patVisit, null, null, null, null, operExtended, postExtended, preExpansion); MED_PATS_IN_HOSPITAL patsInHospital = null; MED_ANESTHESIA_PLAN anesPlan = null; MED_ANESTHESIA_PLAN_EXAM anesPlanExam = null; MED_ANESTHESIA_PLAN_PMH anesPlanPmh = null; operationInfoRepository.SaveMedicalBasicDoc(new { operMaster, patMasterIndex, patVisit, patsInHospital, anesPlan, anesPlanExam, anesPlanPmh, operExtended, postExtended, preExpansion }); }
/// <summary> /// 保存数据 /// </summary> protected override bool OnSaveData(Dictionary <string, DataTable> dataSource) { // 手术清点单添加多表格保存功能 MED_QIXIE_QINGDIAN row = null; List <MED_QIXIE_QINGDIAN> dataTable = new ModelHandler <MED_QIXIE_QINGDIAN>().FillModel(dataSource["MED_QIXIE_QINGDIAN"]); string patientID = ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID; int visitID = ExtendAppContext.Current.PatientInformationExtend.VISIT_ID; int operID = ExtendAppContext.Current.PatientInformationExtend.OPER_ID; if (dataTable == null) { dataTable = CareDocService.ClientInstance.GetOperCheckList(patientID, visitID, operID); } List <MedGridView> grids = base.GetControls <MedGridView>(); foreach (MedGridView grid in grids) { for (int i = 0; i < grid.RowCount; i++) { for (int j = 0; j < grid.ColumnCount; j++) { DataGridViewCell cell = grid[j, i]; List <MED_QIXIE_QINGDIAN> rows = null; rows = dataTable.Where(x => x.PATIENT_ID == patientID && x.VISIT_ID == visitID && x.OPER_ID == operID && x.X_POSITION == j && x.Y_POSITION == i && x.TABLETAG == grid.Name).ToList(); if (rows != null && rows.Count > 0) { row = rows[0]; } else { row = null; } string celltext = string.Empty; if (cell.Value != null && !string.IsNullOrEmpty(cell.Value.ToString().Trim())) { celltext = cell.Value.ToString().Trim(); } if (string.IsNullOrEmpty(celltext)) { if (row != null) { row.POSITION_VALUE = ""; } } else { if (row == null) { row = new MED_QIXIE_QINGDIAN(); row.PATIENT_ID = patientID; row.VISIT_ID = visitID; row.OPER_ID = operID; row.X_POSITION = j; row.Y_POSITION = i; row.TABLETAG = grid.Name; dataTable.Add(row); } row.POSITION_VALUE = celltext; } } } } List <MED_QIXIE_QINGDIAN> operCheck = dataTable; if (operCheck != null) { CareDocService.ClientInstance.SaveOperCheckList(operCheck); } bool result = this.SaveDocDataPars(dataSource); return(result); }