private void LoadUsers()
    {
        MainDataClassesDataContext dataContext = new MainDataClassesDataContext();
        List <ogk_GetUsersResult>  list        = dataContext.ogk_GetUsers().ToList();

        //Формируем вид таблицы для последующего заполнения
        DataTable dt = new DataTable();

        dt.Columns.Add("ID");
        dt.Columns.Add("USER_NAME");
        dt.Columns.Add("ACCESS");

        int i = 1;

        //Заполняем таблицу данными из запроса
        foreach (var item in list)
        {
            string access;
            if (item.EDIT_SKMTR_OKPD_ONLY == 0)
            {
                access = "Полный доступ";
            }
            else
            {
                access = "Редактирование кодов";
            }

            dt.Rows.Add(item.ID, item.NAME, access);

            i++;
        }

        UsersGridView.DataSource = dt;
        UsersGridView.DataBind();
    }
Beispiel #2
0
        public void PopulateGridView()
        {
            DataTable dt = new DataTable();
            //using (SqlConnection conn = new SqlConnection(ConnectionString))

            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString);
            {
                conn.Open();
                SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM UsersList", conn);
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    ViewState["Paging"] = dt;
                    //MedicineGridView.DataSource = null;
                    UsersGridView.DataSource = dt;
                    UsersGridView.DataBind();
                    ViewState["dirState"] = dt;
                    ViewState["sortdr"]   = "Asc";
                }

                if (dt.Rows.Count <= 0)
                {
                    //ErrorLbl.Text = "No Records Found....!!";
                    //successLbl.Visible = false;
                    UsersGridView.DataBind();
                    ErrorLbl.Text = "No Records Found....!!";
                }

                conn.Close();
            }
        }
    // create datasource for user gridview
    private void BindUserAccounts()
    {
        int totalRecords;
        MembershipUserCollection allUsers      = Membership.GetAllUsers(this.PageIndex, this.PageSize, out totalRecords);
        MembershipUserCollection filteredUsers = new MembershipUserCollection();

        bool isOnline = true;

        foreach (MembershipUser user in allUsers)
        {
            // if user is currently online, add to gridview list
            if (user.IsOnline == isOnline)
            {
                filteredUsers.Add(user);
            }
        }

        // Enable/disable the pager buttons based on which page we're on
        bool visitingFirstPage = (this.PageIndex == 0);

        lnkFirst.Enabled = !visitingFirstPage;
        lnkPrev.Enabled  = !visitingFirstPage;

        int  lastPageIndex    = (totalRecords - 1) / this.PageSize;
        bool visitingLastPage = (this.PageIndex >= lastPageIndex);

        lnkNext.Enabled = !visitingLastPage;
        lnkLast.Enabled = !visitingLastPage;

        UsersGridView.DataSource = filteredUsers;
        UsersGridView.DataBind();
    }
