Beispiel #1
0
        protected override int SaveItem()
        {
            int suspectId = GetId();

            d.Suspect suspect = new d.Suspect(suspectId);
            suspect.Number        = tbxNumber.Text.Trim();
            suspect.Description   = tbxDescription.Text.Trim();
            suspect.Gender        = ddlGender.SelectedValue;
            suspect.RaceId        = Convert.ToInt32(ddlRace.SelectedValue);
            suspect.HairColorId   = Convert.ToInt32(ddlHairColor.SelectedValue);
            suspect.AgeRangeId    = Convert.ToInt32(ddlAgeRange.SelectedValue);
            suspect.WeightRangeId = Convert.ToInt32(ddlWeightRange.SelectedValue);
            suspect.ModifiedBy    = Identity.UserId;

            if (suspect.Update() < 0)
            {
                valUnique.IsValid = false;
                return(0);
            }

            if (tbxFile.PostedFile.ContentLength > 0)
            {
                FileInfo fi = new FileInfo(tbxFile.PostedFile.FileName);
                if (!b.ImageHelper.IsImage(fi.Extension))
                {
                    valFileType.IsValid = false;
                    return(0);
                }
                else
                {
                    double ratio = b.ImageHelper.DIMENSIONS_RATIO;

                    int    sWidth  = b.ImageHelper.SMALL_PHOTO_WIDTH;
                    int    sHeight = (int)(sWidth / ratio);
                    string sPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.SMALL_PHOTO_SUFFIX));

                    int    mWidth  = b.ImageHelper.MEDIUM_PHOTO_WIDTH;
                    int    mHeight = (int)(mWidth / ratio);
                    string mPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.MEDIUM_PHOTO_SUFFIX));

                    int    lWidth  = b.ImageHelper.LARGE_PHOTO_WIDTH;
                    int    lHeight = (int)(lWidth / ratio);
                    string lPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.LARGE_PHOTO_SUFFIX));

                    b.ImageHelper iHelper = new b.ImageHelper();
                    iHelper.MakeImage(tbxFile.PostedFile, sPath, sWidth, sHeight, ratio);
                    iHelper.MakeImage(tbxFile.PostedFile, mPath, mWidth, mHeight, ratio);
                    iHelper.MakeImage(tbxFile.PostedFile, lPath, lWidth, lHeight, ratio);
                }
            }
            return(1);
        }
Beispiel #2
0
        protected override int SaveItem()
        {
            string number        = tbxNumber.Text.Trim();
            string description   = tbxDescription.Text.Trim();
            string gender        = ddlGender.SelectedValue;
            int    raceId        = Convert.ToInt32(ddlRace.SelectedValue);
            int    hairColorId   = Convert.ToInt32(ddlHairColor.SelectedValue);
            int    ageRangeId    = Convert.ToInt32(ddlAgeRange.SelectedValue);
            int    weightRangeId = Convert.ToInt32(ddlWeightRange.SelectedValue);

            int suspectId = new d.SuspectData().Create(
                number, description, gender, raceId, hairColorId, ageRangeId, weightRangeId, Identity.UserId);

            if (suspectId < 0)
            {
                valUnique.IsValid = false;
                return(0);
            }
            else
            {
                FileInfo fi = new FileInfo(tbxFile.PostedFile.FileName);
                if (!b.ImageHelper.IsImage(fi.Extension))
                {
                    valFileType.IsValid = false;
                    return(0);
                }

                double ratio = b.ImageHelper.DIMENSIONS_RATIO;

                int    sWidth  = b.ImageHelper.SMALL_PHOTO_WIDTH;
                int    sHeight = (int)(sWidth / ratio);
                string sPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.SMALL_PHOTO_SUFFIX));

                int    mWidth  = b.ImageHelper.MEDIUM_PHOTO_WIDTH;
                int    mHeight = (int)(mWidth / ratio);
                string mPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.MEDIUM_PHOTO_SUFFIX));

                int    lWidth  = b.ImageHelper.LARGE_PHOTO_WIDTH;
                int    lHeight = (int)(lWidth / ratio);
                string lPath   = Server.MapPath(b.UrlHelper.GetSuspectImageUrl(suspectId, b.ImageHelper.LARGE_PHOTO_SUFFIX));

                b.ImageHelper iHelper = new b.ImageHelper();
                iHelper.MakeImage(tbxFile.PostedFile, sPath, sWidth, sHeight, ratio);
                iHelper.MakeImage(tbxFile.PostedFile, mPath, mWidth, mHeight, ratio);
                iHelper.MakeImage(tbxFile.PostedFile, lPath, lWidth, lHeight, ratio);
            }
            return(1);
        }
Beispiel #3
0
        private void makeImages(int photoId, string sourcePath)
        {
            double ratio = b.ImageHelper.DIMENSIONS_RATIO;

            int    sWidth  = b.ImageHelper.SMALL_PHOTO_WIDTH;
            int    sHeight = (int)(sWidth / ratio);
            string sPath   = b.ImageHelper.PHOTOS_PATH + photoId + b.ImageHelper.SMALL_PHOTO_SUFFIX + ".jpg";

            int    mWidth  = b.ImageHelper.MEDIUM_PHOTO_WIDTH;
            int    mHeight = (int)(mWidth / ratio);
            string mPath   = b.ImageHelper.PHOTOS_PATH + photoId + b.ImageHelper.MEDIUM_PHOTO_SUFFIX + ".jpg";

            int    lWidth  = b.ImageHelper.LARGE_PHOTO_WIDTH;
            int    lHeight = (int)(lWidth / ratio);
            string lPath   = b.ImageHelper.PHOTOS_PATH + photoId + b.ImageHelper.LARGE_PHOTO_SUFFIX + ".jpg";

            b.ImageHelper iHelper = new b.ImageHelper();
            iHelper.MakeImage(sourcePath, sPath, sWidth, sHeight, ratio);
            iHelper.MakeImage(sourcePath, mPath, mWidth, mHeight, ratio);
            iHelper.MakeImage(sourcePath, lPath, lWidth, lHeight, ratio);
        }