public void StartBindingData(int menuId)
        {
            _navigationUrl = "ProjectDetail.aspx";
            _menuId        = menuId;

            try
            {
                var result = ProjectsDAL.GetAll(menuId);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;

                    return;
                }

                lbError.Visible              = false;
                _dataSource                  = result.Data.Tables[0];
                grvProjectItems.DataSource   = result.Data;
                grvProjectItems.DataKeyNames = new string[] { "Id" };
                grvProjectItems.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteError("[ucProjectItems][StartBindingData] Exception: " + ex.ToString());
            }
        }
Beispiel #2
0
 public TranslationBL(
     TranslationsDAL translationsDAL,
     PhrasesDAL phrasesDAL,
     ProjectsDAL projectsDAL
     )
 {
     _translationsDAL = translationsDAL;
     _phrasesDAL      = phrasesDAL;
     _projectsDAL     = projectsDAL;
 }
Beispiel #3
0
        private void StartLoadProjectInfo(int id)
        {
            if (id <= 0)
            {
                return;
            }

            var result = ProjectsDAL.Get(id);

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

                return;
            }

            lbError.Visible = false;
            //---
            ProjectBOL BOL = new ProjectBOL(result.Data.Tables[0].Rows[0]);

            if (BOL == null)
            {
                return;
            }

            StartLoadProjectImages(BOL.ImageLink);

            tbxNameVN.Text     = BOL.Name_VN;
            tbxDesVN.Text      = BOL.Description_VN;
            tbxAddress_VN.Text = BOL.Address_VN;
            txaContentVN.Text  = Utilities.SetFullLinkImage(BOL.Content_VN,
                                                            Utilities.GetDirectory("ImageProjectsDir"));
            //chkChooseCategory.Checked = BOL.IsRedirectUrl == "Yes" ? true : false;
            //tbxRedirectLink.Text = BOL.RedirectUrl;
            //---
            tbxNameEN.Text     = BOL.Name_EN;
            tbxDesEN.Text      = BOL.Description_EN;
            tbxAddress_EN.Text = BOL.Address_EN;
            txaContentEN.Text  = Utilities.SetFullLinkImage(BOL.Content_EN,
                                                            Utilities.GetDirectory("ImageProjectsDir"));
            //---
            if (BOL.StartDate != null &&
                BOL.StartDate != DateTime.MinValue)
            {
                tbxStartDate.Text = BOL.StartDate.ToString("MM/dd/yyyy");
            }

            if (BOL.EndDate != null &&
                BOL.EndDate != DateTime.MinValue)
            {
                tbxEndDate.Text = BOL.EndDate.ToString("MM/dd/yyyy");
            }
        }
        public void StartDeleteProjects()
        {
            if (this.grvProjectItems.Rows.Count == 0)
            {
                return;
            }

            string listId = string.Empty;

            for (int i = 0; i < grvProjectItems.Rows.Count; i++)
            {
                GridViewRow row = grvProjectItems.Rows[i];

                HtmlInputCheckBox chx = row.Cells[0].FindControl("chkRowItem") as HtmlInputCheckBox;

                if (!chx.Checked)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(listId))
                {
                    listId += ",";
                }

                listId += grvProjectItems.DataKeys[i].Value.ToString();
            }

            if (!string.IsNullOrEmpty(listId))
            {
                var result = ProjectsDAL.DeleteAll(listId);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    return;
                }

                lbError.Visible = false;
                if (result.Data != null &&
                    result.Data.Tables.Count > 0 &&
                    result.Data.Tables[0].Rows.Count > 0)
                {
                    StartShowDeleteErrors(result);
                }
            }
        }
Beispiel #5
0
        public void StartShowProjectDetail(int projectId)
        {
            string tag = __tag + "[StartShowProjectDetail]";

            LogHelpers.WriteStatus(tag, "PeojectId = " + projectId.ToString(), "Start.");

            if (projectId <= 0)
            {
                return;
            }

            try
            {
                var result = ProjectsDAL.Get(projectId);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    //--
                    LogHelpers.WriteError(tag, result.ErrorMessage);

                    return;
                }

                lbError.Visible = false;
                //--
                ProjectBOL project = new ProjectBOL(result.Data.Tables[0].Rows[0]);
                lbHeader.InnerText      = Utilities.IsLangueEN() ? project.Name_EN : project.Name_VN;
                lbUpdatedDate.InnerText = project.UpdatedDate.ToString("MM/dd/yyyy HH:mm");
                //---
                ltrContent.Text = Utilities.SetFullLinkImage(
                    Utilities.IsLangueEN() ? project.Content_EN : project.Content_VN,
                    Utilities.GetDirectory("ImageProjectsDir"));
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //---
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }

            LogHelpers.WriteStatus(tag, "PeojectId = " + projectId.ToString(), "End.");
        }
