Пример #1
0
        public static List <NewsBOL> GetAll(int id = 0)
        {
#if DEBUG
            _log.Debug("==================== Start ====================");
#endif
            List <NewsBOL> lst   = new List <NewsBOL>();
            string         query = "";
            if (id > 0)
            {
                query = string.Format("select * from vw_News where Type like '{0}' and ParentId = {1}", __type, id);
            }
            else
            {
                query = string.Format("select * from vw_News where Type like '{0}'", __type);
            }

            ResultData <DataSet> result = DataAccessHelpers.ExecuteQuery(query);
            if (result.Code < 0)
            {
                _log.Error(result.Message);
            }
            else if (result.Data != null && result.Data.Tables.Count > 0)
            {
                foreach (DataRow row in result.Data.Tables[0].Rows)
                {
                    NewsBOL news = new NewsBOL(row);
                    if (!news.Disable)
                    {
                        lst.Add(news);
                    }
                }
            }

            return(lst);
        }
Пример #2
0
        public static List <NewsBOL> GetTop(int top = 9)
        {
#if DEBUG
            _log.Debug("top: {0}", top);
#endif
            List <NewsBOL>       lst    = new List <NewsBOL>();
            string               query  = string.Format("select top({0}) * from vw_News where Type like '{1}'", top, __type);
            ResultData <DataSet> result = DataAccessHelpers.ExecuteQuery(query);
            if (result.Code < 0)
            {
                _log.Error(result.Message);
            }
            else if (result.Data != null && result.Data.Tables.Count > 0)
            {
                foreach (DataRow row in result.Data.Tables[0].Rows)
                {
                    NewsBOL news = new NewsBOL(row);
                    if (news.Disable)
                    {
                        continue;
                    }

                    lst.Add(news);
                }
            }

            return(lst);
        }
Пример #3
0
        protected void grvIntroItems_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.DataRow)
            {
                return;
            }

            try
            {
                string    id       = grvIntroItems.DataKeys[e.Row.RowIndex].Value.ToString();
                HyperLink newsLink = (HyperLink)e.Row.Cells[1].Controls[0];
                newsLink.NavigateUrl = string.Format("~/{0}?MenuId={1}&Id={2}", _navigationUrl, _menuId, id);
                //---
                DataRowView       rowView = (DataRowView)e.Row.DataItem;
                NewsBOL           news    = new NewsBOL(rowView.DataView.Table.Rows[e.Row.RowIndex]);
                HtmlInputCheckBox chx     = e.Row.Cells[3].FindControl("chkDisable") as HtmlInputCheckBox;
                chx.Attributes.Add("data-id", news.Id.ToString());
                if (news.Disable)
                {
                    chx.Checked = true;
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError("[ucNewsItems][grvIntroItems_RowDataBound]", ex.ToString());
            }
        }
Пример #4
0
        //
        public static NewsBOL GetWithType(string type, int id)
        {
#if DEBUG
            _log.Debug("type: {0} - id: {1}", type, id);
#endif
            string query = "";
            if (id > 0)
            {
                query = string.Format("select * from vw_News where Type like '{0}' and Id = {1}", type, id);
            }
            else
            {
                query = string.Format("select top(1) * from vw_News where Type like '{0}'", type);
            }

            ResultData <DataSet> result = DataAccessHelpers.ExecuteQuery(query);
            if (result.Code < 0)
            {
                _log.Error(result.Message);
            }
            else if (result.Data != null && result.Data.Tables.Count > 0 && result.Data.Tables[0].Rows.Count > 0)
            {
                NewsBOL news = new NewsBOL(result.Data.Tables[0].Rows[0]);
                if (!news.Disable)
                {
                    return(news);
                }
            }

            return(new NewsBOL());
        }
Пример #5
0
        private NewsBOL CreateNewsObject()
        {
            NewsBOL result = new NewsBOL()
            {
                Name_VN        = tbxNameVN.Text,
                Description_VN = tbxDesVN.Text,
                Content_VN     = txaContentVN.Text,
                //---
                Name_EN        = tbxNameEN.Text,
                Description_EN = tbxDesEN.Text,
                Content_EN     = txaContentEN.Text,
                //---
                InsertDate  = DateTime.Now,
                UpdatedDate = DateTime.Now
            };

            result.ImageLink = StartUploadImage();

            if (_menuId > 0)
            {
                result.MenuId   = _menuId;
                result.ParentId = _menuId;
            }

            int newsId = Utilities.GetRequestParameter("Id");

            if (newsId > 0)
            {
                result.Id = newsId;
            }

            return(result);
        }
