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