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); } }
public Awards() { InitializeComponent(); BranchList = BranchDBInfo.LoadStringList(); DataContext = this; }
// Copy Constructor public BranchDBInfo(BranchDBInfo other) { branch = other.branch; oldBranch = other.oldBranch; branchPicLoc = other.branchPicLoc; hasDataChanged = other.hasDataChanged; isNewRecord = other.isNewRecord; }
public Branches() { InitializeComponent(); branchList = BranchDBInfo.LoadObjectList(); ListBox_BranchDetails.DataContext = branchList; DataContext = this; }
private void Save() { CurrentBranch.WriteDataToDatabase(); branchList = BranchDBInfo.LoadObjectList(); ListBox_BranchDetails.DataContext = branchList; HideControls(); CurrentBranch = null; }
// Default Constructor public AwardDetails() { InitializeComponent(); AwardInfo = new VetAwardDBInfo(); IsOk = false; dataPreviouslyChanged = Tools.hasDataChanged; DataContext = this; BranchList = BranchDBInfo.LoadStringList(); }
// Default Constructor public ServiceDetails() { InitializeComponent(); ServiceInfo = new VetServiceDBInfo(); IsOk = false; dataPreviouslyChanged = Tools.hasDataChanged; DataContext = this; BranchList = BranchDBInfo.LoadStringList(); Ranks = new ObservableCollection <string>(); }
public Queries(MainWindow parent) { InitializeComponent(); parentWin = parent; DataContext = this; // Load lists from the database BranchList = BranchDBInfo.LoadStringList(); CemList = CemeteryDBInfo.LoadStringList(); ConflictList = ConflictDBInfo.LoadStringList(); SetupQueryLists(); }
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); } }
// 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); }
private void Btn_BranchCancel_Click(object sender, RoutedEventArgs e) { HideControls(); CurrentBranch = null; }
private void Btn_AddBranch_Click(object sender, RoutedEventArgs e) { CurrentBranch = new BranchDBInfo(); ShowControls(); }