Exemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string sBackPage;

            try
            {
                OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false);

                if (Request.QueryString["id"] == null)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"]    = _functions.ErrorMessage(104);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                try
                {
                    UserId = Convert.ToInt32(Request.QueryString["id"]);
                }
                catch (FormatException fex)
                {
                    Session["lastpage"] = "admin_users.aspx";
                    Session["error"]    = _functions.ErrorMessage(105);
                    Response.Redirect("error.aspx", false);
                    return;
                }
                lblBack.Text = "<input type=button value=\" Back \" onclick=\"document.location='admin_users.aspx'\">";
                if (!IsPostBack)
                {
                    hlUserEdit.NavigateUrl = "admin_user_detail_edit.aspx?id=" + UserId.ToString();
                    user         = new clsUsers();
                    user.cAction = "S";
                    user.iOrgId  = OrgId;
                    user.iId     = UserId;
                    if (user.UserDetails() == -1)
                    {
                        Session["lastpage"] = "admin_user_detail.aspx?id=" + UserId.ToString();
                        Session["error"]    = _functions.ErrorMessage(134);
                        Response.Redirect("error.aspx", false);
                        return;
                    }
                    lblFirstName.Text   = user.sFirstName.Value;
                    lblLastName.Text    = user.sLastName.Value;
                    lblType.Text        = user.sTypeName.Value;
                    lblEmail.Text       = user.sEmail.Value;
                    lblHourlyRate.Text  = user.dmHourlyRate.Value.ToString("C");
                    lblCreatedDate.Text = user.daCreated.Value.ToLongDateString() + " " + user.daCreated.Value.ToLongTimeString();
                    if (user.bActiveStatus.Value)
                    {
                        lblUserActivateStatus.Text = "Activated";
                    }
                    else
                    {
                        lblUserActivateStatus.Text = "Deactivated";
                    }
                    dgGroups.DataSource = new DataView(user.GetUserGroupsList());
                    dgGroups.DataBind();
                    equip                   = new clsEquipment();
                    equip.iOrgId            = OrgId;
                    equip.iUserId           = UserId;
                    dgEquipments.DataSource = new DataView(equip.GetEquipListByUser());
                    dgEquipments.DataBind();
                }
            }
            catch (Exception ex)
            {
                _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName);
                Session["lastpage"]     = "admin_users.aspx";
                Session["error"]        = ex.Message;
                Session["error_report"] = ex.ToString();
                Response.Redirect("error.aspx", false);
            }
            finally
            {
                if (equip != null)
                {
                    equip.Dispose();
                }
                if (user != null)
                {
                    user.Dispose();
                }
            }
        }