public DataSet GetProjectsForUser(string UsrNam, string UsrPwd) { DataSet oDs = null; try { Int32 UserId = GetUserId(UsrNam, UsrPwd); if (UserId > 0) { ClassProject oPrj = new ClassProject(); oDs = oPrj.ShowProjectsWithUserMap(UserId); } } catch (Exception ex) { Log.LogMsg(ex.Message); } return oDs; }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { // First time initialisation. Page.Title = TXT_PAGETITLE; this.LblPageTitle.Text = TXT_PAGETITLE; if (Request.QueryString["UserId"] == null) Response.Redirect("UserMenu.aspx", true); ViewState["UserId"] = Request.QueryString["UserId"].ToString(); ClassTeam oTm = new ClassTeam(); this.DdlTeam.DataSource = oTm.ShowTeams1(); this.DdlTeam.DataTextField = "TeamName"; this.DdlTeam.DataValueField = "TeamId"; this.DdlTeam.DataBind(); this.DdlTeam.Items.Insert(0, new ListItem("-- Choose team --", "0")); ClassUser oUsr = new ClassUser(Convert.ToInt32(Request.QueryString["UserId"])); this.TxtUserName.Text = oUsr.UserName; string TxtStr = oUsr.Password; if (TxtStr.Length < 8) TxtStr = TxtStr.PadRight(8); this.TxtPassword.Text = TxtStr; this.TxtPassword.TextMode = TextBoxMode.Password; this.TxtPassword.Attributes.Add("value", TxtStr); this.TxtSurname.Text = oUsr.Surname; this.TxtForename.Text = oUsr.Forename; this.TxtEmailAddress.Text = oUsr.EmailAddress; this.TxtHourlyRate.Text = string.Format("{0:f}", oUsr.HourlyRate); ClassUserGroup oGrp = new ClassUserGroup(); this.DdlUserGroup.DataSource = oGrp.ShowUserGroups(); this.DdlUserGroup.DataTextField = "UserGroupName"; this.DdlUserGroup.DataValueField = "UserGroupId"; this.DdlUserGroup.DataBind(); this.DdlUserGroup.Items.Insert(0, new ListItem("-- Choose user group --", "0")); try { this.DdlTeam.SelectedValue = oUsr.TeamId.ToString(); } catch (Exception) { // Do nothing - we don't need to worry about a team which // can't be selected. } try { this.DdlUserGroup.SelectedValue = oUsr.UserGroupId.ToString(); } catch (Exception) { // Okay to error. The supplied user group id isn't in the // dropdown listbox. } ClassProject oPrj = new ClassProject(); DataSet oDs = oPrj.ShowProjectsWithUserMap(oUsr.UserId); this.ClstProjects.DataSource = oDs; this.ClstProjects.DataTextField = "ProjectName"; this.ClstProjects.DataValueField = "ProjectId"; this.ClstProjects.DataBind(); foreach (DataRow oDr in oDs.Tables[0].Rows) { if (Convert.ToInt32(oDr["Selected"].ToString()) != 0) { ListItem oChk = this.ClstProjects.Items.FindByValue(oDr["ProjectId"].ToString()); if (oChk != null) { oChk.Selected = true; } } } this.TxtUserName.Focus(); } }