| Server IP : 199.79.62.161 / Your IP : 216.73.216.245 [ Web Server : Microsoft-IIS/10.0 System : Windows NT MDUS-PP-WB12 10.0 build 20348 (Windows Server 2022) AMD64 User : IWPD_5096(nirmaowd) ( 0) PHP Version : 8.3.30 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/INETPUB/VHOSTS/nirmalamatha.edu.in/ponnuguruvayurappan.org/Admin/ |
Upload File : |
using System;
using System.Data;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Admin_viewadv : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
HiddenField HField1 = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("HiddenField2");
if (HField1.Value != "")
{
try
{
System.IO.File.Delete(Server.MapPath("./Plots_files\\" + HField1.Value));
}
catch (Exception) { }
}
HiddenField Hiddenpic1 = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("Hiddenpic2");
if (Hiddenpic1.Value != "")
{
try
{
File.Delete(Server.MapPath("Plots_files\\" + Hiddenpic1.Value));
}
catch (Exception) { }
}
}
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
if (e.AffectedRows > 0)
{
lblbmessage.Text = "Successfully Updated";
}
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox heading = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtheading");
TextBox Description = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtdetails");
TextBox txtdisplayorder = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtdisplayorder");
HiddenField Hiddenpic1 = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("Hiddenpic1");
HiddenField HiddenField1 = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("HiddenField1");
FileUpload fu_upload = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("fu_upload");
// TextBox Textourprice = (TextBox)GridView1.Rows[e.RowIndex].FindControl("Textourprice");
FileUpload FileUpload1 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload1");
e.NewValues["Heading"] = heading.Text;
e.NewValues["Description"] = Description.Text;
e.NewValues["DisplayOrder"] = txtdisplayorder.Text;
//save first photo
if (FileUpload1.HasFile)
{
try
{
string id = Hiddenpic1.Value;
if (id != "")
{
try
{
File.Delete(Server.MapPath("Plots_files\\" + id));
}
catch (Exception) { }
string[] temp = id.Split('.');
string smallpicname = SaveFile(temp[0], FileUpload1.PostedFile);
e.NewValues["Picture"] = smallpicname;
}
else
{
string newid = e.Keys[0].ToString();
string smallpicname = SaveFile(newid + "PIC1", FileUpload1.PostedFile);
e.NewValues["Picture"] = smallpicname;
}
}
catch (Exception) { }
}
else
e.NewValues["Picture"] = Hiddenpic1.Value;
}
public string SaveFile(string id, HttpPostedFile myFile)
{
string SaveLocation = "";
//string sFileType = System.IO.Path.GetExtension(FileUpload1.FileName);
switch (myFile.ContentType)
{
case "image/gif":
id = id + ".gif";
SaveLocation = Server.MapPath("Plots_files") + "\\" + id;
myFile.SaveAs(SaveLocation);
break;
case "image/pjpeg":
id = id + ".jpg";
SaveLocation = Server.MapPath("Plots_files") + "\\" + id;
myFile.SaveAs(SaveLocation);
break;
case "image/jpeg":
id = id + ".jpg";
SaveLocation = Server.MapPath("Plots_files") + "\\" + id;
myFile.SaveAs(SaveLocation);
break;
case "image/bmp":
id = id + ".bmp";
SaveLocation = Server.MapPath("Plots_files") + "\\" + id;
myFile.SaveAs(SaveLocation);
break;
default:
id = "0.jpg";
break;
}
return id;
}
public string SaveFile1(string id, HttpPostedFile myFile, string SavePath)
{
string fn = id;
fn += System.IO.Path.GetExtension(myFile.FileName);
string SaveLocation = Server.MapPath(SavePath) + "\\" + fn;
myFile.SaveAs(SaveLocation);
return fn;
}
protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}