protected void DeleteClick(object sender, EventArgs e)
        {
            try
            {
                String myFace = ((Button)sender).Text;

                if (myFace.IndexOf("Confirm") != -1)
                {
                    //Put delete method here.
                    ImageAccess db = new ImageAccess();
                    db.Delete_Image(Convert.ToInt32(ViewState["ID_Img"]));

                    txtAltText.Text  = "";
                    txtName.Text     = "";
                    lblFileName.Text = "";
                    LoadImages();
                    btnDelete.Visible     = true;
                    btnDontDelete.Visible = btnRealDelete.Visible = false;
                }
                else if (myFace.IndexOf("Cancel") != -1)
                {
                    master.messageNormal("Delete Canceled");
                    btnDelete.Visible     = true;
                    btnDontDelete.Visible = btnRealDelete.Visible = false;
                }
                else
                {
                    btnDelete.Visible     = false;
                    btnDontDelete.Visible = btnRealDelete.Visible = true;
                }
            }catch (Exception x)
            {
                master.messageError(x.Message);
            }
        }
Exemple #2
0
        protected void LoadImages()
        {
            try
            {
                ImageAccess imgDB  = new ImageAccess();
                DataTable   images = new DataTable();

                images = imgDB.Load_Unverified(Convert.ToInt32(Session["ID_Adm"]));
                if (images.Rows.Count != 0)
                {
                    rptItems.DataSource = images;
                    rptItems.DataBind();
                }
                else
                {
                    rptItems.DataSource = null;
                    rptItems.DataBind();
                    master.messageNormal("There is no images for you to validate");
                }
            }
            catch (Exception ex)
            {
                master.messageError(ex.Message);
            }
        }
        protected void LoadImages()
        {
            ImageAccess imgDB  = new ImageAccess();
            DataTable   images = imgDB.Load_Verified();

            ddlImages.DataSource     = images;
            ddlImages.DataTextField  = "fileName";
            ddlImages.DataValueField = "ID_Img";
            ddlImages.DataBind();
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         ImageAccess db = new ImageAccess();
         if (db.Update_Image(Convert.ToInt32(ViewState["ID_Img"]), txtName.Text, txtAltText.Text, imgPreview.ImageUrl, chkActive.Checked))
         {
             master.messageSuccess("Image Info Updated!");
         }
     }catch (Exception x)
     {
         master.messageError(x.Message);
     }
 }
        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;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ImageAccess imgDB = new ImageAccess();

            if (File.Exists(Server.MapPath("~/imagesTemp") + "\\" + txtName.Text + ViewState["extension"]))
            {
                master.messageError("File Already Exists... try again");
            }
            else
            {
                File.Move(Server.MapPath(imgPreview.ImageUrl), Server.MapPath("~/imagesTemp") + "\\" + txtName.Text + ViewState["extension"]);
                if (imgDB.Save_Image(txtName.Text, txtAltText.Text, "~/imagesTemp/" + txtName.Text + ViewState["extension"], Convert.ToInt32(Session["ID_Adm"])))
                {
                    master.messageSuccess("Images has successfully been uploaded");
                }
                imgPreview.Visible = false;
            }
        }
Exemple #7
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();
            }
        }