Example #1
0
        /// <summary>
        /// 特殊处理
        /// </summary>
        /// <returns></returns>
        private string GetHTNItem()
        {
            string _result = _sqlval;
            string _ids    = string.Empty;

            //string _sql = "SELECT ID FROM HTN_TREATMENTHISTORY WHERE ID NOT IN (SELECT TREATMENTID FROM HTN_TREATMENTHISTORYITEM)";
            string    _sql = "select top 100 ID from HTN_TreatmentHistory a where not exists (select 1 from HTN_TreatmentHistoryItem b where a.ID = b.TreatmentId)";
            DataTable _dt  = HtnData.Query(_sql);

            if (_dt == null || _dt.Rows.Count == 0)
            {
                return(string.Empty);
            }

            foreach (DataRow _dr in _dt.Rows)
            {
                _ids += string.Format("'{0}',", _dr.Str("ID"));
            }
            _ids = _ids.TrimEnd(',');

            string _filter = string.Format(" AND TREATMENTID IN ({0})", _ids);

            _result = string.Format(_result, _filter);

            return(_result);
        }
Example #2
0
 public HtnDataInfo(DataRow p_dr)
 {
     _ids    = new List <string>();
     _sqlkey = p_dr.Str("SQLKey");
     _sqlval = p_dr.Str("SQLVal");
     _sqlpk  = p_dr.Str("SQLPk");
     _sqlup  = p_dr.Str("SQLUp") == "1";
     _model  = HtnData.Query("select top 1 * from " + _sqlkey);
     _exist  = string.Format("select count(*) as [len] from {0} where {1} = ", _sqlkey, _model.Columns[0].ColumnName) + "'{0}'";
 }
Example #3
0
        /// <summary>
        /// 获取Select语句
        /// </summary>
        /// <returns></returns>
        private string GetSelect()
        {
            string _result = _sqlval;

            if (!_result.Contains("{0}"))
            {
                return(_result);
            }

            if (_sqlkey == "HTN_TreatmentHistoryItem")
            {
                return(GetHTNItem());
            }

            if (string.IsNullOrEmpty(_sqlpk))
            {
                return(_result.Replace("{0}", ""));
            }

            string    _sql = string.Format("select max([{0}]) as maxkey from {1}", _sqlpk, _sqlkey);
            DataTable _dt  = HtnData.Query(_sql);

            if (_dt == null || _dt.Rows.Count == 0)
            {
                return(_result.Replace("{0}", ""));
            }

            DataRow _dr     = _dt.Rows[0];
            string  _kekval = _dr.Str("maxkey");

            if (string.IsNullOrEmpty(_kekval))
            {
                return(_result.Replace("{0}", ""));
            }

            if (_dt.Columns[0].DataType == typeof(DateTime) || _dt.Columns[0].DataType == typeof(string))
            {
                _result = string.Format(_result, " AND " + _sqlpk + " >= '" + _kekval + "'");
            }
            else
            {
                _result = string.Format(_result, " AND " + _sqlpk + " >= " + _kekval);
            }

            return(_result);
        }
Example #4
0
        /// <summary>
        /// 数据库种判断是否存在
        /// </summary>
        /// <param name="p_dr"></param>
        /// <returns></returns>
        public bool IsRowExist(DataRow p_dr)
        {
            DataTable _existdt = HtnData.Query(string.Format(_exist, p_dr.Str(0)));

            return(_existdt != null && _existdt.Rows.Count > 0 && _existdt.Rows[0].Str("len") != "0");
        }