示例#1
0
        public void ShowParam2()
        {
            if (pPerf == null || pPerf.pCurrentQuery == null)
              {
            Refresh();
            return;
              }

              this.SuspendLayout();
              //_tlp.SuspendLayout();
              //_tlp.Controls.Clear();
              while (_tlp.Controls.Count > 0)
            _tlp.Controls.RemoveAt(0);
              _tlp.RowCount = 0;

              #region Добавлено DSY 29.11.2007
              _tlp.Height = 0;
              _tlp.Controls.Add(_lblFilter, 0, 0);
              _tlp.SetColumnSpan(_lblFilter, 2);
              int row = 1;
              #endregion

            //      int row = 0;
              foreach (Param prm in pPerf.pCurrentQuery.Params)
              {
            Control ctr = null;
            #region Create control
            switch (prm.Type)
            {
              case eQueryParamType.Boolean:
            {
              CheckBox chk = new CheckBox();
              chk.Checked = prm.ValBool;
              ctr = chk;
            }
            break;
              case eQueryParamType.Date:
            {
              DateTimePicker dtp = new DateTimePicker();
              dtp.Value = prm.ValDate;
              ctr = dtp;
            }
            break;
              case eQueryParamType.Integer:
              case eQueryParamType.String:
              case eQueryParamType.PlaceCode:
            {
              TextBox txt = new TextBox();
              txt.Text = prm.ValStr;
              ctr = txt;
            }
            break;
              /// --------------------- LIST ---------------------
              case eQueryParamType.IntSelectList:
            {
              ucParamCboInt cbo = new ucParamCboInt(pPerf);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              case eQueryParamType.PCSelectList:
            {
              ucParamCboPC cbo = new ucParamCboPC(pPerf);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxPCItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              case eQueryParamType.StrSelectList:
            {
              ucParamCboStr cbo = new ucParamCboStr(pPerf);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxTextItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              /// --------------------- TREE ---------------------
              case eQueryParamType.IntSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              ucIntParamTV tv = new ucIntParamTV(pPerf);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              /// Added M.Tor 25.06.2008:
              if (prm.CurrentValue.Length > 0)
              {
                PCTVItemData tid = new PCTVItemData();
                _ListBoxItem lbi = new _ListBoxItem(prm.CurrentValue);
                tid.pCode = lbi.code;
                tid.pText = lbi.text;
                sft.SetItem(0, 0, tid.pText);
                sft.pItemTreeNodeTag = tid;
              }
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ctr = sft;
            }
            break;
              case eQueryParamType.StrSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              sft.pIsMayBeWithoutRefbook = true;
              ucStringParamTV tv = new ucStringParamTV(pPerf);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              /// Added M.Tor 25.06.2008:
              if (prm.CurrentValue.Length > 0)
              {
                PCTVItemData tid = new PCTVItemData();
                _ListBoxTextItem lbi = new _ListBoxTextItem(prm.CurrentValue);
                tid.pPath = lbi.text1;
                tid.pText = lbi.text2;
                sft.SetItem(0, 0, tid.pText);
                sft.pItemTreeNodeTag = tid;
              }
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ctr = sft;
            }
            break;
              case eQueryParamType.PCSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              ucPCParamTV tv = new ucPCParamTV(pPerf);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              /// Added M.Tor 25.06.2008:
              if (prm.CurrentValue.Length > 0)
              {
                PCTVItemData tid = new PCTVItemData();
                _ListBoxPCItem lbi = new _ListBoxPCItem(prm.CurrentValue);
                tid.pPC = lbi.pPC;
                tid.pText = lbi.pText;
                sft.SetItem(0, 0, tid.pText);
                sft.pItemTreeNodeTag = tid;
              }
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ctr = sft;
            }
            break;
            }
            #endregion
            if (ctr != null)
            {
              Label lbl = new Label();
              lbl.Text = prm.Title;
              lbl.TextAlign = ContentAlignment.MiddleRight;
              lbl.Tag = prm;
              //lbl.Dock = DockStyle.Fill;
              lbl.AutoSize = true;
              ctr.Tag = lbl;

              if ((ctr as DateTimePicker) == null)
            ctr.Dock = DockStyle.Fill;

              _tlp.Controls.Add(lbl, 0, row);
              _tlp.Controls.Add(ctr, 1, row++);

              if (ctr is CASSelectFromTV)
            (ctr as CASSelectFromTV).OnValueChanged += new EventHandler(ctr_TextChanged);
              else
            ctr.TextChanged += new EventHandler(ctr_TextChanged);
            }
              }
              _tlp.RowCount = row;

              if (_autoHeight)
              {
            #region Добавлено DSY 29.11.2007
            int startRowN = 0;
            if (pShowWordFilter && _tlp.RowCount <= 1)
              startRowN++;
            #endregion

            int rh = 0;
            for (int ii = startRowN; ii < _tlp.RowCount; ii++)
              rh += _tlp.GetRowHeights()[ii];
            _tlp.Visible = rh > 0;
            this.Height = rh;
              }

              //_tlp.ResumeLayout(true);
              this.ResumeLayout();
              this.PerformLayout();
        }
