Exemplo n.º 1
0
        /// <summary>
        /// Получение таблиц
        /// </summary>
        private void fillDataTable()
        {
            int          idListener;
            DbConnection connConfigDB;

            int err = -1;

            idListener   = register_idListenerConfDB(out err);
            connConfigDB = DbSources.Sources().GetConnection(idListener, out err);
            if (table_TEC.Columns.Count == 0)
            {
                DataColumn[] columns = { new DataColumn("ID"), new DataColumn("DESCRIPTION") };
                table_TEC.Columns.AddRange(columns);
            }

            m_list_TEC = new InitTEC_200(idListener, true, false).tec;
            table_TEC.Rows.Clear();

            foreach (TEC t in m_list_TEC)
            {
                object[] row = { t.m_id.ToString(), t.name_shr.ToString() };

                table_TEC.Rows.Add(row);
            }

            HStatisticUsers.GetUsers(ref connConfigDB, @"", @"DESCRIPTION", out m_arr_origTable[(int)ID_Table.User], out err);
            m_arr_origTable[(int)ID_Table.User].DefaultView.Sort = "ID";

            HStatisticUsers.GetRoles(ref connConfigDB, @"", @"DESCRIPTION", out m_arr_origTable[(int)ID_Table.Role], out err);
            m_arr_origTable[(int)ID_Table.Role].DefaultView.Sort = "ID";

            m_arr_origTable[(int)ID_Table.Profiles] = User.GetTableAllProfile(connConfigDB);

            unregister_idListenerConfDB(idListener);
        }
Exemplo n.º 2
0
        public FormUser(int id)
        {
            InitializeComponent();

            m_idListener = id;

            m_listUserID = new List <int> ();

            m_arUIControl       = new Control[] { textBoxUserDesc, maskedTextBoxIP, textBoxDomain, textBoxUserName, textBoxComputerName };
            m_curIndexUIControl = INDEX_UICONTROL.COUNT_INDEX_UICONTROL;

            int err = 0,
                i   = -1;

            DbConnection connConfigDB = DbSources.Sources().GetConnection(m_idListener, out err);

            HStatisticUsers.GetUsers(ref connConfigDB, @"", @"DESCRIPTION", out m_users_origin, out err);
            m_users_edit = m_users_origin.Copy();
            //m_userRows = m_users_edit.Select();

            //for (i = 0; i < m_userRows.Length; i++)
            for (i = 0; i < m_users_edit.Rows.Count; i++)
            {
                //listBoxUsers.Items.Add(m_userRows[i]["DESCRIPTION"].ToString());
                dgvUsers.Rows.Add();
                dgvUsers.Rows[i].Cells[0].Value = m_users_edit.Rows[i]["DESCRIPTION"].ToString();
                m_listUserID.Add(Convert.ToInt32(m_users_edit.Rows[i]["ID"]));
            }

            comboBoxRole.SelectedIndexChanged -= comboBoxRole_SelectedIndexChanged;

            m_listRolesID = new List <int>();
            DataTable roles;

            //roles = DbTSQLInterface.Select(m_connectionSetttings, "SELECT * FROM roles WHERE ID < 500", out err);
            HStatisticUsers.GetRoles(ref connConfigDB, @"", @"DESCRIPTION", out roles, out err);
            for (i = 0; i < roles.Rows.Count; i++)
            {
                m_listRolesID.Add(Convert.ToInt32(roles.Rows[i]["ID"]));
                comboBoxRole.Items.Add(roles.Rows[i]["DESCRIPTION"]);
            }

            comboBoxRole.SelectedIndexChanged += comboBoxRole_SelectedIndexChanged;

            m_prevComboBoxAccessSelectedIndex = -1;

            comboBoxAccess.SelectionChangeCommitted -= comboBoxAccess_SelectionChangeCommitted;

            m_listTECID = new List <int>();
            DataTable tec = InitTEC_200.getListTEC(ref connConfigDB, true, out err); //Игнорировать столбец 'InUse' - использовать

            m_listTECID.Add(0);
            comboBoxAccess.Items.Add("Все станции");

            for (i = 0; i < tec.Rows.Count; i++)
            {
                m_listTECID.Add(Convert.ToInt32(tec.Rows[i]["ID"]));
                comboBoxAccess.Items.Add(tec.Rows[i]["NAME_SHR"]);
            }

            comboBoxAccess.SelectionChangeCommitted += comboBoxAccess_SelectionChangeCommitted;

            if (dgvUsers.Rows.Count > 0)
            {
                //dgvUsers_RowSelectedChanged(0);
                dgvUsers.Rows[0].Selected = true;
            }
            else
            {
                ;
            }

            buttonUserAdd.Enabled = false;

            dgvUsers.RowEnter += new DataGridViewCellEventHandler(dgvUsers_RowEnter);

            //DbTSQLInterface.CloseConnection(InitTEC.m_connConfigDB, out err);
        }