Beispiel #1
0
        /// <summary>
        /// 插入条件项
        /// </summary>
        public void InsertWhereItem()
        {
            WhereItem wi = null;

            using (frmQueryWhere whereCfg = new frmQueryWhere())
            {
                wi = whereCfg.ShowWhereItem(_dbHelper, _sysParList, "", this);
            }

            if (wi == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(wi.SourceFmt))
            {
                return;
            }

            rtbSql.SelectedText = wi.SourceFmt;

            qcReview.LoadSqlDesign(rtbSql.Text);
            rtbPreview.Text = qcReview.Query.TestSql();
        }
Beispiel #2
0
        private void rtbSql_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                int mouseIndex = rtbSql.SelectionStart;


                string tmp            = rtbSql.Text.Substring(0, mouseIndex);
                int    indexLeftStart = tmp.LastIndexOf("<wi=");
                int    indexLeftEnd   = tmp.IndexOf("/wi>", indexLeftStart + 1);

                int leftLength = tmp.Length;


                tmp = rtbSql.Text.Substring(mouseIndex);
                int indexRightStart = tmp.IndexOf("<wi=");
                int indexRightEnd   = tmp.IndexOf("/wi>");

                if (indexRightStart <= 0)
                {
                    indexRightStart = 99999999;
                }

                if (indexLeftStart >= 0 && indexLeftStart > indexLeftEnd && indexRightEnd >= 0 && indexRightEnd < indexRightStart)
                {
                    rtbSql.SelectionStart  = indexLeftStart;
                    rtbSql.SelectionLength = leftLength + indexRightEnd - indexLeftStart + 4;
                }
                else
                {
                    return;
                }

                string oldFmt = rtbSql.SelectedText;

                if (string.IsNullOrEmpty(oldFmt))
                {
                    return;
                }

                frmQueryWhere wi = new frmQueryWhere();

                WhereItem result = wi.ShowWhereItem(_dbHelper, _sysParList, oldFmt, this);

                if (result == null)
                {
                    return;
                }

                string whereItemFmt = result.SaveWhereToString();

                if (string.IsNullOrEmpty(whereItemFmt))
                {
                    return;
                }

                rtbSql.SelectedText = whereItemFmt; // rtbSql.Text.Replace(oldFmt, result);
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }