/// <summary> /// 增加指定类型的新成套医嘱主记录 /// </summary> /// <returns></returns> public decimal AddNewMasterRecord(DataApplyRange suiteType) { // 在当前分类下插入一条新记录(到数据库中) string insertCmd = String.Format(CultureInfo.CurrentCulture , ConstSqlSentences.FormatInsertSuite , ConstSchemaNames.SuiteTableName); string newName = String.Format(CultureInfo.CurrentCulture , "({0}) {1}", "新成套", SuiteMasterTable.Rows.Count + 1); InsertMasterParas[0].Value = newName; InsertMasterParas[1].Value = ""; InsertMasterParas[2].Value = ""; InsertMasterParas[6].Value = Convert.ToInt32(suiteType); InsertMasterParas[7].Value = ""; int newSuiteSerialNo; m_SqlExecutor.ExecuteNoneQuery(insertCmd, InsertMasterParas, out newSuiteSerialNo); // 从数据库中读出新插入的记录,合并到当前的Master表中 DataTable newRecords = m_SqlExecutor.ExecuteDataTable(String.Format(CultureInfo.CurrentCulture , ConstSqlSentences.FormatSelectSuite , ConstSchemaNames.SuiteTableName, newSuiteSerialNo)); SuiteMasterTable.Merge(newRecords, true, MissingSchemaAction.Ignore); return((decimal)newSuiteSerialNo); }
/// <summary> /// 删除指定的成套医嘱 /// </summary> /// <param name="serialNo"></param> public void DeleteMasterRecord(decimal serialNo) { if ((serialNo > 0) && (m_MessageBox.MessageShow("确定要删除当前记录吗?", CustomMessageBoxKind.QuestionYesNo) == DialogResult.Yes)) { // 删除对应明细, 删除主记录 string delCmd = String.Format(CultureInfo.CurrentCulture , ConstSqlSentences.FormatDeleteSuiteData , ConstSchemaNames.SuiteDetailTableName , ConstSchemaNames.SuiteTableName , serialNo); try { m_SqlExecutor.ExecuteNoneQuery(delCmd); // 从DataTable中移除 DataRow[] matchRows = SuiteMasterTable.Select(ConstSchemaNames.SuiteDetailColSuiteSerialNo + " = " + serialNo); foreach (DataRow row in matchRows) { row.Delete(); } matchRows = SuiteDetailTable.Select(ConstSchemaNames.SuiteDetailColSuiteSerialNo + " = " + serialNo); foreach (DataRow row in matchRows) { row.Delete(); } } catch { m_MessageBox.MessageShow("删除记录出错,请重试!", CustomMessageBoxKind.ErrorYes); } } }
/// <summary> /// 将传入的成套医嘱对象同步到DataRow中,并保存到数据 /// </summary> /// <param name="serialNo"></param> /// <param name="suiteObject"></param> public void SynchAndSaveMasterData(decimal serialNo, SuiteOrder suiteObject) { if (suiteObject == null) { return; } DataRow[] matchRows = SuiteMasterTable.Select(ConstSchemaNames.SuiteDetailColSuiteSerialNo + " = " + serialNo); if (matchRows.Length == 1) { //if (String.IsNullOrEmpty(suiteObject.Py)) { // 重新生成拼音、五笔缩写 string[] shortCodes = m_GenShortCode.GenerateStringShortCode(suiteObject.Name); suiteObject.Py = shortCodes[0]; suiteObject.Wb = shortCodes[1]; } // 同步属性和DataRow的值 PersistentObjectFactory.SetDataRowValueFromObject(matchRows[0], suiteObject); // 将修改同步到数据库中 m_SqlExecutor.UpdateTable(SuiteMasterTable, ConstSchemaNames.SuiteTableName, false); //SuiteMasterTable.AcceptChanges(); } else { m_MessageBox.MessageShow("成套医嘱数据有错误,请退出程序重新进入!", CustomMessageBoxKind.ErrorOk); } }