예제 #1
0
        }//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();
                }
            }
        }
예제 #2
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);
            }
        }