Ejemplo n.º 1
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            var info = ImageDB.GetInfo(ConvertUtility.ToInt32(txtID.Text));

            info.Image_Name        = ConvertUtility.ToString(txtName.Text);
            info.Image_Description = txtTeaser.Text;
            info.Image_Visible     = chkVisible.Checked;


            try
            {
                ImageDB.Update(info);

                lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_SUCCESS;
            }
            catch
            {
                lblStatusUpdate.Text = lblStatusUpdate2.Text = MiscUtility.UPDATE_ERROR;
            }
        }
Ejemplo n.º 2
0
        protected void dtgPix_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                int       id   = ConvertUtility.ToInt32(e.Item.Cells[0].Text);
                ImageInfo info = ImageDB.GetInfo(id);
                try
                {
                    string avatarsource = info.Image_File;
                    if (avatarsource.Length > 0)
                    {
                        int      lengUploadString3 = AppEnv.UploadImagesThumbDir.Length;
                        string   filename3         = avatarsource.Substring(lengUploadString3);
                        FileInfo file3             = new FileInfo(Server.MapPath(AppEnv.UploadImagesThumbDir) + filename3);
                        if (file3.Exists)
                        {
                            file3.Delete();
                        }
                        FileInfo file4 = new FileInfo(Server.MapPath(AppEnv.UploadImagesNormalDir) + filename3);
                        if (file4.Exists)
                        {
                            file4.Delete();
                        }
                        FileInfo file5 = new FileInfo(Server.MapPath(AppEnv.UploadImagesOriginalDir) + filename3);
                        if (file5.Exists)
                        {
                            file5.Delete();
                        }
                    }

                    ContentImageDB.Delete(_contentId, id);

                    ImageDB.Delete(id);

                    lblStatusUpdate.Text = MiscUtility.UPDATE_SUCCESS;
                }
                catch
                {
                    lblStatusUpdate.Text = MiscUtility.UPDATE_ERROR;
                }
            }
            if (e.CommandName == "updaterow")
            {
                try
                {
                    int       id   = ConvertUtility.ToInt32(e.Item.Cells[0].Text);
                    ImageInfo info = ImageDB.GetInfo(id);

                    TextBox  txtPriority = (TextBox)e.Item.FindControl("txtPriority");
                    CheckBox chkVisible  = (CheckBox)e.Item.FindControl("chkVisible");
                    CheckBox chkCover    = (CheckBox)e.Item.FindControl("chkCover");

                    info.Image_Visible = ConvertUtility.ToBoolean(chkVisible.Checked);

                    ImageDB.Update(info);

                    ContentImageInfo ctinfo = ContentImageDB.GetInfo(_contentId, id);

                    ctinfo.Priority = ConvertUtility.ToInt32(txtPriority.Text);
                    ctinfo.IsCover  = ConvertUtility.ToBoolean(chkCover.Checked);

                    ContentImageDB.Update(ctinfo);

                    lblStatusUpdate.Text = MiscUtility.UPDATE_SUCCESS;
                }
                catch
                {
                    lblStatusUpdate.Text = MiscUtility.UPDATE_ERROR; //ex.ToString();
                }
            }
            if (e.CommandName == "editrow")
            {
                lblStatusUpdate.Text = lblStatusUpdate2.Text = string.Empty;

                var id   = ConvertUtility.ToInt32(e.Item.Cells[0].Text);
                var info = ImageDB.GetInfo(id);

                chkVisible.Checked = info.Image_Visible;
                txtName.Text       = info.Image_Name;
                txtTeaser.Text     = info.Image_Description;
                txtID.Text         = id.ToString();
            }
        }