}//end add new skill

        protected void gvDeleteSkills_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "gvCommandDelete")
            {
                expertObj = (Expert)Session["expertProfileObj"];
                int index = Convert.ToInt32(e.CommandArgument);
                GridViewRow selectedRow = gvDeleteSkills.Rows[index];
                string s = selectedRow.Cells[0].Text;//get skill name from selected row to be deleted.
                int count = 0;//test counter if no matches were found in forEach loop

                foreach (Tuple<int, String> skill in expertObj.AllExpertSkills)
                {
                    if (skill.Item2.Equals(s, StringComparison.OrdinalIgnoreCase))
                    {
                        count++;//found something
                        int result = DbMethods.DeleteExpertSkill(expertObj.tuID, skill.Item1);
                        if (result != -1)
                        {
                            lblGvDeleteTest.Text = "Skill has been deleted.";
                            sm.storeExpertDataInSession();//now get the whole expert object
                            FillControls();
                        }
                        else
                            lblGvDeleteTest.Text = "Unable to restore file. DataBase error. Please try again.";
                    }
                    if (count == 0)
                        lblGvDeleteTest.Text = "could not find skill name in local DataSet. :(";
                }
            }//end Delete Skill Row Command
        }//end gvDeleteSkills_RowCommand
        }//end page load method

        // Fill page controls with updated information
        public void FillControls()
        {
            expertObj = (Expert)Session["expertProfileObj"];
            if (expertObj != null)
            {
                SkillGroupDropdown.DataSource = DbMethods.GetAllSkillGroups();
                SkillGroupDropdown.DataValueField = "SkillGroupID";
                SkillGroupDropdown.DataTextField = "SkillGroupName";
                SkillGroupDropdown.DataBind();
                SkillGroupDropdown.SelectedIndex = SkillGroupDropdown.Items.IndexOf(SkillGroupDropdown.Items.FindByValue(expertObj.skillGroupID.ToString()));

                txtFirstName.Text = expertObj.firstName;
                txtLastName.Text = expertObj.lastName;
                txtUsername.Text = expertObj.username;
                txtEmail.Text = expertObj.email;
                txtPhoneNumber.Text = expertObj.phoneNumber;
                txtLinkedIn.Text = expertObj.linkedIn;
                aboutMe.Text = expertObj.aboutMe;

                //get all Expert's skills and put them on the page
                if (expertObj.AllExpertSkills.Count == 0)
                {
                    lblDeleteTest.Text = "You (the Expert) don't have any skils in your profile. Please add some on this page.";
                    gvDeleteSkills.DataSource = null;
                    gvDeleteSkills.DataBind();
                }
                else
                {
                    this.gvDeleteSkills.DataSource = expertObj.AllExpertSkills;
                    this.gvDeleteSkills.DataBind();
                }
            }//end if
        }//end fill controls
        protected void btnYes_Click(object sender, EventArgs e)
        {
            DbMethodsObj.DeactivateVenture(ventureObj.ventureID);
            Expert expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];

            Response.Redirect("ExpertPage.aspx?username=" + expertProfileObj.username);
        }
        protected void btnSubmitStaticMember_Click(object sender, EventArgs e)
        {
            ventureObj = (Venture)Session["ventureObj"];
            if (valid.IsBlank(txtFirstName.Text) || valid.IsBlank(txtLastName.Text) || valid.IsBlank(txtRole.Text))
            {
                lblStaticRequired.Visible = true;
            }
            else
            {
                string   firstName        = txtFirstName.Text;
                string   lastName         = txtLastName.Text;
                string   role             = txtRole.Text;
                DateTime lastUpdateDate   = DateTime.Now;
                Expert   expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];
                string   lastUpdateUser   = expertProfileObj.lastName + ", " + expertProfileObj.firstName;

                DbMethodsObj.CreateStaticMember(ventureObj.ventureID, firstName, lastName, role, lastUpdateDate, lastUpdateUser);
                txtRole.Text      = "";
                txtFirstName.Text = "";
                txtLastName.Text  = "";
                sm.storeVentureDataInSession(ventureObj.ventureID);
                ventureObj = (Venture)Session["ventureObj"];
                FillControls();
            }
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string username;
            expertObj = (Expert)Session["expertProfileObj"];

            if (Session["Authenticated"] == null)
            {
                username = null;
                Session.Clear();
                Session.Abandon();
                Response.Redirect("default.aspx");
            }
            else if (Request.QueryString["username"] != null)
            {
                username = Request.QueryString["username"];
                studentObj.tuid = DbMethods.GetTUIDByUsername(username);
                expertObj = sm.getAllTheExpertInfo(studentObj.tuid);
            }
            else
            {
                studentObj.tuid = DbMethods.GetTUIDByUsername(expertObj.username);
                expertObj = sm.getAllTheExpertInfo(studentObj.tuid);
            }           

            if (!IsPostBack)
                FillControls();

            if(studentObj.tuid != (string)Session["TU_ID"])
            {
                btnEditExpertPage.Visible = false;
            }
        }//end page load
        public void FillControlls()
        {
            if ((Expert)Session["expertProfileObj"] != null)
            {
                ex = (Expert)Session["expertProfileObj"];
                if (ex.roleVentureNameList.Count != 0)
                {
                    ddlMyVentures.Visible = true;
                    List <string> localVentureNameList = new List <string>();
                    localVentureNameList.Add("My Ventures");
                    //DataSet myDS = objDB.GetAllVentureNamesByTuid((string)Session["TU_ID"]);
                    for (int i = 0; i < ex.roleVentureNameList.Count; i++)
                    {
                        localVentureNameList.Add(ex.roleVentureNameList[i].Item1);
                    }
                    foreach (string ventureName in localVentureNameList)
                    {
                        ddlMyVentures.Items.Add(new ListItem(ventureName));
                    }
                    this.ddlMyVentures.DataBind();
                }
                else
                {
                    ddlMyVentures.Visible = false;
                }

                lblLoggedIn.Text = "You are logged in as: " + ex.firstName + " " + ex.lastName;
            }
        }
        protected void BtnSubmitNewSkill_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Entering BtnSubmitNewSkill_Click");
            int test = 0;
            int result;
            expertObj = (Expert)Session["expertProfileObj"];

            if (string.IsNullOrWhiteSpace(txtAddNewSkill.Text)==false)
            {
                //search expert's skillset to see if the skill added already exsists
                //search all skill to see if the skill added exsists
                //if not to both, add a new skill
                foreach (Tuple<int,String> skill in expertObj.AllExpertSkills)//test if skill added is already in Expert's Skill Set
                {
                    if(skill.Item2.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        test = -1;
                        break;
                    }
                }
                if (test != -1)
                {
                    List<Skills> allSkills = DbMethods.GetSkills();
                    foreach (Skills skill in allSkills)//handle adding the skill
                    {
                        if (skill.SkillName.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                        {
                            result = DbMethods.AddSkillToUser(expertObj.tuID, skill.SkillID);//adding excisting skill to expert
                            if (result != -1)
                            {
                                lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                                test = -2;
                                break;
                            }
                            else
                                lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                            break;
                        }
                    }
                    if(test != -2)
                    {
                        result = DbMethods.AddNewSkillToUser(expertObj.tuID, txtAddNewSkill.Text);//adding brandnew skill
                        if (result != -1)
                            lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                        else
                            lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                    }
                    sm.storeExpertDataInSession();//now get the whole expert object
                    FillControls();
                }
                else
                    lblAddSkillTest.Text = "Cannot add this skill. you already have this skill in your skill set.";
            }//end if statement for textBoxes
            else
                lblAddSkillTest.Text = "Error: Invalid input.";
        }//end add new skill
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Authenticated"] == null)
            {
                Response.Redirect("default.aspx");
            }
            else if (Request.QueryString["name"] == null)
            {
                Response.Redirect("Search.aspx");
            }
            else
            {
                string  ventureName = Request.QueryString["name"];
                int     vId         = Convert.ToInt32(dbm.GetVentureID(ventureName));
                Venture v           = dbm.GetVenture(vId);

                h2VentureName.InnerText     = v.name;
                spVentureContact.InnerText  = v.contactEmail;
                pAboutUs.InnerText          = v.aboutUs;
                imgLogo.ImageUrl            = d.ConvertToImage(v.Picture);
                h3VentureDesc.InnerText     = v.description;
                spVenturePhone.InnerText    = v.contactPhoneNumber;
                spVentureLinkedIn.InnerText = v.contactLinkedIn;
                lblPrimaryContactEmail.Text = v.primaryContactEmail;

                //put venture data into session
                sm.storeVentureDataInSession(vId);
                ventureObj = (Venture)Session["ventureObj"];
                //Bind Repeaters
                this.rptMembersAndRoles.DataSource = ventureObj.memberNameAndRoleList;
                this.rptMembersAndRoles.DataBind();
                this.rptStaticMembersAndRoles.DataSource = ventureObj.staticMembersList;
                this.rptStaticMembersAndRoles.DataBind();
                this.rptVentureSkills.DataSource = ventureObj.AllVentureSkills;
                this.rptVentureSkills.DataBind();

                //Make sure only members of a venture are able to edit this particular venture
                Expert    expertProfileObj = sm.getAllTheExpertInfo((string)Session["TU_ID"]);
                string    user_name        = expertProfileObj.username;
                DataTable usernamesTable   = dbm.GetUsernamesForVenture(vId).Tables[0];
                int       isMember         = 0;
                for (int i = 0; i < usernamesTable.Rows.Count && isMember == 0; i++)
                {
                    if (usernamesTable.Rows[i][0].ToString() == user_name)
                    {
                        isMember            = 1;
                        editVenture.Visible = true;
                    }
                }//End of Restricting Edit Venture
            }
        }
 private List<Param> BuildUpdateExpertParams(Expert e, string tuid)
 {
     List<Param> p = new List<Param>();
     p.Add(new Param("@firstName", e.firstName, SqlDbType.VarChar));            
     p.Add(new Param("@lastName", e.lastName, SqlDbType.VarChar));
     p.Add(new Param("@username", e.username, SqlDbType.VarChar));
     p.Add(new Param("@email", e.email, SqlDbType.VarChar));
     p.Add(new Param("@phoneNumber", e.phoneNumber, SqlDbType.VarChar));            
     p.Add(new Param("@linkedIn", e.linkedIn, SqlDbType.VarChar));
     p.Add(new Param("@aboutMe", e.aboutMe, SqlDbType.VarChar));
     p.Add(new Param("@tuid", tuid, SqlDbType.Int));
     p.Add(new Param("@picture", e.picture, SqlDbType.VarBinary));
     p.Add(new Param("@skillGroupID", e.skillGroupID, SqlDbType.Int));
     return p;
 }
        }//end click event

        protected void btnSubmitExpert_Click(object sender, EventArgs e)
        {
            lblMemberRequired.Visible   = false;
            lblEmailNotInSystem.Visible = false;
            int count = Convert.ToInt32(DbMethodsObj.CheckIfExpertEmailExists(txtExpertEmail.Text));

            ventureObj = (Venture)Session["ventureObj"];
            if (valid.IsBlank(txtExpertEmail.Text) || valid.IsBlank(txtExpertRole.Text))
            {
                lblMemberRequired.Visible = true;
            }
            else if (count < 1)
            {
                lblEmailNotInSystem.Visible = true;
            }
            else
            {
                string   email            = txtExpertEmail.Text;
                string   TUID             = DbMethodsObj.GetExpertTUID(email).ToString();
                string   role             = txtExpertRole.Text;
                DateTime lastUpdateDate   = DateTime.Now;
                Expert   expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];
                string   lastUpdateUser   = expertProfileObj.lastName + ", " + expertProfileObj.firstName;

                DataSet ventureMember = new DataSet();
                ventureMember = DbMethodsObj.CheckIfVentureMemberExists(ventureObj.ventureID, TUID);

                if (ventureMember.Tables[0].Rows.Count != 0)
                {
                    DbMethodsObj.ReactivateVentureMember(TUID, ventureObj.ventureID, role);
                    txtExpertEmail.Text = "";
                    txtExpertRole.Text  = "";
                    sm.storeVentureDataInSession(ventureObj.ventureID);
                    ventureObj = (Venture)Session["ventureObj"];
                    FillControls();
                }
                else
                {
                    DbMethodsObj.CreateVentureMember(TUID, ventureObj.ventureID, role, lastUpdateDate, lastUpdateUser);
                    txtExpertEmail.Text = "";
                    txtExpertRole.Text  = "";
                    sm.storeVentureDataInSession(ventureObj.ventureID);
                    ventureObj = (Venture)Session["ventureObj"];
                    FillControls();
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Debug.WriteLine("Entering Page_Load");
     string username;
     if (Session["Authenticated"] == null)
     {
         username = null;
         Session.Clear();
         Session.Abandon();
         Response.Redirect("default.aspx");
     }
     else if (!IsPostBack)
     {
         expertObj = (Expert)Session["expertProfileObj"];
         FillControls();
     }
 }//end page load method
Exemple #12
0
        public int CreateExpert(Expert e)
        {
            DBConnect objDB = new DBConnect();

            objCommand.CommandType = CommandType.StoredProcedure;
            objCommand.CommandText = "CreateExpert";
            objCommand.Parameters.Clear();

            List<Param> p = BuildCreateExpertParams(e);

            foreach (Param param in p)
            {
                SqlParameter inputParameter = new SqlParameter(param.Name, param.Val);
                inputParameter.Direction = ParameterDirection.Input;
                inputParameter.SqlDbType = param.Type;
                objCommand.Parameters.Add(inputParameter);
            }

            int result = objDB.DoUpdateUsingCmdObj(objCommand);
            return result;
        }
Exemple #13
0
 private List<Param> BuildCreateExpertParams(Expert e)
 {
     List<Param> p = new List<Param>();
     p.Add(new Param("@tuid", e.tuID, SqlDbType.Int));
     p.Add(new Param("@username", e.username, SqlDbType.VarChar));
     p.Add(new Param("@lastName", e.lastName, SqlDbType.VarChar));
     p.Add(new Param("@firstName", e.firstName, SqlDbType.VarChar));
     p.Add(new Param("@college", e.college, SqlDbType.VarChar));
     p.Add(new Param("@major", e.major, SqlDbType.VarChar));
     p.Add(new Param("@email", e.email, SqlDbType.VarChar));
     p.Add(new Param("@dateJoined", e.dateJoined, SqlDbType.DateTime));
     p.Add(new Param("@phoneNumber", e.phoneNumber, SqlDbType.VarChar));
     p.Add(new Param("@aboutMe", e.aboutMe, SqlDbType.VarChar));
     p.Add(new Param("@linkedIn", e.linkedIn, SqlDbType.VarChar));
     p.Add(new Param("@picture", e.picture, SqlDbType.VarBinary));
     p.Add(new Param("@isActive", e.isActive, SqlDbType.Bit));
     p.Add(new Param("@skillGroupID", e.skillGroupID, SqlDbType.Int));
     p.Add(new Param("@genderID", e.genderID, SqlDbType.Int));
     p.Add(new Param("@ethnicityID", e.ethnicityID, SqlDbType.Int));
     p.Add(new Param("@lastUpdate", e.lastUpdateDate, SqlDbType.DateTime));
     p.Add(new Param("@lastUpdateUser", e.lastUpdateUser, SqlDbType.VarChar));
     return p;
 }
Exemple #14
0
        protected void btnCreateVenture_Click(object sender, EventArgs e)
        {
            lblEmailsMust.Visible   = false;
            lblRequired.Visible     = false;
            lblPicCheckSize.Visible = false;
            lblPicCheckType.Visible = false;
            string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName); //uploaded file extension
            int    iFileSize     = FileUpload1.PostedFile.ContentLength;               //uploaded file size
            int    count         = Convert.ToInt32(db.CheckIfVentureNameExists(txtVentureName.Text));

            if (valid.IsBlank(txtVentureName.Text) || valid.IsBlank(txtPrimaryContactEmail.Text) || valid.IsBlank(txtEmail.Text) || valid.IsBlank(txtDescription.Text))
            {
                lblRequired.Visible = true;
            }
            else if (count >= 1)
            {
                lblVentureNameCheck.Visible = true;
            }
            else if (FileUpload1.FileContent == null && FileUpload1.HasFile == false)
            {//no pic detected in control
            }
            else if (valid.TestForLegalImageTypes(fileExtension) == false)
            {//fail
                lblPicCheckType.Visible = true;
                lblPicCheckType.Text    = fileExtension + " file extension is not allowed. Please use .png, .gif, .jpg, .jpeg, .pdf, .pcd, .fpx, .tif instead";
            }
            else if (iFileSize >= 90000)
            {//fail
                lblPicCheckSize.Visible = true;
                lblPicCheckSize.Text    = "Your file size is " + iFileSize + " bytes. Please reduce the size to less than 90 KB (9000 bytes).";
            }
            else
            {
                MemoryStream ms  = new MemoryStream();
                var          img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                byte[] imageBytes = ms.ToArray();
                Session["venture-pic-upload"] = imageBytes;

                Venture venture = new Venture
                {
                    name                = txtVentureName.Text,
                    description         = txtDescription.Text,
                    aboutUs             = aboutUs.Text,
                    contactEmail        = txtEmail.Text,
                    contactPhoneNumber  = txtPhoneNumber.Text,
                    contactLinkedIn     = txtLinkedIn.Text,
                    Picture             = (byte[])Session["venture-pic-upload"],
                    primaryContactEmail = txtPrimaryContactEmail.Text,
                    isActive            = true,
                    lastUpdateDate      = DateTime.Now,
                    lastUpdateUser      = txtVentureName.Text
                };
                //create new venture

                int result = db.CreateVenture(venture);

                //add venture info to session
                int ventureID = Convert.ToInt32(db.GetVentureID(venture.name));
                sessionObj.storeVentureDataInSession(ventureID);

                //add current user as a venture member
                string   role             = "Founder";
                Expert   expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];
                string   lastUpdateUser   = expertProfileObj.lastName + ", " + expertProfileObj.firstName;
                DateTime lastUpdateDate   = DateTime.Now;
                string   TUID             = expertProfileObj.tuID;
                db.CreateVentureMember(TUID, ventureID, role, lastUpdateDate, lastUpdateUser);

                //redirect to venture page
                Response.Redirect("VenturePage.aspx?name=" + venture.name);
            }
        }
        protected void btnEditVenture_Click(object sender, EventArgs e)
        {
            lblPicCheckType.Visible = false;
            lblPicCheckSize.Visible = false;
            ventureObj                  = (Venture)Session["ventureObj"];
            lblRequired.Visible         = false;
            lblVentureNameCheck.Visible = false;
            int count = Convert.ToInt32(DbMethodsObj.CheckIfVentureNameExists(txtVentureName.Text));

            if (valid.IsBlank(txtVentureName.Text) || valid.IsBlank(txtPrimaryEmail.Text) || valid.IsBlank(txtEmail.Text) || valid.IsBlank(txtDescription.Text))
            {
                lblRequired.Visible = true;
            }
            else if (count >= 1 && txtVentureName.Text != ventureObj.name)
            {
                lblVentureNameCheck.Visible = true;
            }
            else
            {
                Venture v = new Venture();

                v.ventureID           = Convert.ToInt32(DbMethodsObj.GetVentureID(ventureObj.name));
                v.name                = txtVentureName.Text;
                v.description         = txtDescription.Text;
                v.aboutUs             = txtAboutUs.Text;
                v.contactEmail        = txtEmail.Text;
                v.contactPhoneNumber  = txtPhoneNumber.Text;
                v.contactLinkedIn     = txtLinkedIn.Text;
                v.primaryContactEmail = txtPrimaryEmail.Text;
                v.lastUpdateDate      = DateTime.Now;
                Expert expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];
                v.lastUpdateUser = expertProfileObj.lastName + ", " + expertProfileObj.firstName;

                if (FileUpload1.HasFile)
                {
                    string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName); //uploaded file extension
                    int    iFileSize     = FileUpload1.PostedFile.ContentLength;               //uploaded file size
                    if (valid.TestForLegalImageTypes(fileExtension) == false)
                    {                                                                          //fail
                        lblPicCheckType.Visible = true;
                        lblPicCheckType.Text    = fileExtension + " file extension is not allowed. Please use .png, .gif, .jpg, .jpeg, .pdf, .pcd, .fpx, .tif instead";
                    }
                    else if (iFileSize >= 90000)
                    {//fail
                        lblPicCheckSize.Visible = true;
                        lblPicCheckSize.Text    = "Your file size is " + iFileSize + " bytes. Please reduce the size to less than 90 KB (90000 bytes).";
                    }
                    else
                    {
                        MemoryStream ms  = new MemoryStream();
                        var          img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        v.Picture = ms.ToArray();
                        int result = DbMethodsObj.UpdateVenture(v);
                        Response.Redirect("VenturePage.aspx?name=" + ventureObj.name);
                    }
                }
                else
                {
                    v.Picture = ventureObj.Picture;
                    int result = DbMethodsObj.UpdateVenture(v);
                    Response.Redirect("VenturePage.aspx?name=" + ventureObj.name);
                }
            }
        }//end edit venture click event
