示例#1
0
/**
 * Display the data collected from the (previous) post_item page.  The data now resides in a general entry item object
 * Show the general info then display the specifics
 */
        private void BindData(classes.Coupon bItem)
        {
            hdnUserDir.Value = Session["userDir"].ToString();

            //show today's date
            if (bItem.Expired != DateTime.MinValue)
            {
                lblDateData.Text = "Exp: " + String.Format("{0:MM/dd/yyyy}", bItem.Expired);
            }

            lblDetailsData.Text = Global.ReplaceEx(bItem.Details, "''", "'"); //details
            lblTitle.Text       = bItem.Title;                                //title

            //TODO
            //lblCouponCode = bItem.CCode;

            //ShowPic
            hdnProcPics.Value = "0";
            if (bItem.UseDefaultImg)
            {
                Pic1.ImageUrl = "../images/CouponDefault.gif";
            }
            else
            {
                hdnProcPics.Value = "1";
                Pic1.ImageUrl     = GetPicPath(bItem.ImgPath1, bItem.UseTempDir);
            }
        }
示例#2
0
/*
 */
        public void btnUpdate_Click(object sender, EventArgs e)
        {
            if (btnUpdate.Text == "Add Coupon")
            {
                Response.Redirect("post.aspx", true);
            }

            try
            {
                classes.Coupon oQP = new classes.Coupon();

                if (dlEntryList.Items.Count > 0)
                {
                    foreach (DataListItem item in dlEntryList.Items)
                    {
                        CheckBox    pubChkBox = item.FindControl("chkPublish") as CheckBox;
                        HiddenField hdnVal    = item.FindControl("hdnItemVal") as HiddenField;
                        oQP.PublishUpdate(hdnVal.Value, pubChkBox.Checked);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLog.ErrorRoutine(false, "Error publishing model: " + ex.Message);
            }

            finally { }

            this.FillCouponMgr();
        }
示例#3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Global.AuthenticateUser();

            classes.Coupon cItem = (classes.Coupon)Session["cItem"];

            if (cItem == null)
            {
                HandleError();
                return;
            }

            if (!Page.IsPostBack)
            {
                // Put user code to initialize the page here
                lnkSignIn.Text = Global.SetLnkSignIn( );
                lnkSignUp.Text = Global.SetLnkSignUp( );

                //Load up display data and show a preview of the posting
                BindData(cItem);

                ErrorLog.ErrorRoutine(false, "cItem.Status: " + cItem.Status);

                SetUI(cItem.Status);
            }
        }
示例#4
0
文件: Post.aspx.cs 项目: vizualz/BH3
/*
 */
        public void BindData(classes.Coupon cI)
        {
            //sets the dynamic UI up according to category
            //FillDropDowns();

            //TODO: SetupUI();
        }
示例#5
0
/*
 * */
        private void StepBackEdit()
        {
            classes.Coupon oItem = (classes.Coupon)Session["cItem"];
            oItem.EditMode  = 1;            //Set Edit flag
            Session["Item"] = oItem;
            oItem           = null;
            Response.Redirect("Post.aspx", true);
        }
示例#6
0
文件: Post.aspx.cs 项目: vizualz/BH3
        protected void Page_Load(object sender, System.EventArgs e)
        {
            //if 1st coupon then redirect to get footer settings
            if (!CheckForFooterSettings())
            {
                Response.Redirect("Settings.aspx?r=1", true);
            }

            lnkSignIn.Text = Global.SetLnkSignIn( );
            lnkSignUp.Text = Global.SetLnkSignUp( );

            SetUI();

            if (!Page.IsPostBack)
            {
                //authenticate
                Global.AuthenticateUser();

                BindControls();

                //check for edits from manager
                string[] arrStr;
                arrStr = Request.QueryString.GetValues("q");
                if (arrStr != null)
                {
                    hdnBackToMgr.Value = "1";
                    LoadForEdits(arrStr[0]);
                    return;
                }

                //check for edits from preview
                if (Session["cItem"] != null)
                {
                    classes.Coupon cpItem = new classes.Coupon();
                    cpItem = (classes.Coupon)Session["cItem"];
                    if (cpItem.EditMode == 1)
                    {
                        LoadForEdits(cpItem);
                    }
                }
                else
                {
                    InitImgMgr();
                }
            }
        }
示例#7
0
文件: Post.aspx.cs 项目: vizualz/BH3
/*
 * TODO: Still need to code for all cats and adtypes
 */
        private bool LoadForEdits(classes.Coupon cItm)
        {
            txtDetails.Text = cItm.Details;
            txtTitle.Text   = cItm.Title;
            txtCode.Text    = cItm.CCode;
            if (cItm.Expired != null)
            {
                if (cItm.Expired != DateTime.MinValue)
                {
                    txtDate.Text = cItm.Expired.ToString();
                }
            }
            cboCategory.SelectedValue = cItm.Category.ToString();

            img1.ImageUrl = "../images/s1x1.gif";
            img2.ImageUrl = "../images/CouponDefault.gif";

            string strServerURL = System.Configuration.ConfigurationSettings.AppSettings["ServerURL"];

            if (cItm.ImgPath1.Length > (int)0)  //show pic
            {
                //get URL to show pic
                string path = strServerURL + @"/users/" + Session["userDir"].ToString();
                if (cItm.UseTempDir == 1)
                {
                    path += @"/temp/";
                }
                string[] strArray;
                char[]   splitter = { '\\' };
                strArray         = cItm.ImgPath1.Split(splitter);
                img1.ImageUrl    = path + strArray[strArray.Length - 1];
                hdnImgPath.Value = img1.ImageUrl;
            }
            else        //no pic was uploaded
            {
                rdoImgMgr1.Items[2].Text = "Add";
                rdoImgMgr1.Items.Remove("Delete");
                rdoImgMgr1.Items.Remove("Keep");
                File1.Disabled        = true;
                chkDefaultImg.Checked = true;
            }
            return(true);
        }
示例#8
0
        private void SubmitItem(bool publishVal)
        {
            //at this point it's useless to ask for (editmode = 1) because we cannot guarantee where it came from. check c.id instead

            classes.Coupon oItem = (classes.Coupon)Session["cItem"];

            // - Tasks:
            // - Move pics from temp dir to user dir  2)clear temp dir (if needed)
            // - Write obj values to db

            if (oItem == null)
            {
                ErrorLog.ErrorRoutine(false, "Error:Preview:imgContinue_Click: BoardItem obj NULL: Session: " + Session.SessionID);
                HandleError();
                return;
            }
            else
            {
                ErrorLog.ErrorRoutine(false, "Preview:imgContinue_Click:ENTRYITEM OK: " + Session.SessionID);
            }

            if (oItem.EntryId <= 0) //new entry?
            {
                oItem.Created = DateTime.Now;
                oItem.IUser   = Convert.ToInt32(Session["userId"].ToString());
            }

            //TODO: figure this out
            //if (publishVal)
            //    oItem.Status = 5;
            //else
            //    oItem.Status = 4;


            //how to determine editMode, iD
            //check for pics
            if (hdnProcPics.Value == "1")
            {
                if (oItem.UseTempDir == 1) //note: hdnProcPics is based on s1x1.gif
                {
                    string userDir = Global.ReplaceEx(hdnUserDir.Value, "/", "\\");
                    string sUPath  = Global.ReplaceEx(Server.MapPath(".\\"), "\\qp", string.Empty) + @"users\" + userDir;

                    if (MoveFiles(sUPath))
                    {
                        DeletePicsInTempDir(sUPath);
                    }
                }
            }
            else
            {
                oItem.ImgPath1 = string.Empty;  //default
            }
            //validate text
            oItem.Details = Global.ReplaceEx(oItem.Details, "'", string.Empty);
            oItem.Details = Global.ReplaceEx(oItem.Details, "\"", string.Empty);

            oItem.Title = Global.ReplaceEx(oItem.Title, "'", string.Empty);
            oItem.Title = Global.ReplaceEx(oItem.Title, "\"", string.Empty);

            //Save or Update entry
            try
            {
                //update
                if (oItem.EntryId > 0)
                {
                    if (!oItem.UpdateCoupon())
                    {
                        lblStatus.Text     = "Error in Update";
                        lblStatus.CssClass = "errorLabel";
                        return;
                    }
                }
                else
                {
                    oItem.EntryId = oItem.SaveCoupon();
                    ErrorLog.ErrorRoutine(false, "EntryId: " + oItem.EntryId);
                    if (oItem.EntryId < 0)
                    {
                        lblStatus.Text     = "Error Saving Data";
                        lblStatus.CssClass = "errorLabel";
                        return;
                    }
                }

                if (publishVal)
                {
                    Session["ServiceId"] = "4";
                    Session["TxnItemId"] = oItem.EntryId;
                    Response.Redirect("../Pay/OrderForm.aspx", true);
                }
                Response.Redirect("Manager.aspx", true);
            }
            catch (Exception ex)
            {
                lblStatus.Text = "Arg! Something happened.  Nerdy geeks have been notified. You can try again shortly.";
                ErrorLog.ErrorRoutine(false, ex.Message);
            }
            finally
            {
                //destroy objects
                oItem            = null;
                Session["cItem"] = null;
            }
        }
示例#9
0
文件: Post.aspx.cs 项目: vizualz/BH3
/*
 * Upload any/all images
 */
        //TODO: FIX FIX FIX: new scale logic: scale only if needed. check images
        private classes.Coupon UpLoadAllImages(classes.Coupon bItem, string[] strImgPathArray)
        {
            string tmpFile;
            //string thmbNailPath;
            string userDir = string.Empty;

            //get user dir
            userDir = Global.ReplaceEx(Session["userDir"].ToString(), "/", "\\");

            if (bItem == null)  //TODO: should return
            {
                ErrorLog.ErrorRoutine(false, "Post:UploadAllImages():bItem NULL!");
            }

            //if panel is open check for loaded img files
            if (pnlAddImages.Visible)
            {
                //Collect files names, iterate through each and update accordingly
                HttpFileCollection uploadFilCol = System.Web.HttpContext.Current.Request.Files;
                int count = uploadFilCol.Count;

                if (count < 1)  //TODO: set imgArray here?
                {
                    return(bItem);
                }

                //loop thru for each posted file
                for (int i = 0; i < count; i++)
                {
                    //get handle to file
                    HttpPostedFile file = uploadFilCol[i];

                    if (file.ContentLength > (int)0)    //needed?  we already checked
                    {
                        //get file name & ext
                        string fileName   = Path.GetFileName(file.FileName);
                        string fileExt    = Path.GetExtension(file.FileName).ToLower();
                        string serverPath = Global.ReplaceEx(Server.MapPath(".\\"), "\\qp", string.Empty) + @"users\" + userDir + @"temp\";
                        int    noScale    = 0;

                        ErrorLog.ErrorRoutine(false, "MP: " + serverPath);

                        //check for temp dir and create if non-existent
                        if (!(Directory.Exists(serverPath)))
                        {
                            //'E:\kunden\homepages\31\d213027625\qp\users\0\0\0\0\0\0\0\1\6\2\temp\'
                            //Directory.CreateDirectory(Server.MapPath(".\\" + @"\users\" + userDir + @"\temp\"));
                            Directory.CreateDirectory(serverPath);
                        }

                        //get physical path to temp dir for upload
                        string path = serverPath;

                        //Generate random file name
                        tmpFile = GenerateRandomString(8).ToLower();

                        //concatenate renamed file with ext
                        tmpFile = tmpFile + fileExt;

                        //add together path and file name; This is our fully qualified *temp path where the file gets uploaded
                        strImgPathArray[i] = Path.Combine(path, tmpFile);
                        //thmbNailPath = Path.Combine(path, "thmbNail_" + tmpFile);

                        //Upload to temp dir; we'll write to perm directory after user confirms on preview!
                        //FIXME: Check for file type and size

                        if (fileName != string.Empty)
                        {
                            //resize the image and save
                            //Create an image object from the uploaded file.

                            try
                            {
                                System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(file.InputStream);

                                //Larger Image variables
                                int maxWidth  = picSizeBigX;
                                int maxHeight = picSizeBigY;

                                int sourceWidth  = UploadedImage.Width;
                                int sourceHeight = UploadedImage.Height;

                                if ((sourceWidth > maxWidth) || (sourceHeight > maxHeight))
                                {
                                    noScale = 1;
                                }

                                int sourceX = 0;
                                int sourceY = 0;

                                int destX = 0;
                                int destY = 0;

                                float nPercent  = 0;
                                float nPercentW = 0;
                                float nPercentH = 0;

                                //ThumbNail variables
                                //int maxWidth_T = 75;
                                //int maxHeight_T = 75;
                                //int destX_T = 0;
                                //int destY_T = 0;
                                //float nPercent_T = 0;
                                //float nPercentW_T = 0;
                                //float nPercentH_T = 0;

                                //START scaling here but check first if we really need to

                                //Larger Image percents
                                nPercentW = ((float)maxWidth / (float)sourceWidth);
                                nPercentH = ((float)maxHeight / (float)sourceHeight);

                                //Thumbnail percents
                                //nPercentW_T = ((float)maxWidth_T / (float)sourceWidth);
                                //nPercentH_T = ((float)maxHeight_T / (float)sourceHeight);

                                //Find the biggest change(smallest pct)
                                if (nPercentH < nPercentW)
                                {
                                    //Larger Image Calculations
                                    nPercent = nPercentH;
                                    destX    = System.Convert.ToInt16((maxWidth -
                                                                       (sourceWidth * nPercent)) / 2);

                                    //Thumbnail Calculations
                                    //nPercent_T = nPercentH_T;
                                    //destX_T = System.Convert.ToInt16((maxWidth_T -
                                    //              (sourceWidth * nPercent_T)) / 2);
                                }
                                else
                                {
                                    //Larger Image Calculations
                                    nPercent = nPercentW;
                                    destY    = System.Convert.ToInt16((maxHeight -
                                                                       (sourceHeight * nPercent)) / 2);

                                    //ThumbNail Calculations
                                    //nPercent_T = nPercentW_T;
                                    //destY_T    = System.Convert.ToInt16((maxWidth_T -
                                    //              (sourceHeight * nPercent_T)) / 2);
                                }

                                //Larger Image Calculations
                                int destWidth  = (int)(sourceWidth * nPercent);
                                int destHeight = (int)(sourceHeight * nPercent);

                                ErrorLog.ErrorRoutine(false, "Dest H + W: " + destHeight + " " + destHeight);

                                //Smaller Image Calculations
                                //int destWidth_T  = (int)(sourceWidth * nPercent_T);
                                //int destHeight_T = (int)(sourceHeight * nPercent_T);

                                //create the larger bitmap
                                Bitmap bmPhoto = new Bitmap(maxWidth, maxHeight);
                                bmPhoto.SetResolution(UploadedImage.HorizontalResolution,
                                                      UploadedImage.VerticalResolution);

                                //create the thumbnail bitmap
                                //Bitmap bmPhotoThmbNail = new Bitmap(maxWidth_T, maxHeight_T);
                                //bmPhotoThmbNail.SetResolution(UploadedImage.HorizontalResolution,
                                //                          UploadedImage.VerticalResolution);

                                //create larger graphic
                                Graphics grPhoto = Graphics.FromImage(bmPhoto);
                                grPhoto.SmoothingMode   = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                                grPhoto.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                                grPhoto.Clear(Color.Transparent);
                                grPhoto.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                                grPhoto.DrawImage(UploadedImage,
                                                  new Rectangle(destX, destY, destWidth, destHeight),
                                                  new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                                                  GraphicsUnit.Pixel);

                                //create thumbnail graphic
                                //Graphics grPhotoThmbNail = Graphics.FromImage(bmPhotoThmbNail);
                                //grPhotoThmbNail.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                                //grPhotoThmbNail.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                                //grPhotoThmbNail.Clear(Color.Transparent);
                                //grPhotoThmbNail.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                                //grPhotoThmbNail.DrawImage(UploadedImage,
                                //    new Rectangle(destX_T, destY_T, destWidth_T, destHeight_T),
                                //    new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                                //    GraphicsUnit.Pixel);

                                //int memberID = 0;

                                //Save the Image(s)
                                // (1) "Saves" the graphic.  It really just updates the bitmap with the contents of the graphic.
                                // Basically saving it in memory.
                                // (2) Actually save the bitmap to the file system.

                                //Larger
                                grPhoto.Save();                   //  (1)
                                bmPhoto.Save(strImgPathArray[i]); //  (2)  .., ImageFormat.Jpeg)

                                //strip out the superfluous server path and just save the file name;  this was the cause of much grief as we were previously saving the entire path!
                                strImgPathArray[i] = Path.GetFileName(strImgPathArray[i]);

                                //Thumbnail
                                //grPhotoThmbNail.Save();
                                //bmPhotoThmbNail.Save(thmbNailPath);

                                bItem.UseTempDir = 1;   //use the temp dir to move pics
                                noScale          = 0;   //reset scale flag

                                //Find out who is set to "change" or "add" so we know who to update
                                //  - We call the clearSelection() to let ourselves know that index has been processed
                                //TODO: append  (&& File1.Value.Length>0)
                                if (rdoImgMgr1.SelectedValue == "Change" || rdoImgMgr1.SelectedValue == "Add")
                                {
                                    bItem.ImgPath1 = strImgPathArray[i];
                                    rdoImgMgr1.ClearSelection();
                                }
                                //else if (rdoImgMgr2.SelectedValue == "Change" || rdoImgMgr2.SelectedValue == "Add")
                                //{

                                //    bItem.ImgPath2 = strImgPathArray[i];
                                //    rdoImgMgr2.ClearSelection();

                                //}
                            }
                            catch (Exception ex)
                            {
                                ErrorLog.ErrorRoutine(false, "Post:UpdateAllImages:Error: " + ex.Message);
                                lblStatus.Text = "Resize/Save Error!";
                            }
                        }
                        else
                        {
                            strImgPathArray[i] = string.Empty;
                        }
                    }
                }
            }//end main if
            //return strImgPathArray;
            return(bItem);
        }//end function
示例#10
0
文件: Post.aspx.cs 项目: vizualz/BH3
/*
 */

/*
 * Things to keep in mind here for this event handler:
 *      - we process all board types here including gear
 *      - we process wanted ads too which is a very limited subset including only
 *        category, boardtype, region, town, details, and price maybe
 */

        private void btnNext_Click(object sender, System.EventArgs e)
        {
            ErrorLog.ErrorRoutine(false, "Post:btnNext_Click: " + Session.SessionID);

            //TODO: Resolve how Preview will know where the srctempdir is located (2 places)
            // we know if we're updating by checking oItem.Id
            //that's all

            classes.Coupon oItem;

            HttpFileCollection uploadFilCol = Request.Files;

            if (uploadFilCol.Count < 1)
            {
                chkDefaultImg.Checked = true;
            }

            //pre-check file type
            if (!chkDefaultImg.Checked)
            {
                if (!CheckUploadedFiles())
                {
                    ResetImgMgr();
                    ErrorLog.ErrorRoutine(false, "Post:btnNext_Click:CheckUploadedFiles failed");
                    ShowError(false, ERR_MSG_BAD_PIC);
                    return;
                }
            }

            //validate form
            if (!(Page.IsValid))
            {
                //re-set anything here that needs a reset
                ErrorLog.ErrorRoutine(false, "Post:btnNext_Click:PageNotValid");
                ResetImgMgr();
                ShowError(false, ERR_MSG_INVALID_FORM);
                return;
            }

            if (txtTitle.Text.Length < 1)
            {
                ShowError(false, "Coupon title needs a valid entry.");
                return;
            }

            //New or Editing a coupon?
            if (Session["cItem"] != null)
            {
                oItem = (classes.Coupon)Session["cItem"];
            }
            else
            {
                //start fresh
                oItem = new classes.Coupon();

                //check for manager edit; we will know if there's an id from the query string
                if (hdnEntryId.Value != "-1")
                {
                    //get status: active or in-active
                    if (hdnStatus.Value.Length > 0)
                    {
                        oItem.Status = Convert.ToInt32(hdnStatus.Value);    //tells us if the coupon is active or not
                    }
                    else
                    {
                        oItem.Status = 0;   //not active
                    }
                    oItem.EditMode = 2;     //editing via manager
                    oItem.EntryId  = Convert.ToInt32(hdnEntryId.Value);
                }
            }

            if (!chkDefaultImg.Checked)
            {
                oItem.UseDefaultImg = false;
            }
            else
            {
                oItem.ImgPath1 = string.Empty;
            }

            //Check for new or swapped pics.  The user has 3 possible options here; Keep, Delete, Change
            //Pics will be uploaded to temp then moved to userdir once user accepts final approval in Preview page.
            //Delete any files in imgDel array
            bool blnProcImgs = false;

            if (!oItem.UseDefaultImg)
            {
                switch (rdoImgMgr1.SelectedValue)
                {
                case "Keep":
                    if (oItem.EditMode == 2)
                    {
                        oItem.UseTempDir = 0;
                        oItem.ImgPath1   = hdnImgPath.Value;
                    }
                    break;

                case "Delete":
                    oItem.ImgPath1 = string.Empty;
                    break;

                case "Change":
                    blnProcImgs = true;
                    break;

                case "Add":
                    blnProcImgs = true;
                    break;

                default:
                    break;
                }

                //Process images / *video
                if (blnProcImgs)
                {
                    //init pic array holder
                    string[] strImgPathArray = new string[2];
                    for (int j = 0; j <= 1; j++)
                    {
                        strImgPathArray[j] = string.Empty;
                    }

                    oItem = UpLoadAllImages(oItem, strImgPathArray);
                }
            }

            oItem.Category = Convert.ToInt32(cboCategory.SelectedValue);
            string tmpDetails = txtDetails.Text;

            //truncate characters after 140.
            if (tmpDetails.Length > 140)
            {
                oItem.Details = tmpDetails.Remove(140, tmpDetails.Length - 140);
            }

            string tmpStr;

            tmpStr        = Global.CheckString(txtDetails.Text);
            tmpStr        = Regex.Replace(tmpStr, @"\s+", " ").Trim();
            oItem.Details = tmpStr;

            oItem.Title = Global.CheckString(txtTitle.Text);
            oItem.CCode = txtCode.Text;

            if (txtDate.Text.Length > 0)
            {
                oItem.Expired = Convert.ToDateTime(txtDate.Text);
            }

            //Save object to session variable
            Session["cItem"] = oItem;

            //Goto preview_post
            Response.Redirect("Preview.aspx", true);
        }