예제 #1
0
        public void ProcessRequest(HttpContext context)
        {
            pictureTableAdapter pictureAdapter = new pictureTableAdapter();
            DataTable dtPictures = new DataTable();
            dtPictures = pictureAdapter.GetImageByID(int.Parse(context.Request.QueryString["imgid"]));

            context.Response.ContentType = dtPictures.Rows[0]["contentType"].ToString();
            context.Response.BinaryWrite((byte[])(dtPictures.Rows[0]["image"]));
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid currentUserID = Guid.Parse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
            int whiskyID = int.Parse(Request.QueryString["id"]);

            freundeTableAdapter freundeTable = new freundeTableAdapter();
            pictureTableAdapter pictureTable = new pictureTableAdapter();

            DataTable uploadedImages = pictureTable.GetImageByUserAndWhisky(currentUserID,int.Parse(Request.QueryString["id"]));

            if (uploadedImages.Rows.Count > 0)
                panUpload.Visible = false;

            DataTable freePictures = new DataTable();
            DataTable freunde = freundeTable.GetFriendsByUserID(currentUserID);
            DataTable allPictures = pictureTable.GetImagesByWhisky(whiskyID);

            if (freunde.Rows.Count == 0 || allPictures.Rows.Count == 0)
                return;

            // Die veroeffentlichten Bilder der freunde herraussuchen bzw. mit freigabe fuer alle User
            foreach (DataRow picture in allPictures.Rows)
            {
                foreach (DataRow friend in freunde.Rows)
                {
                    if ( picture["userID"] == friend["freundID"] &&  ( (int.Parse(picture["allowFriends"].ToString()) == 1 ) || (int.Parse(picture["allowAll"].ToString()) == 1) ) )
                        freePictures.Rows.Add(picture);
                }
            }

            //Falls noch Bilder anzuzeigen sind...
            if (freePictures.Rows.Count == 0)
            {
                Label noSee = new Label();
                noSee.Text = "Hier gibt es nichts zu sehen!";
                panImages.Controls.Add(noSee);
                return;
            }

            //Image-Buttons erstellen
            foreach (DataRow picture in freePictures.Rows)
            {
                Panel imgPanel = new Panel();
                imgPanel.CssClass = "imgpanel";
                ImageButton imgBtnControl = new ImageButton();
                imgBtnControl.CssClass = "select";
                imgBtnControl.ImageUrl = "ImageHandler.ashx?imgid=" + picture["id"];
                imgBtnControl.ImageAlign = ImageAlign.Middle;
                imgBtnControl.ID = picture["id"].ToString();
                imgBtnControl.Click += new ImageClickEventHandler(selectImage_Click);
                imgPanel.Controls.Add(imgBtnControl);

                panImages.Controls.Add(imgPanel);
            }
        }
예제 #3
0
 protected void btnUploadImage_Click(object sender, EventArgs e)
 {
     pictureTableAdapter pictureTable = new pictureTableAdapter();
     userwhiskyTableAdapter userwhiskyTable = new userwhiskyTableAdapter();
     Guid currentUserID = Guid.Parse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
     if (fuImageUpload.PostedFile != null &&
         fuImageUpload.FileName != "")
     {
         HttpPostedFile imageFile = fuImageUpload.PostedFile;
         byte[] imageData = new byte[imageFile.ContentLength];
         imageFile.InputStream.Read(imageData, 0, imageFile.ContentLength);
         pictureTable.Insert(
             currentUserID,
             int.Parse(this.Request.QueryString["id"]),
             radioFriendsOnly.Checked,
             radioAllowAll.Checked,
             imageData,
             imageFile.ContentType);
         DataTable pictures = pictureTable.GetImageByUserAndWhisky(currentUserID, int.Parse(this.Request.QueryString["id"]));
         userwhiskyTable.UpdatePicture(int.Parse(pictures.Rows[0]["id"].ToString()),currentUserID,int.Parse(this.Request.QueryString["id"]));
     }
 }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["action"]) && Request.QueryString["action"].Equals("new"))
                fvWhisky.ChangeMode(FormViewMode.Insert);

            if (fvWhisky.CurrentMode == FormViewMode.ReadOnly)
            {
                imgWhisky.Visible = false;
                if (!Request.IsAuthenticated)
                {
                    fvWhisky.FindControl("imgBtnEdit").Visible = false;
                    fvWhisky.FindControl("imgBtnDelete").Visible = false;
                    fvWhisky.FindControl("imgBtnNew").Visible = false;
                    fvWhisky.FindControl("imgBtnImages").Visible = false;
                    fvWhisky.FindControl("imgBtnAddTasting").Visible = false;
                    return;
                }

                if (!System.Web.Security.Roles.IsUserInRole("Administratoren"))
                {
                    fvWhisky.FindControl("imgBtnEdit").Visible = false;
                    fvWhisky.FindControl("imgBtnDelete").Visible = false;
                    fvWhisky.FindControl("rowAktiv").Visible = false;
                }

                Guid currentUserID = Guid.Parse(System.Web.Security.Membership.GetUser().ProviderUserKey.ToString());
                pictureTableAdapter pictureTable = new pictureTableAdapter();
                DataTable pictures = pictureTable.GetImageForWhisky(currentUserID, int.Parse(Request.QueryString["id"]));

                if (pictures.Rows.Count > 0)
                {
                    imgWhisky.ImageUrl = "ImageHandler.ashx?imgid=" + pictures.Rows[0]["id"];
                    imgWhisky.Visible = true;
                }
            }
        }