public override bool AddNewLeafNode(string strItemGuid, string strParentID, int depth, string strItemName, int itemOrder, int type, string strUserID, string strTemplateGuid, string strGender, ReportTemplateModel model) { RisDAL dataAccess = new RisDAL(); model.CheckItemName = model.CheckItemName.Replace("'", "''"); model.DoctorAdvice = model.DoctorAdvice.Replace("'", "''"); //model.TechInfo = model.TechInfo.Replace("'", "''"); //model.WYG = model.WYG.Replace("'", "''"); //model.WYS = model.WYS.Replace("'", "''"); string sql = string.Format("Insert into tReportTemplateDirec(ItemGUID,ParentID,Depth,ItemName,ItemOrder,Type,UserGuid,TemplateGuid,Leaf) values('{0}','{1}',{2},'{3}',{4},{5},'{6}','{7}',{8})" , strItemGuid, strParentID, depth, strItemName, itemOrder, type, strUserID, strTemplateGuid, 1); string sql1 = string.Format("Insert into tReportTemplate(TemplateGuid,TemplateName,ModalityType,BodyPart,CheckItemName,DoctorAdvice,ShortcutCode,ACRCode,ACRAnatomicDesc,ACRPathologicDesc,BodyCategory) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')" , strTemplateGuid, model.TemplateName, model.ModalityType, model.BodyPart, model.CheckItemName, model.DoctorAdvice, model.ShortcutCode, model.ACRCode, model.ACRAnatomicDesc, model.ACRPathologicDesc, model.BodyCategory); try { dataAccess.BeginTransaction(); dataAccess.ExecuteNonQuery(sql, RisDAL.ConnectionState.KeepOpen); dataAccess.ExecuteNonQuery(sql1, RisDAL.ConnectionState.KeepOpen); byte [] byteWYS = System.Text.Encoding.Default.GetBytes(model.WYS); byte [] byteWYG = System.Text.Encoding.Default.GetBytes(model.WYG); byte [] byteAppendInfo = System.Text.Encoding.Default.GetBytes(model.AppendInfo); byte [] byteTechInfo = System.Text.Encoding.Default.GetBytes(model.TechInfo); dataAccess.CommitTransaction(); dataAccess.WriteLargeObj("tReportTemplate", "TemplateGuid", strTemplateGuid, "WYS", byteWYS, byteWYS.Length, RisDAL.ConnectionState.CloseOnExit); dataAccess.WriteLargeObj("tReportTemplate", "TemplateGuid", strTemplateGuid, "WYG", byteWYG, byteWYG.Length, RisDAL.ConnectionState.CloseOnExit); dataAccess.WriteLargeObj("tReportTemplate", "TemplateGuid", strTemplateGuid, "AppendInfo", byteAppendInfo, byteAppendInfo.Length, RisDAL.ConnectionState.CloseOnExit); dataAccess.WriteLargeObj("tReportTemplate", "TemplateGuid", strTemplateGuid, "TechInfo", byteTechInfo, byteTechInfo.Length, RisDAL.ConnectionState.CloseOnExit); } catch (Exception e) { lm.Error((long)ModuleEnum.Templates_DA, ModuleInstanceName.Templates, 1, e.Message, Application.StartupPath.ToString(), (new System.Diagnostics.StackFrame(true)).GetFileName(), Convert.ToInt32(new System.Diagnostics.StackFrame(true).GetFileLineNumber().ToString())); return(false); } finally { if (dataAccess != null) { dataAccess.Dispose(); } } return(true); }
public override bool UpdateEYTemplate(DataSet ds, ref string strError) { bool bReturn = true; RisDAL oKodak = new RisDAL(); try { List <string> listSQL = new List <string>(); DataTable dt = ds.Tables["EYTemplate"]; StringBuilder strBuiler = new StringBuilder(); foreach (DataRow dr in dt.Rows) { string strTemplateName = Convert.ToString(dr["TemplateName"]); string strTemplateGuid = Convert.ToString(dr["TemplateGuid"]); string strSQL = string.Format("SELECT count(*) FROM tEmergencyTemplate where TemplateGuid='{0}'", strTemplateGuid); object obj = oKodak.ExecuteScalar(strSQL); if (obj == null) { throw new Exception("Unknow error"); } int nCount = Convert.ToInt32(obj); if (nCount == 0) { throw new Exception("Can not save due to the template not exists."); } strSQL = string.Format("SELECT count(*) FROM tEmergencyTemplate where TemplateName='{0}' AND TemplateGuid!='{1}'", strTemplateName, strTemplateGuid); obj = oKodak.ExecuteScalar(strSQL); if (obj == null) { throw new Exception("Unknow error"); } nCount = Convert.ToInt32(obj); if (nCount > 0) { throw new Exception("Reduplicate template name"); } strBuiler.Remove(0, strBuiler.Length); strBuiler = strBuiler.AppendFormat("UPDATE tEmergencyTemplate SET TemplateName='{0}',NamePrefix='{1}',Birthday=to_date('{2}','YYYY-MM-DD'),Gender='{3}',Telephone='{4}',", Convert.ToString(dr["TemplateName"]), Convert.ToString(dr["NamePrefix"]), Convert.ToDateTime(dr["Birthday"]).ToString("yyyy-MM-dd"), Convert.ToString(dr["GenderValue"]), Convert.ToString(dr["Telephone"])) .AppendFormat("InhospitalNo='{0}',ClinicNo='{1}',BedNo='{2}',ApplyDept='{3}',", dr["InhospitalNo"].ToString(), dr["ClinicNo"].ToString(), dr["BedNo"].ToString(), dr["ApplyDeptValue"].ToString()) .AppendFormat("ApplyDoctor='{0}',ProcedureCode='{1}',Description='{2}' WHERE TemplateGuid='{3}'", Convert.ToString(dr["ApplyDoctorValue"]), Convert.ToString(dr["ProcedureCode"]), Convert.ToString(dr["Description"]), Convert.ToString(dr["TemplateGuid"])); listSQL.Add(strBuiler.ToString()); string strApplyDept = Convert.ToString(dr["ApplyDeptValue"]); string strApplyDoctor = Convert.ToString(dr["ApplyDoctorValue"]); strApplyDept = strApplyDept.Trim(); if (strApplyDept.Length > 0) { strSQL = string.Format("SELECT count(*) FROM tDictionaryValue WHERE (DictionaryValue='{0}' or Description='{1}') and Tag=2", strApplyDept, strApplyDept); obj = oKodak.ExecuteScalar(strSQL); if (obj == null) { throw new Exception("Unknow error"); } nCount = Convert.ToInt32(obj); if (nCount == 0) { strSQL = string.Format("INSERT INTO tDictionaryValue(Tag,DictionaryValue,Description,shortcutcode) VALUES(2,'{0}','{1}','')", strApplyDept, strApplyDept); listSQL.Add(strSQL); } } strApplyDoctor = strApplyDoctor.Trim(); if (strApplyDoctor.Length > 0) { strSQL = string.Format("SELECT count(*) FROM tDictionaryValue WHERE (DictionaryValue='{0}' or Description='{1}') and Tag=8", strApplyDoctor, strApplyDoctor); obj = oKodak.ExecuteScalar(strSQL); if (obj == null) { throw new Exception("Unknow error"); } nCount = Convert.ToInt32(obj); if (nCount == 0) { strSQL = string.Format("INSERT INTO tDictionaryValue(Tag,DictionaryValue,Description,shortcutcode) VALUES(8,'{0}','{1}','')", strApplyDoctor, strApplyDoctor); listSQL.Add(strSQL); } } } oKodak.BeginTransaction(); foreach (string strSQL in listSQL) { oKodak.ExecuteNonQuery(strSQL, RisDAL.ConnectionState.KeepOpen); } oKodak.CommitTransaction(); } catch (Exception e) { strError = e.Message; bReturn = false; lm.Error((long)ModuleEnum.Templates_DA, ModuleInstanceName.Templates, 1, e.Message, Application.StartupPath.ToString(), (new System.Diagnostics.StackFrame(true)).GetFileName(), Convert.ToInt32(new System.Diagnostics.StackFrame(true).GetFileLineNumber().ToString())); } finally { if (oKodak != null) { oKodak.Dispose(); } } return(bReturn); }