Пример #6
0
        private void StartLoadNewsInfo(int id)
        {
            string tag = _tag + "[StartLoadNewsInfo]";

            var result = NewsDAL.Get(id);

            if (result.Code < 0)
            {
                LogHelpers.WriteError(tag, result.ErrorMessage);
                lbError.InnerText = result.ErrorMessage;
                lbError.Visible   = true;

                return;
            }

            lbError.Visible = false;
            if (result.Data.Tables[0].Rows.Count == 0)
            {
                return;
            }

            NewsBOL BOL = new NewsBOL(result.Data.Tables[0].Rows[0]);

            StartShowData(BOL);
        }
Пример #7
0
        protected void lvAbout_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            string tag = __tag + "[lvAbout_ItemDataBound]";

            if (e.Item.ItemType != ListViewItemType.DataItem)
            {
                return;
            }

            try
            {
                DataRowView row  = (DataRowView)e.Item.DataItem;
                NewsBOL     news = new NewsBOL(row.Row);
                //----
                Label lbName = (Label)e.Item.FindControl("lbName");
                lbName.Text = Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN;

                Literal ltrContent = (Literal)e.Item.FindControl("ltrContent");
                ltrContent.Text = Utilities.IsLangueEN() ?
                                  Utilities.SetFullLinkImage(news.Content_EN, Utilities.GetDirectory("ImageNewsDir")) :
                                  Utilities.SetFullLinkImage(news.Content_VN, Utilities.GetDirectory("ImageNewsDir"));
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
        }
