private void listGroups_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = listGroups.IndexFromPoint(e.Location);

            if (index < 0 || index >= listGroups.Items.Count)
            {
                return;
            }

            var inputForm = new InputStringForm();

            inputForm.Text    = "Modify Custom Group Name";
            inputForm.Message = "Name of the custom group";
            inputForm.Value   = CustomGroups[index].Name;

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            CustomGroups[index].Name = inputForm.Value;
            listGroups.SelectedIndex = index;

            Redraw();
        }
        private void buttonAddPattern_Click(object sender, EventArgs e)
        {
            int selectedIndex = listGroups.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= listGroups.Items.Count)
            {
                return;
            }

            CustomGroup group = CustomGroups[selectedIndex];

            var inputForm = new InputStringForm();

            inputForm.Text    = "Add New Regex Pattern";
            inputForm.Message = "Regex Pattern";

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            group.Patterns.Add(inputForm.Value);

            listPatterns.Items.Add(inputForm.Value);
            listPatterns.SelectedIndex = listPatterns.Items.Count - 1;

            Redraw();
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the Click event of the buttonGoto control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void ButtonGoto_Click(object sender, EventArgs e)
        {
            InputStringForm inputForm = new InputStringForm();

            inputForm.Message = "Input ID:";
            DialogResult result = inputForm.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            int id;

            if (int.TryParse(inputForm.Value, out id))
            {
                this.SelectClosestEventByID(id);
            }
            else
            {
                MessageBox.Show(
                    "Invalid ID",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
        private void buttonAddGroup_Click(object sender, EventArgs e)
        {
            var inputForm = new InputStringForm();

            inputForm.Text    = "Create New Custom Group";
            inputForm.Message = "Name of the custom group";

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            var newGroup = new CustomGroup(inputForm.Value);

            CustomGroups.Add(newGroup);

            listGroups.Items.Add(newGroup);
            listGroups.SelectedIndex = listGroups.Items.Count - 1;

            Redraw();
        }
        private void listPatterns_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = listPatterns.IndexFromPoint(e.Location);

            if (index < 0 || index >= listPatterns.Items.Count)
            {
                return;
            }

            int selectedIndex = listGroups.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= listGroups.Items.Count)
            {
                return;
            }

            CustomGroup group = CustomGroups[selectedIndex];

            var inputForm = new InputStringForm();

            inputForm.Text    = "Modify Regex Pattern";
            inputForm.Message = "Regex Pattern";
            inputForm.Value   = group.Patterns[index];

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            group.Patterns[index]      = inputForm.Value;
            listPatterns.SelectedIndex = index;

            Redraw();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (_ReportName == "")
            {
                InputStringForm form = new InputStringForm("请输入报表名称", "");
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                _ReportName = form.InputContext.Trim();
                bool find = true;
                while ((_ReportName != "" && find) || _ReportName == "")
                {
                    if (_ReportName == "")
                    {
                        MessageBox.Show("报表名称必须设定,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        form = new InputStringForm("请输入报表名称", "");
                        if (form.ShowDialog() != DialogResult.OK)
                        {
                            _ReportName = "";
                            return;
                        }
                        _ReportName = form.InputContext.Trim();
                    }
                    find = false;
                    string    sql   = SqlHelper.GetSql("SelectReportName");
                    DataTable table = SqlHelper.Select(sql, null);
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        if (table.Rows[i]["ReportName"].ToString() == _ReportName)
                        {
                            find = true;
                            MessageBox.Show("报表名称重复,请重新输入。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            form = new InputStringForm("请输入报表名称", "");
                            if (form.ShowDialog() != DialogResult.OK)
                            {
                                _ReportName = "";
                                return;
                            }
                            _ReportName = form.InputContext.Trim();
                            break;
                        }
                    }
                }
            }
            SqlConnection  conn = null;
            SqlTransaction tran = null;

            try
            {
                conn = SqlHelper.GetConnection();
                conn.Open();
                tran = conn.BeginTransaction();
                decimal id = SaveReport(conn, tran);
                if (radioButton2.Checked)
                {
                    SaveReportParameter(conn, tran, id);
                }
                _ReportId = id;
                tran.Commit();
                conn.Close();
            }
            catch (Exception ex)
            {
                if (conn != null)
                {
                    if (tran != null)
                    {
                        tran.Rollback();
                    }
                    conn.Close();
                }
                ShowErrorForm form = new ShowErrorForm(ex);
                form.ShowDialog(this);
            }
        }