Example #1
0
    private void BindUserGrid()
    {
        MembershipUserCollection allUsers = Membership.GetAllUsers();

        UserGrid.DataSource = allUsers;
        UserGrid.DataBind();
    }
Example #2
0
    /// <summary>
    /// bind the datagrid with a existing user from the database.
    /// </summary>
    public void UserInfoBind()
    {
        DataSet UserDs = objQMS.UserDetails();

        UserGrid.DataSource = UserDs.Tables[0];
        UserGrid.DataBind();
    }
Example #3
0
        protected void BindUserGrid()
        {
            DataTable dt;

            try
            {
                SqlConnection con = new SqlConnection(Common.GetConnectionString());

                SqlCommand cmd = new SqlCommand("sp_select_userbyclientID", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("ClientID", Globals.nClientID);

                conn.Open();

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);

                DataSet ds = new DataSet();
                adapter.Fill(ds);

                dt = ds.Tables[0];
                //Bind the fetched data to gridview
                UserGrid.DataSource = dt;
                UserGrid.DataBind();
            }
            catch (SqlException ex)
            {
            }
            finally
            {
                conn.Close();
            }
        }
Example #4
0
        //protected void Fetch_AllCompanyUsers()
        //{
        //    SqlCommand cmd = new SqlCommand("spCommonSelectStmt", Connection);
        //    cmd.CommandType = CommandType.StoredProcedure;

        //    cmd.Parameters.Add("@TableName", SqlDbType.NVarChar).Value = "Company";
        //    cmd.Parameters.Add("@Condition", SqlDbType.NVarChar).Value = "UserID=" + UserInfo.UserID;

        //    SqlDataAdapter dap = new SqlDataAdapter(cmd);
        //    DataSet DS = new DataSet();
        //    dap.Fill(DS);
        //    int CompanyId = 0;
        //    if (DS != null)
        //    {
        //        if (DS.Tables[0].Rows.Count != 0)
        //        {
        //            CompanyId = Convert.ToInt32(DS.Tables[0].Rows[0]["companyID"].ToString());
        //        }
        //    }


        //    SqlCommand cmd2 = new SqlCommand("spCommonSelectStmt", Connection);
        //    cmd2.CommandType = CommandType.StoredProcedure;

        //    cmd2.Parameters.Add("@TableName", SqlDbType.NVarChar).Value = "organisation";
        //    cmd2.Parameters.Add("@Condition", SqlDbType.NVarChar).Value = "companyFId=" + CompanyId;

        //    SqlDataAdapter dap2 = new SqlDataAdapter(cmd2);
        //    DataSet DS2 = new DataSet();
        //    dap2.Fill(DS2);
        //    int orgID = 0;
        //    if (DS2 != null)
        //    {
        //        if (DS2.Tables[0].Rows.Count != 0)
        //        {
        //            for (int i = 0; i < DS2.Tables[0].Rows.Count; i++)
        //            {
        //                orgID = Convert.ToInt32(DS2.Tables[0].Rows[i]["orgId"].ToString());
        //                //bind_Users(orgID);

        //                SqlCommand cmd1 = new SqlCommand("sp_Users_select", Connection);
        //                cmd1.CommandType = CommandType.StoredProcedure;

        //                cmd1.Parameters.Add("@orgID", SqlDbType.NVarChar).Value = orgID;

        //                SqlDataAdapter dap1 = new SqlDataAdapter(cmd1);
        //                DataSet DS1 = new DataSet();
        //                dap1.Fill(DS1);

        //                if (DS1 != null)
        //                {
        //                    if (DS1.Tables[0].Rows.Count != 0)
        //                    {

        //                        UserGrid.DataSource = DS1.Tables[0];

        //                        UserGrid.DataBind();

        //                    }

        //                    else
        //                    {

        //                    }

        //                }
        //            }
        //        }
        //    }


        //}

        private void bind_Users(int orgID)
        {
            SqlCommand cmd1 = new SqlCommand("sp_Users_select", Connection);

            cmd1.CommandType = CommandType.StoredProcedure;

            cmd1.Parameters.Add("@orgID", SqlDbType.NVarChar).Value = orgID;

            SqlDataAdapter dap1 = new SqlDataAdapter(cmd1);
            DataSet        DS1  = new DataSet();

            dap1.Fill(DS1);

            if (DS1 != null)
            {
                if (DS1.Tables[0].Rows.Count != 0)
                {
                    UserGrid.DataSource = DS1.Tables[0];

                    UserGrid.DataBind();
                }

                else
                {
                }
            }
        }
        private void GetUsers()
        {
            dt = new DataTable();
            DataRow dr;

            dt.Columns.Add(new DataColumn("IdValue", typeof(Int32)));
            dt.Columns.Add(new DataColumn("UserNameValue", typeof(string)));
            dt.Columns.Add(new DataColumn("LoginValue", typeof(string)));
            dt.Columns.Add(new DataColumn("EmailValue", typeof(string)));
            dt.Columns.Add(new DataColumn("RoleValue", typeof(string)));
            dt.Columns.Add(new DataColumn("UrlValue", typeof(string)));

            MembershipUserCollection allUsers = Membership.GetAllUsers();

            MembershipUser[] arr = new MembershipUser[allUsers.Count];
            allUsers.CopyTo(arr, 0);

            for (int i = 0; i < arr.Length; i++)
            {
                dr    = dt.NewRow();
                dr[0] = i + 1;
                dr[1] = arr[i].UserName;
                dr[2] = arr[i].UserName;
                dr[3] = arr[i].Email;
                dr[4] = Roles.GetRolesForUser(arr[i].UserName).FirstOrDefault();
                //foreach (var rl in Roles.GetRolesForUser(arr[i].UserName))
                //    dr[4] = rl + " ";
                dr[5] = "~/Admin/EditUser?Id=" + arr[i].UserName;
                dt.Rows.Add(dr);
            }
            dv = new DataView(dt);
            UserGrid.DataSource = dv;
            UserGrid.DataBind();
        }
        protected void UserGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            BindUserGrid();

            UserGrid.PageIndex = e.NewPageIndex;
            UserGrid.DataBind();
        }
        private void BindUserGrid()
        {
            var allUsers = Membership.GetAllUsers();

            UserGrid.DataSource = allUsers;
            UserGrid.DataBind();
        }
