Esempio n. 1
0
        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                ImageAlbum banner = db.ImageAlbums.SingleOrDefault(c => c.ImageAlbumId.ToString() == e.CommandArgument.ToString());

                if (e.CommandName == "Show")
                {
                    banner.Ishow = !banner.Ishow;
                    db.SubmitChanges();

                    LoadGridView(Convert.ToInt32(ddlCategory.SelectedValue));
                }
                if (e.CommandName == "Delete")
                {
                    if (banner != null)
                    {
                        //delete ảnh nếu có
                        if (ParadiseHotelPath.Banner_Image_Default != banner.ImageAlbumUrl)//khác default
                        {
                            ParadiseHotelFile.DeleteFile(Setup.host + banner.ImageAlbumUrl);
                        }
                        if (ParadiseHotelPath.Banner_Image_Default != banner.ImageAlbumUrlSmall)//khác default
                        {
                            ParadiseHotelFile.DeleteFile(Setup.host + banner.ImageAlbumUrlSmall);
                        }

                        db.ImageAlbums.DeleteOnSubmit(banner);
                        db.SubmitChanges();
                        messSuccess.Visible       = true;
                        messSuccessText.InnerText = "Xóa 1 bản ghi thành công!";
                        LoadGridView(Convert.ToInt32(ddlCategory.SelectedValue));
                    }
                }
                if (e.CommandName == "Edit")
                {
                    Response.Redirect("UpdateBanner.aspx?ID=" + e.CommandArgument.ToString());
                }
                //if (e.CommandName == "Preview")
                //{
                //    Response.Redirect("ChiTietTin.aspx?ID= " + e.CommandArgument.ToString());
                //}
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                //phương thức xóa nhiều tin

                int i = 0;

                foreach (GridViewRow row in gvList.Rows)
                {
                    CheckBox chk = (CheckBox)row.FindControl("chkSelect");
                    if (chk != null)
                    {
                        if (chk.Checked)
                        {
                            LinkButton lbt    = (LinkButton)row.FindControl("lbtDelete");
                            ImageAlbum banner = db.ImageAlbums.SingleOrDefault(c => c.ImageAlbumId.ToString() == lbt.CommandArgument.ToString());
                            if (banner != null)
                            {
                                //delete ảnh nếu có
                                if (ParadiseHotelPath.Banner_Image_Default != banner.ImageAlbumUrl)//khác default
                                {
                                    ParadiseHotelFile.DeleteFile(Setup.host + banner.ImageAlbumUrl);
                                }
                                if (ParadiseHotelPath.Banner_Image_Default != banner.ImageAlbumUrlSmall)//khác default
                                {
                                    ParadiseHotelFile.DeleteFile(Setup.host + banner.ImageAlbumUrlSmall);
                                }
                            }
                            db.ImageAlbums.DeleteOnSubmit(banner);
                            i++;
                        }
                    }
                }
                messSuccess.Visible       = true;
                messSuccessText.InnerText = "Xóa " + i + " bản ghi thành công!";
                db.SubmitChanges();


                LoadGridView(Convert.ToInt32(ddlCategory.SelectedValue));
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
 partial void DeleteImageAlbum(ImageAlbum instance);
Esempio n. 4
0
 partial void UpdateImageAlbum(ImageAlbum instance);
Esempio n. 5
0
 partial void InsertImageAlbum(ImageAlbum instance);
Esempio n. 6
0
 private void detach_ImageAlbums(ImageAlbum entity)
 {
     this.SendPropertyChanging();
     entity.Category = null;
 }
        /// <summary>
        /// Thêm mới
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //try
            //{

            if (CheckCondition())
            {
                var    cn    = new ImageAlbum();
                string index = ddlCategory.SelectedValue.Trim();
                if (index != "-1")
                {
                    cn.CategoryId = Convert.ToInt32(ddlCategory.SelectedValue);
                }


                cn.ImageAlbumText = txtNote.Text;
                cn.ImageOrder     = Convert.ToInt32(txtNumber.Text);
                cn.Ishow          = true;
                cn.ImageTag       = txtImageTag.Text;
                // xu ly anh

                if (fulImage.HasFile)
                {
                    if (ParadiseHotelFile.IsFileImage(fulImage.FileName))
                    {
                        ParadiseHotelFile.CreateFoder(Setup.host + ParadiseHotelPath.Banner_Image_Small_Upload);
                        ParadiseHotelFile.CreateFoder(Setup.host + ParadiseHotelPath.Banner_Image_Upload);
                        if (ParadiseHotelFile.StrFoder != "")
                        {
                            ParadiseHotelFile.CreateFile(ParadiseHotelFile.StrFoder,
                                                         ParadiseHotelFile.StyleFile.HOUR_MINUTE_SECOND.ToString(),
                                                         fulImage.FileName);



                            if (ParadiseHotelFile.StrFile != "")
                            {
                                fulImage.PostedFile.SaveAs(ParadiseHotelFile.StrFile);
                                ParadiseHotelFile.ThayDoiKichThuocAnhNho(ParadiseHotelFile.StrFoder + "Small", ParadiseHotelFile.StrFile.Substring(ParadiseHotelFile.StrFile.LastIndexOf('/') + 1), 200, fulImage.PostedFile.InputStream);
                                cn.ImageAlbumUrlSmall = ParadiseHotelFile.StrFile.Replace(Setup.host, "").Replace("Banner", "BannerSmall");
                                cn.ImageAlbumUrl      = ParadiseHotelFile.StrFile.Replace(Setup.host, "");
                            }
                            else
                            {
                                cn.ImageAlbumUrl      = ParadiseHotelPath.Banner_Image_Default;
                                cn.ImageAlbumUrlSmall = ParadiseHotelPath.Banner_Image_Default;
                            }
                        }
                        else
                        {
                            cn.ImageAlbumUrl      = ParadiseHotelPath.Banner_Image_Default;
                            cn.ImageAlbumUrlSmall = ParadiseHotelPath.Banner_Image_Default;
                        }
                    }
                    else
                    {
                        cn.ImageAlbumUrl      = ParadiseHotelPath.Banner_Image_Default;
                        cn.ImageAlbumUrlSmall = ParadiseHotelPath.Banner_Image_Default;
                    }
                }
                else
                {
                    cn.ImageAlbumUrl      = ParadiseHotelPath.Banner_Image_Default;
                    cn.ImageAlbumUrlSmall = ParadiseHotelPath.Banner_Image_Default;
                }

                db.ImageAlbums.InsertOnSubmit(cn);
                db.SubmitChanges();
                Clear();
                messError.Visible   = false;
                messSuccess.Visible = true;
            }
            //}
            //catch (Exception)
            //{

            //}
        }