Beispiel #4
0
        private void FillUsersGrid()
        {
            try
            {
                UsersDataTable = new DataTable();
                DataSet UsersDataSet = new DataSet();
                UsersDataTable = BL.UsersBL.Ins.GetCompanyData();
                //if (UsersDataTable.Rows.Count > 0)
                //{
                DataTable dtcopy = UsersDataTable.Copy();
                dtcopy.PrimaryKey = new DataColumn[] { dtcopy.Columns["ID"] };
                Session["Users"]  = dtcopy;

                UsersGridView.DataSource = dtcopy;
                //}
                UsersGridView.DataBind();
                //}
                //else
                //{

                //    UsersDataTable.Columns.Add("CompanyName", typeof(String));
                //    UsersGridView.DataBind();
                //}
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
            finally { }
        }
Beispiel #5
0
        private void BindUserAccounts()
        {
            MembershipUserCollection allUsers = new MembershipUserCollection();

            if (UsernameToMatch == string.Empty)
            {
                allUsers = Membership.GetAllUsers();
            }
            else if (this.UsernameToMatch == "All")
            {
                this.PageIndex = 0;
                allUsers       = Membership.GetAllUsers();
            }
            else
            {
                allUsers = Membership.FindUsersByName(this.UsernameToMatch + "%");
            }


            int totalRecords = 0;
            MembershipUserCollection filteredUsers = new MembershipUserCollection();

            foreach (MembershipUser user in allUsers)
            {
                if (user.IsApproved == true)
                {
                    filteredUsers.Add(user);
                    totalRecords++;
                }
            }
            List <MembershipUser> users = new List <MembershipUser>();

            foreach (MembershipUser user in filteredUsers)
            {
                users.Add(user);
            }

            List <MembershipUser> _sortedUsers = users.OrderByDescending(x => x.CreationDate).ToList();

            if (UsernameToMatch == string.Empty)
            {
                UsersGridView.DataSource = _sortedUsers.Skip(this.PageIndex * this.PageSize).Take(this.PageSize);
            }
            else
            {
                UsersGridView.DataSource = _sortedUsers;
            }
            UsersGridView.DataBind();

            bool visitingFirstPage = (this.PageIndex == 0);

            lnkFirst.Enabled = !visitingFirstPage;
            lnkPrev.Enabled  = !visitingFirstPage;

            int  lastPageIndex    = (totalRecords - 1) / this.PageSize;
            bool visitingLastPage = (this.PageIndex >= lastPageIndex);

            lnkNext.Enabled = !visitingLastPage;
            lnkLast.Enabled = !visitingLastPage;
        }
Beispiel #6
0
        private void DeleteItemBtn_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MessageBox.Show("Ви дійсно бажаєте відалити цей запис з довідника?", "Підтвердіть видалення", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
            {
                return;
            }

            switch (focused_tree_node.GType)
            {
            case 1:
                var u = UsersGridView.GetFocusedRow() as v_Users;
                using (var db = DB.SkladBase())
                {
                    db.DeleteWhere <Users>(w => w.UserId == u.UserId);
                }
                break;

            //case 3: SkladData->DBList->Delete(); break ;
            case 5:     //if(cxGrid4->ActiveLevel->Index == 0 ) OperLog->Delete();
                //if(cxGrid4->ActiveLevel->Index == 1) PrintLog->Delete();
                if (xtraTabControl2.SelectedTabPageIndex == 2)
                {
                    var er = ErrorLogGridView.GetFocusedRow() as v_ErrorLog;
                    using (var db = DB.SkladBase())
                    {
                        db.DeleteWhere <ErrorLog>(w => w.Id == er.Id);
                    }
                }

                break;
            }

            RefrechItemBtn.PerformClick();
        }
Beispiel #7
0
        protected void RoleFilterDropDownList_SelectedIndexChanged(object sender, EventArgs e)
        {
            UsersDataSource.Where = "it.SecurityRole = @Role";

            /*
             * The parameters from the previous selection will persist between requests, so we need
             * to clear them, otherwise we'll get an exception about duplicates.
             */
            UsersDataSource.WhereParameters.Clear();

            switch (RoleFilterDropDownList.SelectedValue)
            {
            case "Managers":
                UsersDataSource.WhereParameters.Add("Role", DbType.String, "Manager");
                break;

            case "Clients":
                UsersDataSource.WhereParameters.Add("Role", DbType.String, "Client");
                break;

            case "Staff":
                UsersDataSource.WhereParameters.Add("Role", DbType.String, "Staff");
                break;

            case "All":
            default:
                UsersDataSource.Where = "";
                return;
            }

            // Update the grid view with the filter
            UsersGridView.DataBind();
        }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["isAdmin"] == null)
        {
            Response.Redirect("NoAccess.aspx");
        }

        Users   user = new Users();
        DataSet ds   = new DataSet();

        try
        {
            ds = user.Admin_GetAllUsers();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        DataTable dt = ds.Tables[0];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dt.Rows[i]["picture"]      = "~/images/" + dt.Rows[i]["picture"].ToString();
            dt.Rows[i]["creationDate"] = Convert.ToDateTime(dt.Rows[i]["creationDate"]).ToShortDateString();
        }

        UsersGridView.DataSource = dt;
        UsersGridView.DataBind();
    }
 protected void btnCancel_Click(object sender, EventArgs e)
 {
     BindGridViewResults();
     tblUserGrid.Visible     = true;
     tblUserForm.Visible     = false;
     UsersGridView.EditIndex = -1;
     UsersGridView.DataBind();
 }
Beispiel #10
0
        private async Task Binding()
        {
            var users = await _context.Users.ToListAsync();

            userBindingSource.DataSource = new BindingListView <UI.Models.User>(list: users);
            UsersGridView.Refresh();
            SoftwareGridView.Refresh();
        }
Beispiel #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     FormsAuthenticationEx.RedirectIfUserNotInRole("~/Default.aspx", "Manager");
     if (!IsPostBack)
     {
         // Data-binding on a postback interferes with GridView updates, so don't do it!
         UsersGridView.DataBind();
     }
 }
 /**
  * <summary>
  * This method gets the users from the database
  * </summary>
  * @method GetUsers
  * @return {void}
  * */
 protected void GetUsers()
 {
     using (UsersConnection db = new UsersConnection())
     {
         var Users = (from users in db.AspNetUsers
                      select users);
         UsersGridView.DataSource = Users.ToList();
         UsersGridView.DataBind();
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        _MyUsers = Membership.GetAllUsers();
        UsersGridView.DataSource = _MyUsers;

        if (!this.IsPostBack)
        {
            UsersGridView.DataBind();
        }
    }
Beispiel #14
0
        /// <summary>
        /// 加载用户
        /// </summary>
        void LoadUsers()
        {
            //string ownerType = "user";
            //int typeID = ownerType == "role" ? Constants.OwnerRole : Constants.OwnerAccount;
            List <string>  ownerIds = AccountHelper.GetPermissionOwners(Constants.OwnerAccount, AdviceTypeID);
            List <Account> users    = AccountHelper.GetAccountList(ownerIds);

            UsersGridView.DataSource = users;
            UsersGridView.DataBind();
        }
Beispiel #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //调用GetAllUsers获取所有的用户信息
     UsersList = Membership.GetAllUsers();
     if (!this.IsPostBack)
     {
         UsersGridView.DataSource = UsersList;
         UsersGridView.DataBind();
     }
 }