Example #8
0
    private void GetUsers()
    {
        UsersOnlineLabel.Text = Membership.GetNumberOfUsersOnline().ToString();
        var members = Membership.GetAllUsers(currentPage - 1, pageSize, out totalUsers);

        if (!String.IsNullOrEmpty(Session["SearchFilter"].ToString()))
        {
            var filter = Session["SearchFilter"].ToString();
            var parms  = filter.Split('=');
            if (parms[0] == "Initial")
            {
                members = Membership.FindUsersByName(parms[1], currentPage - 1, pageSize, out totalUsers);
            }
            else
            {
            }
        }
        UserGrid.DataSource = members;
        totalPages          = ((totalUsers - 1) / pageSize) + 1;

        // Ensure that we do not navigate past the last page of users.

        if (currentPage > totalPages)
        {
            currentPage = totalPages;
            GetUsers();
            return;
        }

        UserGrid.DataBind();
        CurrentPageLabel.Text = currentPage.ToString();
        TotalPagesLabel.Text  = totalPages.ToString();

        if (currentPage == totalPages)
        {
            NextButton.Visible = false;
        }
        else
        {
            NextButton.Visible = true;
        }

        if (currentPage == 1)
        {
            PreviousButton.Visible = false;
        }
        else
        {
            PreviousButton.Visible = true;
        }

        if (totalUsers <= 0)
        {
            NavigationPanel.Visible = false;
        }
        else
        {
            NavigationPanel.Visible = true;
        }
    }
Example #9
0
        public void LoadGrid()
        {
            myDAL obj = new myDAL();

            UserGrid.DataSource = obj.getOnlineUsers();
            UserGrid.DataBind();
        }
