private void tsbSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (_reportTemplateQuery == null)
                {
                    _reportTemplateQuery      = new JReportTemplateQuery();
                    _reportTemplateQuery.查询ID = SqlHelper.GetCmpUID();
                }

                _reportTemplateQuery.查询名称  = txtName.Text;
                _reportTemplateQuery.数据源别名 = cbxDBSource.Text;
                _reportTemplateQuery.查询内容  = rtbContext.Text;

                OnSaveReportTemplateDataSource?.Invoke(_reportTemplateQuery);

                IsModify = false;

                this.Close();
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
Exemple #2
0
        /// <summary>
        /// 保存查询配置处理事件
        /// </summary>
        /// <param name="templateQuery"></param>
        private void SaveReportTemplateDataSource(JReportTemplateQuery templateQuery)
        {
            if (string.IsNullOrEmpty(templateQuery.查询名称))
            {
                MessageBox.Show("查询名称不允许为空。", "提示");
                return;
            }

            if (string.IsNullOrEmpty(templateQuery.查询内容))
            {
                MessageBox.Show("查询内容不允许为空。", "提示");
                return;
            }


            int index = _reportItem.数据来源.查询信息.FindIndex(T => T.查询ID == templateQuery.查询ID);

            if (index < 0)
            {
                int nameIndex = _reportItem.数据来源.查询信息.FindIndex(T => T.查询名称 == templateQuery.查询名称);
                if (nameIndex >= 0)
                {
                    MessageBox.Show("查询名称不允许重复。", "提示");
                    return;
                }

                _reportItem.数据来源.查询信息.Add(templateQuery);
            }
            else
            {
                int nameIndex = _reportItem.数据来源.查询信息.FindIndex(T => T.查询名称 == templateQuery.查询名称);
                if (nameIndex != index)
                {
                    MessageBox.Show("查询名称不允许重复。", "提示");
                    return;
                }

                _reportItem.数据来源.查询信息[index].查询名称 = templateQuery.查询名称;
                //_reportItem.数据来源.查询信息[index].数据源名称 = templateQuery.数据源名称;
                _reportItem.数据来源.查询信息[index].查询内容 = templateQuery.查询内容;
            }

            listDataSource.DataSource = null;

            listDataSource.DisplayMember = "查询名称";
            listDataSource.ValueMember   = "查询ID";

            listDataSource.DataSource = _reportItem.数据来源.查询信息;

            //绑定数据源
            designerControl1.DataSet = SqlHelper.GetReportDataSource(_reportItem.数据来源.查询信息, _dbHelper);

            IsModify = true;
        }
 public void ShowDataConfig(JReportTemplateQuery templateQuery, IWin32Window owner)
 {
     _reportTemplateQuery = templateQuery;
     this.ShowDialog(owner);
 }