public Venture GetVenture(int ventureId) { Venture v = new Venture(); DBConnect objdb = new DBConnect(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "GetVentureById"; objCommand.Parameters.Clear(); SqlParameter inputParameter = new SqlParameter("@ventureId", ventureId); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.Int; objCommand.Parameters.Add(inputParameter); DataSet results = objdb.GetDataSetUsingCmdObj(objCommand); v.ventureID = (int) results.Tables[0].Rows[0][0]; v.name = (string) results.Tables[0].Rows[0][1]; v.description = (string) results.Tables[0].Rows[0][2]; v.aboutUs = (string) results.Tables[0].Rows[0][3]; v.contactEmail = (string) results.Tables[0].Rows[0][4]; v.contactPhoneNumber = (string) results.Tables[0].Rows[0][5]; v.contactLinkedIn = (string) results.Tables[0].Rows[0][6]; v.Picture = (byte[]) results.Tables[0].Rows[0][7]; v.primaryContactEmail = (string) results.Tables[0].Rows[0][8]; v.isActive = (bool) results.Tables[0].Rows[0][9]; v.lastUpdateDate = (DateTime) results.Tables[0].Rows[0][10]; v.lastUpdateUser = (string) results.Tables[0].Rows[0][11]; return v; }
protected void gvDeleteSkills_RowCommand(object sender, GridViewCommandEventArgs e) { ventureObj = (Venture)Session["ventureObj"]; if (e.CommandName == "gvCommandDelete") { 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 ventureObj.AllVentureSkills) { if (skill.Item2.Equals(s, StringComparison.OrdinalIgnoreCase)) { count++;//found something int result = DbMethodsObj.DeleteVentureSkill(ventureObj.ventureID, skill.Item1); if (result != -1) { lblGvDeleteTest.Text = "Skill has been deleted."; } 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 sm.storeVentureDataInSession(ventureObj.ventureID);//now get the whole expert object ventureObj = (Venture)Session["ventureObj"]; FillControls(); }//end click event
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(); } }
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 } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Authenticated"] == null) { Response.Redirect("default.aspx"); } else if (!IsPostBack) { string ventureName = Session["currentVentureName"].ToString(); int ventureID = Convert.ToInt32(DbMethodsObj.GetVentureID(ventureName)); sm.storeVentureDataInSession(ventureID); ventureObj = (Venture)Session["ventureObj"]; FillControls(); } }
private List<Param> BuildUpdateVentureParams(Venture v) { List<Param> p = new List<Param>(); p.Add(new Param("@Name", v.name, SqlDbType.VarChar)); p.Add(new Param("@Description", v.description, SqlDbType.VarChar)); p.Add(new Param("@AboutUs", v.aboutUs, SqlDbType.VarChar)); p.Add(new Param("@ContactEmail", v.contactEmail, SqlDbType.VarChar)); p.Add(new Param("@ContactPhoneNumber", v.contactPhoneNumber, SqlDbType.VarChar)); p.Add(new Param("@ContactLinkedIn", v.contactLinkedIn, SqlDbType.VarChar)); p.Add(new Param("@PrimaryContactEmail", v.primaryContactEmail, SqlDbType.VarChar)); p.Add(new Param("@LastUpdateDate", v.lastUpdateDate, SqlDbType.DateTime)); p.Add(new Param("@LastUpdateUser", v.lastUpdateUser, SqlDbType.VarChar)); p.Add(new Param("@VentureID", v.ventureID, SqlDbType.Int)); p.Add(new Param("@Picture", v.Picture, SqlDbType.VarBinary)); 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 btnRemoveStaticMember_Click(object sender, EventArgs e) { ventureObj = (Venture)Session["ventureObj"]; for (int row = 0; row < gvStaticMembers.Rows.Count; row++) { CheckBox CBox; CBox = (CheckBox)gvStaticMembers.Rows[row].FindControl("chkSelect"); if (CBox.Checked) { int staticMemberID = Convert.ToInt32(gvStaticMembers.DataKeys[row].Values[0]); DbMethodsObj.DeactivateStaticMemberByID(staticMemberID); } } sm.storeVentureDataInSession(ventureObj.ventureID); ventureObj = (Venture)Session["ventureObj"]; FillControls(); }
protected void btnRemoveExpert_Click(object sender, EventArgs e) { ventureObj = (Venture)Session["ventureObj"]; for (int row = 0; row < gvVentureMembers.Rows.Count; row++) { CheckBox CBox; CBox = (CheckBox)gvVentureMembers.Rows[row].FindControl("chkSelect"); if (CBox.Checked) { string tuid = DbMethodsObj.GetTUIDByUsername(gvVentureMembers.Rows[row].Cells[1].Text); DbMethodsObj.DeactivateVentureMember(ventureObj.ventureID, tuid); } } sm.storeVentureDataInSession(ventureObj.ventureID); ventureObj = (Venture)Session["ventureObj"]; FillControls(); }
}//end btnSearchExperts_Click public List <ExpertSearchObj> getVentureSkillDuplicatesAndData(List <ExpertSearchObj> expertSkillSearch) { List <ExpertSearchObj> distinctVentureIds = new List <ExpertSearchObj>(); //distinct ventures with all their skills var temp = expertSkillSearch.Select(o => o.VentureID).Distinct(); //get all unique tuids foreach (var i in temp) {//add unique tuids to a new list distinctVentureIds.Add(new ExpertSearchObj { VentureID = i }); //only contains venture names } foreach (ExpertSearchObj dvid in distinctVentureIds) { //get all duplicates on put them into distinct objects var newList = (from n in expertSkillSearch where n.VentureID == dvid.VentureID select new { n.SkillName, n.VentureID, n.Name, n.Picture }).Distinct(); //get all data //add venture data to each object Venture currentVenture = DbMethods.GetVenture(dvid.VentureID);//get that venture's data and load that into it's object dvid.VentureID = currentVenture.ventureID; dvid.Name = currentVenture.name; dvid.VentureDesc = currentVenture.description; if (currentVenture.Picture != null) { dvid.image = d.ConvertToImage((byte[])currentVenture.Picture);//returns string url } else {//in case expert's profile pic is null byte[] imageBytes; MemoryStream ms = new MemoryStream(); System.Drawing.Image img = System.Drawing.Image.FromFile("Images/TUOwls_logo.png"); img.Save(ms, System.Drawing.Imaging.ImageFormat.Png); imageBytes = ms.ToArray(); dvid.image = d.ConvertToImage(imageBytes); } //dvid.SkillName = currentVenture.skillName; foreach (var j in newList) { //add all skillNames associated with the distinct tuid into its SkillName list in VentureSearch obj dvid.AllVentureSkills.Add(j.ToString()); } }//end getting distinct ventures and adding data return(distinctVentureIds); }
public int UpdateVenture(Venture v) { DBConnect objDB = new DBConnect(); objCommand.CommandType = System.Data.CommandType.StoredProcedure; objCommand.CommandText = "UpdateVenture"; objCommand.Parameters.Clear(); List<Param> p = BuildUpdateVentureParams(v); 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 results = objDB.DoUpdateUsingCmdObj(objCommand); return results; }
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
protected void BtnSubmitNewSkill_Click(object sender, EventArgs e) { Debug.WriteLine("Entering BtnSubmitNewSkill_Click"); ventureObj = (Venture)Session["ventureObj"]; 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 ventureObj.AllVentureSkills)//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 = DbMethodsObj.GetSkills(); foreach (Skills skill in allSkills)//handle adding the skill { if (skill.SkillName.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase)) { result = DbMethodsObj.AddSkillToVenture(ventureObj.ventureID, 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 = DbMethodsObj.AddNewSkillToVenture(ventureObj.ventureID, txtAddNewSkill.Text);//adding brandnew skill if (result != -1) { lblAddSkillTest.Text = "Success! A New Skill was added to the Ventures wanted Skills."; } else { lblAddSkillTest.Text = "Error: Process did not execute successfully. :("; } } sm.storeVentureDataInSession(ventureObj.ventureID);//now get the whole expert object ventureObj = (Venture)Session["ventureObj"]; 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."; } }