Пример #8
0
        public void StartShowNewsDetail(NewsBOL news)
        {
            string tag = "[ucNewsDetail][StartShowNewsDetail]";

            if (news == null)
            {
                return;
            }

            try
            {
                bool langueEn = Utilities.IsLangueEN();

                lbUpdatedDate.InnerText = news.UpdatedDate.ToString("MM/dd/yyyy HH:mm zzz");
                lbTitle.InnerText       = Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN;
                ltrContent.Text         = Utilities.SetFullLinkImage(langueEn ? news.Content_EN : news.Content_VN,
                                                                     Utilities.GetDirectory("ImageNewsDir"));
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Пример #9
0
        private void StartShowData(NewsBOL BOL)
        {
            string tag = _tag + "[StartShowData]";

            try
            {
                tbxNameVN.Text    = BOL.Name_VN;
                tbxDesVN.Text     = BOL.Description_VN;
                txaContentVN.Text = Utilities.SetFullLinkImage(BOL.Content_VN,
                                                               Utilities.GetDirectory("ImagesDir"));
                //---
                tbxNameEN.Text = BOL.Name_EN;
                tbxDesEN.Text  = BOL.Description_EN;

                if (!string.IsNullOrEmpty(BOL.ImageLink))
                {
                    imgImage.ImageUrl = "~/" + Path.Combine(Utilities.GetDirectory("ImagesDir"), BOL.ImageLink);
                    imgImage.Visible  = true;
                }
                else
                {
                    imgImage.Visible = false;
                }

                txaContentEN.Text = Utilities.SetFullLinkImage(BOL.Content_EN,
                                                               Utilities.GetDirectory("ImagesDir"));

                ddlVacancy.Items.FindByValue(BOL.VacancyId).Selected   = true;
                ddlVacancyEN.Items.FindByValue(BOL.VacancyId).Selected = true;
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError(tag, ex.ToString());
            }
        }
Пример #10
0
        public ActionResult Details(int?id)
        {
            if (!id.HasValue || id.Value <= 0)
            {
                return(RedirectToAction("Index"));
            }

            NewsBOL news = NewsDAL.Get(id.Value);

            return(View(news));
        }
Пример #11
0
        public static ResultBOL <int> InsertOrUpdate(NewsBOL BOL)
        {
            string imageDir = Utilities.GetDirectory("ImageNewsDir");

            BOL.Content_VN = Utilities.ReplaceImageUri(BOL.Content_VN, imageDir);
            BOL.Content_EN = Utilities.ReplaceImageUri(BOL.Content_VN, imageDir);

            string stored = "sp_News_Insert_Update";
            var    result = DataAccessHelpers.ExecuteStored(stored, BOL.GetParameters());

            return(result);
        }
Пример #12
0
        public void StartBindingDataNews(int menuId, int id, string navigationUrl, string header)
        {
            string tag = __tag + "[StartBindingDataNews]";

            //--
            lbHeader.InnerText = header;

            if (menuId <= 0)
            {
                return;
            }

            try
            {
                var result = NewsDAL.GetAll(menuId);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    //---
                    LogHelpers.WriteError(tag, result.ErrorMessage);
                    return;
                }

                if (result.Data.Tables.Count == 0 || result.Data.Tables[0].Rows.Count == 0)
                {
                    return;
                }

                ucNewsList.StartBindingData(result.Data, menuId, navigationUrl);
                //--
                if (id <= 0)
                {
                    NewsBOL news = new NewsBOL(result.Data.Tables[0].Rows[0]);
                    lbHeader.InnerText = Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN;
                    //--
                    ucNewsDetail.StartShowNewsDetail(news);
                }
                else
                {
                    StartLoadNewsDetail(id);
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //--
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Пример #13
0
        public ActionResult Details(int id = 0)
        {
#if DEBUG
            _log.Debug("id: {0}", id);
#endif
            ViewBag.PageType = __type;
            NewsBOL model = NewsDAL.GetWithType(__type, id);
            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Пример #14
0
        private void StartAddSubItemAbout(HtmlGenericControl li, int menuId)
        {
            string tag = __tag + "[StartAddSubItemAbout]";

            if (menuId <= 0)
            {
                return;
            }

            var result = NewsDAL.GetAll(menuId);

            if (result.Code < 0)
            {
                LogHelpers.WriteError(tag, result.ErrorMessage);
                return;
            }

            if (result.Data.Tables.Count == 0 || result.Data.Tables[0].Rows.Count < 0)
            {
                return;
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            foreach (DataRow row in result.Data.Tables[0].Rows)
            {
                try
                {
                    NewsBOL news = new NewsBOL(row);
                    //---
                    HtmlGenericControl subLi = new HtmlGenericControl("li");
                    subLi.InnerHtml = string.Format("<a href='{0}#{1}'>{2}</a>",
                                                    Utilities.GetNavigationUrl("AboutPage"),
                                                    news.Id,
                                                    Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN);
                    //----
                    ul.Controls.Add(subLi);
                }
                catch (Exception ex)
                {
                    LogHelpers.WriteException(tag, ex.ToString());
                }
            }

            if (ul.Controls.Count > 0)
            {
                li.Controls.Add(ul);
            }
        }
Пример #15
0
        protected void lvNews_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            string tag = __tag + "[lvNews_ItemDataBound]";

            if (e.Item.ItemType != ListViewItemType.DataItem)
            {
                return;
            }

            try
            {
                Image img = (Image)e.Item.FindControl("imgImageLink");

                if (string.IsNullOrEmpty(img.ImageUrl))
                {
                    img.ImageUrl = Utilities.GetApplicationSettingsValue("NoImageUrl");
                }
                else
                {
                    img.ImageUrl = Path.Combine(Utilities.GetDirectory("ImageNewsDir"),
                                                img.ImageUrl);
                }

                DataRowView rowView = (DataRowView)e.Item.DataItem;
                NewsBOL     news    = new NewsBOL(rowView.Row);

                HyperLink hplDetail = (HyperLink)e.Item.FindControl("hplName");
                hplDetail.Text        = Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN;
                hplDetail.NavigateUrl = string.Format("~/{0}?Id={1}",
                                                      _navigationUrl,
                                                      hplDetail.NavigateUrl);

                Label lbDes = (Label)e.Item.FindControl("lbDes");
                if (!string.IsNullOrEmpty(news.Description_EN) || !string.IsNullOrEmpty(news.Description_VN))
                {
                    lbDes.Text = Utilities.IsLangueEN() ? news.Description_EN : news.Description_VN;
                }
                else
                {
                    lbDes.Text = Utilities.IsLangueEN() ? news.Content_EN : news.Content_VN;
                }
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
        }
Пример #16
0
        public static AllCategoriesModel GetAllServices(int id = 0)
        {
#if DEBUG
            _log.Debug("=================== Start ==================");
#endif
            string stored = "sp_GetAllData_WithType";
            object obj    = new {
                Type = "DichVu",
                Id   = id
            };

            ResultData <DataSet> result = DataAccessHelpers.ExecuteStoredReturnDataSet(stored, obj);
            if (result.Code < 0)
            {
                _log.Error(result.Message);
            }

            AllCategoriesModel model = new AllCategoriesModel();

            if (result.Data != null && result.Data.Tables.Count > 1)
            {
                foreach (DataRow row in result.Data.Tables[0].Rows)
                {
                    MenuBOL menu = new MenuBOL(row);
                    if (menu.ParentId > 0)
                    {
                        model.Roots.Add(menu);
                    }
                }

                foreach (DataRow row in result.Data.Tables[1].Rows)
                {
                    NewsBOL news = new NewsBOL(row);
                    if (!news.Disable)
                    {
                        model.News.Add(news);
                    }
                }
            }

            return(model);
        }
Пример #17
0
        public static NewsBOL Get(int id)
        {
#if DEBUG
            _log.Debug("id: {0}", id);
#endif
            string query = string.Format("select * from vw_News where Id = {0}", id);
            ResultData <DataSet> result = DataAccessHelpers.ExecuteQuery(query);
            if (result.Code < 0)
            {
                _log.Error(result.Message);
            }
            else if (result.Data != null && result.Data.Tables.Count > 0 && result.Data.Tables[0].Rows.Count > 0)
            {
                NewsBOL news = new NewsBOL(result.Data.Tables[0].Rows[0]);
                if (!news.Disable)
                {
                    return(news);
                }
            }

            return(null);
        }
Пример #18
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                NewsBOL BOL    = CreateNewsObject();
                var     result = NewsDAL.InsertOrUpdate(BOL);

                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }

                lbError.Visible = false;
                GoBackPage();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError("[ucNewsItems][btnSubmit_Click]", ex.ToString());
            }
        }
Пример #19
0
        protected void lvHomeNews_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType != ListViewItemType.DataItem)
            {
                return;
            }

            string tag = __tag + "[lvHomeNews_ItemDataBound]";

            LogHelpers.WriteStatus(tag, "Start...");

            try
            {
                Image img = (Image)e.Item.FindControl("imgNews");

                if (string.IsNullOrEmpty(img.ImageUrl))
                {
                    img.ImageUrl = Utilities.GetNoImageUrl();
                }
                else
                {
                    img.ImageUrl = Path.Combine(Utilities.GetDirectory("ImageNewsDir"), img.ImageUrl);
                }

                NewsBOL   news    = new NewsBOL((e.Item.DataItem as DataRowView).Row);
                HyperLink hplName = (HyperLink)e.Item.FindControl("hplName");
                hplName.Text = Utilities.IsLangueEN() ? news.Name_EN : news.Name_VN;
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }
            finally
            {
                LogHelpers.WriteStatus(tag, "End.");
            }
        }
Пример #20
0
        public void StartShowNewsDetail(int newsId)
        {
            string tag = "[ucNewsDetail][StartShowNewsDetail]";

            if (newsId <= 0)
            {
                return;
            }

            var result = NewsDAL.Get(newsId);

            if (result.Code < 0)
            {
                lbError.InnerText = result.ErrorMessage;
                lbError.Visible   = true;

                return;
            }

            lbError.Visible = false;
            try
            {
                bool langueEn = Utilities.IsLangueEN();
                //--
                NewsBOL news = new NewsBOL(result.Data.Tables[0].Rows[0]);
                lbUpdatedDate.InnerText = news.UpdatedDate.ToString("MM/dd/yyyy HH:mm zzz");
                lbTitle.InnerText       = langueEn ? news.Name_EN : news.Name_VN;
                ltrContent.Text         = Utilities.SetFullLinkImage(langueEn ? news.Content_EN : news.Content_VN,
                                                                     Utilities.GetDirectory("ImageNewsDir"));
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Пример #21
0
        private void StartLoadNewsDetail(int id)
        {
            string tag = __tag + "[StartShowNewsDetail]";

            if (id <= 0)
            {
                return;
            }

            var result = NewsDAL.Get(id);

            if (result.Code < 0)
            {
                lbError.InnerText = result.ErrorMessage;
                lbError.Visible   = true;

                return;
            }

            lbError.Visible = false;
            try
            {
                bool langueEn = Utilities.IsLangueEN();
                //--
                NewsBOL news = new NewsBOL(result.Data.Tables[0].Rows[0]);
                lbHeader.InnerText = langueEn ? news.Name_EN : news.Name_VN;
                //--
                ucNewsDetail.StartShowNewsDetail(news);
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }
        }
Пример #22
0
        public ActionResult Index(int id = 0)
        {
            NewsBOL news = AboutDAL.Get(id);

            return(View(news));
        }