Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the btnsave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                int i = 0;
                using (supereventimagesmgmt objsuper = new supereventimagesmgmt())
                {
                    if (hdnimage1.Value.Trim().Length > 0)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmsss") + "1.jpg";
                        string dir       = MapPath("../superevent/");
                        string imgpath   = dir + imageName;
                        #region :: Base64 ::
                        string strImg = hdnimage1.Value;
                        strImg = strImg.Replace("data:image/png;base64,", "");
                        if (strImg.Trim().Length > 0)
                        {
                            Base64ToImage(strImg).Save(imgpath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        #endregion
                        objsuper.SaveSuperEventImages(Request.QueryString["supereventid"], imageName);
                        i++;
                    }

                    if (hdnimage2.Value.Trim().Length > 0)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmsss") + "2.jpg";
                        string dir       = MapPath("../superevent/");
                        string imgpath   = dir + imageName;
                        #region :: Base64 ::
                        string strImg = hdnimage2.Value;
                        strImg = strImg.Replace("data:image/png;base64,", "");
                        if (strImg.Trim().Length > 0)
                        {
                            Base64ToImage(strImg).Save(imgpath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        #endregion
                        objsuper.SaveSuperEventImages(Request.QueryString["supereventid"], imageName);
                        i++;
                    }
                    if (hdnimage3.Value.Trim().Length > 0)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmsss") + "3.jpg";
                        string dir       = MapPath("../superevent/");
                        string imgpath   = dir + imageName;
                        #region :: Base64 ::
                        string strImg = hdnimage3.Value;
                        strImg = strImg.Replace("data:image/png;base64,", "");
                        if (strImg.Trim().Length > 0)
                        {
                            Base64ToImage(strImg).Save(imgpath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        #endregion
                        objsuper.SaveSuperEventImages(Request.QueryString["supereventid"], imageName);
                        i++;
                    }

                    if (hdnimage4.Value.Trim().Length > 0)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmsss") + "4.jpg";
                        string dir       = MapPath("../superevent/");
                        string imgpath   = dir + imageName;
                        #region :: Base64 ::
                        string strImg = hdnimage4.Value;
                        strImg = strImg.Replace("data:image/png;base64,", "");
                        if (strImg.Trim().Length > 0)
                        {
                            Base64ToImage(strImg).Save(imgpath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        #endregion
                        objsuper.SaveSuperEventImages(Request.QueryString["supereventid"], imageName);
                        i++;
                    }
                    if (hdnimage5.Value.Trim().Length > 0)
                    {
                        string imageName = DateTime.Now.ToString("ddMMyyyyHHmmsss") + "5.jpg";
                        string dir       = MapPath("../superevent/");
                        string imgpath   = dir + imageName;
                        #region :: Base64 ::
                        string strImg = hdnimage5.Value;
                        strImg = strImg.Replace("data:image/png;base64,", "");
                        if (strImg.Trim().Length > 0)
                        {
                            Base64ToImage(strImg).Save(imgpath, System.Drawing.Imaging.ImageFormat.Jpeg);
                        }
                        #endregion
                        objsuper.SaveSuperEventImages(Request.QueryString["supereventid"], imageName);
                        i++;
                    }
                }

                if (i > 0)
                {
                    Page.RegisterStartupScript("onsave", "<script>closePOP();</script>");
                }
            }
            catch (Exception ex)
            {
                CommonLib.ExceptionHandler.WriteLog(CommonLib.Sections.Client, "eventimage.aspx.cs btnsave_Click ", ex);
            }
        }