Esempio n. 1
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);
            }
        }
Esempio n. 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);
            }
        }