Example #1
0
        /// <summary>
        /// 报到操作
        /// 1 json库写入数据
        /// 2 ZLHIS库暂时只更新 检查过程为2  其他暂时不管
        /// </summary>
        /// <returns></returns>
        private bool Request()
        {
            try
            {
                string strjson;

                strjson = JsonHelper.SerializeObject(_studyInfo);

                System.Diagnostics.Debug.WriteLine("Request JSON库获取MAXID OK");

                if (_dbHelper != null)
                {
                    _dataTable = _dbHelper.ExecuteSQL("INSERT INTO 影像检查信息 " +
                                                      "(ID,患者ID,姓名,检查号,住院号,门诊号,报到日期,患者信息) " +
                                                      "VALUES" +
                                                      " (" + _studyInfo.ID + " , " + _studyInfo.患者ID + "  , '" + _studyInfo.姓名 + "'  , '" + _studyInfo.检查号 + "' ,"
                                                      + (_studyInfo.住院号 == "" ? "null" : _studyInfo.住院号) + ","
                                                      + (_studyInfo.门诊号 == "" ? "null" : _studyInfo.门诊号) + "  ,"
                                                      + "to_date('" + _studyInfo.报到时间.ToString("yyyy-MM-dd HH:mm") + "', 'yyyy-MM-dd HH24:MI:ss')" + " ," + "'" + strjson + "') ");
                }

                System.Diagnostics.Debug.WriteLine("Request json库插入数据OK");

                _dataTable = _rsHis.ExecuteSQL("update 病人医嘱发送 SET 执行过程=2  WHERE  医嘱ID=" + _studyInfo.ID);
                System.Diagnostics.Debug.WriteLine("Request HIS库插入数据OK");
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }

            // _studyInfo.住院号<>""? studyInfo.住院号 : null
            return(true);
        }
Example #2
0
        /// <summary>
        /// 测试查询
        /// </summary>
        /// <param name="dbHelper"></param>
        /// <returns></returns>
        public bool TestQuery(IDBQuery dbHelper)
        {
            string sql = qcReview.Query.TestSql();

            dbHelper.ExecuteSQL(sql);

            return(true);
        }
Example #3
0
        private object GetDefaultValue(InputItem ii)
        {
            if (string.IsNullOrEmpty(ii.DefaultValue))
            {
                return(null);
            }

            if (ii.DefaultValue.IndexOf("[") < 0 && ii.DefaultValue.IndexOf("]") < 0)
            {
                return(ii.DefaultValue);
            }

            if (ii.DefaultValue.IndexOf("[SQL:") >= 0)
            {
                //sql语句处理
                IDBQuery thridDbHelper = _dbHelper;

                if (string.IsNullOrEmpty(ii.DBAlias) == false)
                {
                    string strErr = "";
                    thridDbHelper = SqlHelper.GetThridDBHelper(ii.DBAlias, _dbHelper, ref strErr);
                    if (thridDbHelper == null)
                    {
                        MessageBox.Show("录入项 [" + ii.Name + "] 对应的数据源不能创建。", "提示");
                        return(null);
                    }
                }

                if (thridDbHelper != null)
                {
                    string    sql      = "Select (" + ii.DefaultValue.Replace("[SQL:", "").Replace("]", "") + ") as Result from dual";
                    DataTable dtResult = thridDbHelper.ExecuteSQL(sql);

                    if (dtResult == null || dtResult.Rows.Count <= 0)
                    {
                        return(null);
                    }

                    return(dtResult.Rows[0]["Result"]);
                }
                else
                {
                    MessageBox.Show("尚未初始化数据查询对象。", "提示");
                    return(null);
                }
            }
            else if (ii.DefaultValue.IndexOf("[CS:") >= 0)
            {
                //csharp代码处理
                return(null);
            }
            else
            {
                return(ii.DefaultValue);
            }
        }
Example #4
0
        private bool ExecuteQuery(bool isPopupWindow = false)
        {
            if (DoActions(QueryEventDefine.QueryBefore, null) == false)
            {
                return(false);
            }

            string strSql = "";
            Dictionary <string, object> pars = new Dictionary <string, object>();

            IDBQuery curDBQuery = _dbQuery;

            if (string.IsNullOrEmpty(_queryDesign.DBSourceAlias) == false)
            {
                string strErr = "";
                curDBQuery = SqlHelper.GetThridDBHelper(_queryDesign.DBSourceAlias, _dbQuery, ref strErr);
                if (curDBQuery == null)
                {
                    MessageBox.Show("获取数据访问接口产生错误:" + strErr, "提示");
                    return(false);
                }
            }

            queryFace1.DBHelper = curDBQuery;

            if (isPopupWindow)
            {
                queryFace1.PopupFilter(out strSql, out pars);
            }
            else
            {
                queryFace1.Query.CreateQuerySql(out strSql, out pars);
            }

            if (string.IsNullOrEmpty(strSql))
            {
                return(false);
            }

            Dictionary <string, List <JsonFieldPro> > jsonFieldMap = null;

            strSql = SqlHelper.FmtJsonDb(strSql, out jsonFieldMap);

            _queryDbAlias   = _queryDesign.DBSourceAlias;
            _queryCfgFormat = queryFace1.Query.SourceSqlFmt;

            _queryTable = curDBQuery.ExecuteSQL(strSql, pars);

            DoActions(QueryEventDefine.QueryAfter, null);

            return(true);
        }
Example #5
0
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="statment"></param>
        /// <returns></returns>
        private DataTable ReadDataFromDB(string statment, string pars)
        {
            if (_db == null)
            {
                throw new DBNullException();
            }

            Dictionary <string, object> objPars = (Dictionary <string, object>)StringToSerialObject(pars);

            //判断是否包含select语句,如果不包含,则表示存储过程
            if (statment.ToUpper().IndexOf("SELECT") >= 0)
            {
                //执行查询语句
                return(_db.ExecuteSQL(statment, objPars));
            }
            else
            {
                //执行存储过程
                return(_db.ExecuteProcedureOneOutput(statment, objPars));
            }
        }
Example #6
0
        /// <summary>
        /// 显示查询
        /// </summary>
        /// <param name="dbHelper"></param>
        public void ShowQuery(IDBQuery dbHelper)
        {
            string queryScheme = SaveToString();

            string sql = "";
            Dictionary <string, object> pars = null;

            if (qcReview.Query.GetInputCount() <= 0)
            {
                qcReview.Query.CreateQuerySql(out sql, out pars);
            }
            else
            {
                using (frmQueryFilter qf = new frmQueryFilter())
                {
                    qf.ShowQueryFilter(this, dbHelper, queryScheme, out sql, out pars);
                }
            }

            //显示数据展现窗口
            if (dbHelper == null)
            {
                MessageBox.Show("数据库未链接,不能执行如下查询:" + System.Environment.NewLine + sql, "提示");
                return;
            }

            if (string.IsNullOrEmpty(sql))
            {
                MessageBox.Show("未获取到有效的查询语句。", "提示");
                return;
            }

            using (DataTable dtResult = dbHelper.ExecuteSQL(sql, pars))
                using (frmQueryResult qr = new frmQueryResult())
                {
                    qr.ShowResult(this, dtResult);
                }
        }
