protected void rptAnnouncement_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; int paramImage = 0; if (ParameterServices.DisplayNewImage != "") { paramImage = Int32.Parse(ParameterServices.DisplayNewImage); } if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { LinkButton ctlAnnouncement = (LinkButton)item.FindControl("ctlAnnouncement"); Image imgNew = (Image)item.FindControl("imgNew"); SuAnnouncementLang suAnnouncementLang = (SuAnnouncementLang)item.DataItem; short announcementId = suAnnouncementLang.AnnouncementId; short languageId = suAnnouncementLang.Language.Languageid; SuAnnouncement announcement = SuAnnouncementService.FindByIdentity(announcementId); DateTime EffectiveDate = announcement.EffectiveDate.Value; string filePath = ParameterServices.IconUploadFilePath; if (EffectiveDate.AddDays(paramImage) >= DateTime.Now.Date) { imgNew.ImageUrl = filePath + "new.gif"; } else { imgNew.ImageUrl = filePath + "blank.gif"; } string newWindowUrl = "../SCG.eAccounting.Web/Forms/SU/Programs/AnnouncementPopup.aspx?announcementId=" + announcementId + "&languageId=" + languageId; ctlAnnouncement.Attributes.Add("onclick", "javascript:window.open('" + newWindowUrl + "',null,'height=300,width=600,status=yes,toolbar=no,menubar=no,location=no')"); } }
protected void ctlAnnouncementLangForm_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short announcementId; long announcementLangId = UIHelper.ParseLong(ctlAnnouncementLangForm.DataKey["Id"].ToString()); SuAnnouncementLang announcementLang = SuAnnouncementLangService.FindProxyByIdentity(announcementLangId); announcementId = announcementLang.Announcement.Announcementid; GetSuAnnouncementLangInfo(announcementLang); try { SuAnnouncementLangService.UpdateAnnouncementLang(announcementLang); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } // Check if no validation error then changemode to default mode. if (ValidationErrors.IsEmpty) { ctlAnnouncementForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUpAnnouncementLangForm(); BindAnnouncementLangGrid(announcementId); ctlAnnouncementGrid.DataCountAndBind(); ctlUpdatePanelAnnnouncementGrid.Update(); } }
protected void ctlAnnouncementLangForm_ItemInserting(object sender, FormViewInsertEventArgs e) { short announcementId = UIHelper.ParseShort(ctlAnnouncementGrid.SelectedDataKey.Value.ToString()); SuAnnouncementLang announcementLang = new SuAnnouncementLang(); announcementLang.Announcement = SuAnnouncementService.FindProxyByIdentity(announcementId); announcementLang.Language = DbLanguageService.FindProxyByIdentity(UIHelper.ParseShort(ctlAnnouncementLangGrid.SelectedDataKey["LanguageId"].ToString())); GetSuAnnouncementLangInfo(announcementLang); try { SuAnnouncementLangService.InsertAnnouncementLang(announcementLang); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } // Check if no validation error then changemode to default mode. if (ValidationErrors.IsEmpty) { ctlAnnouncementLangForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUpAnnouncementLangForm(); BindAnnouncementLangGrid(announcementId); ctlAnnouncementGrid.DataCountAndBind(); ctlUpdatePanelAnnnouncementGrid.Update(); } }
public short AddAnnouncement(SuAnnouncement announcement, SuAnnouncementLang announcementLang) { #region Validate SuAnnouncementGroup Spring.Validation.ValidationErrors errors = new Spring.Validation.ValidationErrors(); if (string.IsNullOrEmpty(announcementLang.AnnouncementHeader)) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("AnnouncementHeaderRequired")); } if (announcement.EffectiveDate == null) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("EffectiveDateFormatError")); } else if (announcement.EffectiveDate.GetValueOrDefault(DateTime.MinValue).Equals(DateTime.MinValue)) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("EffectiveDateRequired")); } else if (announcement.EffectiveDate.GetValueOrDefault(DateTime.MinValue) < DateTime.Today) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("EffectiveDateNotBeBackDate")); } if (announcement.LastDisplayDate == null) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("LastDisplayDateFormatError")); } else if (announcement.LastDisplayDate.GetValueOrDefault(DateTime.MinValue).Equals(DateTime.MinValue)) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("LastDisplayDateRequired")); } else if (announcement.LastDisplayDate.GetValueOrDefault(DateTime.MinValue) < DateTime.Today) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("LastDisplayDateNotBeBackDate")); } if ((!announcement.EffectiveDate.GetValueOrDefault(DateTime.MinValue).Equals(DateTime.MinValue)) && (!announcement.LastDisplayDate.GetValueOrDefault(DateTime.MinValue).Equals(DateTime.MinValue)) && (announcement.EffectiveDate != null) && (announcement.LastDisplayDate != null)) { if (announcement.EffectiveDate.Value > announcement.LastDisplayDate.Value) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("EffectiveDateGTLastDisplayDate")); } } if (announcement.AnnouncementGroup == null) { errors.AddError("Announcement.Error", new Spring.Validation.ErrorMessage("AnnouncementGroupRequired")); } if (!errors.IsEmpty) { throw new ServiceValidationException(errors); } #endregion short announcementId = DaoProvider.SuAnnouncementDao.Save(announcement); DaoProvider.SuAnnouncementLangDao.Save(announcementLang); return(announcementId); }
protected void rptAnnouncement_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { Panel ctlPanelGroup = item.FindControl("ctlPanelGroup") as Panel; Label ctlDayOfMonth = item.FindControl("ctlDayOfMonth") as Label; Label ctlMonthOfYear = item.FindControl("ctlMonthOfYear") as Label; System.Web.UI.WebControls.Image ctlImageNew = item.FindControl("ctlImageNew") as System.Web.UI.WebControls.Image; LinkButton ctlReadMore = item.FindControl("ctlReadMore") as LinkButton; SuAnnouncementLang announcementLang = (SuAnnouncementLang)item.DataItem; string filePath = ParameterServices.AnnouncementGoupUploadFilePath; string imageName = announcementLang.Announcement.AnnouncementGroup.ImagePath; DateTime EffectiveDate = announcementLang.Announcement.EffectiveDate.Value; int paramImage = 0; if (ParameterServices.DisplayNewImage != "") { paramImage = Int32.Parse(ParameterServices.DisplayNewImage); } string statusFilePath = ParameterServices.IconUploadFilePath; if (EffectiveDate.AddDays(paramImage) >= DateTime.Now.Date) { ctlImageNew.ImageUrl = statusFilePath + "new.gif"; } else { ctlImageNew.ImageUrl = statusFilePath + "blank.gif"; } try { System.Drawing.Image image = System.Drawing.Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + filePath.Replace("~", string.Empty).Replace("/", "\\") + imageName); ctlPanelGroup.Width = image.Width; ctlPanelGroup.Height = image.Height; ctlPanelGroup.BackImageUrl = filePath + imageName; } catch (Exception) { //for not found file using default image } ctlDayOfMonth.Text = UIHelper.ToDateString(announcementLang.Announcement.CreDate, "dd"); ctlMonthOfYear.Text = UIHelper.ToDateString(announcementLang.Announcement.CreDate, "MMM"); string newWindowUrl = ResolveClientUrl("~/Forms/SU/Programs/AnnouncementPopup.aspx?announcementId=" + announcementLang.AnnouncementId + "&languageId=" + announcementLang.LanguageId); ctlReadMore.OnClientClick = "javascript:window.open('" + newWindowUrl + "',null,'height=300,width=600,status=yes,toolbar=no,menubar=no,location=no,resizable=1,scrollbars=1'); return false;"; } }
private void GetSuAnnouncementLangInfo(SuAnnouncementLang announcementLang) { TextBox ctlTxtHeader = ctlAnnouncementLangForm.FindControl("ctlTxtHeader") as TextBox; TextBox ctlTxtBody = ctlAnnouncementLangForm.FindControl("ctlTxtBody") as TextBox; TextBox ctlTxtFooter = ctlAnnouncementLangForm.FindControl("ctlTxtFooter") as TextBox; TextBox ctlTxtComment = ctlAnnouncementLangForm.FindControl("ctlTxtComment") as TextBox; CheckBox ctlActive = ctlAnnouncementLangForm.FindControl("ctlActive") as CheckBox; FCKeditor ctlFCK = ctlAnnouncementLangForm.FindControl("ctlFCK") as FCKeditor; announcementLang.AnnouncementHeader = ctlTxtHeader.Text; //announcementLang.AnnouncementBody = ctlTxtBody.Text; announcementLang.AnnouncementBody = ctlFCK.Value; announcementLang.AnnouncementFooter = ctlTxtFooter.Text; announcementLang.Comment = ctlTxtComment.Text; announcementLang.Active = ctlActive.Checked; announcementLang.UpdPgm = ProgramCode; announcementLang.CreBy = UserAccount.UserID; announcementLang.CreDate = DateTime.Now; announcementLang.UpdBy = UserAccount.UserID; announcementLang.UpdDate = DateTime.Now; }
protected void ctlAnnouncementForm_ItemInserting(object sender, FormViewInsertEventArgs e) { SuAnnouncement announcement = new SuAnnouncement(); GetSuAnnouncementInfo(announcement); SuAnnouncementLang announcementLang = new SuAnnouncementLang(); TextBox ctlTxtHeader = ctlAnnouncementForm.FindControl("ctlTxtHeader") as TextBox; short languageId = UserAccount.CurrentLanguageID; announcementLang.Language = DbLanguageService.FindByIdentity(languageId); announcementLang.Announcement = announcement; announcementLang.AnnouncementHeader = ctlTxtHeader.Text; announcementLang.Active = announcement.Active; announcementLang.CreBy = UserAccount.UserID; announcementLang.CreDate = DateTime.Now; announcementLang.UpdPgm = ProgramCode; announcementLang.UpdBy = UserAccount.UserID; announcementLang.UpdDate = DateTime.Now; try { SuAnnouncementService.AddAnnouncement(announcement, announcementLang); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); } // Check if no validation error then changemode to default mode. if (ValidationErrors.IsEmpty) { ctlAnnouncementForm.ChangeMode(FormViewMode.ReadOnly); ClosePopUpAnnouncementForm(); ctlAnnouncementGrid.DataCountAndBind(); } }