コード例 #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);
            }
        }
コード例 #2
0
        public Awards()
        {
            InitializeComponent();

            BranchList = BranchDBInfo.LoadStringList();

            DataContext = this;
        }
コード例 #3
0
        // Copy Constructor
        public BranchDBInfo(BranchDBInfo other)
        {
            branch       = other.branch;
            oldBranch    = other.oldBranch;
            branchPicLoc = other.branchPicLoc;

            hasDataChanged = other.hasDataChanged;
            isNewRecord    = other.isNewRecord;
        }
コード例 #4
0
        public Branches()
        {
            InitializeComponent();

            branchList = BranchDBInfo.LoadObjectList();

            ListBox_BranchDetails.DataContext = branchList;

            DataContext = this;
        }
コード例 #5
0
        private void Save()
        {
            CurrentBranch.WriteDataToDatabase();

            branchList = BranchDBInfo.LoadObjectList();

            ListBox_BranchDetails.DataContext = branchList;

            HideControls();

            CurrentBranch = null;
        }
コード例 #6
0
        // Default Constructor
        public AwardDetails()
        {
            InitializeComponent();

            AwardInfo = new VetAwardDBInfo();

            IsOk = false;
            dataPreviouslyChanged = Tools.hasDataChanged;

            DataContext = this;

            BranchList = BranchDBInfo.LoadStringList();
        }
コード例 #7
0
        // Default Constructor
        public ServiceDetails()
        {
            InitializeComponent();

            ServiceInfo = new VetServiceDBInfo();

            IsOk = false;
            dataPreviouslyChanged = Tools.hasDataChanged;

            DataContext = this;

            BranchList = BranchDBInfo.LoadStringList();
            Ranks      = new ObservableCollection <string>();
        }
コード例 #8
0
        public Queries(MainWindow parent)
        {
            InitializeComponent();

            parentWin = parent;

            DataContext = this;

            // Load lists from the database
            BranchList   = BranchDBInfo.LoadStringList();
            CemList      = CemeteryDBInfo.LoadStringList();
            ConflictList = ConflictDBInfo.LoadStringList();

            SetupQueryLists();
        }
コード例 #9
0
        private void Btn_EditBranch_Click(object sender, RoutedEventArgs e)
        {
            string selected;

            selected = Convert.ToString(ListBox_BranchDetails.SelectedValue);

            // Verify the user selected a record to edit
            if (!string.IsNullOrEmpty(selected))
            {
                CurrentBranch = new BranchDBInfo(selected);

                ShowControls();
            }
            else
            {
                MessageBox.Show(Tools.RecordSelectMessage, Tools.RecordSelectTitle);
            }
        }
コード例 #10
0
        // Loads the branches into a list of objects
        public static List <BranchDBInfo> LoadObjectList()
        {
            List <BranchDBInfo> records = new List <BranchDBInfo>();
            BranchDBInfo        current;

            try
            {
                using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString))
                {
                    conn.OpenAsync();

                    using (MySqlCommand command = conn.CreateCommand())
                    {
                        command.CommandText = "SELECT BranchName FROM BranchesList;";

                        using (MySqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (!reader.IsDBNull(0))
                                {
                                    current = new BranchDBInfo(reader.GetString(0));
                                    records.Add(current);
                                }
                            }
                        }
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Tools.DBErrorMessage, Tools.DBErrorTitle);
            }
            catch (MySqlException e)
            {
                Tools.HandleSQLExceptions(e);
            }

            return(records);
        }
コード例 #11
0
        private void Btn_BranchCancel_Click(object sender, RoutedEventArgs e)
        {
            HideControls();

            CurrentBranch = null;
        }
コード例 #12
0
        private void Btn_AddBranch_Click(object sender, RoutedEventArgs e)
        {
            CurrentBranch = new BranchDBInfo();

            ShowControls();
        }