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(); } }
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 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); } }