예제 #1
0
        /// <summary>
        /// Request for editing of the rule record.
        /// </summary>
        private void ModifyRuleRecord()
        {
            if (this.dataGridViewRules.SelectedRows.Count == 0)
            {
                MessageBox.Show(
                    this, ParentControlClient.Strings.GetString("must_select_record"),
                    ParentControlClient.Strings.GetString("warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int selectedIndex = this.dataGridViewRules.SelectedRows[0].Index;

            Rule rule = (Rule)this.dataGridViewRules.SelectedRows[0].Tag;

            // We take a new instance from server, may be something was changed.
            rule = rulesRemote.GetRule(rule.Id.Value);

            RuleDetailForm detailForm = new RuleDetailForm(rule);

            detailForm.Text = ParentControlClient.Strings.GetString("change_rule");
            if (detailForm.ShowDialog(this) == DialogResult.OK)
            {
                RefreshData();

                if (selectedIndex >= 0 && selectedIndex < this.dataGridViewRules.Rows.Count)
                {
                    this.dataGridViewRules.Rows[selectedIndex].Selected = true;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Click on new rule button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNewRule_Click(object sender, EventArgs e)
        {
            Rule           rule       = new Rule();
            RuleDetailForm detailForm = new RuleDetailForm(rule);

            detailForm.Text = ParentControlClient.Strings.GetString("new_rule");
            if (detailForm.ShowDialog(this) == DialogResult.OK)
            {
                RefreshData();

                if (this.dataGridViewRules.Rows.Count > 0)
                {
                    this.dataGridViewRules.Rows[this.dataGridViewRules.Rows.Count - 1].Selected = true;
                }
            }
        }