コード例 #1
0
        protected void UpdateImage_Click(object sender, EventArgs e)
        {
            ImageDb image = new ImageDb()
            {
                IdImage   = Convert.ToInt32(this.LabelImageId.Text),
                ImageName = this.tbEditImageName.Text,
                ImgAlt    = this.tbEditImageAlt.Text
            };

            if (this.CheckBoxNewImage.Checked)
            {
                UploadImageDb img = UploadFile.UploadImage(this.FileUploadEditImage, Server.MapPath("~/Upload/"), true);
                if (img.IsUploaded)
                {
                    image.BigPictureUrl       = img.BigPictureUrl;
                    image.SmallPictureUrl     = img.SmallPictureUrl;
                    this.GridView2.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpImageUpdate()
                    {
                        Image = image
                    }).DbItems.Cast <ImageDb>().ToArray();
                    this.GridView2.DataBind();
                }
            }
            else
            {
                this.GridView2.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpImageUpdateWithoutImg()
                {
                    Image = image
                }).DbItems.Cast <ImageDb>().ToArray();
                this.GridView2.DataBind();
            }
            this.PanelShowEditImage.Visible = false;
        }
コード例 #2
0
        protected void btnUpdateProject_Click(object sender, EventArgs e)
        {
            ProjectDb project = new ProjectDb()
            {
                IdProject   = Convert.ToInt32(this.LabelProjectId.Text),
                Description = this.TextAreaDescription.Value,
                Title       = this.tbProjectTitle.Text,
                Tag         = this.tbProjectTag.Text
            };

            if (this.CheckBoxUploadNewMainImage.Checked)
            {
                UploadImageDb img = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/"));
                if (img.IsUploaded)
                {
                    project.MainImageLink = img.BigPictureUrl;
                    //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithImg() { Project = project }).DbItems.Cast<ProjectDb>().ToArray();
                    this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithImg()
                    {
                        Project = project
                    }).DbItems.Cast <ProjectDb>().ToArray();
                }
                else
                {
                    //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() { Project = project }).DbItems.Cast<ProjectDb>().ToArray();
                    this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg()
                    {
                        Project = project
                    }).DbItems.Cast <ProjectDb>().ToArray();
                }
            }
            else
            {
                //this.GridViewProjects.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg() {Project = project }).DbItems.Cast<ProjectDb>().ToArray();
                this.GridView1.DataSource = OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateWithoutImg()
                {
                    Project = project
                }).DbItems.Cast <ProjectDb>().ToArray();
            }
            this.PanelShowData.Visible = false;
            //this.GridViewProjects.DataBind();
            this.GridView1.DataBind();
        }
コード例 #3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                UploadImageDb img = UploadFile.UploadImage(this.FileUploadImage, Server.MapPath("~/Upload/"), true);
                if (img.IsUploaded)
                {
                    ImageDb image = new ImageDb()
                    {
                        IdProject       = ProjectId,
                        ImageName       = this.tbImageName.Text,
                        ImgAlt          = this.tbImageAlt.Text,
                        SmallPictureUrl = img.SmallPictureUrl,
                        BigPictureUrl   = img.BigPictureUrl
                    };

                    OperacijaRezultat res = OperationManager.Singleton.izvrsiOperaciju(new OpImageInsertOnly()
                    {
                        Image = image
                    });
                    if (res.Status)
                    {
                        Response.Redirect("/SingleProject.aspx?projectid=" + ProjectId);
                    }
                    else
                    {
                        this.LabelMessage.Visible = true;
                        this.LabelMessage.Text    = "something went wrong. we couldnt insert into database";
                    }
                }
                else
                {
                    this.LabelMessage.Visible = true;
                    this.LabelMessage.Text    = "something went wrong. we couldnt upload image";
                }
            }
        }
コード例 #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                if (this.CheckBoxEditing.Checked)
                {
                    ProjectDb project = new ProjectDb()
                    {
                        IdProject   = Convert.ToInt32(this.LabelEditingId.Text),
                        IdUser      = (int)Session["idUser"],
                        Title       = this.tbTitle.Text,
                        Tag         = this.tbTag.Text,
                        Description = this.taDescription.Value
                    };
                    if (this.CheckBoxEditImage.Checked)
                    {
                        UploadImageDb image = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/"));

                        if (image.IsUploaded)
                        {
                            project.MainImageLink          = image.BigPictureUrl;
                            this.LabelMessage.ForeColor    = System.Drawing.Color.Green;
                            this.CheckBoxEditImage.Checked = false;
                            this.CheckBoxEditImage.Visible = false;
                            OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateOnlyWithImg()
                            {
                                Project = project
                            });
                        }
                        else
                        {
                            this.LabelMessage.ForeColor = System.Drawing.Color.Red;
                        }
                    }
                    else
                    {
                        this.CheckBoxEditImage.Checked = false;
                        this.CheckBoxEditImage.Visible = false;
                        OperationManager.Singleton.izvrsiOperaciju(new OpProjectUpdateOnlyWithoutImg()
                        {
                            Project = project
                        });
                    }
                    this.tbTitle.Text        = "";
                    this.tbTag.Text          = "";
                    this.taDescription.Value = "";
                }
                else
                {
                    //obradi ono za sliku prvo
                    UploadImageDb image = UploadFile.UploadImage(this.FileUploadMainImage, Server.MapPath("~/Upload/"));

                    if (image.IsUploaded)
                    {
                        ProjectDb project = new ProjectDb()
                        {
                            IdUser        = (int)Session["idUser"],
                            Title         = this.tbTitle.Text,
                            Tag           = this.tbTag.Text,
                            Description   = this.taDescription.Value,
                            MainImageLink = image.BigPictureUrl
                        };
                        OperationManager.Singleton.izvrsiOperaciju(new OpProjectInsertOnly()
                        {
                            Project = project
                        });
                        this.tbTitle.Text        = "";
                        this.tbTag.Text          = "";
                        this.taDescription.Value = "";

                        this.CheckBoxEditImage.Visible = false;
                        this.LabelMessage.ForeColor    = System.Drawing.Color.Green;
                    }
                    else
                    {
                        this.LabelMessage.ForeColor = System.Drawing.Color.Red;
                    }
                    this.LabelMessage.Visible = true;
                    this.LabelMessage.Text    = image.ErrorMessage;
                }
            }
            this.LabelEditingId.Text     = "";
            this.CheckBoxEditing.Checked = false;
            this.GridView1.DataBind();
        }