Example #1
0
        private void OnButtonUpdateClick(object sender, EventArgs e)
        {
            if (lvPartners.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select one partner.", Constant.StoreAppName);
                return;
            }

            Partners partner = (Partners)lvPartners.SelectedItems[0].Tag;
            var      dialog  = new FormPartnerDialog(partner);

            DialogResult result = dialog.ShowDialog();

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

            int entriesWritten = _unitOfWork.Complete();

            if (entriesWritten == 0)
            {
                MessageBox.Show("There was a problem updating the partner.", Constant.StoreAppName);
                return;
            }

            UpdateListView(partner, ListViewAction.Update, lvPartners.SelectedItems[0].Index);
        }
Example #2
0
        private void OnButtonAddClick(object sender, EventArgs e)
        {
            var partner = new Partners();

            var dialog = new FormPartnerDialog(partner);

            DialogResult result = dialog.ShowDialog();

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

            _unitOfWork.Partners.Add(partner);
            int entriesWritten = _unitOfWork.Complete();

            if (entriesWritten == 0)
            {
                MessageBox.Show("There was a problem adding a new partner.", Constant.StoreAppName);
                return;
            }

            UpdateListView(partner, ListViewAction.Add, Constant.IndexNone);
        }