/// <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); } }