Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in rptList.Items)
            {
                HiddenField hfContentID = item.FindControl("hfContentID") as HiddenField;
                TextBox     txtContent  = item.FindControl("txtContent") as TextBox;
                CheckBox    chkActive   = item.FindControl("chkActive") as CheckBox;

                int id = 0;
                if (hfContentID != null)
                {
                    int.TryParse(hfContentID.Value, out id);
                }

                DM.Content content = DomainManager.GetObject <DM.Content>(id);
                if (content != null)
                {
                    if (txtContent != null)
                    {
                        content.ContentText = TextInputUtil.GetSafeInput(txtContent.Text);
                    }

                    if (chkActive != null)
                    {
                        content.Active = chkActive.Checked;
                    }

                    DomainManager.Update(content);
                }
            }
            Utils.ShowMessage(lblMsg, "Cập nhật dữ liệu thành công");
        }
Beispiel #2
0
        protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (string.Compare(e.CommandName, "delete", true) == 0)
            {
                int id = 0;
                int.TryParse(e.CommandArgument.ToString(), out id);

                DM.Content content = DomainManager.GetObject <DM.Content>(id);
                if (content != null)
                {
                    DomainManager.Delete(content);
                    LoadData();
                    Utils.ShowMessage(lblMsg, "Xóa thông bthành công");
                }
            }
        }
Beispiel #3
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                DM.Content content = new DM.Content();
                content.ContentText = TextInputUtil.GetSafeInput(txtContent.Text);
                content.Active      = radYes.Checked;
                content.ContentType = ContentType;
                DomainManager.Insert(content);

                txtContent.Text = string.Empty;
                radYes.Checked  = true;
                radNo.Checked   = false;

                LoadData();
                Utils.ShowMessage(lblMsg, "Lưu banner thành công");
            }
        }
 protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item ||
         e.Item.ItemType == ListItemType.AlternatingItem)
     {
         DM.Content content    = e.Item.DataItem as DM.Content;
         Literal    litContent = e.Item.FindControl("litContent") as Literal;
         if (litContent != null)
         {
             if (content.ContentType != null && content.ContentType.IsBanner)
             {
                 litContent.Text = content.ContentText;
             }
             else
             {
                 litContent.Text = string.Format("<a class='anotice' href='/thong-bao/{0}/{1}' title='{2}'>{2}</a>", content.Id, content.ContentAlias, content.ContentTitle);
             }
         }
     }
 }
        protected void LoadData()
        {
            string strId = Page.RouteData.Values["id"] as string;
            int    id    = 0;

            int.TryParse(strId, out id);

            DM.Content content = TNHelper.GetContentObject(id);
            if (content != null)
            {
                litTitle.Text   = content.ContentTitle;
                litContent.Text = content.ContentText;

                if (content.ContentType != null)
                {
                    List <DM.Content> lst = TNHelper.GetContentsByType(content.ContentType.Id);
                    if (lst != null && lst.Count > 0)
                    {
                        lst = lst.Where(p => p.Active && p.Id < content.Id)
                              .OrderByDescending(p => p.Id)
                              .Take(10)
                              .ToList();
                    }

                    if (lst != null && lst.Count > 0)
                    {
                        rptList.DataSource = lst;
                        rptList.DataBind();
                    }
                }
            }
            else
            {
                Utils.ShowMessage(lblMsg, "Không tìm thấy dữ liệu yêu cầu");
            }
        }