protected void Button1_Click(object sender, EventArgs e) { bool redir = true; if (FileUpload1.PostedFile.ContentLength <= 5 * 1024 * 1024 && FileUpload1.PostedFile.ContentLength > 0) { //System.Drawing.Image newbrokerimage = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream); //newbrokerimage.Save( Server.MapPath("~/BrokerImages/") + Session["BrokerID"] + ".png", System.Drawing.Imaging.ImageFormat.Png); byte[] bytes = FileUpload1.FileBytes; bytes = imageResize.ResizeFromByteArray(150, bytes, "test"); System.Data.Linq.Binary image = new System.Data.Linq.Binary(bytes); ElectronicAppStorageDBDataContext eappstor = new ElectronicAppStorageDBDataContext(); eappstor.uspDeleteBrokerImageByOwnerID((Guid)(Session["BrokerID"])); String filename = FileUpload1.FileName; String ext = filename.Substring(filename.LastIndexOf('.') + 1); filename = filename.Substring(0, filename.LastIndexOf('.')); eappstor.uspInsertBrokerImage(System.Guid.NewGuid(), (Guid)(Session["BrokerID"]), image, filename, ext); } else if (FileUpload1.PostedFile.ContentLength > 0) { redir = false; lblMessage.Text = "File must be less than 5MB in size."; lblMessage.Visible = true; } ElectronicAppDBDataContext ElectronicAppDB = new ElectronicAppDBDataContext(); ElectronicAppDB.uspAlterBrokerInfo((Guid)Session["BrokerID"], BrokerFirstName.Text, BrokerLastName.Text, BrokerEmail.Text, BrokerPhone.Text, BrokerFax.Text, BrokerAddress.Text, BrokerCity.Text, BrokerState.Text, BrokerZip.Text); if (redir) { Response.Redirect("Welcome.aspx", false); } }
protected void Button1_Click(object sender, EventArgs e) { bool redir = true; if (FileUpload1.PostedFile.ContentLength <= 5 * 1024 * 1024 && FileUpload1.PostedFile.ContentLength > 0) { //System.Drawing.Image newbrokerimage = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream); //newbrokerimage.Save( Server.MapPath("~/BrokerImages/") + Session["BrokerID"] + ".png", System.Drawing.Imaging.ImageFormat.Png); byte[] bytes = FileUpload1.FileBytes; bytes = imageResize.ResizeFromByteArray( 150, bytes, "test"); System.Data.Linq.Binary image = new System.Data.Linq.Binary(bytes); ElectronicAppStorageDBDataContext eappstor = new ElectronicAppStorageDBDataContext(); eappstor.uspDeleteBrokerImageByOwnerID((Guid)(Session["BrokerID"])); String filename = FileUpload1.FileName; String ext = filename.Substring( filename.LastIndexOf('.') + 1 ); filename = filename.Substring( 0, filename.LastIndexOf('.')); eappstor.uspInsertBrokerImage(System.Guid.NewGuid(), (Guid)(Session["BrokerID"]), image, filename, ext); } else if (FileUpload1.PostedFile.ContentLength > 0) { redir = false; lblMessage.Text = "File must be less than 5MB in size."; lblMessage.Visible = true; } ElectronicAppDBDataContext ElectronicAppDB = new ElectronicAppDBDataContext(); ElectronicAppDB.uspAlterBrokerInfo( (Guid)Session["BrokerID"], BrokerFirstName.Text, BrokerLastName.Text, BrokerEmail.Text, BrokerPhone.Text, BrokerFax.Text, BrokerAddress.Text, BrokerCity.Text, BrokerState.Text, BrokerZip.Text); if (redir) { Response.Redirect("Welcome.aspx", false); } }