protected void ctlDelete_Click(object sender, ImageClickEventArgs e) { foreach (GridViewRow row in ctlAnnouncementGrid.Rows) { if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked)) { try { short announcementId = UIHelper.ParseShort(ctlAnnouncementGrid.DataKeys[row.RowIndex].Value.ToString()); SuAnnouncement announcement = SuAnnouncementService.FindProxyByIdentity(announcementId); SuAnnouncementService.Delete(announcement); } catch (Exception ex) { string exMessage = ex.Message; } } } ctlAnnouncementLangGrid.DataSource = null; ctlAnnouncementLangGrid.DataBind(); ctlCancel.Visible = false; ctlFieldSetDetailGridView.Visible = false; ctlUpddatePanelAnnouncementLangGrid.Update(); ctlAnnouncementGrid.SelectedIndex = -1; 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(); } }
protected void ctlAnnouncementGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditAnnouncement") { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; short announcementId = UIHelper.ParseShort(ctlAnnouncementGrid.DataKeys[rowIndex].Value.ToString()); ctlAnnouncementGrid.EditIndex = rowIndex; IList <SuAnnouncement> list = new List <SuAnnouncement>(); list.Add(SuAnnouncementService.FindProxyByIdentity(announcementId)); ctlAnnouncementForm.DataSource = list; ctlAnnouncementForm.ChangeMode(FormViewMode.Edit); ctlModalPopupExtender1.Show(); ctlUpdatePanelAnnouncementForm.Update(); ctlAnnouncementForm.DataBind(); ctlAnnouncementGrid.DataCountAndBind(); } if (e.CommandName == "Select") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; short announcementId = UIHelper.ParseShort(ctlAnnouncementGrid.DataKeys[rowIndex].Value.ToString()); ctlUpddatePanelAnnouncementLangGrid.Update(); BindAnnouncementLangGrid(announcementId); ctlAnnouncementGrid.DataCountAndBind(); //ctlSubmit.Visible = true; } }
protected void rptAnnouncementDetail_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) { 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; Image ctlImage = item.FindControl("ctlImage") as Image; Image ctlImageHeader = item.FindControl("ctlImageHeader") as Image; AnnouncementLang announcementLang = (AnnouncementLang)item.DataItem; short announcementId = announcementLang.AnnouncementId.GetValueOrDefault(0); SuAnnouncement announcement = SuAnnouncementService.FindByIdentity(announcementId); DateTime EffectiveDate = announcement.EffectiveDate.Value; string filePath = ParameterServices.AnnouncementGoupUploadFilePath; string imageName = announcementLang.ImagePath; string ststusfilePath = ParameterServices.IconUploadFilePath; if (EffectiveDate.AddDays(paramImage) >= DateTime.Now.Date) { ctlImageHeader.ImageUrl = ststusfilePath + "new.gif"; } else { ctlImageHeader.ImageUrl = ststusfilePath + "blank.gif"; } //ctlImage.ImageUrl = imageName.Trim(); 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) { } ctlDayOfMonth.Text = UIHelper.ToDateString(announcement.CreDate, "dd"); ctlMonthOfYear.Text = UIHelper.ToDateString(announcement.CreDate, "MMM"); } }
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(); } }
protected void ctlAnnouncementForm_ItemUpdating(object sender, FormViewUpdateEventArgs e) { short announcementId = UIHelper.ParseShort(ctlAnnouncementForm.DataKey.Value.ToString()); SuAnnouncement announcement = SuAnnouncementService.FindProxyByIdentity(announcementId); GetSuAnnouncementInfo(announcement); try { SuAnnouncementService.UpdateAnnouncement(announcement); } 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(); } }