Beispiel #6
0
        public void StartLoadProjectInfo(int id)
        {
            string tag = __tag + "[StartLoadProjectInfo]";

            //---
            LogHelpers.WriteStatus(tag, "Id = " + id, "Start...");
            //---
            if (id <= 0)
            {
                return;
            }
            _selectedId = id;

            try
            {
                var result = ProjectsDAL.GetAllFromParent(id);
                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    //---
                    return;
                }

                lbError.Visible = false;
                //---
                StartLoadProjectDetail(result.Data.Tables[0].Rows[0]);
                //---
                _itemsCount = result.Data.Tables[1].Rows.Count;
                //---
                lvProjectsCarousel.DataSource = result.Data.Tables[1];
                lvProjectsCarousel.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //---
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }

            LogHelpers.WriteStatus(tag, "End.");
        }
        public void StartLoadTopNew()
        {
            string tag = __tag + "[StartLoadTopNew]";

            LogHelpers.WriteStatus(tag, "Start.");
            try
            {
                var result = ProjectsDAL.GetTopProjects(
                    int.Parse(Utilities.GetApplicationSettingsValue("HomeProject-Items")),
                    0);

                if (result.Code < 0)
                {
                    LogHelpers.WriteError(tag, result.ErrorMessage);
                    hfScanTime.Value          = "-1";
                    hfScanTimeFirstLoad.Value = hfScanTime.Value;

                    return;
                }

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

                int rowCount = result.Data.Tables[0].Rows.Count;

                hfScanTime.Value          = Utilities.GetDataUpdatedDate(result.Data.Tables[0].Rows[rowCount - 1]);
                hfScanTimeFirstLoad.Value = hfScanTime.Value;

                lvHomeProjects.DataSource = result.Data;
                lvHomeProjects.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
            }

            LogHelpers.WriteStatus(tag, "End.");
        }
Beispiel #8
0
        public void CanDelete()
        {
            using (var data = new DbTestData())
            {
                var projectsDAL     = new ProjectsDAL(DbTestData.ConnectionString);
                var translationsDAL = new TranslationsDAL(DbTestData.ConnectionString);
                var votesDAL        = new VotesDAL(DbTestData.ConnectionString);
                var user            = data.user1;

                dal.ReadById(user.ID).Should().NotBeNull();
                projectsDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty();
                translationsDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty();
                votesDAL.ReadAllByUserId(user.ID).Should().NotBeEmpty();

                dal.DeleteById(user.ID);

                dal.ReadById(user.ID).Should().BeNull();
                projectsDAL.ReadAllByUserId(user.ID).Should().BeEmpty();
                translationsDAL.ReadAllByUserId(user.ID).Should().BeEmpty();
                votesDAL.ReadAllByUserId(user.ID).Should().BeEmpty();
            }
        }
Beispiel #9
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ProjectBOL BOL = CreateNewProject();

            //---
            if (BOL == null)
            {
                return;
            }

            var result = ProjectsDAL.InsertOrUpdate(BOL);

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

                return;
            }

            lbError.Visible = false;
            //----
            GoBackPage();
        }