Beispiel #16
0
        private void FillUsersGrid()
        {
            try
            {
                //bool isadmin = false;
                //DataTable sa = BL.UsersBL.Ins.GetIsAdmin(Session["UserID"].ToString());
                //if (sa.Rows.Count > 0)
                //{
                //    if (sa.Rows[0]["SuperAdmin"].ToString() == "Y")
                //    {
                //        isadmin = true;
                //    }
                //}
                //if (isadmin)
                //{
                //    UsersGridView.Columns["IsConsoleComm"].Visible = true;
                //    UsersGridView.Columns["IsConsoleComm"].ShowInCustomizationForm = true;
                //}
                //else
                //{
                //    UsersGridView.Columns[0].Visible = false;
                //    UsersGridView.Columns[1].Visible = false;
                //    UsersGridView.Columns[2].Visible = false;
                //}
                UsersDataTable = new DataTable();
                DataSet UsersDataSet = new DataSet();
                UsersDataTable = BL.UsersBL.Ins.GetAllData();
                if (UsersDataTable.Rows.Count > 0)
                {
                    DataTable dtcopy = UsersDataTable.Copy();
                    dtcopy.PrimaryKey        = new DataColumn[] { dtcopy.Columns["ID"] };
                    Session["Users"]         = dtcopy;
                    UsersGridView.DataSource = dtcopy;
                    UsersGridView.DataBind();
                }
                else
                {
                    UsersGridView.DataSource = UsersDataTable;
                    UsersDataTable.Columns.Add("FullName", typeof(String));
                    UsersDataTable.Columns.Add("Email", typeof(String));
                    UsersDataTable.Columns.Add("Status", typeof(String));
                    UsersDataTable.Columns.Add("UserType", typeof(String));
                    UsersDataTable.Columns.Add("LoginName", typeof(String));

                    //Session{Newname"]=UsersDataTable.rows[0].columns["LoginName"].text;
                    UsersGridView.DataBind();
                }
            }
            catch (Exception ex)
            {
                Log.Entry.Ins.WriteHistoryEntry(DateTime.Now.ToString() + " Exception - " + ex);
                throw ex;
            }
            finally { }
        }
        protected void AddUserButton_Click(object sender, EventArgs e)
        {
            try {
                connection.Open();
                cmd_AddNew.ExecuteNonQuery();
            } finally {
                connection.Close();
            }

            UsersGridView.DataBind();
        }
Beispiel #18
0
 private void BindGridViewResults()
 {
     OdsResults.EnablePaging = false;
     OdsResults.TypeName     = "SouthStarTitleBLL.BLL.RelUserEntityBLL";
     OdsResults.SelectMethod = "GetUsersFromEntities";
     OdsResults.SelectParameters.Add("entityId", ddlEntity.SelectedValue);
     UsersGridView.AllowPaging  = false;
     UsersGridView.AllowSorting = false;
     UsersGridView.DataSourceID = OdsResults.ID;
     UsersGridView.DataSource   = OdsResults;
     UsersGridView.DataBind();
 }
Beispiel #19
0
        /// <summary>
        ///     Добавление пользователя
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddUserBtn_Click(object sender, EventArgs e)
        {
            var userAddForm  = new UserAddForm();
            var dialogResult = userAddForm.ShowDialog();

            if (dialogResult == Yes)
            {
                await SetBinding();

                UsersGridView.Refresh();
            }
        }
 private void BindGridViewResults()
 {
     OdsResults.EnablePaging               = true;
     OdsResults.MaximumRowsParameterName   = "maximumRows";
     OdsResults.StartRowIndexParameterName = "startRowIndex";
     OdsResults.TypeName     = "SouthStarTitleBLL.BLL.UserBLL";
     OdsResults.SelectMethod = "GetUsers";
     OdsResults.SelectParameters.Add("sortExpression", SortExpression);
     OdsResults.SelectCountMethod = "GetUsersCount";
     UsersGridView.DataSourceID   = OdsResults.ID;
     UsersGridView.DataSource     = OdsResults;
     UsersGridView.DataBind();
 }
