Exemplo n.º 1
0
        public QueryFace()
        {
            InitializeComponent();

            lcDemo.RegisterUserCustomizationForm(typeof(DesignMiddleWare));

            lcDemo.AllowCustomization = false;

            _queryCore             = new QueryCore();
            _queryCore.LinkControl = this;

            _queryCore.OnRequestSystemPar -= RequestSystemPar;
            _queryCore.OnRequestSystemPar += RequestSystemPar;
        }
Exemplo n.º 2
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);
            }
        }