예제 #1
0
 protected void btnsubmit_Click(object sender, EventArgs e)
 {
     try
     {
         GallaryMaster cm = new GallaryMaster();
         if (btnsubmit.Text == "Submit")
         {
             cm.Id = GallaryMaster.GetMaxID() + 1;
             string exten1 = System.IO.Path.GetExtension(fileImage.FileName);
             if (fileImage.HasFile == true)
             {
                 cm.FileName = "Gal" + cm.Id + exten1;
                 fileImage.SaveAs(Server.MapPath("~/images/Gallery/" + "Gal" + cm.Id + exten1));
             }
             else
             {
                 cm.FileName = GallaryMaster.GetById(cm.Id).FileName;
             }
             cm.Heading = txthesd.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Submit Successfully....');</Script>", false);
         }
         else if (btnsubmit.Text == "Update")
         {
             cm    = GallaryMaster.GetById(int.Parse(ViewState["id"].ToString()));
             cm.Id = int.Parse(ViewState["id"].ToString());
             string exten1 = System.IO.Path.GetExtension(fileImage.FileName);
             if (fileImage.HasFile == true)
             {
                 cm.FileName = "Gal" + cm.Id + exten1;
                 fileImage.SaveAs(Server.MapPath("~/images/Gallery/" + "Gal" + cm.Id + exten1));
             }
             else
             {
                 cm.FileName = GallaryMaster.GetById(cm.Id).FileName;
             }
             cm.Heading = txthesd.Text;
             cm.Heading = txthesd.Text;
             cm.Save();
             grid();
             ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<Script>alert('Update Successfully...');</Script>", false);
         }
         ClearInputs(Page.Controls);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert(error);</script>", false);
     }
 }
예제 #2
0
        protected void linkbtnEdit_Click(object sender, EventArgs e)
        {
            LinkButton  lb = (LinkButton)sender;
            GridViewRow gr = (GridViewRow)lb.NamingContainer;

            ViewState["id"] = ((Label)gr.FindControl("labelNOTICE_ID")).Text;
            string        nid = ViewState["id"].ToString();
            GallaryMaster cm  = GallaryMaster.GetById(int.Parse(nid));

            if (cm.FileName == "" || cm.FileName == null)
            {
                ImagePhoto.ImageUrl = "~/images/b1.jpg";
            }
            else
            {
                ImagePhoto.ImageUrl = "~/images/Gallery/" + cm.FileName;
            }
            txthesd.Text   = cm.Heading;
            btnsubmit.Text = "Update";
        }