Example #10
0
        protected void SearchButton_Click(object sender, EventArgs e)
        {
            UserGrid.PageIndex = 0;
            UserGrid.DataBind();

            // DISPLAY THE RESET BUTTON
            ResetSearchButton.Visible = true;
        }
Example #11
0
 protected void DeleteUser(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(UserNameText.Text))
     {
         Membership.DeleteUser(UserNameText.Text);
         UserGrid.DataBind();
     }
 }
Example #12
0
    private void SortGridView(string sortExpression, string direction)
    {
        DataSet  ds = objQMS.UserDetails();
        DataView dv = new DataView(ds.Tables[0]);

        dv.Sort = sortExpression + " " + direction;
        this.UserGrid.DataSource = dv;
        UserGrid.DataBind();
    }
        /// <summary>
        /// Handles the Click event of the btnGetUsers control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing
        /// the event data.</param>
        protected void OnGetUsersButtonClick(object sender, EventArgs e)
        {
            ConfigureUserForOAuth();

            try {
                // Get the UserService.
                UserService userService = (UserService)user.GetService(DfpService.v201405.UserService);

                // Create a Statement to get all users.
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .OrderBy("id ASC")
                                                    .Limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

                // Set default for page.
                UserPage page = new UserPage();

                DataTable dataTable = new DataTable();
                dataTable.Columns.AddRange(new DataColumn[] {
                    new DataColumn("Serial No.", typeof(int)),
                    new DataColumn("User Id", typeof(long)),
                    new DataColumn("Email", typeof(string)),
                    new DataColumn("Role", typeof(string))
                });
                do
                {
                    // Get users by Statement.
                    page = userService.getUsersByStatement(statementBuilder.ToStatement());

                    if (page.results != null && page.results.Length > 0)
                    {
                        int i = page.startIndex;
                        foreach (User usr in page.results)
                        {
                            DataRow dataRow = dataTable.NewRow();
                            dataRow.ItemArray = new object[] { i + 1, usr.id, usr.email, usr.roleName };
                            dataTable.Rows.Add(dataRow);
                            i++;
                        }
                    }
                    statementBuilder.IncreaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
                } while (statementBuilder.GetOffset() < page.totalResultSetSize);
                if (dataTable.Rows.Count > 0)
                {
                    UserGrid.DataSource = dataTable;
                    UserGrid.DataBind();
                }
                else
                {
                    Response.Write("No users were found.");
                }
            } catch (Exception ex) {
                Response.Write(string.Format("Failed to get users. Exception says \"{0}\"",
                                             ex.Message));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //SELECT user.BsnNumber,user.EmailAdress, user.FirstName,user.LastName from user  where user.Confirmed=0
            if (!IsPostBack)
            {
                Messager.Text    = "";
                Messager.Visible = false;

                loggedinUser = Session["User"] as Entities.User;
                if (loggedinUser != null)
                {
                    try
                    {
                        UserGrid.DataSource = dBUserConnection.getPendingUsers(loggedinUser);
                        UserGrid.DataBind();
                        ListBoxUsers.DataSource     = dBUserConnection.GetAllUsers(loggedinUser);
                        ListBoxUsers.DataTextField  = "FirstName";
                        ListBoxUsers.DataValueField = "BsnNumber";
                        ListBoxUsers.DataBind();

                        DAL.DBRoleConnection dBRoleConnection = new DAL.DBRoleConnection();
                        ListBoxRoles.DataSource     = dBRoleConnection.GetRoles();
                        ListBoxRoles.DataTextField  = "Description";
                        ListBoxRoles.DataValueField = "RoleID";
                        ListBoxRoles.DataBind();

                        ListBoxUserTherapist.DataSource     = ListBoxUsers.DataSource;
                        ListBoxUserTherapist.DataTextField  = "FirstName";
                        ListBoxUserTherapist.DataValueField = "BsnNumber";
                        ListBoxUserTherapist.DataBind();

                        ListBoxTherapist.DataSource     = dBUserConnection.GetAllUsersWithRole(loggedinUser);
                        ListBoxTherapist.DataTextField  = "FirstName";
                        ListBoxTherapist.DataValueField = "ID";
                        ListBoxTherapist.DataBind();

                        ListboxFunctionRoles.DataSource     = dBRoleConnection.GetRoles();
                        ListboxFunctionRoles.DataTextField  = "Description";
                        ListboxFunctionRoles.DataValueField = "RoleID";
                        ListboxFunctionRoles.DataBind();

                        RoleGrid.DataSource = dBRoleConnection.GetRights();
                        RoleGrid.DataBind();
                    }
                    catch (Exception ex)
                    {
                        showMessage(ex.Message);
                    }
                }
            }
        }
Example #15
0
        private void RefreshGrid()
        {
            var userId = Context.User.Identity.GetUserId();
            var user   = _userCache.Get(userId);

            var users = _userDal.GetByCompany(user.CompanyId)
                        .Where(u => !u.Id.Equals(userId))
                        .ToSafeList();

            UserGrid.DataSource = string.IsNullOrEmpty(SearchText.Text)
                ? users
                : users.Where(d => d.UserName.ToLower().Contains(SearchText.Text.ToLower())).ToList();

            UserGrid.DataBind();
        }
Example #16
0
        protected void searchManagerB_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(managerT.Text))
            {
                M1.SetMessage = "Поле не должно быть пустым!";
                MessageExtender.Show();
                return;
            }
            if (managerT.Text.Length < 2)
            {
                M1.SetMessage = "Минимальная длина фамилии 3 символа!";
                MessageExtender.Show();
                return;
            }

            List <ADuser> usr = new ADconnector().GetUser(managerT.Text);

            if (usr.Count > 0)
            {
                if (usr.Count == 1)
                {
                    managerT.Text     = usr[0].name;
                    subdivisionT.Text = usr[0].reply;
                    officeT.Text      = usr[0].office;
                }
                else
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("ФИО");
                    dt.Columns.Add("Офис");
                    dt.Columns.Add("Подразделение");
                    foreach (ADuser one in usr)
                    {
                        dt.Rows.Add(one.name, one.office, one.reply);
                    }
                    dt.AcceptChanges();
                    UserGrid.DataSource = dt;
                    UserGrid.DataBind();
                    UserPanelExtender.Show();
                }
            }
            else
            {
                subdivisionT.Text = "<Не найдено!>";
                officeT.Text      = "<Не найдено!>";
            }
        }
