コード例 #1
0
        /// <summary>
        /// 载入sql格式内容
        /// </summary>
        /// <param name="sqlFormatContext"></param>
        public void LoadFromString(string sqlFormatContext)
        {
            Clear();

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

            _sourceSqlFmt = sqlFormatContext;

            MatchInfos whereItems = QueryHelper.GetMinMatchData(sqlFormatContext, "<wi=", "/wi>");

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



            foreach (MatchInfo whereitem in whereItems)
            {
                WhereItem wi = new WhereItem();
                wi.LoadWhereFromString("<wi=" + whereitem.MatchContext + "/wi>");

                _whereItems.Add(wi.Name, wi, whereitem.StartIndex);
            }
        }
コード例 #2
0
 private void frmQueryWhere_FormClosed(object sender, FormClosedEventArgs e)
 {
     try
     {
         if (_isOk == false)
         {
             _wi = null;
         }
     }
     catch (Exception ex)
     {
         MsgBox.ShowException(ex, this);
     }
 }
コード例 #3
0
        private void butSure_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == false)
                {
                    return;
                }

                WhereItem result = new WhereItem();

                result.Name      = txtWhereItemName.Text;
                result.LinkType  = cbxLinkType.Text;
                result.Condition = rtbWhereContext.Text;


                foreach (TabPage tc in tabItems.TabPages)
                {
                    InputItem ii = new InputItem();
                    ii.CopyFrom(_wi.InputItems[tc.Name]);

                    if (string.IsNullOrEmpty(ii.ControlType))
                    {
                        ii.ControlType = QueryConstDefine.Txt;
                    }


                    result.AddInputItem(ii, ii.StartIndex);
                }

                result.SourceFmt = result.SaveWhereToString();

                _wi = result;

                _isOk = true;

                this.Close();
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
コード例 #4
0
        public void CopyFrom(WhereItem wi)
        {
            Name       = wi.Name;
            LinkType   = wi.LinkType;
            Condition  = wi.Condition;
            Tag        = wi.Tag;
            SourceFmt  = wi.SourceFmt;
            StartIndex = wi.StartIndex;

            InputItems.Clear();

            foreach (InputItem ii in wi.InputItems.Values)
            {
                InputItem curNew = new InputItem();
                curNew.CopyFrom(ii);

                InputItems.Add(ii.Name, curNew);
            }
        }
コード例 #5
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();
        }
コード例 #6
0
 private void butCancel_Click(object sender, EventArgs e)
 {
     _isOk = false;
     _wi   = null;
     this.Close();
 }
コード例 #7
0
        public frmQueryWhere()
        {
            InitializeComponent();

            _wi = new WhereItem();
        }
コード例 #8
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);
            }
        }