Exemple #1
0
        protected void btnUserEditSave_Click(object sender, EventArgs e)
        {
            const string METHOD_NAME = "btnUserEditSave_Click";

            try {
                int userID = 0;
                if (grdUserResults.SelectedRow == null)
                {
                    WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please select a user from the User Search Results");
                    throw (warn);
                }
                else
                {
                    userID = Convert.ToInt32(grdUserResults.SelectedRow.Cells[0].Text);
                }

                // Save User's Region assignments and Role assignments
                bool   isActive = chkUserEditIsActive.Checked;
                string roles    = "";

                foreach (ListItem li in lstUserEditRole.Items)
                {
                    if (li.Selected)
                    {
                        if (roles.Length == 0)
                        {
                            roles = li.Value;
                        }
                        else
                        {
                            roles += "," + li.Value;
                        }
                    }
                }

                string regions = "";
                foreach (ListItem li in lstUserEditRegion.Items)
                {
                    if (li.Selected)
                    {
                        if (regions.Length == 0)
                        {
                            regions = li.Value;
                        }
                        else
                        {
                            regions += "," + li.Value;
                        }
                    }
                }

                WSCSecurity.UserSecuritySave(userID, isActive, roles, regions);
                FillUserSearchGrid();
            }
            catch (System.Exception ex) {
                Common.CException wex = new Common.CException(MOD_NAME + METHOD_NAME, ex);
                ((PrimaryTemplate)Page.Master).ShowWarning(ex);
            }
        }