Example #7
0
        private DataTable GetDataForm(InputItem ii)
        {
            if (string.IsNullOrEmpty(ii.DataFrom))
            {
                return(null);
            }

            string datafrom = ii.DataFrom;

            //判断是否查询语句
            if (datafrom.ToUpper().IndexOf("SELECT ") >= 0)
            {
                //查询语句处理
                QueryCore qc = new QueryCore();

                qc.OnRequestSystemPar += RequestSystemPar;

                qc.LoadFromString(ii.DataFrom);

                string sql = "";
                Dictionary <string, object> dataPars = new Dictionary <string, object>();
                qc.CreateQuerySql(out sql, out dataPars);

                if (string.IsNullOrEmpty(sql))
                {
                    MessageBox.Show("录入项 [" + ii.Name + "] 对应的数据来源无效。", "提示");
                    return(null);
                }

                IDBQuery thridDbHelper = _dbHelper;

                if (string.IsNullOrEmpty(ii.DBAlias) == false)
                {
                    string strErr = "";
                    thridDbHelper = SqlHelper.GetThridDBHelper(ii.DBAlias, _dbHelper, ref strErr);
                    if (thridDbHelper == null)
                    {
                        MessageBox.Show("录入项 [" + ii.Name + "] 对应的数据源不能创建。", "提示");
                        return(null);
                    }
                }

                if (thridDbHelper != null)
                {
                    DataTable dtResult = thridDbHelper.ExecuteSQL(sql, dataPars);

                    DataRow drNull = dtResult.NewRow();
                    dtResult.Rows.Add(drNull);

                    return(dtResult);
                }
                else
                {
                    MessageBox.Show("尚未初始化数据查询对象。", "提示");
                    return(null);
                }
            }
            else
            {
                //字符串处理
                string[] aryDatas = (datafrom + ";").Split(';');

                DataTable dtData = new DataTable();

                dtData.Columns.Add("数据值", typeof(string));
                dtData.Columns.Add("数据描述", typeof(string));

                foreach (string dataItem in aryDatas)
                {
                    if (string.IsNullOrEmpty(dataItem))
                    {
                        continue;
                    }

                    DataRow dr = dtData.NewRow();

                    string[] parseData = (dataItem + "-" + dataItem).Split('-');
                    dr["数据值"]  = parseData[0];
                    dr["数据描述"] = parseData[1];

                    dtData.Rows.Add(dr);
                }

                DataRow drNull = dtData.NewRow();
                dtData.Rows.Add(drNull);

                return(dtData);
            }
        }
Example #8
0
 public DataTable ExecuteSql()
 {
     return(_dbHelper.ExecuteSQL(this));
 }
Example #9
0
        static public IDBQuery GetThridDBHelper(string dbServerAlias, IDBQuery dbSys, ref string strErr, bool blnForceRefresh = false)
        {
            strErr = "";

            if (string.IsNullOrEmpty(dbServerAlias))
            {
                return(dbSys);
            }

            if (_thridDbBuffer == null)
            {
                _thridDbBuffer = new Dictionary <string, IDBQuery>();
            }

            if (blnForceRefresh)
            {
                //如果是强制刷新,则先移除缓存对象
                if (_thridDbBuffer.ContainsKey(dbServerAlias))
                {
                    _thridDbBuffer.Remove(dbServerAlias);
                }
            }

            if (_thridDbBuffer.ContainsKey(dbServerAlias))
            {
                return(_thridDbBuffer[dbServerAlias]);
            }
            else
            {
                SQL sql = CreateSQL("查询三方数据源信息", "Select 数据源ID, 数据源别名,数据源信息 From 影像数据源信息 where 数据源别名=:数据源别名");
                sql.AddParameter("数据源别名", DbType.String, dbServerAlias);

                DataTable dtThridDb = dbSys.ExecuteSQL(sql);
                if (dtThridDb == null || dtThridDb.Rows.Count <= 0)
                {
                    return(dbSys);
                }

                ThridDBSourceData thridDbSource = new ThridDBSourceData();
                thridDbSource.BindRowData(dtThridDb.Rows[0]);


                IDBProvider dbProvider = ServerEnum.GetDBProvider(thridDbSource.数据源信息.驱动文件);
                if (dbProvider == null)
                {
                    strErr = "数据访问实例 [" + thridDbSource.数据源信息.驱动文件 + "] 创建失败,将返回默认数据提供对象。";
                    return(null);
                }


                dbProvider.Init(thridDbSource.数据源信息.务器IP, thridDbSource.数据源信息.端口, thridDbSource.数据源信息.数据实例,
                                thridDbSource.数据源信息.授权账号, ThridDBSourceModel.DecryPwd(thridDbSource.数据源信息.授权密码));

                IDbConnection dc = dbProvider.Open(ref strErr);

                if (dc == null)
                {
                    strErr = "数据服务访问失败:" + strErr;
                    return(null);
                }

                //缓存有效的数据源链接对象
                if (dbProvider != null)
                {
                    _thridDbBuffer.Add(dbServerAlias, dbProvider);
                }

                return(dbProvider);
            }
        }
Example #10
0
        static public DataTable GetDataSource(string sql, string dbAlias, IDBQuery dbSys, List <SqlParamInfo> parValues)
        {
            if (string.IsNullOrEmpty(sql))
            {
                return(null);
            }

            string strSql = "";

            if (parValues == null)
            {
                string pars = GetSqlPars(sql);
                strSql = SqlHelper.SqlParsToNull(sql, pars);
            }
            else
            {
                strSql = sql;
                foreach (SqlParamInfo spi in parValues)
                {
                    string sqlParName = spi.Name;
                    sqlParName = "[" + sqlParName + "]";

                    strSql = strSql.Replace(sqlParName, ":" + spi.Name);
                }
            }

            Dictionary <string, JsonFieldMapItem> jsonField = null;

            strSql = FmtJsonDb(strSql, out jsonField);

            DataTable dt = new DataTable();

            string   strErr    = "";
            IDBQuery curHelper = SqlHelper.GetThridDBHelper(dbAlias, dbSys, ref strErr);

            if (curHelper != null)
            {
                if (parValues != null)
                {
                    dt = curHelper.ExecuteSQL(strSql, parValues.ToArray());
                }
                else
                {
                    dt = curHelper.ExecuteSQL(strSql);
                }

                if (jsonField.Count <= 0)
                {
                    return(dt);
                }

                SqlHelper.JsonTableDataConvert(dt, 0, jsonField, dt.Rows.Count);

                return(dt);
            }
            else
            {
                DialogResult dr = MessageBox.Show("数据源 [ " + dbAlias + "] 链接失败,失败信息:" + System.Environment.NewLine
                                                  + "    " + strErr, "提示");

                return(null);
            }
        }
Example #11
0
        static public DataTable GetDataSource(string sql, IDBQuery dbHelper, QueryParValueEvent queryEvent = null)
        {
            if (string.IsNullOrEmpty(sql))
            {
                return(null);
            }
            if (dbHelper == null)
            {
                return(null);
            }



            string pars = GetSqlPars(sql);

            string strSql = "";

            if (queryEvent == null)
            {
                strSql = SqlHelper.SqlParsToNull(sql, pars);
            }
            else
            {
                strSql = SqlHelper.SqlParsToReplaceParName(sql, pars);
            }

            Dictionary <string, JsonFieldMapItem> jsonField = null;

            strSql = FmtJsonDb(strSql, out jsonField);

            DataTable dt = new DataTable();


            List <SqlParamInfo> sqlPars = null;

            if (queryEvent != null)
            {
                sqlPars = new List <SqlParamInfo>();
                //配置查询参数
                foreach (string curPar in pars.Split(','))
                {
                    object parValue = queryEvent(curPar);

                    if (parValue != null)
                    {
                        if (parValue is DateTime)
                        {
                            sqlPars.Add(new SqlParamInfo(curPar, DbType.DateTime, parValue));
                        }
                        else if (parValue is int)
                        {
                            sqlPars.Add(new SqlParamInfo(curPar, DbType.Int64, parValue));
                        }
                        else if (parValue is double)
                        {
                            sqlPars.Add(new SqlParamInfo(curPar, DbType.Double, parValue));
                        }
                        else if (parValue is string)
                        {
                            sqlPars.Add(new SqlParamInfo(curPar, DbType.String, parValue));
                        }
                        else
                        {
                            sqlPars.Add(new SqlParamInfo(curPar, DbType.String, parValue));
                        }
                    }
                    else
                    {
                        sqlPars.Add(new SqlParamInfo(curPar, DbType.String, null));
                    }
                }
            }

            if (sqlPars != null)
            {
                dt = dbHelper.ExecuteSQL(strSql, sqlPars.ToArray());
            }
            else
            {
                dt = dbHelper.ExecuteSQL(strSql);
            }

            if (jsonField.Count <= 0)
            {
                return(dt);
            }

            SqlHelper.JsonTableDataConvert(dt, 0, jsonField, dt.Rows.Count);

            return(dt);
        }