protected void btnImage_Click(object sender, EventArgs e)
        {
            ImageAccess db    = new ImageAccess();
            DataTable   image = new DataTable();

            image = db.Load_Image(Convert.ToInt32(ddlImages.SelectedValue));
            imgPreview.ImageUrl = image.Rows[0]["locus"].ToString();
            string fileName = image.Rows[0]["fileName"].ToString();
            string altText  = image.Rows[0]["altText"].ToString();
            bool   active   = Convert.ToBoolean(image.Rows[0]["active"]);

            ViewState["ID_Img"] = Convert.ToInt32(image.Rows[0]["ID_Img"]);

            lblFileName.Text  = fileName;
            txtName.Text      = fileName;
            txtAltText.Text   = altText;
            chkActive.Checked = active;
        }
Esempio n. 2
0
        protected void rptItems_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument.ToString());

            if (e.CommandName == "Accept")
            {
                ImageAccess db    = new ImageAccess();
                DataTable   image = new DataTable();

                image = db.Load_Image(id);
                string locus     = image.Rows[0]["locus"].ToString();
                string extension = locus.Substring(locus.Length - 4);
                string fileName  = image.Rows[0]["fileName"].ToString();
                string newLocus  = locus.Replace("imagesTemp", "images");


                if (File.Exists(Server.MapPath("~/images") + "\\" + fileName + extension))
                {
                    master.messageError("File Already Exists... try again");
                }
                else
                {
                    db.VerifyImage(Convert.ToInt32(image.Rows[0]["ID_Img"]), Convert.ToInt32(Session["ID_Adm"]), newLocus);
                    File.Move(Server.MapPath(locus), Server.MapPath(newLocus));
                    LoadImages();
                }
            }
            else if (e.CommandName == "Reject")
            {
                ImageAccess db    = new ImageAccess();
                DataTable   image = new DataTable();
                image = db.Load_Image(id);
                db.Delete_Image(Convert.ToInt32(id));
                File.Delete(Server.MapPath(image.Rows[0]["locus"].ToString()));
                LoadImages();
            }
        }