Exemple #16
0
        protected void BtnSubmitNewSkill_Click(object sender, EventArgs e)
        {
            Expert tempExpert = new Expert {
                tuID = (string)Session["TU_ID"]
            };
            int test = 0;
            int result;

            if (string.IsNullOrWhiteSpace(txtAddNewSkill.Text) == false)
            {
                //search expert's skillset to see if the skill added already exsists
                //search all skill to see if the skill added exsists
                //if not to both, add a new skill
                foreach (Tuple <int, String> skill in tempExpert.AllExpertSkills)//test if skill added is already in Expert's Skill Set
                {
                    if (skill.Item2.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        test = -1;
                        break;
                    }
                }
                if (test != -1)
                {
                    List <Skills> allSkills = db.GetSkills();
                    foreach (Skills skill in allSkills)//handle adding the skill
                    {
                        if (skill.SkillName.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                        {
                            result = db.AddSkillToUser(tempExpert.tuID, skill.SkillID);//adding existing skill to expert
                            if (result != -1)
                            {
                                lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                                test = -2;
                                break;
                            }
                            else
                            {
                                lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                            }
                            break;
                        }
                    }
                    if (test != -2)
                    {
                        result = db.AddNewSkillToUser(tempExpert.tuID, txtAddNewSkill.Text);//adding brandnew skill
                        if (result != -1)
                        {
                            lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                        }
                        else
                        {
                            lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                        }
                    }
                    //sm.storeExpertDataInSession();//now get the whole expert object
                    gvDeleteSkills.DataSource = db.GetExpertsSkills(tempExpert.tuID);
                    gvDeleteSkills.DataBind();
                }
                else
                {
                    lblAddSkillTest.Text = "Cannot add this skill. you already have this skill in your skill set.";
                }
            }//end if statement for textBoxes
            else
            {
                lblAddSkillTest.Text = "Error: Invalid input.";
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            lblPicCheckType.Visible = false;
            lblPicCheckSize.Visible = false;
            byte[] imageBytes;
            Expert expertProfileObj = (Expert)Session["expertProfileObj"];
            string username = expertProfileObj.username;
            int count = Convert.ToInt32(DbMethods.CheckIfUsernameExists(txtUsername.Text));
            if (count >= 1 && txtUsername.Text != username)
            {
                lblUsernameCheck.Visible = true;
            }
            else if (vlad.IsBlank(txtFirstName.Text) || vlad.IsBlank(txtLastName.Text) || vlad.IsBlank(txtEmail.Text) || vlad.IsBlank(txtUsername.Text) || vlad.IsBlank(txtEmail.Text))
            {
                lblRequired.Visible = true;
            }
            else
            {
                string fileExtension = Path.GetExtension(fileNew1.PostedFile.FileName);//uploaded file extension
                int iFileSize = fileNew1.PostedFile.ContentLength;//uploaded file size
                
                if (fileNew1.FileContent != null && fileNew1.HasFile == true)
                {//if you have a file in the file upload control
                    if (vlad.TestForLegalImageTypes(fileExtension) == false)
                    {//fail
                        lblPicCheckType.Visible = true;
                        lblPicCheckType.Text = fileExtension + " file extension is not allowed. Please use .png, .gif, .jpg, .jpeg, .pdf, .pcd, .fpx, .tif instead";
                    }
                    else if(iFileSize >= 90000)
                    {//fail
                        lblPicCheckSize.Visible = true;
                        lblPicCheckSize.Text = "Your file size is "+ iFileSize+" bytes. Please reduce the size to less than 90 KB (90000 bytes).";
                    }
                    else
                    {
                        MemoryStream ms = new MemoryStream();
                        var img = System.Drawing.Image.FromStream(fileNew1.FileContent);
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        imageBytes = ms.ToArray();
                        Session.Add("picture", imageBytes);

                        Expert updatedExpert = new Expert
                        {
                            firstName = txtFirstName.Text,
                            lastName = txtLastName.Text,
                            username = txtUsername.Text,
                            email = txtEmail.Text,
                            phoneNumber = txtPhoneNumber.Text,
                            linkedIn = txtLinkedIn.Text,
                            aboutMe = aboutMe.Text,
                            picture = imageBytes,
                            skillGroupID = Convert.ToInt32(SkillGroupDropdown.SelectedItem.Value)
                        };
                        int x = DbMethods.UpdateExpert(updatedExpert, (string)Session["TU_ID"]);
                        sm.storeExpertDataInSession();
                        FillControls();
                        Response.Redirect("ExpertPage.aspx?username="******"TU_ID"]);
                    sm.storeExpertDataInSession();
                    FillControls();
                    Response.Redirect("ExpertPage.aspx?username=" + updatedExpert.username);
                }
            }
            
        }
Exemple #18
0
        protected void btnCreateProfile_Click(object sender, EventArgs e)
        {
            lblPicCheckSize.Visible = false;
            lblPicCheckType.Visible = false;
            int count = Convert.ToInt32(db.CheckIfUsernameExists(txtUsername.Text));

            if (valid.IsBlank(txtFirstName.Text) || valid.IsBlank(txtLastName.Text) || valid.IsBlank(txtEmail.Text) || valid.IsBlank(txtUsername.Text) || valid.IsBlank(txtEmail.Text))
            {
                lblRequired.Visible = true;
            }
            else if (count >= 1)
            {
                lblUsernameCheck.Visible = true;
            }
            else
            {
                string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName); //uploaded file extension
                int    iFileSize     = FileUpload1.PostedFile.ContentLength;               //uploaded file size
                if (FileUpload1.FileContent != null && FileUpload1.HasFile)
                {
                    if (valid.TestForLegalImageTypes(fileExtension) == false)
                    {//fail
                        lblPicCheckType.Visible = true;
                        lblPicCheckType.Text    = fileExtension + " file extension is not allowed. Please use .png, .gif, .jpg, .jpeg, .pdf, .pcd, .fpx, .tif instead";
                    }
                    else if (iFileSize >= 90000)
                    {//fail
                        lblPicCheckSize.Visible = true;
                        lblPicCheckSize.Text    = "Your file size is " + iFileSize + " bytes. Please reduce the size to less than 90 KB (90000 bytes).";
                    }
                    else
                    {
                        MemoryStream ms  = new MemoryStream();
                        var          img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        imageBytes = ms.ToArray();
                        Session.Add("picture", imageBytes);
                    }
                }
                else
                {
                    string     FilePath = System.Web.VirtualPathUtility.ToAbsolute("~/Images/TUOwls_logo.png");
                    FileStream fs       = new FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    imageBytes = new byte[fs.Length];
                    fs.Read(imageBytes, 0, Convert.ToInt32(fs.Length));
                    fs.Close();
                    MemoryStream ms = new MemoryStream();
                    Session.Add("picture", imageBytes);
                }

                Expert newExpert = new Expert
                {
                    tuID           = (string)Session["TU_ID"],
                    username       = txtUsername.Text,
                    firstName      = txtFirstName.Text,
                    lastName       = txtLastName.Text,
                    college        = (string)Session["School"],
                    major          = (string)Session["Major_1"],
                    email          = txtEmail.Text,
                    dateJoined     = DateTime.Now,
                    phoneNumber    = txtPhoneNumber.Text,
                    aboutMe        = aboutMe.Text,
                    linkedIn       = txtLinkedIn.Text,
                    picture        = (byte[])Session["picture"],
                    isActive       = true,
                    skillGroupID   = Int32.Parse(SkillGroupDropdown.SelectedValue),
                    genderID       = Int32.Parse(genderDropdown.SelectedValue),
                    ethnicityID    = Int32.Parse(ethnicityDropdown.SelectedValue),
                    lastUpdateDate = DateTime.Now,
                    lastUpdateUser = txtLastName.Text + ", " + txtFirstName.Text
                };

                DbMethods      dbmethods         = new DbMethods();
                SessionMethods sessionMethodsObj = new SessionMethods();
                int            result            = dbmethods.CreateExpert(newExpert);

                sessionMethodsObj.storeExpertDataInSession();
                Response.Redirect("ExpertPage.aspx?username=" + newExpert.username);
                //Response.Write(result);
            }
        }
Exemple #19
0
        protected void btn_login_Click(object sender, EventArgs e)
        {
            /*1 - Grabbing the user's login info*/
            String Username = txb_TUID.Text;
            String Password = txb_Password.Text;

            /*2 - Resetting controls to default values*/
            lbl_Error.Text = "";

            /*3 - Basic validation*/
            if (Username.Equals(""))
            {
                lbl_Error.Text      = "ERROR: The username field is empty.";
                lbl_Error.ForeColor = Color.Red;
            }
            else if (Password.Equals(""))
            {
                lbl_Error.Text      = "ERROR: The password field is empty.";
                lbl_Error.ForeColor = Color.Red;
            }
            else if (valid.validateLogin(Username) || valid.validateLogin(Password))
            {
                lbl_Error.Text      = "ERROR: Illegal input character was used.";
                lbl_Error.ForeColor = Color.Red;
            }
            else
            {
                /*3 - Checking that the Username and Password are both correct*/
                bool Correct_Login_Information = AuthenticateUser(Username, Password);
                if (!Correct_Login_Information)
                {
                    lbl_Error.Text      = "ERROR: Your username or password is incorrect.";
                    lbl_Error.ForeColor = Color.Red;
                }
                else
                {
                    /*4 - Requesting Web Service information*/
                    TempleUser.LDAPuser   Temple_Information  = TempleUser.WebService.getLDAPEntryByAccessnet(Username);
                    TempleUser.StudentObj Student_Information = TempleUser.WebService.getStudentInfo(Temple_Information.templeEduID);

                    /*5 - Checking we received something from Web Services*/
                    if (Temple_Information == null)
                    {
                        lbl_Error.Text = "ERROR: Web Services did not return anything.";
                    }
                    else if (Temple_Information != null)
                    {
                        /*Populating the Session Object with the user's information*/
                        Session["TU_ID"]                 = Temple_Information.templeEduID;//TUID
                        Session["First_Name"]            = Temple_Information.givenName;
                        Session["Last_Name"]             = Temple_Information.sn;
                        Session["Email"]                 = Temple_Information.mail;
                        Session["Title"]                 = Temple_Information.title;
                        Session["Affiliation_Primary"]   = Temple_Information.eduPersonPrimaryAffiliation;
                        Session["Affiliation_Secondary"] = Temple_Information.eduPersonAffiliation;

                        /*Security Session Variable*/
                        Session["Authenticated"] = true;


                        /*If the user is also a student, we can also retreive their information and add them to the Session Object*/
                        if (Student_Information != null)
                        {
                            Session["School"]  = Student_Information.school;
                            Session["Major_1"] = Student_Information.major1;
                            Session["Major_2"] = Student_Information.major2;
                        }

                        /*Successful Login - Allowed to be redirected to Home.aspx*/

                        DbMethods DbMethodsObj = new DbMethods();
                        bool      test         = DbMethodsObj.CheckIfAdminExists(Student_Information.tuid);
                        //check if user is an Admin
                        if (test == true)
                        {
                            //Security Session Variable for Admin
                            Session["AdminToken"] = true;
                            Response.Redirect("Admin.aspx");
                        }
                        else
                        {
                            //check if expert exists in system
                            int count = Convert.ToInt32(DbMethodsObj.CheckIfExpertExists(Student_Information.tuid));
                            if (count == 0)
                            {
                                Response.Redirect("CreateProfile.aspx");
                            }
                            else
                            {
                                SessionMethods sessionMethodsObj = new SessionMethods();
                                sessionMethodsObj.storeExpertDataInSession();
                                //change isActive to true
                                DbMethodsObj.SetExpertIsActiveTrue();
                                Expert expertProfileObj = (CapstoneBlackstone.Expert)Session["expertProfileObj"];
                                string user_name        = expertProfileObj.username;

                                var x = Session["Authenticated"];
                                //redirect to expert page
                                Response.Redirect("ExpertPage.aspx?username=" + user_name);// conserve the session token at login
                            }
                        }
                    }
                }
            }
        }//end logIn button clickEvent
Exemple #20
0
        }//end page load

        // Fill page controls with updated information
        public void FillControls()
        {
            if (expertObj != null)
            {
                if (expertObj.picture != null)
                {
                    imgProfilePic.ImageUrl = d.ConvertToImage(expertObj.picture);//returns string url 
                }
                else
                {//in case expert's profile pic is null
                    imgProfilePic.ImageUrl = "Images/TUOwls_logo.png";
                }
                if (studentObj.tuid != (string)Session["TU_ID"])
                {
                    Expert e = sm.getAllTheExpertInfo(studentObj.tuid);
                    h2Name.InnerText = e.firstName + " " + e.lastName;
                    h3SkillGroup.InnerText = e.SkillGroupName;
                    spCollege.InnerText = e.college;
                    spMajor.InnerText = e.major;
                    spEmail.InnerText = e.email;
                    spPhone.InnerText = e.phoneNumber;
                    spLinkedIn.InnerText = e.linkedIn;
                    pAboutMe.InnerText = e.aboutMe;

                    if (e.roleVentureNameList.Count == 0)
                    {
                        this.rptVentureNames.DataSource = null;
                        this.rptVentureNames.DataBind();
                    }
                    else
                    {
                        this.rptVentureNames.DataSource = e.roleVentureNameList;
                        this.rptVentureNames.DataBind();
                    }

                    if (e.AllExpertSkills.Count == 0)
                    {
                        this.rptExpertSkills.DataSource = null;
                        this.rptExpertSkills.DataBind();
                    }
                    else
                    {
                        this.rptExpertSkills.DataSource = e.AllExpertSkills;
                        this.rptExpertSkills.DataBind();
                    }
                }
                else
                {
                    h2Name.InnerText = expertObj.firstName + " " + expertObj.lastName;
                    h3SkillGroup.InnerText = expertObj.SkillGroupName;
                    spCollege.InnerText = expertObj.college;
                    spMajor.InnerText = expertObj.major;
                    spEmail.InnerText = expertObj.email;
                    spPhone.InnerText = expertObj.phoneNumber;
                    spLinkedIn.InnerText = expertObj.linkedIn;
                    pAboutMe.InnerText = expertObj.aboutMe;

                    if (expertObj.roleVentureNameList.Count == 0)
                    {
                        this.rptVentureNames.DataSource = null;
                        this.rptVentureNames.DataBind();
                    }
                    else
                    {
                        this.rptVentureNames.DataSource = expertObj.roleVentureNameList;
                        this.rptVentureNames.DataBind();
                    }

                    if (expertObj.AllExpertSkills.Count == 0)
                    {
                        this.rptExpertSkills.DataSource = null;
                        this.rptExpertSkills.DataBind();
                    }
                    else
                    {
                        this.rptExpertSkills.DataSource = expertObj.AllExpertSkills;
                        this.rptExpertSkills.DataBind();
                    }
                }
            }//end fill controls
        }