protected void UpdateRelatedMedia(string productID, string tmpID)
        {
            #region Cap nhap vao bang MediaObject
            // Xoa tat ca News_Media cu theo NewsID
            string strObjectId = NewsMediaHelper.Get_ObjectId_By_FilmId(tmpID);
            if (strObjectId != null && strObjectId != "")
            {
                string[] mediaIds = strObjectId.Split(",".ToCharArray());
                foreach (string strMediaId in mediaIds)
                {
                    NewsMediaHelper.DeleteNews_Media_Film_Object_By_FilmIdAndObjectId(tmpID, strMediaId);
                }
            }

            //truong hop co media object
            if (!string.IsNullOrEmpty(hdMedia.Value))
            {
                News_MediaRow objMrow  = null;
                string[]      mediaIds = hdMedia.Value.Split(",".ToCharArray());
                using (MainDB objDb = new MainDB())
                {
                    foreach (string strMediaId in mediaIds)
                    {
                        objMrow           = new News_MediaRow();
                        objMrow.Film_ID   = productID;
                        objMrow.Object_ID = int.Parse(strMediaId);
                        objDb.News_MediaCollection.Insert(objMrow);
                    }
                }
            }

            #endregion
        }
        private void BindData()
        {
            if (ID > 0)
            {
                var productObj = productController.SelectProduct(ID);
                if (productObj != null)
                {
                    txt_Name.Value            = productObj.ProductName;
                    txt_Name_En.Value         = productObj.ProductName_En;
                    txt_Summary.Value         = productObj.ProductSumary;
                    txt_Sum_En.Value          = productObj.ProductSumary_En;
                    txtSelectedFile.Value     = productObj.ProductAvatar;
                    NewsContent.Text          = productObj.ProductDescription;
                    NewsContent_En.Text       = productObj.ProductDescription_En;
                    txt_Cost.Value            = productObj.ProductCost.ToString();
                    ddlCategory.SelectedValue = productObj.ProductCategory.ToString();
                    txt_Video.Text            = productObj.ProductVideo;
                    txt_tags.Value            = productObj.ProductTag;
                    ddlLayout.SelectedValue   = productObj.ProductLayout.ToString();
                    cb_IsActive.Checked       = productObj.IsActive;
                    ddlGift.SelectedValue     = productObj.ProductColor.ToString();
                    productType.Items.FindByValue(productObj.ProductType.ToString()).Selected = true;
                    try
                    {
                        hdMedia.Value = NewsMediaHelper.Get_ObjectId_By_FilmId(productObj.Id.ToString());

                        if (hdMedia.Value.TrimEnd(',').Length > 0)
                        {
                            BindToDropdown(cboMedia, NewsEditHelper.Get_Media_By_ListsId("Object_ID", "Object_Url", "MediaObject", hdMedia.Value));
                        }
                    }
                    catch (Exception ex)
                    {
                    }


                    if (productObj.ProductOtherCat != null)
                    {
                        string[] strOthers = productObj.ProductOtherCat.Split(",".ToCharArray());
                        for (int i = 0; i < lstOtherCat.Items.Count; i++)
                        {
                            foreach (string strItem in strOthers)
                            {
                                if (strItem == lstOtherCat.Items[i].Value)
                                {
                                    lstOtherCat.Items[i].Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        private void ShowSelectedMedia()
        {
            string strNewsId  = Request.QueryString["newsid"] != null ? Request.QueryString["newsid"] : "";
            string str_FilmId = Request.QueryString["pid"] != null ? Request.QueryString["pid"].ToString().Trim() : "";
            string str_Type   = Request.QueryString["type"] != null ? Request.QueryString["type"].ToString().Trim() : "";
            string strWhere   = "";

            if (str_Type.ToLower() == "ShowAll".ToLower())
            {
                strWhere = " AND 1=1";
                //lnkAddMedia.Visible = false;
                //ltrAddMedia.Visible = false;
            }
            else if (strNewsId.Trim() != "")
            {
                string strObject_Id = NewsMediaHelper.Get_ObjectId_By_NewsId(Convert.ToInt64(strNewsId));
                if (strObject_Id.Trim() != "")
                {
                    strWhere = " AND News_Media.Object_ID IN (" + strObject_Id + ")";
                }

                ShowGridCol(5);
            }
            else if (str_FilmId.Trim() != "")
            {
                string strObject_Id = NewsMediaHelper.Get_ObjectId_By_FilmId(str_FilmId);
                if (strObject_Id.Trim() != "")
                {
                    strWhere = " AND News_Media.Object_ID IN (" + strObject_Id + ")";
                }

                ShowGridCol(5);
            }
            else if (Session["Object_Id"] != null && Session["Object_Id"].ToString() != "")
            {
                // Neu Tao Bai viet moi hay tao film moi
                strWhere = " AND News_Media.Object_ID IN (" + Session["Object_Id"].ToString().Substring(1) + ")";
            }
            else
            {
                // Neu Tao moi Film va News Thi khong hien thi Media nao ca
                strWhere = " And News_Media.Object_ID = -2 ";
            }

            if (strWhere.Trim() != "")
            {
                objNewsMediaSource.SelectParameters[0].DefaultValue = "UserID='" + ChannelUsers.GetUserName() + "'" + strWhere;
            }
            else
            {
                objNewsMediaSource.SelectParameters[0].DefaultValue = "UserID='" + ChannelUsers.GetUserName() + "'" + " AND News_Media.Object_ID = -1 ";
            }
        }
Exemple #4
0
        protected void lnkRealDel_Click(object sender, EventArgs e)
        {
            string strCheckedRow = getCheckedRow();

            if (strCheckedRow != null && strCheckedRow != "")
            {
                string[] strArCheckedRow = strCheckedRow.Split(',');
                foreach (string strObjectId in strArCheckedRow)
                {
                    // Check xem image này mà đang được chọn trong bài viết thì không được xóa
                    if (NewsMediaHelper.Check_Exist_News_Media_ByObjectId(strObjectId))
                    {
                        Page.RegisterClientScriptBlock("CannotDeleteImage", "<script language='javascript'>alert('Có một số image bạn không thể xóa được !');</script>");
                    }
                    else
                    {
                        // Neu khong dc su dung thi co the xoa di duoc
                        objNewsMediaSource.DeleteParameters[0].DefaultValue = strObjectId;
                        objNewsMediaSource.Delete();
                    }
                }
            }
        }
Exemple #5
0
        protected void grdMedia_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow grdrow = this.grdMedia.Rows[e.RowIndex];

            if (grdrow != null)
            {
                ImageButton btnSave = grdrow.FindControl("imgSave") as ImageButton;
                if (btnSave != null)
                {
                    // Check xem image này mà đang được chọn trong bài viết thì không được xóa
                    string object_id = btnSave.CommandArgument;
                    if (NewsMediaHelper.Check_Exist_News_Media_ByObjectId(object_id))
                    {
                        Page.RegisterClientScriptBlock("CannotDeleteImage", "<script language='javascript'>alert('Bạn không thể xóa image này được!');</script>");
                    }
                    else
                    {
                        objNewsMediaSource.DeleteParameters[0].DefaultValue = btnSave.CommandArgument;
                        objNewsMediaSource.Delete();
                    }
                }
            }
            this.grdMedia.EditIndex = -1;
        }
Exemple #6
0
        protected void grdMedia_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "NewMediaObject".ToLower())
            {
                GridViewRow grdrow = this.grdMedia.FooterRow;
                if (grdrow != null)
                {
                    TextBox      txtINote = grdrow.FindControl("txtINote") as TextBox;
                    DropDownList cboType  = grdrow.FindControl("cboIType") as DropDownList;
                    FileUpload   flObject = grdrow.FindControl("flObject") as FileUpload;
                    if (cboType != null)
                    {
                        if (flObject.FileName != "")
                        {
                            objNewsMediaSource.InsertParameters[0].DefaultValue = flObject.FileName;
                            objNewsMediaSource.InsertParameters[1].DefaultValue = cboType.SelectedValue;
                            objNewsMediaSource.InsertParameters[2].DefaultValue = txtINote.Text;
                            objNewsMediaSource.InsertParameters[3].DefaultValue = ChannelUsers.GetUserName();
                            objNewsMediaSource.Insert();
                            //thuc hien upload anh vao thu muc Share

                            if (DFISYS.FileHelper.isFileMediaObject(flObject.FileName))
                            {
                                //duong dan den thu muc upload1
                                string strFolder = "Images2018/Uploaded/";
                                string strType   = "Picture";
                                if (cboType.SelectedValue != "1")
                                {
                                    strType = "Video";
                                }
                                string strFileUploaded = DFISYS.FileHelper.UploadMediaObject(strFolder, "Share/Media/" + strType, flObject.PostedFile, 125);
                            }
                        }

                        //ShowSelectedMedia();
                        //grdMedia.DataBind();
                    }
                }
            }

            if (e.CommandName.ToLower() == "DeleteMedia".ToLower())
            {
                string str_MediaId = e.CommandArgument.ToString().Trim();
                string str_Newsid  = Request.QueryString["newsid"] != null ? Request.QueryString["newsid"].ToString().Trim() : "";
                string str_FilmId  = Request.QueryString["filmid"] != null ? Request.QueryString["filmid"].ToString().Trim() : "";

                /*
                 * if (str_Newsid.Trim() != "")
                 * {
                 *  NewsMediaHelper.Delete_News_Media_ByNewsIdAndObjectId(Convert.ToInt64(str_Newsid), str_MediaId);
                 *
                 * }
                 * else
                 * if (str_FilmId.Trim() != "")
                 * {
                 *  NewsMediaHelper.DeleteNews_Media_Film_Object_By_FilmIdAndObjectId(Convert.ToInt32(str_FilmId), Convert.ToInt32(str_MediaId));
                 *
                 *
                 * }
                 */

                if (NewsMediaHelper.Check_Exist_News_Media_ByObjectId(str_MediaId))
                {
                    Page.RegisterClientScriptBlock("CannotDeleteImage", "<script language='javascript'>alert('Có một số image bạn không thể xóa được !');</script>");
                }
                else
                {
                    // Neu khong dc su dung thi co the xoa di duoc
                    objNewsMediaSource.DeleteParameters[0].DefaultValue = str_MediaId;
                    objNewsMediaSource.Delete();
                }

                grdMedia.DataBind();
            }
        }