Esempio n. 1
0
    protected void gvUsrDetails_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string strUsrId = e.CommandArgument.ToString();

        if (e.CommandName == "Edit")
        {
            Server.Transfer("~/Administration/CreateUser.aspx?UsrId=" + strUsrId);
        }

        if (e.CommandName == "Delete")
        {
            _objUsrAdmin.DeleteUser(Convert.ToInt32(strUsrId));

            //************
            //TV: 04/2009 - double check that the user was deleted (which means the Active flag was set to false)
            string sDeleteMsg = "";
            string sErrMsg    = "There may have been a problem with the Delete action. Please check with your system administrator for the user whose ID number is: " + strUsrId;

            //get user details
            DataSet dsUsrDetails = _objUsrAdmin.GetUserById(Convert.ToInt32(strUsrId));
            if (dsUsrDetails != null && dsUsrDetails.Tables[0] != null && dsUsrDetails.Tables[0].Rows.Count > 0)
            {
                //check the value of the Active flag - if it is false, then the user was deleted ("logically deleted")
                if (DBNull.Value.Equals(dsUsrDetails.Tables[0].Rows[0]["Active"]) == false)
                {
                    bool bActiveFlag = (bool)dsUsrDetails.Tables[0].Rows[0]["Active"];
                    if (bActiveFlag == false)
                    {
                        sDeleteMsg = "User deleted successfully";
                    }
                }
            }
            //show appropriate message to user and clear out any prior messages that may exist
            if (sDeleteMsg.Length > 0)
            {
                lblErrMsg.Text = "";
                lblMsg.Text    = sDeleteMsg;
            }
            else
            {
                lblMsg.Text    = "";
                lblErrMsg.Text = sErrMsg;
            }
            //************

            PopulateGrid();
        }
    }
Esempio n. 2
0
    //Populate controls for update mode
    private void PopulateCtrls()
    {
        string  strUsrId = Request.QueryString["UsrId"];
        DataSet dsUsrDetails;

        dsUsrDetails = _objUsrAdmin.GetUserById(Convert.ToInt32(strUsrId));

        txtFirstNm.Text       = dsUsrDetails.Tables[0].Rows[0]["FirstName"].ToString();
        txtLastNm.Text        = dsUsrDetails.Tables[0].Rows[0]["LastName"].ToString();
        txtEmail.Text         = dsUsrDetails.Tables[0].Rows[0]["Email"].ToString();
        txtPhNo.Text          = dsUsrDetails.Tables[0].Rows[0]["PhoneNumber"].ToString();
        txtPwd.Text           = dsUsrDetails.Tables[0].Rows[0]["Password"].ToString();
        ddlRole.SelectedValue = dsUsrDetails.Tables[0].Rows[0]["UserRole"].ToString();

        if (ddlRole.SelectedValue == _strMovementCampsAdmin)
        {
            lstMovements.SelectedValue = dsUsrDetails.Tables[0].Rows[0]["MovementID"].ToString();
        }
        else
        {
            lstFed.SelectedValue = dsUsrDetails.Tables[0].Rows[0]["Federation"].ToString();
        }
    }