protected void RadGridUser_PreRender(object sender, EventArgs e) { if (Request["me"] != null) { // select me LinqDataSourceUser.WhereParameters.Clear(); LinqDataSourceUser.WhereParameters.Add("UserId", DbType.Int32, CurrentUserId.ToString()); LinqDataSourceUser.Where = "UserId == @UserId"; RadGridUser.MasterTableView.Rebind(); foreach (GridDataItem item in RadGridUser.Items) { if (item.GetDataKeyValue("UserId").ToString() == CurrentUserId.ToString()) { item.Selected = true; GetStaffInfo(); RadToolBarUser.FindItemByText("New").Enabled = false; RadToolBarUser.FindItemByText("Permission").Enabled = false; RadToolBarUser.FindItemByText("User Information").Enabled = false; RadToolBarUser.FindItemByText("Update").Enabled = true; break; } } } }
protected void ResetForm() { LoadSite(CurrentSiteId); LoadSiteLocation(CurrentSiteId); LoadUserGroup(CurrentSiteId); LoadUserPosition(0); LoadSupervisor(); tbUserID.Text = ""; tbPassWord.Text = ""; tbFName.Text = ""; tbMName.Text = ""; tbLName.Text = ""; tbSIN.Text = ""; tbDOB.SelectedDate = null; tbAge.Text = ""; ddlMarital.SelectedValue = ""; ddlGender.SelectedValue = ""; tbWEmail.Text = ""; tbWPhone.Text = ""; RadComboBoxSite.SelectedValue = CurrentSiteId.ToString(); RadComboBoxSiteLocation.SelectedValue = CurrentSiteLocationId.ToString(); RadComboBoxUserGroup.SelectedValue = ""; RadComboBoxUserPosition.SelectedValue = ""; RadComboBoxSuper.SelectedValue = ""; tbEmpNo.Text = ""; cbActive.Checked = true; tbPAddess1.Text = ""; tbPAddess2.Text = ""; tbPCity.Text = ""; tbPProvince.Text = ""; tbPPostal.Text = ""; tbPHomePhone.Text = ""; tbPCell.Text = ""; tbPEmail.Text = ""; tbEName.Text = ""; tbERelation.Text = ""; tbEPhone.Text = ""; tbEAddress.Text = ""; tbUserID.Enabled = true; RadComboBoxSite.Enabled = true; RadComboBoxSiteLocation.Enabled = true; tbEmpNo.Enabled = true; RadBinaryImagePicture.DataValue = null; RadBinaryImagePicture.Visible = false; if (RadToolBarUser.FindItemByText("New") != null) { RadToolBarUser.FindItemByText("New").Enabled = false; } if (RadToolBarUser.FindItemByText("Update") != null) { RadToolBarUser.FindItemByText("Update").Text = @"Save"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ResetForm(); if (new CUser().IsUserPermission(CurrentGroupId)) { RadToolBarUser.FindItemByText("Permission").Enabled = true; } if (new CUser().IsUserInformation(CurrentGroupId)) { RadToolBarUser.FindItemByText("User Information").Enabled = true; } } SearchUser(); RadComboBoxSiteLocation.OpenDropDownOnLoad = false; }
protected void GetStaffInfo() { if (RadGridUser.SelectedValue != null) { var cUser = new CUser(); var user = cUser.Get(Convert.ToInt32(RadGridUser.SelectedValue)); if (user.UserId > 0) { var cSiteLocation = new CSiteLocation(); var siteLocation = cSiteLocation.Get(user.SiteLocationId); LoadSite(siteLocation.SiteId); LoadSiteLocation(siteLocation.SiteId); LoadUserGroup(siteLocation.SiteId); LoadSupervisor(); RadComboBoxSite.SelectedValue = siteLocation.SiteId.ToString(); RadComboBoxSiteLocation.SelectedValue = user.SiteLocationId.ToString(); var cUserPosition = new CUserPosition(); var userPosition = cUserPosition.Get(user.UserPositionId); if (userPosition != null) { RadComboBoxUserGroup.SelectedValue = userPosition.UserGroupId.ToString(); LoadUserPosition(userPosition.UserGroupId); RadComboBoxUserPosition.SelectedValue = user.UserPositionId.ToString(); } RadComboBoxSuper.SelectedValue = user.Supervisor.ToString(); tbUserID.Enabled = false; tbUserID.Text = user.LoginId; //tbPassWord.Text = user.Password; tbFName.Text = user.FirstName; tbMName.Text = user.MidName; tbLName.Text = user.LastName; tbSIN.Text = Convert.ToString(user.SINNo); tbDOB.SelectedDate = user.DOB; DateTime Today = DateTime.Now; DateTime Dob = Convert.ToDateTime(user.DOB); TimeSpan ts = Today - Dob; DateTime Age = DateTime.MinValue + ts; int Years = Age.Year - 1; tbAge.Text = Years.ToString(); ddlMarital.SelectedValue = user.MaritalStatus; ddlGender.SelectedValue = user.Gender; tbWEmail.Text = user.Email; tbWPhone.Text = user.Phone; tbEmpNo.Text = user.EmployeeNumber; cbActive.Checked = user.IsActive; tbPAddess1.Text = user.Address1; tbPAddess2.Text = user.Address2; tbPCity.Text = user.City; tbPProvince.Text = user.Province; tbPPostal.Text = user.PostalCode; tbPHomePhone.Text = user.HomePhone; tbPCell.Text = user.CellPhone; tbPEmail.Text = user.PersonalEmail; tbEName.Text = user.EContactName; tbERelation.Text = user.ERelation; tbEPhone.Text = user.EPhone; tbEAddress.Text = user.EAddress; // pic if (user.Picture != null) { RadBinaryImagePicture.DataValue = user.Picture.ToArray(); RadBinaryImagePicture.Visible = true; } else { RadBinaryImagePicture.DataValue = null; RadBinaryImagePicture.Visible = false; } if (RadToolBarUser.FindItemByText("New") != null) { RadToolBarUser.FindItemByText("New").Enabled = true; } if (RadToolBarUser.FindItemByText("Save") != null) { RadToolBarUser.FindItemByText("Save").Text = @"Update"; } } } }