private void RefreshData() { i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.Security, SecurityType.Security_PersonnelGroupsGet, ""); if (responseMsg.ErrorStatus.IsError) { LogManager.Instance.LogMessage(responseMsg.ErrorStatus); MessageBox.Show("Unable to get Security information, please try again.", "Security Personnel Groups", MessageBoxButton.OK, MessageBoxImage.Information); return; } m_PageDataSet = responseMsg.MsgBodyDataSet; //Load Agency ComboBox if (AgencyComboBox.Items.Count <= 0) { AgencyComboBox.Items.Clear(); foreach (DataRow dr in m_PageDataSet.Tables["i9Agency"].Rows) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Content = dr["AgencyName"].ToString(); cbi.Tag = dr["i9AgencyID"].ToString(); int i = AgencyComboBox.Items.Add(cbi); } } //Add a new column for the UI List View Check List if (m_PageDataSet.Tables["i9SysPersonnel"].Columns.Contains("Enabled") == false) { m_PageDataSet.Tables["i9SysPersonnel"].Columns.Add("Enabled", typeof(string)); } //Clear Check List foreach (DataRow drv in m_PageDataSet.Tables["i9SysPersonnel"].Rows) { drv["Enabled"] = "False"; } //============================================================================ //Accept all changes //============================================================================ m_PageDataSet.AcceptChanges(); //============================================================================ //Load Agency ListBox //============================================================================ if (AgencyComboBox.Items.Count > 0) { if (AgencyComboBox.SelectedItem == null) { AgencyComboBox.BeginInit(); AgencyComboBox.IsEnabled = false; AgencyComboBox.SelectedIndex = 0; AgencyComboBox.IsEnabled = true; AgencyComboBox.EndInit(); } } ComboBoxItem SelectCbi = (ComboBoxItem)AgencyComboBox.SelectedItem; string i9AgencyID = SelectCbi.Tag.ToString(); //============================================================================ // Refresh the Security Group list view based on the selected agency //============================================================================ SecurityGroupsListView.SelectedValuePath = "i9SecurityGroupID"; SecurityGroupsListView.DisplayMemberPath = "SecurityGroupName"; SecurityGroupsListView.BeginInit(); m_SecurityGroupsDV = new DataView(m_PageDataSet.Tables["i9SecurityGroup"]); m_SecurityGroupsDV.RowFilter = "i9AgencyID = '" + i9AgencyID + "'"; this.DataContext = m_SecurityGroupsDV; SecurityGroupsListView.UnselectAll(); //============================================================================ // Refresh the Security Personnel list view based on the selected agency //============================================================================ m_i9SysPersonnelDV = m_PageDataSet.Tables["i9SysPersonnel"].DefaultView; PersonnelListView.ItemsSource = m_i9SysPersonnelDV; PersonnelListView.UnselectAll(); //============================================================================ //Select the first item in the nav group //============================================================================ SecurityGroupsListView.EndInit(); if (SecurityGroupsListView.SelectedItem == null) { if (SecurityGroupsListView.Items.Count > 0) { SecurityGroupsListView.SelectedIndex = 0; } } }
private void RefreshData() { i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.Security, SecurityType.Security_SecurityGroupsGet, "SecurityPage"); if (responseMsg.ErrorStatus.IsError) { LogManager.Instance.LogMessage(responseMsg.ErrorStatus); MessageBox.Show("Unable to get Security Groups list, please try again.", "Security Groups", MessageBoxButton.OK, MessageBoxImage.Information); return; } mSecurityDS = responseMsg.MsgBodyDataSet; //Load Agency ComboBox if (AgencyComboBox.Items.Count <= 0) { AgencyComboBox.Items.Clear(); foreach (DataRow dr in mSecurityDS.Tables["i9Agency"].Rows) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Content = dr["AgencyName"].ToString(); cbi.Tag = dr["i9AgencyID"].ToString(); int i = AgencyComboBox.Items.Add(cbi); } } //Populate modules list box if (ModulesListView.Items.Count <= 0) { //Add a new column for the UI List View Check List if (mSecurityDS.Tables["i9Module"].Columns.Contains("Enabled") == false) { mSecurityDS.Tables["i9Module"].Columns.Add("Enabled", typeof(string)); } //if (mSecurityDS.Tables["i9Module"].Columns.Contains("OriginalEnabled") == false) //{ // mSecurityDS.Tables["i9Module"].Columns.Add("OriginalEnabled", typeof(string)); //} //Clear Check List foreach (DataRow drv in mSecurityDS.Tables["i9Module"].Rows) { drv["Enabled"] = "False"; } mi9ModuleDV = mSecurityDS.Tables["i9Module"].DefaultView; ModulesListView.ItemsSource = mi9ModuleDV; } //Populate Task list box if (TaskListView.Items.Count <= 0) { //Add a new column for the UI List View Check List if (mSecurityDS.Tables["i9SecurityTask"].Columns.Contains("Enabled") == false) { mSecurityDS.Tables["i9SecurityTask"].Columns.Add("Enabled", typeof(string)); } //Clear Check List foreach (DataRow drv in mSecurityDS.Tables["i9SecurityTask"].Rows) { drv["Enabled"] = 0; } mi9SecurityTaskDV = mSecurityDS.Tables["i9SecurityTask"].DefaultView; TaskListView.ItemsSource = mi9SecurityTaskDV; } //Accept all changes mSecurityDS.AcceptChanges(); //Load Security Groups Navigation ListBox if (AgencyComboBox.Items.Count > 0) { if (AgencyComboBox.SelectedItem == null) { AgencyComboBox.BeginInit(); AgencyComboBox.IsEnabled = false; AgencyComboBox.SelectedIndex = 0; AgencyComboBox.IsEnabled = true; AgencyComboBox.EndInit(); } } RefreshSecurityGroups(); }