using System.Data; using System.Data.SqlClient; 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 right7image : System.Web.UI.Page { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["transfer"].ConnectionString); string branchid = "";
protected void Page_Load(object sender, EventArgs e) { branchid = Session["UserName"].ToString(); if (IsPostBack == false) { Image1.ImageUrl = "right7.ashx?BranchId=" + branchid; Image2.ImageUrl = "right7old.ashx?BranchId=" + branchid; } } protected void LinkButton1_Click(object sender, EventArgs e) { Response.Redirect("Images.aspx"); } protected void Button1_Click(object sender, EventArgs e) { //update //1st copy using ptr SqlCommand cmdptr = new SqlCommand("copyprevimgr7", con); cmdptr.CommandType = CommandType.StoredProcedure; con.Open(); cmdptr.Parameters.AddWithValue("@BranchId", branchid); cmdptr.ExecuteNonQuery(); con.Close(); //2nd newlybrowse once updateleft1image SqlCommand cmdupdate = new SqlCommand("updateright7", con); cmdupdate.CommandType = CommandType.StoredProcedure; con.Open(); cmdupdate.Parameters.AddWithValue("@BranchId", branchid); if (FileUpload1.HasFile) { FileInfo left1info = new FileInfo(FileUpload1.PostedFile.FileName.Trim()); byte[] left1content = new byte[left1info.Length]; FileStream left1stream = left1info.OpenRead(); left1stream.Read(left1content, 0, left1content.Length); left1stream.Close(); cmdupdate.Parameters.AddWithValue("@imgright7", left1content); } cmdupdate.Parameters.AddWithValue("@noter7", TextBox1.Text); if (cmdupdate.ExecuteNonQuery() != 0) { con.Close(); clsdatasettransfer.ShowAlertMessage("Updated....."); TextBox1.Text = ""; System.Threading.Thread.Sleep(2000); Image1.ImageUrl = "right7.ashx?BranchId=" + Session["UserName"].ToString(); Image2.ImageUrl = "right7old.ashx?BranchId=" + Session["UserName"].ToString(); } else { clsdatasettransfer.ShowAlertMessage("Updatefailed"); } } }
|