コード例 #1
0
        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;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void BindNewsEdit(long _news_id)
        {
            NewsRow      objNewsRow = NewsEditHelper.GetNewsInfo_NewsExtension(_news_id, false);
            MainSecurity objSercu   = new MainSecurity();
            Permission   objPer     = objSercu.GetPermission(Page.User.Identity.Name);

            if (objPer.isXuat_Ban_Bai)
            {
                //Kiểm tra nếu có quyền xuất bản thì sẽ hiện dầy đủ thông tin
                btnPublish.Visible = true;
                // pnControl.Visible = true;
            }
            else
            {
                btnPublish.Visible = false;
            }
            if (objNewsRow != null)
            {
                if (!objPer.isXuat_Ban_Bai && Page.User.Identity.Name.Trim().ToLower() != objNewsRow.News_Author.Trim().ToLower())
                {
                    throw new SecurityException("Bạn không có quyền truy cập vào trang này");
                    return;
                }



                ltrXuatBan.Text      = "Bài viết do \"" + objNewsRow.News_Approver.ToUpper() + "\" xuất bản lúc " + objNewsRow.News_PublishDate.ToString("dd/MM/yyyy hh:mm");
                lstCat.SelectedValue = objNewsRow.Cat_ID.ToString();
                txtTitle.Text        = objNewsRow.News_Title != null ? objNewsRow.News_Title : "";
                txtSubTitle.Text     = objNewsRow.News_Subtitle != null ? objNewsRow.News_Subtitle : "";
                txtSource.Text       = objNewsRow.News_Source != null ? objNewsRow.News_Source : "";
                txtInit.Text         = objNewsRow.News_InitialContent != null?NewsEditHelper.ReplaceImageSrcToEmoticon(objNewsRow.News_InitialContent) : "";

                txtInit.Text = txtInit.Text.Replace("<br/>", System.Environment.NewLine);
                if (Request.QueryString["redirect"] == null)
                {
                    NewsContent.Text       = objNewsRow.News_Content != null ? objNewsRow.News_Content : "";
                    Session["NewsContent"] = NewsContent.Text;
                }
                else
                {
                    NewsContent.Text = Session["NewsContent"].ToString();
                }
                chkIsFocus.Checked     = objNewsRow.IsNews_isFocusNull != true ? objNewsRow.News_isFocus : false;
                cboIsHot.SelectedValue = objNewsRow.IsNews_ModeNull != true?objNewsRow.News_Mode.ToString() : "0";

                hdRelatNews.Value      = objNewsRow.News_Relation != null ? objNewsRow.News_Relation : "";
                chkShowComment.Checked = objNewsRow.IsisCommentNull != true ? objNewsRow.isComment : false; //Cho phép hiện ảnh hay ko?
                chkShowRate.Checked    = objNewsRow.IsisUserRateNull != true ? objNewsRow.isUserRate : false;
                txtSelectedFile.Text   = objNewsRow.News_Image != null ? objNewsRow.News_Image : "";
                txtImageTitle.Text     = objNewsRow.News_ImageNote != null ? objNewsRow.News_ImageNote : "";
                txtIcon.Text           = objNewsRow.Icon != null ? objNewsRow.Icon : "";
                txtMaCP.Text           = objNewsRow.Extension1 != null ? objNewsRow.Extension1 : "";
                txtExtension2.Text     = objNewsRow.Extension2 != null ? objNewsRow.Extension2 : "";
                txtSourceLink.Text     = objNewsRow.Extension3 != null ? objNewsRow.Extension3 : "";


                ddlAuthor.SelectedValue = objNewsRow.IsExtension4Null != true?objNewsRow.Extension4.ToString() : "0";

                if (objNewsRow.Template != 0)
                {
                    ddlProvinces.SelectedValue = objNewsRow.Template.ToString();
                }

                if (objNewsRow.News_OtherCat != null)
                {
                    string[] strOthers = objNewsRow.News_OtherCat.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;
                            }
                        }
                    }
                }

                if (!objNewsRow.IsNews_PublishDateNull)
                {
                    SetValueForCombo(cboMonth, objNewsRow.News_PublishDate.Month.ToString());
                    SetValueForCombo(cboDay, objNewsRow.News_PublishDate.Day.ToString());
                    SetValueForCombo(cboYear, objNewsRow.News_PublishDate.Year.ToString());
                    SetValueForCombo(cboSercond, objNewsRow.News_PublishDate.Second.ToString());
                    SetValueForCombo(cboMinute, objNewsRow.News_PublishDate.Minute.ToString());
                    SetValueForCombo(cboHour, objNewsRow.News_PublishDate.Hour.ToString());
                }
                else
                {
                    SetValueForCombo(cboMonth, "0");
                    SetValueForCombo(cboDay, "0");
                    SetValueForCombo(cboYear, "2000");
                    SetValueForCombo(cboSercond, "-1");
                    SetValueForCombo(cboMinute, "-1");
                    SetValueForCombo(cboHour, "-1");
                }

                if (!IsPostBack)
                {
                    hdMedia.Value = DFISYS.BO.Editoral.NewsMedia.NewsMediaHelper.Get_ObjectId_By_NewsId(_news_id);
                    DataTable dtThread = ThreadHelper.SelectThreadByNewsID(_news_id);
                    if (dtThread != null && dtThread.Rows.Count > 0)
                    {
                        hidLuongSuKien.Value = dtThread.Rows[0]["Thread_ID"].ToString();
                    }
                }


                //Load data to Combobox Tin lien quan;
                string str;
                if (hdRelatNews.Value.TrimEnd(',') != "")
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("News_ID", "News_Title", "News", hdRelatNews.Value);
                    BindToDropdown(cboNews, str);
                }


                string strThread;
                if (hidLuongSuKien.Value.TrimEnd(',') != "")
                {
                    strThread = NewsEditHelper.Get_Media_By_ListsId("Thread_ID", "Title", "NewsThread", hidLuongSuKien.Value);
                    BindToDropdown(lstThread, strThread);

                    string[] arrThread = hidLuongSuKien.Value.Split(',');
                    if (arrThread != null && arrThread.Length > 0)
                    {
                        for (int i = 0; i < cblTags.Items.Count; i++)
                        {
                            foreach (string strItem in arrThread)
                            {
                                if (strItem == cblTags.Items[i].Value)
                                {
                                    cblTags.Items[i].Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (hdMedia.Value.TrimEnd(',').Length > 0)
                {
                    str = NewsEditHelper.Get_Media_By_ListsId("Object_ID", "Object_Url", "MediaObject", hdMedia.Value);
                    //BindToDropdown(cboMedia, str);
                }

                LoadAttachmentsType(_news_id);
            }
        }