Example #17
0
    private void GetUsers()
    {
        UsersOnlineLabel.Text = Membership.GetNumberOfUsersOnline().ToString();

        UserGrid.DataSource = Membership.GetAllUsers(currentPage - 1, pageSize, out totalUsers);
        totalPages          = ((totalUsers - 1) / pageSize) + 1;

        // Ensure that we do not navigate past the last page of users.

        if (currentPage > totalPages)
        {
            currentPage = totalPages;
            GetUsers();
            return;
        }

        UserGrid.DataBind();
        CurrentPageLabel.Text = currentPage.ToString();
        TotalPagesLabel.Text  = totalPages.ToString();

        if (currentPage == totalPages)
        {
            NextButton.Visible = false;
        }
        else
        {
            NextButton.Visible = true;
        }

        if (currentPage == 1)
        {
            PreviousButton.Visible = false;
        }
        else
        {
            PreviousButton.Visible = true;
        }

        if (totalUsers <= 0)
        {
            NavigationPanel.Visible = false;
        }
        else
        {
            NavigationPanel.Visible = true;
        }
    }
Example #18
0
        private void FetchUsers()
        {
            try
            {
                {
                    SqlCommand cmd = new SqlCommand("mts_User_Select", Connection);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@role", SqlDbType.NVarChar).Value         = int.Parse(Session["role"].ToString());
                    cmd.Parameters.Add("@fk_CompanyID", SqlDbType.NVarChar).Value = int.Parse(Session["fk_CompanyID"].ToString());
                    cmd.Parameters.Add("@fk_OrgID", SqlDbType.NVarChar).Value     = int.Parse(Session["fk_OrgID"].ToString());
                    if (int.Parse(Session["role"].ToString()) == 50)
                    {
                        cmd.Parameters.Add("@userID", SqlDbType.NVarChar).Value = int.Parse(Session["userID"].ToString());
                    }
                    else
                    {
                        cmd.Parameters.Add("@userID", SqlDbType.NVarChar).Value = 0;
                    }
                    SqlDataAdapter dap = new SqlDataAdapter(cmd);
                    DataSet        DS  = new DataSet();
                    dap.Fill(DS);

                    if (DS != null)
                    {
                        if (DS.Tables[0].Rows.Count != 0)
                        {
                            UserGrid.Visible    = true;
                            UserGrid.DataSource = DS;
                            UserGrid.DataBind();
                        }

                        else
                        {
                            UserGrid.Visible       = false;
                            lblUserPermission.Text = "No Records Found..";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #19
0
 protected void AlphabetRepeater_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
 {
     if ((e.CommandArgument.ToString().Length == 1))
     {
         SearchUserName.Text = (e.CommandArgument.ToString() + "*");
     }
     else
     {
         SearchUserName.Text = String.Empty;
     }
     // CLEAR OUT OTHER CRITERIA
     SearchEmail.Text          = string.Empty;
     SearchFirstName.Text      = string.Empty;
     SearchLastName.Text       = string.Empty;
     SearchGroup.SelectedIndex = 0;
     SearchCompany.Text        = string.Empty;
     SearchPhone.Text          = string.Empty;
     UserGrid.DataBind();
 }
    private void FillGrid()
    {
        var userManager = new UserManager(ctx);
        var allUsers    = userManager.GetUsers();

        var farmManager = new FarmManager(ConfigurationManager.ConnectionStrings["AdditionalInformation"].ConnectionString);
        var farms       = farmManager.GetAllFarmsForDropDown();

        foreach (var user in allUsers)
        {
            var farm = farms.FirstOrDefault(x => x.Cod == user.UserCod);
            if (farm != null)
            {
                user.UserCod = farm.Cod + " - " + farm.Nume;
            }
        }

        lcount.Text         = allUsers.Count + " useri";
        UserGrid.DataSource = allUsers;
        UserGrid.DataBind();
    }
Example #21
0
        protected void ManageUserSave(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser(UserGrid.SelectedRow.Cells[1].Text);

            if (user != null)
            {
                user.Email      = UserEmailTxt.Text;
                user.IsApproved = ActiveBox.Checked;
                Membership.UpdateUser(user);

                foreach (Control control in roleDiv.Controls)
                {
                    if (control is CheckBox)
                    {
                        CheckBox      box       = (CheckBox)control;
                        List <string> roleUsers = new List <string>(System.Web.Security.Roles.GetUsersInRole(box.ID));

                        if (box.Checked)
                        {
                            if (!roleUsers.Contains(user.UserName))
                            {
                                System.Web.Security.Roles.AddUserToRole(user.UserName, box.ID);
                            }
                        }
                        else
                        {
                            if (roleUsers.Contains(user.UserName))
                            {
                                System.Web.Security.Roles.RemoveUserFromRole(user.UserName, box.ID);
                            }
                        }
                    }
                }

                UserGrid.DataBind();
            }
        }
Example #22
0
 protected void SearchButton_Click(object sender, EventArgs e)
 {
     UserGrid.PageIndex = 0;
     UserGrid.DataBind();
 }
Example #23
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "FindAD")
            {
                int rowInd = Convert.ToInt32(e.CommandArgument);
                Session["_editRowIndex"] = rowInd;
                TextBox t  = GridView1.Rows[rowInd].FindControl("managerTb") as TextBox;
                Label   sd = GridView1.Rows[rowInd].FindControl("divisionFactL") as Label;
                if (string.IsNullOrEmpty(t.Text))
                {
                    M1.SetMessage = "Поле не должно быть пустым!";
                    MessageExtender.Show();
                    return;
                }
                if (t.Text.Length < 2)
                {
                    M1.SetMessage = "Минимальная длина фамилии 3 символа!";
                    MessageExtender.Show();
                    return;
                }

                List <ADuser> usr = new ADconnector().GetUser(t.Text);
                if (usr.Count > 0)
                {
                    if (usr.Count == 1)
                    {
                        t.Text  = usr[0].name;
                        sd.Text = usr[0].office + "<br/>" + usr[0].reply;
                    }
                    else
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("ФИО");
                        dt.Columns.Add("Офис");
                        dt.Columns.Add("Подразделение");
                        foreach (ADuser one in usr)
                        {
                            dt.Rows.Add(one.name, one.office, one.reply);
                        }
                        dt.AcceptChanges();
                        UserGrid.DataSource = dt;
                        UserGrid.DataBind();
                        UserPanelExtender.Show();
                    }
                }
                else
                {
                    sd.Text = "<Не найдено!>";
                }
            }
            else if (e.CommandName == "DuplicateUE")
            {
                int    rowInd  = Convert.ToInt32(e.CommandArgument);
                string mySQLid = GridView1.DataKeys[rowInd].Value.ToString();
                comm = new MySqlCommand("SELECT type_id,model_id,status_id,subdivision_id,ue_price FROM ue WHERE id=@id", conn);
                comm.Parameters.AddWithValue("@id", mySQLid);
                newUEDiv.Visible = true;
                conn.Open();
                reader = comm.ExecuteReader();
                string modelID = null;
                while (reader.Read())
                {
                    typeDdl.SelectedValue = reader.GetString(0);
                    modelID = reader.GetString(1);
                    statusDdl.SelectedValue      = reader.GetString(2);
                    subdivisionDdl.SelectedValue = reader.GetString(3);
                    priceT.Text = reader.GetString(4);
                }
                reader.Close();
                // тут изврат, строим таблицу моделей исходя из типа и выбираем его
                comm = new MySqlCommand("SELECT name,id FROM models WHERE type_id=@id", conn);
                comm.Parameters.AddWithValue("@id", typeDdl.SelectedValue);
                reader = comm.ExecuteReader();
                while (reader.Read())
                {
                    modelsDdl.Items.Add(new ListItem(reader.GetString(0), reader.GetString(1)));
                }
                reader.Close();
                modelsDdl.SelectedValue = modelID;
                conn.Close();
            }
        }
Example #24
0
        protected void Setup_Tabs()
        {
            //OK, HOW THIS WORKS.
            //We loop trough all roles. per function of the system the user has access to we add a number that is a bitwise new number ( 0,1,2,4,8,16,32,64,128,...)
            //after we've looped trough the roles, we do a bitwise or so we can easily tell if the user has access to a part of the system

            User user = null;

            if (LoggedInUser.IsUserLoggedIn)
            {
                user = LoggedInUser.GetUser();
            }

            var roles = RoleManager.GetUserPermissions(user);

            //handle the tasks tab
            if (!roles.Any(x => x == RolesPermissions.Tasks))
            {
                TasksTab.Visible = false;
                Tasks.Visible    = false;
            }
            else
            {
                //link the departments drop down
                var list = SystemLists.General.Departments;

                var DepartmentsList = new ObservableCollection <Department>();
                DepartmentsList.Add(new Department(0)
                {
                    Description = LanguageFiles.GetLocalTranslation("AllDepartments", "All")
                });
                foreach (var item in SystemLists.General.Departments)
                {
                    DepartmentsList.Add(item);
                }

                DropDownSorting.DataSource = DepartmentsList;
                DropDownSorting.DataBind();

                if (LoggedInUser.IsUserLoggedIn && (!roles.Any(x => x == RolesPermissions.Technician)))
                {
                    DropDownSorting.SelectedIndex =
                        DepartmentsList.ToList().FindIndex(x => x.ID == LoggedInUser.GetUser().Department.ID);
                }
                else
                {
                    DropDownSorting.SelectedIndex = 0;
                }


                //set the parameters for the datasource
                string departmentID = Request.QueryString["depID"];
                var    searchText   = Request.QueryString["Search"];

                var departmentField = TaskSource.SelectParameters["DepartmentID"];
                var searchField     = TaskSource.SelectParameters["SearchText"];
                if (LoggedInUser.IsUserLoggedIn)
                {
                    if (
                        !RoleManager.UserHasPermission(LoggedInUser.GetUser(), RolesPermissions.ManageTasks) &&
                        (
                            (String.IsNullOrWhiteSpace(departmentID) && String.IsNullOrWhiteSpace(searchText)) ||
                            (LoggedInUser.GetUser().Department.ID.ToString() == departmentID)
                        ))
                    {
                        // logged in + either nothing was given or the user's department was chosen -> show department + user's tasks
                        departmentField.DefaultValue = LoggedInUser.GetUser().Department.ID.ToString();
                        searchText = LoggedInUser.GetUser().UserName;
                    }
                    else if (!String.IsNullOrWhiteSpace(departmentID))
                    {
                        //department was set.
                        departmentField.DefaultValue = departmentID;
                    }

                    if (!String.IsNullOrWhiteSpace(searchText))
                    {
                        //search text was given.
                        searchField.DefaultValue = searchText;
                    }
                }
                else
                {
                    if (!String.IsNullOrWhiteSpace(departmentID))
                    {
                        departmentField.DefaultValue = departmentID;
                    }

                    if (!String.IsNullOrWhiteSpace(searchText))
                    {
                        searchField.DefaultValue = searchText;
                    }
                }

                //set the department parameter
                TaskSource.SelectParameters["DepartmentID"] = departmentField;
                TaskSource.SelectParameters["SearchText"]   = searchField;

                //set datasource and bind/retrieve data (databind also executes all inline code to bind to them)
                TaskSource.DataBind();
                TaskGrid.DataSourceID = nameof(TaskSource);
                TaskGrid.DataBind();
            }

            //handle machines tab
            //if (!roles.Any(x => x == RolesPermissions.ManageMachines))
            {
                //no permissions!
                MachinesTab.Visible = false;
                //Machines.Visible = false;
            }

            /*else
             * {
             *  MachinesTab.Visible = true;
             *  //Machines.Visible = true;
             * }*/

            //permissions to the Suppliers tab!

            /*if (!roles.Any(x => x == RolesPermissions.ManageSuppliers) &&
             *  !roles.Any(x => x == RolesPermissions.ViewSuppliers))*/
            {
                SuppliersTab.Visible = false;
                //Suppliers.Visible = false;
            }

            /*else
             * {
             *  SuppliersTab.Visible = true;
             *  Suppliers.Visible = true;
             * }*/


            //permissions for the Users tab!
            if (!roles.Any(x => x == RolesPermissions.ManageUsers))
            {
                UsersTab.Visible = false;
                Users.Visible    = false;
            }
            else
            {
                UsersTab.Visible = true;
                Users.Visible    = true;

                var RolesList = new ObservableCollection <RoleModel>();
                var roleList  = LanguageFiles.LoadLanguageFile("Roles");

                for (int i = 0; i < roleList.Length; i++)
                {
                    RolesList.Add(RoleModel.CreateModel((Role)i, roleList[i]));
                }

                //bind User dropdown of roles
                selectUserType.DataSource = RolesList;
                selectUserType.DataBind();

                //set the parameters for the datasource
                string role       = Request.QueryString["UserRole"];
                var    searchText = Request.QueryString["SearchUser"];

                if (!String.IsNullOrWhiteSpace(role) && role != nameof(Role.AllRoles))
                {
                    var RoleField = UserSource.SelectParameters["role"];
                    RoleField.DefaultValue = role;
                    UserSource.SelectParameters["role"] = RoleField;
                }

                if (!String.IsNullOrWhiteSpace(searchText))
                {
                    var searchField = UserSource.SelectParameters["contains"];
                    searchField.DefaultValue = searchText;
                    UserSource.SelectParameters["contains"] = searchField;
                }

                UserSource.DataBind();
                UserGrid.DataSourceID = nameof(UserSource);
                UserGrid.DataBind();
            }

            //set the last known open tab
            if (!String.IsNullOrWhiteSpace(ActiveTab))
            {
                hidTABControl.Value = ActiveTab;
            }
        }
 protected void SearchButton_Click(object sender, EventArgs e)
 {
     UserGrid.Visible = true;
     UserGrid.DataBind();
 }
Example #26
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            // CHECK IF PAGE IS VALID
            if (Page.IsValid)
            {
                // MAKE SURE PASSWORD VALIDATES AGAINST POLICY
                if (ValidatePassword())
                {
                    // ATTEMPT TO CREATE THE USER
                    MembershipCreateStatus status;
                    User newUser = UserDataSource.CreateUser(AddEmail.Text, AddEmail.Text, AddPassword.Text, string.Empty, string.Empty, true, 0, out status);
                    if (status == MembershipCreateStatus.Success)
                    {
                        // FORCE PASSWORD EXPIRATION
                        newUser.Passwords[0].ForceExpiration = ForceExpiration.Checked;
                        newUser.Passwords[0].Save();

                        // ASSIGN GROUPS TO NEW USER
                        IList <Group> availableGroups = SecurityUtility.GetManagableGroups();
                        int           groupId         = AlwaysConvert.ToInt(AddGroup.SelectedValue);
                        if (groupId > 0)
                        {
                            int index = availableGroups.IndexOf(groupId);
                            if (groupId > -1)
                            {
                                // ADD THE GROUP ASSOCIATION FOR THE NEW USER
                                newUser.UserGroups.Add(new UserGroup(newUser, availableGroups[index]));
                                newUser.Save();
                            }
                        }

                        // REDIRECT TO EDIT FORM IF INDICATED
                        if (((Button)sender).ID == "AddEditButton")
                        {
                            Response.Redirect("EditUser.aspx?UserId=" + newUser.Id.ToString());
                        }

                        // NO REDIRECT, DISPLAY A CONFIRMATION FOR CREATED USER
                        UserAddedMessage.Text    = string.Format(UserAddedMessage.Text, newUser.UserName);
                        UserAddedMessage.Visible = true;

                        // RESET THE ADD FORM FIELDS
                        AddEmail.Text           = String.Empty;
                        AddPassword.Text        = String.Empty;
                        AddConfirmPassword.Text = String.Empty;
                        AddGroup.SelectedIndex  = -1;

                        //REBIND THE SEARCH
                        UserGrid.DataBind();
                    }
                    else
                    {
                        // CREATE USER FAILED WITHIN THE API
                        switch (status)
                        {
                        case MembershipCreateStatus.DuplicateEmail:
                        case MembershipCreateStatus.DuplicateUserName:
                            AddCustomValidationError(phEmailValidation, AddEmail, "The email address is already registered.");
                            break;

                        case MembershipCreateStatus.InvalidEmail:
                        case MembershipCreateStatus.InvalidUserName:
                            AddCustomValidationError(phEmailValidation, AddEmail, "The email address is invalid.");
                            break;

                        case MembershipCreateStatus.InvalidPassword:
                            AddCustomValidationError(phPasswordValidation, AddPassword, "The password is invalid.");
                            break;

                        default:
                            AddCustomValidationError(phEmailValidation, AddEmail, "Unexpected error: " + status.ToString());
                            break;
                        }
                        AddPopup.Show();
                    }
                }
                else
                {
                    AddPopup.Show();
                }
            }
            else
            {
                AddPopup.Show();
            }
        }
Example #27
0
 private void BindData()
 {
     //Bind the grid view
     UserGrid.DataSource = RetrieveData();
     UserGrid.DataBind();
 }
Example #28
0
 protected void UserDetails_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
 {
     UserGrid.DataBind();
     UserGrid.SelectRow(UserGrid.SelectedRow.RowIndex);
 }
Example #29
0
 protected void UserDetails_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
 {
     UserGrid.DataBind();
     UserGrid.SelectRow(-1);
 }