void IconReSizeImage(string ImagePath, string ImageName)
 {
     System.Drawing.Image Image1 = System.Drawing.Image.FromFile(ImagePath);
     System.Drawing.Image Image2 = new Bitmap(Image1,14,16);
     Graphics oGraphic = Graphics.FromImage(Image2);
     oGraphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     oGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     oGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     Rectangle oRectangle = new Rectangle(0, 0, 14, 16);
     oGraphic.DrawImage(Image2, oRectangle);           
     Image1.Dispose();
     string NewIconPath = Server.MapPath("~/images/PictureGallery/Icon/");
     NewIconPath += ImageName;
     Image2.Save(NewIconPath, System.Drawing.Imaging.ImageFormat.Jpeg);
     Image2.Dispose();
     Label2.Text = "~/images/PictureGallery/Icon/" + ImageName;
     //AccessDataSource1.Insert();
     try
     {
         AppCode appcode = new AppCode();
         appcode.Query("pic_update_insert", "Icon_Name", ImageName, "Path", ImagePath);
     }
     catch (Exception)
     {
     }
     //Rename the Original Image File to the same name as the new Image ...
     try
     {
         System.IO.File.Copy(ImagePath, Server.MapPath("~/images/PictureGallery/Original_Icon/" + ImageName), true);
     }
     catch
     {                
     }
     try
     {
         System.IO.File.Delete(ImagePath);
         System.IO.File.Delete(Server.MapPath("~/images/PictureGallery/Original_Icon/" + ImageName));
     }
     catch (Exception)
     {
     }
 }
 void HomePictureResizeImage(string ImagePath, string ImageName)
 {
     System.Drawing.Image Image1 = System.Drawing.Image.FromFile(ImagePath);
     System.Drawing.Image Image2 = new Bitmap(Image1, 160, 120);
     Graphics oGraphic = Graphics.FromImage(Image2);
     oGraphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     oGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     oGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     Rectangle oRectangle = new Rectangle(0, 0, 160, 120);
     oGraphic.DrawImage(Image2, oRectangle);
     Image1.Dispose();
     string NewHomePicturePath = Server.MapPath("~/images/PictureGallery/HomePic/" + ImageName);
     Image2.Save(NewHomePicturePath, System.Drawing.Imaging.ImageFormat.Jpeg);
     Image2.Dispose();
     Label3.Text = "~/images/PictureGallery/HomePic/" + ImageName;
     Label5.Text = ImageName;
     try
     {
         //AccessDataSource2.Insert();
         AppCode appcode = new AppCode();
         appcode.Query("home_pic_upate_insert", "FileName", ImageName, "FilePath", ImagePath);
     }
     catch (Exception)
     {                               
     }
 }
 protected void Button4_Click(object sender, EventArgs e)
 {
     try
     {
         //AccessDataSource4.Insert();
         AppCode appcode = new AppCode();
         appcode.Query("pic_update_category_insert", "Category", TextBox2.Text);
     }
     catch (Exception)
     {
     }            
     // Notify the user that the category is uploaded ... 
     ClientScriptManager cs3 = Page.ClientScript;
     Type cstype3 = this.GetType();
     if (!cs3.IsStartupScriptRegistered(cstype3, "CategorySuccess"))
     {
         string s = "<script language=\"JScript\">window.alert('The new Picture Category was added successfully.');</script>";
         ClientScript.RegisterStartupScript(cstype3, "CategorySuccess", s);
     }
     TextBox2.Text = "";
     AppCode appcode1 = new AppCode();
     DataTable dt = appcode1.DataTableSelectQuery("pic_update_category_select");
     DropDownList1.DataSource = dt;
     DropDownList1.DataBind();
 }
 protected void Button1_Click1(object sender, EventArgs e)
 {
     string path = HttpContext.Current.Server.MapPath("~/images/EnewsLetters/");
     path += FileUpload1.FileName;
     // Take apart selected date, to make it the 1st of the month...
     int TodayMonth = Calendar1.SelectedDate.Month;
     int TodayYear = Calendar1.SelectedDate.Year;
     int TodayDay = 01;
     string eNewsDateString = Convert.ToString(TodayMonth) + "/" + Convert.ToString(TodayDay) + "/" + Convert.ToString(TodayYear);
     Calendar1.SelectedDate = Convert.ToDateTime(eNewsDateString);
     // Check the filename, and make sure there are no spaces in it ...
     string SelectedFileName = FileUpload1.FileName;
     // Check to make sure a date was selected ... 
     if (eNewsDateString == "1/1/1")
     {
         ClientScriptManager cs1 = Page.ClientScript;
         Type cstype1 = this.GetType();
         if (!cs1.IsStartupScriptRegistered(cstype1, "CalendarError"))
         {
             string s = "<script language=\"JScript\">window.alert('Please select a valid date from the calendar for this eNewsLetter, and try again.');</script>";
             ClientScript.RegisterStartupScript(cstype1, "CalendarError", s);
         }
     }
     // Check to make sure there are no spaces in the filename ....
     else if (SelectedFileName.Contains(" "))
     {
        ClientScriptManager cs2 = Page.ClientScript;
        Type cstype2 = this.GetType();
        if (!cs2.IsStartupScriptRegistered(cstype2, "FilenameError"))
        {
             string s = "<script language=\"JScript\">window.alert('Please remove all \"Spaces\" from the filename of the eNewsLetter, and try again.');</script>";
             ClientScript.RegisterStartupScript(cstype2, "FilenameError", s);
        }
     }
     else
     {
         try
         {
             //AccessDataSource1.Insert();
             AppCode appcode = new AppCode();
             appcode.Query("Enewletter_Update_Insert", "p1", Calendar1.SelectedDate, "p2", FileUpload1.FileName, "p3", TextBox2.Text);
         }
         catch (System.Data.OleDb.OleDbException)
         {
             ClientScriptManager cs = Page.ClientScript;
             Type cstype = this.GetType();
             if (!cs.IsStartupScriptRegistered(cstype, "DataError"))
             {
                 string s = "<script language=\"JScript\">window.alert('There was a problem accessing the database file.  Please try again.  If you continue to get this error, please contact the system administrator.');</script>";
                 ClientScript.RegisterStartupScript(cstype, "DataError", s);
             }
         }
         try
         {
             FileUpload1.SaveAs(path);
             ClientScriptManager cs1 = Page.ClientScript;
             Type cstype1 = this.GetType();
             if (!cs1.IsStartupScriptRegistered(cstype1, "UploadSuccess"))
             {
                 string s = "<script language=\"JScript\">window.alert('The eNewsLetter was updated successfully!');</script>";
                 ClientScript.RegisterStartupScript(cstype1, "UploadSuccess", s);
             }
         }
         catch (System.IO.DirectoryNotFoundException)
         {
             ClientScriptManager cs = Page.ClientScript;
             Type cstype = this.GetType();
             if (!cs.IsStartupScriptRegistered(cstype, "IOError"))
             {
                 string s = "<script language=\"JScript\">window.alert('There was a problem uploading the file. Please check the filename, and file location, and try again.  If you continue to get this error, please contact the system administrator.');</script>";
                 ClientScript.RegisterStartupScript(cstype, "IOError", s);
             }
         }
         TextBox2.Text = "";
     }
 }
 void RecentPicturesResizeImage(string ImagePath, string ImageName)
 {
     System.Drawing.Image Image1 = System.Drawing.Image.FromFile(ImagePath);
     System.Drawing.Image Image2 = new Bitmap(Image1, 230, 261);
     Graphics oGraphic = Graphics.FromImage(Image2);
     oGraphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
     oGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     oGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
     Rectangle oRectangle = new Rectangle(0, 0, 230, 261);
     oGraphic.DrawImage(Image2, oRectangle);
     Image1.Dispose();
     string NewHomePicturePath = Server.MapPath("~/images/PictureGallery/RecentPic/" + ImageName);
     Image2.Save(NewHomePicturePath, System.Drawing.Imaging.ImageFormat.Jpeg);
     Image2.Dispose();
     Label4.Text = "~/images/PictureGallery/RecentPic/" + ImageName;
     Label6.Text = ImageName;
     try
     {
         //AccessDataSource3.Insert();
         AppCode appcode = new AppCode();
         appcode.Query("recent_pic_update_insert", "ImageName", ImageName, "ImagePath", ImagePath, "Category", DropDownList1.SelectedValue.ToString());
     }
     catch (Exception)
     {
     }
 }