示例#2
0
        //Query aQr)
        public void ShowParam()
        {
            BeforeExecute(); // сохраним предыдущие значения параметров !!!

              this.Controls.Clear();

              //_cq = aQr;
              //pTask.pCurrentQuery

              if (pTask.pCurrentQuery == null)
              {
            Refresh();
            return;
              }

              Label lbl;
              foreach (Param prm in pTask.pCurrentQuery.Params)
              {
            lbl = new Label();
            lbl.Text = prm.Title;
            lbl.TextAlign = ContentAlignment.MiddleRight;
            lbl.Tag = prm;
            this.Controls.Add(lbl);

            Control ctr = null;
            switch (prm.Type)
            {
              case eQueryParamType.Boolean:
            {
              CheckBox chk = new CheckBox();
              chk.Checked = prm.ValBool;
              ctr = chk;
            }
            break;
              case eQueryParamType.Date:
            {
              DateTimePicker dtp = new DateTimePicker();
              dtp.Value = prm.ValDate;
              ctr = dtp;
            }
            break;
              case eQueryParamType.Integer:
              case eQueryParamType.String:
              case eQueryParamType.PlaceCode:
            {
              TextBox txt = new TextBox();
              txt.Text = prm.ValStr;
              ctr = txt;
            }
            break;
              /// --------------------- LIST ---------------------
              case eQueryParamType.IntSelectList:
            {
              ucParamCboInt cbo = new ucParamCboInt(pTask);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              case eQueryParamType.PCSelectList:
            {
              ucParamCboPC cbo = new ucParamCboPC(pTask);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxPCItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              case eQueryParamType.StrSelectList:
            {
              ucParamCboStr cbo = new ucParamCboStr(pTask);
              if (prm.CurrentValue.Length > 0)
              {
                cbo.Items.Add(new _ListBoxTextItem(prm.CurrentValue));
                cbo.SelectedIndex = 0;
              }
              cbo.BeforeFill += new EventHandler(cbo_BeforeFill);
              ctr = cbo;
            }
            break;
              /// --------------------- TREE ---------------------
              case eQueryParamType.IntSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ucIntParamTV tv = new ucIntParamTV(pTask);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              ctr = sft;
            }
            break;
              case eQueryParamType.StrSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ucStringParamTV tv = new ucStringParamTV(pTask);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              ctr = sft;
            }
            break;
              case eQueryParamType.PCSelectTree:
            {
              CASSelectFromTV sft = new CASSelectFromTV();
              sft.OnBeforeShowTV += new EventHandler(sft_OnBeforeShowTV);
              ucPCParamTV tv = new ucPCParamTV(pTask);
              tv.pSQLString = prm.SelectValue; // ReplaceCommonParameter(prm.SelectValue);
              sft.pTreeView = tv;
              ctr = sft;
            }
            break;
            }
            if (ctr != null)
            {
              ctr.Tag = lbl;
              this.Controls.Add(ctr);
              ctr.TextChanged += new EventHandler(ctr_TextChanged);
            }
              }

              //Refresh();
              OnResize(new EventArgs());
        }