Ejemplo n.º 1
0
        private void RefreshCodeList()
        {
            i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.Admin, AdminType.Code_GetCodeList_Admin, "");

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

            DataSet CodeDataSet = responseMsg.MsgBodyDataSet;

            //string sql = "Select CodeSetName FROM i9Code group by CodeSetName order by CodeSetName";
            //ClientDataAccess cda = new ClientDataAccess();
            //DataTable dt = cda.GetDataTable(sql, "i9CodeSet");

            if (CodeDataSet != null)
            {
                if (CodeDataSet.Tables.Count > 0)
                {
                    if (AgencyComboBox.Items.Count <= 0)
                    {
                        AgencyComboBox.Items.Clear();
                        foreach (DataRow dr in CodeDataSet.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();

                        CodeTypesListBox.SelectedValuePath = "CodeSetName";
                        CodeTypesListBox.DisplayMemberPath = "CodeSetName";

                        DataView dv = CodeDataSet.Tables["i9Code"].DefaultView;
                        dv.RowFilter = "i9AgencyID = '" + i9AgencyID + "'";

                        CodeTypesListBox.ItemsSource = dv;
                        CodeTypesListBox.UnselectAll();
                    }
                    else
                    {
                        CodeTypesListBox.ItemsSource = null;
                    }
                }
            }
            else
            {
                AppCommand.SendCommand(AppCommandType.Error, AppSubCommandType.DisplayError, "Unable to retrieve data");
                //Need to give an error message.
            }
        }
Ejemplo 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;
                    }
                }
            }
        }