Beispiel #21
0
        protected void btnEditUser_Click(object sender, EventArgs e)
        {
            const string val = "E";

            UpsertAddress(val);
            ClearFields();
            BindGridViewResults();
            tblUserGrid.Visible     = true;
            tblUserForm.Visible     = false;
            btnAddUser.Enabled      = true;
            UsersGridView.EditIndex = -1;
            UsersGridView.DataBind();
        }
Beispiel #22
0
 protected void UsersGridView_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteUser")
     {
         string userName = (string)UsersGridView.DataKeys[0].Value;
         //调用Membership的DeleteUser方法删除用户
         Membership.DeleteUser(userName);
         //下面的代码用于刷新 GridView控件的显示
         UsersList = Membership.GetAllUsers();
         UsersGridView.DataSource = UsersList;
         UsersGridView.DataBind();
     }
 }
Beispiel #23
0
 private void UsersGridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
 {
     if (UsersGridView.GetRow(e.RowHandle) is Users user)
     {
         if (user.IsSelectedUserInDocuments)
         {
             userIds.Add(user.Id);
         }
         else
         {
             userIds.Remove(user.Id);
         }
     }
 }
    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        UsersBLL user = new UsersBLL();

        if (user.AddUser(AccountNameTextBox.Text, DisplayNameTextBox.Text, EmailTextBox.Text, Convert.ToInt32(DefaultViewDropDownList.SelectedValue), null, ActiveCheckBox.Checked, Convert.ToInt32(ManagerIDDropDownList.SelectedValue), Convert.ToInt32(SectionIDDropDownList.SelectedValue)))
        {
            InfoBarLabel.Text = "User Added!!";
            UsersGridView.DataBind();
        }
        else
        {
            InfoBarLabel.Text = "Error: User not added.";
        }
    }
Beispiel #25
0
        /// <summary>
        ///     Удаление пользователя
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void RemoveUserBtn_Click(object sender, EventArgs e)
        {
            if (UsersGridView.SelectedRows.Count > 0)
            {
                var id   = (int)UsersGridView.SelectedRows[index : 0].Cells[index : 0].Value;
                var user = await _context.Users.FindAsync(id);

                _context.Users.Remove(entity: user);
                await _context.SaveChangesAsync();
                await SetBinding();

                UsersGridView.Refresh();
            }
        }
Beispiel #26
0
        protected void UserGridBind(object sender, EventArgs e)
        {
            BanUserH.Visible          = true;
            BanUser.Visible           = true;
            GeneralUsInfoHead.Visible = true;
            GeneralUsInfo.Visible     = true;
            string    username  = Username.Text;
            string    email     = Email.Text;
            string    country   = Country.Text;
            string    languages = lang.Text;
            DataTable listUsers = UserInfo.RetrieveUserTableByCredentials(username, email, country, languages);

            UsersGridView.DataSource = listUsers;
            UsersGridView.DataBind();
        }
Beispiel #27
0
        protected void ItemsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var gridView = (GridView)sender;

            if (e.CommandName == "DeleteItem")
            {
                Membership.DeleteUser(e.CommandArgument.ToString());
                UsersGridView.DataBind();
            }
            if (e.CommandName == "SelectItem")
            {
                // If event was atatched then...
                RiseUserSelected(e);
            }
        }
Beispiel #28
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            var response = _userService.GetActionResponse("SearchByName", SearchInput.Text.Trim());

            if (response.IsSuccessStatusCode)
            {
                var users = response.Content.ReadAsAsync <List <UserDto> >().Result;
                UsersGridView.DataSource = users;
                UsersGridView.ClearSelection();
            }
            else
            {
                MessageBox.Show("Error Code: " + response.StatusCode + " Message: " + response.ReasonPhrase);
            }
        }
 protected void btnAddPassword_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text != txtConfirmPassword.Text)
     {
         lblPasswordCheck.Text = "Your password and confirmation password do not match.";
     }
     else
     {
         AddPasswordByUserId(UserId);
         BindGridViewResults();
         tblUserGrid.Visible     = true;
         tblUserForm.Visible     = false;
         UsersGridView.EditIndex = -1;
         UsersGridView.DataBind();
     }
 }
    protected void ActionUpdateUser_Click(object sender, EventArgs e)
    {
        if (UsersGridView.SelectedIndex >= 0)
        {
            MembershipUser Current = _MyUsers[(string)UsersGridView.SelectedValue];

            Current.Email = EmailText.Text;
            Current.Comment = CommentText.Text;
            Current.IsApproved = IsApprovedCheck.Checked;

            Membership.UpdateUser(Current);

            // Refresh the grids view
            UsersGridView.DataBind();
        } 
    }