/// <summary> /// Saving the updated privilege for the selected Staff. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cmdOK_Click(object sender, EventArgs e) { string strRedirectUrl = string.Empty; try { objTeamStaffRegistrationBLL = new TeamStaffRegistrationBLL(); objStaffData = objTeamStaffRegistrationBLL.GetSelectedStaffDetails(strParentSiteURL, strSelectedID, TEAMSTAFFLIST); objStaffData.PRIVILEGE = cboEditPrivileges.SelectedItem.Text; objTeamStaffRegistrationBLL.UpdateStaffPrivilege(strParentSiteURL, objStaffData, TEAMSTAFFLIST); string strTeamId = objStaffData.TeamID; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "ClosePopupAndRefreshParent", "javascript:ClosePopupAndRefreshParent('+ strTeamId + ',' + TEAMSTAFFLIST + ');", true); } catch(WebException webEx) { CommonUtility.HandleException(strParentSiteURL, webEx, 1); lblException.Text = webEx.Message; lblException.Visible = true; ExceptionBlock.Visible = true; } catch(Exception ex) { CommonUtility.HandleException(strParentSiteURL, ex); } }
/// <summary> /// /// </summary> /// <param name="siteUrl"></param> /// <param name="selectedId"></param> /// <param name="listName"></param> public void UpdateStaffPrivilege(string siteUrl, StaffDetails objStaffDetails, string listName) { objTeamStaffRegistrationDAL = new TeamStaffRegistrationDAL(); objTeamStaffRegistrationDAL.UpdateStaffPrivilege(siteUrl, objStaffDetails, listName); }
/// <summary> /// Gets the new staff ranks. /// </summary> /// <returns></returns> private ArrayList GetNewStaffRanks() { ArrayList arlStaffs = new ArrayList(); StaffDetails objStaffDetails = null; for (int intIndex = 0; intIndex < dualListPrivileges.RightItems.Count; intIndex++) { objStaffDetails = new StaffDetails(); objStaffDetails.RowID = dualListPrivileges.RightItems[intIndex].Value; objStaffDetails.UserRank = Convert.ToString(intIndex + 1); arlStaffs.Add(objStaffDetails); } return arlStaffs; }
/// <summary> /// Save Handler. /// Saves the changes to SharePoint list. /// Redirectes to Maintenance Screen. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cmdSave_Click(object sender, EventArgs e) { /// Update the Privileges column for the new Privileges string strPrivileges = string.Empty; bool blnUpdateSuccess = false; objListEntry = new ListEntry(); try { if (!string.IsNullOrEmpty(strListType)) { switch (strListType) { case USERREGISTRATION: /// Case to add/remove privileges to Users { objListEntry.UserDetails = new UserDetails(); objListEntry.UserDetails.RowId = int.Parse(HttpContext.Current.Request.QueryString[IDVALUEQUERYSTRING]); foreach (ListItem lstItemSelectedPrivilege in dualListPrivileges.RightItems) { if (lstItemSelectedPrivilege != null) { strPrivileges += lstItemSelectedPrivilege.Value + SPLITTER_STRING; } } objListEntry.UserDetails.Privileges = strPrivileges; blnUpdateSuccess = UpdateListEntry(objListEntry, USERLIST, USERPRIVILEGES, AUDITACTIONUPDATION); break; } case STAFFREGISTRATION:/// Case to add/remove Staffs from team { objListEntry.Staffs = new ArrayList(); objListEntry.TeamDetails = new TeamDetails(); objListEntry.TeamDetails.RowId = Int32.Parse(strParentID); objListEntry.TeamDetails.TeamName = hdnParentName.Value; StaffDetails objStaffDetails = null; int index = 0; foreach (ListItem lstItemSelectedStaff in dualListPrivileges.RightItems) { if (lstItemSelectedStaff != null) { objStaffDetails = new StaffDetails(); objStaffDetails.RowID = lstItemSelectedStaff.Value; objStaffDetails.UserName = lstItemSelectedStaff.Text; objStaffDetails.TeamID = strParentID; objStaffDetails.UserRank = index.ToString(); objListEntry.Staffs.Add(objStaffDetails); index++; } } blnUpdateSuccess = UpdateListEntry(objListEntry, TEAMSTAFFLIST, STAFFREGISTRATION, AUDITACTIONUPDATION); break; } } } if (blnUpdateSuccess) { Page.Response.Redirect(GetRedirectUrl(), false); } else { lblException.Text = GetErrorMessage(); } } catch (WebException webEx) { lblException.Text = webEx.Message; lblException.Visible = true; ExceptionBlock.Visible = true; } catch (Exception ex) { CommonUtility.HandleException(strParentSiteURL, ex); } }
protected void Page_Load(object sender, EventArgs e) { strMode = HttpContext.Current.Request.QueryString[MODEQUERYSTRING]; strSelectedID = HttpContext.Current.Request.QueryString[IDVALUEQUERYSTRING]; string strCAMLQuery = string.Empty; string strViewFields = string.Empty; try { if(!IsPostBack) { objTeamStaffRegistrationBLL = new TeamStaffRegistrationBLL(); strViewFields = "<FieldRef Name='Title'/>"; objStaffData = objTeamStaffRegistrationBLL.GetSelectedStaffDetails(strParentSiteURL, strSelectedID, TEAMSTAFFLIST); if(objStaffData != null) { SetListValues(cboEditPrivileges, SYSTEMPRIVILEGESLIST, strCAMLQuery, strViewFields); //cboEditPrivileges.Items.FindByValue(objStaffData.RowID).Selected = true; if(!string.IsNullOrEmpty(objStaffData.PRIVILEGE)) cboEditPrivileges.Items.FindByText(objStaffData.PRIVILEGE).Selected = true; } } } catch(WebException webEx) { lblException.Text = webEx.Message; lblException.Visible = true; ExceptionBlock.Visible = true; } catch(Exception ex) { CommonUtility.HandleException(strParentSiteURL, ex); } }
/// <summary> /// Updating the Privilege For the selected Staff /// Member /// </summary> /// <param name="siteUrl"></param> /// <param name="selectedId"></param> /// <param name="listName"></param> internal void UpdateStaffPrivilege(string siteUrl, StaffDetails objStaffDeatils, string listName) { SPList list; SPSecurity.RunWithElevatedPrivileges(delegate() { using(SPSite site = new SPSite(siteUrl)) { using(SPWeb web = site.OpenWeb()) { web.AllowUnsafeUpdates = true; list = web.Lists[listName]; int row = Convert.ToInt32(objStaffDeatils.RowID); SPListItem objListItem = list.GetItemById(row); /// Privileges objListItem["Privilege"] = objStaffDeatils.PRIVILEGE; objListItem.Update(); web.AllowUnsafeUpdates = false; } } }); }
/// <summary> /// Get The Details for the selected Staff Member /// </summary> /// <param name="siteUrl"></param> /// <param name="selectedID"></param> /// <param name="listName"></param> /// <returns></returns> internal StaffDetails GetSelectedStaffDetails(string siteUrl, string selectedID, string listName) { StaffDetails objStaffData = null; SPList list; SPListItem objListItem; SPSecurity.RunWithElevatedPrivileges(delegate() { using(SPSite site = new SPSite(siteUrl)) { using(SPWeb web = site.OpenWeb()) { list = web.Lists[listName]; string strCAMLQuery = @"<Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>" + selectedID + "</Value></Eq></Where>"; //string strViewFields = @"<FieldRef Name='Title'/><FieldRef Name='Asset_Owner'/><FieldRef Name='Terminate_Status'/><FieldRef Name='ID'/>"; SPQuery query = new SPQuery(); query.Query = strCAMLQuery; //query.ViewFields = strViewFields; SPListItemCollection listItemCollection = list.GetItems(query); if(listItemCollection != null && listItemCollection.Count > 0) { objListItem = listItemCollection[0]; if(objListItem != null) { objStaffData = new StaffDetails(); objStaffData.UserName = Convert.ToString(objListItem["Title"]); objStaffData.TeamID = Convert.ToString(objListItem["Team_ID"]); objStaffData.UserID = Convert.ToString(objListItem["User_ID"]); objStaffData.UserRank = Convert.ToString(objListItem["User_Rank"]); objStaffData.Discipline = Convert.ToString(objListItem["Discipline"]); objStaffData.PRIVILEGE = Convert.ToString(objListItem["Privilege"]); objStaffData.RowID = Convert.ToString(objListItem["ID"]); } } } } }); return objStaffData; }