// Load RateYear comboBox with Distinct RateYears Values private void Load_RateYear_ComboBox() { lwdom_Rates_Worker RWkr = new lwdom_Rates_Worker(); List<string> strRY_List = new List<string>(); strRY_List = RWkr.Get_RateYear_List(); // load combo box cboRateYear.ItemsSource = strRY_List; }
// constructor public uc_LWRates_Detail() { InitializeComponent(); // worker LWRWkr = new lwdom_Rates_Worker(); // load combo box LoadRateID_Combobox(); // reset and initialize ResetDisplayFields(); InitialButtonConfiguration(); // view model viewModel.PropertyChanged += viewModel_PropertyChanged; }
// constructor public Rates_ViewModel() { // worker RWkr = new lwdom_Rates_Worker(); }
// constructor public Win_LWRates() { InitializeComponent(); // worker LWRWkr = new lwdom_Rates_Worker(); strRY = ""; strRId = ""; // load comboBox LoadRateID_Combobox(); // LISTENER: Selected data changed // Handle on ChemList selection changed events ucRate_List.OnRates_SELECTION += (o, e) => { var datagrid = (DataGrid)o; var itm = datagrid.SelectedItem; if ((itm is lwdom_Rates_Model) == false) return; lwdom_Rates_Model selectedContent = (lwdom_Rates_Model)itm; ucRates_Detail.DataContext = selectedContent; labelStatus.Content = "ID: " + selectedContent.ID; ucRates_Detail.Execute_UpdateButtonConfiguration(); }; // LISTENER: ADD ucRates_Detail.OnRates_ADD += (o, e) => { string strMsg = o.ToString(); bool result = false; int intRy = 0; // get the select Rate Year and convert to int Year result = int.TryParse(strRY, out intRy); // turn ON busy Indicator busy_Indicator.IsBusy = true; // reset and initial button ucRates_Detail.Execute_InitialButtonConfiguration(); // Get List, Async Get if (intRy > 0) { rVM.Get_Rates_byRateYear_Async(intRy); ucRate_List.LabelBanner.Content = "Rates List for Year " + intRy.ToString(); } else { rVM.Get_Rates_Async(); ucRate_List.LabelBanner.Content = "Rates List"; } }; // LISTENER: UPDATE ucRates_Detail.OnRates_UPDATE += (o, e) => { string strMsg = o.ToString(); bool result = false; int intRy = 0; // get the select Rate Year and convert to int Year result = int.TryParse(strRY, out intRy); // turn ON busy Indicator busy_Indicator.IsBusy = true; // reset and initial button ucRates_Detail.Execute_InitialButtonConfiguration(); // Get List, Async Get if (intRy > 0) { rVM.Get_Rates_byRateYear_Async(intRy); ucRate_List.LabelBanner.Content = "Rates List for Year " + intRy.ToString(); } else { rVM.Get_Rates_Async(); ucRate_List.LabelBanner.Content = "Rates List"; } }; // LISTENER: Cancel ucRates_Detail.OnRates_CANCEL += (o, e) => { // display message labelStatus.Content = o.ToString(); // turn ON busy Indicator busy_Indicator.IsBusy = true; // redisplay data in grid // Get Async Rates List rVM.Get_Rates_Async(); ucRate_List.cboRateYear.Text = ""; cboRateID.Text = ""; }; // LISTENER: DELETE ucRates_Detail.OnRates_DELETE += (o, e) => { string strMsg = o.ToString(); bool result = false; int intRy = 0; // get the select Rate Year and convert to int Year result = int.TryParse(strRY, out intRy); // turn ON busy Indicator busy_Indicator.IsBusy = true; // reset and initial button ucRates_Detail.Execute_InitialButtonConfiguration(); // Get List, Async Get if (intRy > 0) { rVM.Get_Rates_byRateYear_Async(intRy); ucRate_List.LabelBanner.Content = "Rates List for Year " + intRy.ToString(); } else { rVM.Get_Rates_Async(); ucRate_List.LabelBanner.Content = "Rates List"; } }; // LISTENER: Async Get Ratest base on Rate Year // status selection ucRate_List.OnRates_byRateYearSELECTED += (o, e) => { strRY = o.ToString(); bool result = false; int intRy = 0; // get the select Rate Year and convert to int Year result = int.TryParse(strRY, out intRy); // turn ON busy Indicator busy_Indicator.IsBusy = true; // reset and initial button ucRates_Detail.Execute_InitialButtonConfiguration(); // Get List, Async Get if (intRy > 0) { rVM.Get_Rates_byRateYear_Async(intRy); ucRate_List.LabelBanner.Content = "Rates List for Year " + intRy.ToString(); } else { rVM.Get_Rates_Async(); ucRate_List.LabelBanner.Content = "Rates List"; } }; // Listening for ViewModel Property Change // -------------------------------- // Loading the data grid MVVM style // -------------------------------- rVM.PropertyChanged += (o, e) => { // the View Model is notifying us that a property was updated // checking for a specific property returned by the View Model if (e.PropertyName == "Rates_List") { ucRate_List.DataContext = rVM.rvmMod_List; labelStatus.Content = "Retrieved " + rVM.rvmMod_List.Count + " Rates."; // turn off busy Indicator busy_Indicator.IsBusy = false; } }; // Telling the ViewModel to retieve data rVM.Get_Rates_Async(); labelStatus.Content = "Retrieving data..."; }
// load the lwdom_RateID into string list private void LoadRateID_Combobox() { List<string> rID_List = new List<string>(); lwdom_Rates_Worker RWkr = new lwdom_Rates_Worker(); rID_List = RWkr.Get_RateIDString_List(); cboRateID.ItemsSource = rID_List; }