private void btnAddSellRule_Click(object sender, EventArgs e) { SellRuleWindow s = new SellRuleWindow(); if (s.ShowDialog() == DialogResult.OK) { SellRule rule = s.SellRule; lstSellRules.Items.Add(rule); rule.Priority = lstSellRules.Items.Count; SaveSellRules(); } }
private void ModifySellRule() { if (lstSellRules.SelectedIndex < 0) return; SellRule selectedRule = (SellRule)lstSellRules.SelectedItem; int selectedIndex = lstSellRules.SelectedIndex; SellRuleWindow s = new SellRuleWindow(selectedRule); if (s.ShowDialog() == DialogResult.OK) { lstSellRules.Items.Remove(selectedRule); lstSellRules.Items.Insert(selectedIndex, s.SellRule); lstSellRules.SelectedItem = s.SellRule; SaveSellRules(); } }