Beispiel #10
0
 public ProjectBL(ProjectsDAL projectsDAL)
 {
     _projectsDAL = projectsDAL;
 }
 public static void Init(TestContext context)
 {
     dal = new ProjectsDAL(DbTestData.ConnectionString);
 }
        public void ProcessRequest(HttpContext context)
        {
            string tag = "[GetProjectsHandler][ProcessRequest]";

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

            string menuId      = context.Request["MenuId"];
            string receiveTime = context.Request["ScanTime"];
            string receiveType = context.Request["ScanType"];

            object result;

            try
            {
                DateTime scanTime;

                if (receiveTime == "0")
                {
                    scanTime = DateTime.Now;
                }
                else
                {
                    scanTime = DateTime.ParseExact(receiveTime, "MMddyyyy HH:mm:ss.fff", CultureInfo.CurrentCulture);
                }

                var resultDAL = ProjectsDAL.GetPageItems(int.Parse(menuId), scanTime, receiveType);
                //---

                List <ProjectAjaxBOL> data = null;

                if (resultDAL.Code >= 0 &&
                    resultDAL.Data.Tables.Count > 0 &&
                    resultDAL.Data.Tables[0].Rows.Count > 0)
                {
                    data = new List <ProjectAjaxBOL>();
                    foreach (DataRow row in resultDAL.Data.Tables[0].Rows)
                    {
                        ProjectBOL     project     = new ProjectBOL(row);
                        ProjectAjaxBOL projectAjax = new ProjectAjaxBOL();
                        projectAjax.Id = project.Id;
                        //----
                        projectAjax.Name     = "";
                        projectAjax.Name     = Utilities.IsLangueEN() ? project.Name_EN : project.Name_VN;
                        projectAjax.MenuName = Utilities.IsLangueEN() ? project.MenuName_EN : project.MenuName_VN;
                        projectAjax.Name     = string.Format("<a href='ProjectsInfo.aspx?Id={0}'>{1}</a>",
                                                             projectAjax.Id,
                                                             projectAjax.Name);
                        projectAjax.MenuName = string.Format("<a href='ProjectsInfo.aspx?Id={0}'>{1}</a>",
                                                             projectAjax.MenuId,
                                                             projectAjax.MenuName);
                        //----
                        projectAjax.ImageLink = Path.Combine(Utilities.GetDirectory("ImageProjectsDir"), project.ImageLink.Split('|')[0]);
                        projectAjax.ImageLink = string.Format("<img src='{0}' onclick=\"{1}\"/>",
                                                              projectAjax.ImageLink,
                                                              string.Format("javascript:window.location.href='ProjectsInfo.aspx?Id={0}'",
                                                                            projectAjax.Id));
                        //---

                        data.Add(projectAjax);
                        //---
                        scanTime = project.UpdatedDate;
                    }
                }

                result = new {
                    Code     = resultDAL.Code,
                    Message  = resultDAL.ErrorMessage,
                    Data     = data,
                    ScanTime = scanTime.ToString("MMddyyyy HH:mm:ss.fff")
                };
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                result = new {
                    Code    = ex.HResult,
                    Message = ex.Message
                };
            }

            string resJson = JsonConvert.SerializeObject(result);

            context.Response.ContentType = "application/json";
            context.Response.Write(resJson);
        }
Beispiel #13
0
 public PhraseBL(PhrasesDAL phrasesDAL, ProjectsDAL projectsDAL)
 {
     _phrasesDAL  = phrasesDAL;
     _projectsDAL = projectsDAL;
 }
Beispiel #14
0
        public void StartBindingProjects(int menuId, string navigationUrl, bool isLoadAll)
        {
            string tag = __tag + "[StartBindingProjects]";

            //---
            LogHelpers.WriteStatus(tag,
                                   "MenuId = " + menuId.ToString(),
                                   "Start.");

            if (menuId <= 0)
            {
                return;
            }

            StartLoadHeder(menuId);
            //---

            _navigationUrl = navigationUrl;

            try
            {
                var result = ProjectsDAL.GetTopProjects(int.Parse(Utilities.GetApplicationSettingsValue("Project-Items")),
                                                        isLoadAll ? 0 : menuId);

                if (result.Code < 0)
                {
                    lbError.InnerText = result.ErrorMessage;
                    lbError.Visible   = true;
                    //---
                    hfScanTime.Value      = result.Code.ToString();
                    hfFirstScanTime.Value = hfScanTime.Value;
                    //---
                    LogHelpers.WriteError(tag, result.ErrorMessage);

                    return;
                }

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

                string scanTime = Utilities.GetDataUpdatedDate(result.Data.Tables[0].Rows[result.Data.Tables[0].Rows.Count - 1]);
                hfMenuId.Value        = isLoadAll ? "0" : menuId.ToString();
                hfScanTime.Value      = scanTime;
                hfFirstScanTime.Value = hfScanTime.Value;

                lvProjects.DataSource   = result.Data;
                lvProjects.DataKeyNames = new string[] { "Id" };
                lvProjects.DataBind();
            }
            catch (Exception ex)
            {
                LogHelpers.WriteException(tag, ex.ToString());
                //--
                lbError.InnerText = ex.Message;
                lbError.Visible   = true;
            }

            LogHelpers.WriteStatus(tag, "End.");
        }