Esempio n. 6
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     AppCode appcode = new AppCode();
     appcode.Query("signup_insert", "@emailaddress", TextBox1.Text);            
     TextBox1.Text = "";
 }
 protected void Button5_Click(object sender, EventArgs e)
 {
     AppCode appcode = new AppCode();
     appcode.Query("Calendar_Modify_Delete", "p1", DataList1.SelectedValue);
     TextBox_EventDate.Text = "";
     TextBox_EventName.Text = "";
     TextBoxEventInfo.Text = "";
     Panel1.Visible = false;
     DataList1.DataBind();
     DataList1.Visible = true;
 }
 protected void Button4_Click(object sender, EventArgs e)
 {
     //AccessDataSource4.Delete();
     AppCode appcode1 = new AppCode();
     appcode1.Query("pic_mod_category_delete", "ID", DropDownList1.SelectedValue);
     DataTable dt1 = appcode1.DataTableSelectQuery("pic_update_category_select");
     DropDownList1.DataSource = dt1;
     DropDownList1.DataBind();
 }
        protected void DataList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ControlIndex = this.DataList2.SelectedIndex;
            //Find the Image Control in the selected Datalist Colum
            DataListItem dli = this.DataList2.Controls[ControlIndex] as DataListItem;
            Image MyImage = dli.FindControl("Image2") as Image;
            //Grab the ImageUrl for this picture.
            string MyImagePath = MyImage.ImageUrl;
            //Delete the actual image file.
            string ActualImagePath = Server.MapPath(MyImagePath);
            System.IO.File.Delete(ActualImagePath);
            //Delete the original image file.
            string OrignialImageName = "";
            string[] split = MyImagePath.Split(new Char[] { '/' });
            foreach (string s in split)
            {
                if (s.Trim().Contains(".jpg"))
                {
                    OrignialImageName = s;
                }
            }
            string OriginalImagePath = Server.MapPath("~/images/PictureGallery/Original_HomePic/" + OrignialImageName);
            //Delete the image information from the database.
            //AccessDataSource2.DeleteParameters.Add("FilePath", MyImagePath);
            //AccessDataSource2.Delete();
            try
            {
                AppCode appcode2 = new AppCode();
                appcode2.Query("pic_mod_home_delete", "ImagePath", MyImagePath);
                DataTable dt1 = appcode2.DataTableSelectQuery("pic_mod_home_select");
                DataList2.DataSource = dt1;
                DataList2.DataBind();
            }
            catch (Exception)
            {

            }
        }
 protected void Button1_Click(object sender, EventArgs e)
 {
     AppCode appcode = new AppCode();
     appcode.Query("eNewsLetter_Unsubscribe_Delete", "@origemailaddress", TextBox1.Text);            
     TextBox1.Text = "";
 }