Exemplo n.º 1
0
        protected void rptGroup_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rptNews  = (Repeater)item.FindControl("rptNews");
                Literal  ltrNews  = (Literal)item.FindControl("ltrNews");
                string   sGroupId = DataBinder.Eval(item.DataItem, "Id").ToString();
                if (dtNews.Rows.Count == 0)
                {
                    return;
                }
                DataRow[] drRows = dtNews.Select("GroupNewsId=" + sGroupId);
                if (drRows != null && drRows.Length > 0)
                {
                    DataTable dtTmp = PageHelper.ModifyData(drRows.CopyToDataTable(), Consts.CON_TIN_TUC);
                    DataRow   dr    = dtTmp.Rows[0];
                    ltrNews.Text += "<a href='" + dr["Link"].ToString() + "'>";
                    ltrNews.Text += "<img src='" + StringClass.ThumbImage(dr["Image"].ToString()) + "' title='" + dr["Name"].ToString() + "' alt='" + dr["Name"].ToString() + "' /></a>";
                    ltrNews.Text += "<h4><a href='" + dr["Link"].ToString() + "' title='" + dr["Name"].ToString() + "'>" + dr["Name"].ToString() + "</a></h4>";
                    dr.Delete();
                    dtTmp.AcceptChanges();
                    rptNews.DataSource = dtTmp;
                    rptNews.DataBind();
                }
            }
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Page.RouteData.Values["GroupId"] != null)
         {
             GroupId = Page.RouteData.Values["GroupId"] as string;
         }
         if (Lang == "en")
         {
             Page.Title = "VietNam Association Of Social Psychology";
         }
         else
         {
             Page.Title = "Hội Tâm Lý Học Xã Hội Việt Nam";
         }
         if (!IsPostBack)
         {
             if (Request.Cookies["CurrentLanguage"] != null)
             {
                 Lang = Request.Cookies["CurrentLanguage"].Value;
             }
             List <GroupImages> listGrp = GroupImagesService.GroupImages_GetByTop("", "Active=1 AND Language='" + Lang + "'", "Ord");
             if (listGrp.Count > 0)
             {
                 if (string.IsNullOrEmpty(GroupId))
                 {
                     GroupId = listGrp[0].Id;
                 }
                 for (int i = 0; i < listGrp.Count; i++)
                 {
                     if (listGrp[i].Id == GroupId)
                     {
                         GroupName  = listGrp[i].Name;
                         Page.Title = GroupName;
                         break;
                     }
                 }
                 rptGroupImages.DataSource = listGrp;
                 rptGroupImages.DataBind();
                 List <Data.Images> listImages = ImagesService.Images_GetByTop("", "Active = 1 AND GroupId = '" + GroupId + "'", "Ord");
                 for (int i = 0; i < listImages.Count; i++)
                 {
                     //ltrImages.Text += "<a href=http://unitegallery.net>\n";
                     ltrImages.Text += "<img alt='" + GroupName + "'\n";
                     ltrImages.Text += "src='" + StringClass.ThumbImage(listImages[i].Image) + "'\n";
                     ltrImages.Text += "data-image='" + listImages[i].Image + "'\n";
                     ltrImages.Text += "style='display:none'>";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message);
     }
 }
