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 static ResultBOL <int> InsertOrUpdate(ProjectBOL BOL) { string imageDir = Utilities.GetDirectory("ImagesDir"); BOL.Content_VN = Utilities.ReplaceImageUri(BOL.Content_VN, imageDir); BOL.Content_EN = Utilities.ReplaceImageUri(BOL.Content_VN, imageDir); string stored = "sp_Peojects_Insert_Update"; var result = DataAccessHelpers.ExecuteStored(stored, BOL.GetParameters()); return(result); }
protected void lvProjects_ItemDataBound(object sender, ListViewItemEventArgs e) { string tag = __tag + "[lvProjects_ItemDataBound]"; //--- if (e.Item.ItemType != ListViewItemType.DataItem) { return; } try { DataRowView rowView = (DataRowView)e.Item.DataItem; ProjectBOL project = new ProjectBOL(rowView.Row); HyperLink hplName = (HyperLink)e.Item.FindControl("hplName"); string id = hplName.NavigateUrl; hplName.NavigateUrl = string.Format("~/{0}?Id={1}", _navigationUrl, hplName.NavigateUrl); //---- Image ctrlImage = (Image)e.Item.FindControl("imageLink"); ctrlImage.ImageUrl = Path.Combine(Utilities.GetDirectory("ImageProjectsDir"), ctrlImage.ImageUrl.Split('|')[0]); //if (!string.IsNullOrEmpty(project.IsRedirectUrl) && // project.IsRedirectUrl.Contains("Yes")) //{ // ctrlImage.Attributes.Add("onclick", // string.Format("javascript:window.location.href='{0}'", // project.RedirectUrl)); //} //else //{ // ctrlImage.Attributes.Add("onclick", // string.Format("javascript:window.location.href='{0}?Id={1}'", // _navigationUrl, // id)); //} ctrlImage.Attributes.Add("onclick", string.Format("javascript:window.location.href='{0}?Id={1}'", _navigationUrl, id)); } catch (Exception ex) { LogHelpers.WriteException(tag, ex.ToString()); } }
private void StartLoadProjectDetail(DataRow row) { string tag = __tag + "StartLoadProjectDetail"; LogHelpers.WriteStatus(tag, "Start...."); if (row == null) { lbError.InnerText = Utilities.GetErrorMessage("NullObject"); lbError.Visible = true; return; } try { ProjectBOL project = new ProjectBOL(row); lbProjectNameInfo.InnerText = Utilities.IsLangueEN() ? project.Name_EN : project.Name_VN; //imgCurrentProject.ImageUrl = Path.Combine(Utilities.GetDirectory("ImageRootDir"), project.ImageLink); lbContent.Text = Utilities.IsLangueEN() ? Utilities.SetFullLinkImage(project.Content_EN, Utilities.GetDirectory("ImageProjectsDir")) : Utilities.SetFullLinkImage(project.Content_VN, Utilities.GetDirectory("ImageProjectsDir")); //--- StartLoadProjectImages(project.ImageLink); //--- lbProjectAddressInfo.InnerText = Utilities.IsLangueEN() ? project.Address_EN : project.Address_VN; if (project.StartDate != null && project.StartDate != DateTime.MinValue) { this.lbStartDateInfo.InnerText = project.StartDate.ToString("MM/dd/yyyy"); } if (project.EndDate != null && project.EndDate != DateTime.MinValue) { this.lbEndDateInfo.InnerText = project.EndDate.ToString("MM/dd/yyyy"); } } catch (Exception ex) { LogHelpers.WriteException(tag, ex.ToString()); //-- lbError.InnerText = ex.Message; lbError.Visible = true; } }
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."); }
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(); }
private ProjectBOL CreateNewProject() { string tag = _tag + "[CreateNewProject]"; try { DateTime startDate = DateTime.MinValue; if (!string.IsNullOrEmpty(tbxStartDate.Text) && !DateTime.TryParseExact(tbxStartDate.Text, "MM/dd/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out startDate)) { startDate = DateTime.MinValue; } DateTime endDate = DateTime.MinValue; if (!string.IsNullOrEmpty(tbxEndDate.Text) && !DateTime.TryParseExact(tbxEndDate.Text, "MM/dd/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out endDate)) { endDate = DateTime.MinValue; } ProjectBOL BOL = new ProjectBOL() { Name_VN = tbxNameVN.Text, Description_VN = tbxDesVN.Text, Content_VN = txaContentVN.Text, Address_VN = tbxAddress_VN.Text, //--- Name_EN = tbxNameEN.Text, Description_EN = tbxDesEN.Text, Address_EN = tbxAddress_EN.Text, Content_EN = txaContentEN.Text, StartDate = startDate, EndDate = endDate, //IsRedirectUrl = chkChooseCategory.Checked ? "Yes" : "No", //RedirectUrl = tbxRedirectLink.Text.Trim(), //-- ImageLink = hfListImage.Value, //--- InsertDate = DateTime.Now, UpdatedDate = DateTime.Now }; //--- int menuId = Utilities.GetRequestParameter("MenuId"); if (menuId > 0) { BOL.MenuId = menuId; } int id = Utilities.GetRequestParameter("Id"); if (id > 0) { BOL.Id = id; } return(BOL); } catch (Exception ex) { LogHelpers.WriteError(string.Format("{0} Exception: {1}", tag, ex.ToString())); return(null); } }
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); }