Esempio n. 1
0
        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;
                }
            }
        }
Esempio n. 2
0
        private void RefreshPersonnel()
        {
            //***********************************************************************************************
            // load Security Groups
            //***********************************************************************************************

            //if (SecurityGroupsListView.Items.Count <= 0)
            //{
            //    string sql = "Select * FROM i9SecurityGroup ORDER BY SecurityGroupName ASC";
            //    ClientDataAccess cda = new ClientDataAccess();
            //    DataTable i9SecurityGroupDT = cda.GetDataTable(sql, "i9SecurityGroup");

            //    //Add a new column for the UI List View Check List
            //    if (i9SecurityGroupDT.Columns.Contains("Enabled") == false)
            //    {
            //        i9SecurityGroupDT.Columns.Add("Enabled", typeof(string));
            //    }

            //    //Clear Check List
            //    foreach (DataRow drv in i9SecurityGroupDT.Rows)
            //    {
            //        drv["Enabled"] = "False";
            //    }

            //    SecurityGroupsListView.ItemsSource = i9SecurityGroupDT.DefaultView;
            //}


            //***********************************************************************************************
            // Get codes from server dataset
            //***********************************************************************************************
            string i9SysPersonnelID = SettingManager.Instance.LoginDataSet.Tables["i9SysPersonnel"].Rows[0]["i9SysPersonnelID"].ToString();

            i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.Admin, AdminType.SysPer_GetList, "", typeof(string), i9SysPersonnelID);

            if (responseMsg.ErrorStatus.IsError)
            {
                LogManager.Instance.LogMessage(responseMsg.ErrorStatus);
                //AppCommand.SendCommand(AppCommandType.Error, AppSubCommandType.DisplayError, "");
                MessageBox.Show("Unable to get personnel, please try again.", "Personnel", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            DataSet SysPerListDataSet = responseMsg.MsgBodyDataSet;

            if (SysPerListDataSet == null)
            {
                AppCommand.SendCommand(AppCommandType.Error, AppSubCommandType.DisplayError, "Unable to retrieve data");
                //Error message.
                MessageBox.Show("Unable to get personnel, please try again.", "Personnel", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                // Load Security Tasks
                RefreshSecurityGrid(i9SysPersonnelID);

                if (SysPerListDataSet.Tables.Count > 0)
                {
                    if (AgencyComboBox.Items.Count <= 0)
                    {
                        AgencyComboBox.Items.Clear();
                        foreach (DataRow dr in SysPerListDataSet.Tables["i9Agency"].Rows)
                        {
                            ComboBoxItem cbi = new ComboBoxItem();
                            cbi.Content = dr["AgencyName"].ToString();
                            cbi.Tag     = dr["i9AgencyID"].ToString();
                            int i = AgencyComboBox.Items.Add(cbi);
                        }
                    }

                    if (AgencyComboBox.Items.Count > 0)
                    {
                        if (AgencyComboBox.SelectedItem == null)
                        {
                            AgencyComboBox.IsEnabled     = false;
                            AgencyComboBox.SelectedIndex = 0;
                            AgencyComboBox.IsEnabled     = true;
                        }

                        ComboBoxItem SelectCbi  = (ComboBoxItem)AgencyComboBox.SelectedItem;
                        string       i9AgencyID = SelectCbi.Tag.ToString();

                        m_PersonnelListViewDV           = SysPerListDataSet.Tables["i9SysPersonnel"].DefaultView;
                        m_PersonnelListViewDV.RowFilter = "i9AgencyID = '" + i9AgencyID + "'";

                        PersonnelListView.ItemsSource = m_PersonnelListViewDV;
                        PersonnelListView.UnselectAll();
                    }
                    else
                    {
                        PersonnelListView.ItemsSource = null;
                    }
                }
            }
        }