Exemplo n.º 3
0
        protected void rptNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rptGroupNewsSub = (Repeater)item.FindControl("rptGroupNewsSub");
                Repeater rptNews         = (Repeater)item.FindControl("rptNews");
                Repeater rptNewsOne      = (Repeater)item.FindControl("rptNewsOne");
                Literal  ltrNews         = (Literal)item.FindControl("ltrNews");

                if (rptGroupNewsSub != null)
                {
                    string    level    = DataBinder.Eval(item.DataItem, "Level").ToString();
                    string    sGroupId = DataBinder.Eval(item.DataItem, "Id").ToString();
                    DataRow[] drSub    = dtGrp.Select("LEN(level)=10 AND substring(level,1,5)='" + level.Substring(0, 5) + "'");
                    if (drSub != null && drSub.Length > 0)
                    {
                        rptGroupNewsSub.DataSource = drSub.CopyToDataTable();
                        rptGroupNewsSub.DataBind();
                    }
                    string strGroup = "(" + sGroupId;
                    for (int i = 0; i < drSub.Length; i++)
                    {
                        strGroup += "," + drSub[i]["Id"].ToString();
                    }
                    strGroup += ")";
                    DataRow[] drNews = dtNews.Select("GroupNewsId IN " + strGroup, "Date DESC");
                    if (drNews != null && drNews.Length > 0)
                    {
                        DataTable dtTemp    = PageHelper.ModifyData(drNews.CopyToDataTable(), Consts.CON_TIN_TUC);
                        DataTable dtNewsOne = dtTemp.AsEnumerable().Take(1).CopyToDataTable();
                        rptNewsOne.DataSource = dtNewsOne;
                        rptNewsOne.DataBind();
                        dtTemp.Rows[0].Delete();
                        dtTemp.AcceptChanges();
                        if (dtTemp.Rows.Count == 0)
                        {
                            return;
                        }
                        string sLink  = dtTemp.Rows[0]["Link"].ToString();
                        string sName  = dtTemp.Rows[0]["Name"].ToString();
                        string sImage = StringClass.ThumbImage(dtTemp.Rows[0]["Image"].ToString());
                        ltrNews.Text += "<li class='top1'><a href='" + sLink + "'>\n";
                        ltrNews.Text += "<img src='" + sImage + "' title='" + sName + "' alt='" + sName + "'><span>" + StringClass.FormatContentNews(sName, 100) + "</span></a></li>\n";

                        dtTemp.Rows[0].Delete();
                        dtTemp.AcceptChanges();
                        rptNews.DataSource = dtTemp.AsEnumerable().Take(4).CopyToDataTable();
                        rptNews.DataBind();
                    }
                }
            }
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Page.RouteData.Values["GroupId"] != null)
         {
             GroupId = Page.RouteData.Values["GroupId"] as string;
         }
         if (!IsPostBack)
         {
             List <GroupImages> listGrp;
             if (GroupId != null)
             {
                 listGrp = GroupImagesService.GroupImages_GetByTop("", "Active=1", "Ord");
             }
             else
             {
                 listGrp = GroupImagesService.GroupImages_GetById(GroupId);
             }
             if (listGrp.Count > 0)
             {
                 groupName = listGrp[0].Name;
                 List <Data.Images> listImages = ImagesService.Images_GetByTop("", "Active = 1 AND GroupId = '" + listGrp[0].Id + "'", "Ord");
                 for (int i = 0; i < listImages.Count; i++)
                 {
                     ltrImages.Text += "<a href=#>\n";
                     ltrImages.Text += "<img alt='" + groupName + "'\n";
                     ltrImages.Text += "src='" + StringClass.ThumbImage(listImages[i].Image) + "'\n";
                     ltrImages.Text += "data-image='" + listImages[i].Image + "'\n";
                     ltrImages.Text += "style='display:none'></a>";
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             DataTable dt = NewsService.News_GetByTop("5", "Active = 1 AND Priority <> 3", "Date DESC");
             if (dt.Rows.Count > 0)
             {
                 ltrNews.Text  = "<h4 class='title_block'>Tin mới nhất</h4>\n";
                 ltrNews.Text += "<div class='block_content products-block'>\n<ul>\n";
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     if (i == 0)
                     {
                         ltrNews.Text += "<li class='clearfix first_item'>\n";
                     }
                     else if (i == dt.Rows.Count - 1)
                     {
                         ltrNews.Text += "<li class='clearfix last_item'>\n";
                     }
                     else
                     {
                         ltrNews.Text += "<li class='clearfix'>\n";
                     }
                     ltrNews.Text += "<a class='products-block-image' title='" + dt.Rows[i]["Name"].ToString() + "' href='" + PageHelper.GeneralDetailUrl(Consts.CON_TIN_TUC, dt.Rows[i]["GroupNewsId"].ToString(), dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString()) + "'>\n";
                     ltrNews.Text += "<img width='200' alt='" + dt.Rows[i]["Name"].ToString() + "' src='" + StringClass.ThumbImage(dt.Rows[i]["Image"].ToString()) + "'></a>\n";
                     ltrNews.Text += "<div class='product-content'>\n";
                     ltrNews.Text += "<h5><a class='post-name product-name' title='" + dt.Rows[i]["Name"].ToString() + "' href='" + PageHelper.GeneralDetailUrl(Consts.CON_TIN_TUC, dt.Rows[i]["GroupNewsId"].ToString(), dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString()) + "'>" + dt.Rows[i]["Name"].ToString() + "</a></h5>\n";
                     ltrNews.Text += "<span class='info'>" + dt.Rows[i]["Date"].ToString() + "</span></div>\n";
                 }
                 ltrNews.Text += "</ul></div>\n";
             }
         }
     }
     catch (Exception ex)
     {
         MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace);
     }
 }