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;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 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 ";
            }
        }