Beispiel #1
0
        private void Btn_DeleteBranch_Click(object sender, RoutedEventArgs e)
        {
            string selected;

            selected = Convert.ToString(ListBox_BranchDetails.SelectedValue);

            // Verify the user selected a record to delete
            if (!string.IsNullOrEmpty(selected))
            {
                MessageBoxResult result;
                result = MessageBox.Show(Tools.deleteMessage, Tools.deleteTitle, MessageBoxButton.YesNo);

                if (result == MessageBoxResult.Yes)
                {
                    foreach (BranchDBInfo branch in branchList)
                    {
                        if (branch.Branch == selected)
                        {
                            // Remove from the database
                            branch.DeleteFromDatabase();
                        }
                    }

                    branchList = BranchDBInfo.LoadObjectList();

                    ListBox_BranchDetails.DataContext = branchList;
                }
            }
            else
            {
                MessageBox.Show(Tools.RecordDeleteMessage, Tools.RecordSelectTitle);
            }
        }
Beispiel #2
0
        public Branches()
        {
            InitializeComponent();

            branchList = BranchDBInfo.LoadObjectList();

            ListBox_BranchDetails.DataContext = branchList;

            DataContext = this;
        }
Beispiel #3
0
        private void Save()
        {
            CurrentBranch.WriteDataToDatabase();

            branchList = BranchDBInfo.LoadObjectList();

            ListBox_BranchDetails.DataContext = branchList;

            HideControls();

            CurrentBranch = null;
        }