protected void ctlDetailGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("DetailEdit")) { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long RateId = UIHelper.ParseLong(ctlDetailGrid.DataKeys[rowIndex].Value.ToString()); long ProfileId = UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value); ctlForeignPerdiemRateProfileDetailEditor.Initialize(FlagEnum.EditFlag, RateId, ProfileId); ctlForeignPerdiemRateProfileDetailEditor.ShowPopUp(); ctlUpdatePanelDetailGrid.Update(); } if (e.CommandName.Equals("DetailDelete")) { try { int rowIndex = ((GridViewRow)((ImageButton)e.CommandSource).NamingContainer).RowIndex; long detailId = UIHelper.ParseLong(ctlDetailGrid.DataKeys[rowIndex].Value.ToString()); FnPerdiemRate fp = ScgeAccountingQueryProvider.FnPerdiemRateQuery.FindByIdentity(detailId); FnPerdiemRateService.DeleteFnPerdiemRate(fp); } catch (Exception ex) { if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData", "alert('This data is now in use.');", true); BindDetailGrid(UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value)); ctlUpdatePanelDetailGrid.Update(); } } BindDetailGrid(UIHelper.ParseLong(foreignPerdiemRateProfileCode2.Value)); ctlUpdatePanelDetailGrid.Update(); } }
protected void ctlAdd_Click(object sender, ImageClickEventArgs e) { FnPerdiemRate fp; try { if (Mode.Equals(FlagEnum.EditFlag)) { fp = ScgeAccountingQueryProvider.FnPerdiemRateQuery.FindByIdentity(RATEID); } else { fp = new FnPerdiemRate(); } fp.PerdiemProfileID = PPFID; // fp.PerdiemRateID = RATEID; fp.PersonalLevel = ctlPersonalLevelDropdown.SelectedItem.Value; fp.ZoneID = Helper.UIHelper.ParseShort(ctlZoneDropdown.SelectedItem.Value); fp.OfficialPerdiemRate = Helper.UIHelper.ParseDouble(ctlOfficialRate.Text); fp.ExtraPerdiemRate = Helper.UIHelper.ParseDouble(ctlExtraRate.Text); fp.InternationalStaffPerdiemRate = Helper.UIHelper.ParseDouble(ctlInternationalStaffRate.Text); fp.SCGStaffPerdiemRate = Helper.UIHelper.ParseDouble(ctlSCGStaffRate.Text); fp.Active = ctlActive.Checked; if (Mode.Equals(FlagEnum.EditFlag)) { fp.UpdBy = UserAccount.UserID; fp.UpdDate = DateTime.Now.Date; fp.UpdPgm = ProgramCode; FnPerdiemRateService.UpdateFnPerdiemRate(fp); } else if (Mode.Equals(FlagEnum.NewFlag)) { fp.UpdBy = UserAccount.UserID; fp.UpdDate = DateTime.Now.Date; fp.UpdPgm = ProgramCode; fp.CreBy = UserAccount.UserID; fp.CreDate = DateTime.Now.Date; FnPerdiemRateService.AddFnPerdiemRate(fp); } Notify_Ok(sender, e); } catch (ServiceValidationException ex) { ValidationErrors.MergeErrors(ex.ValidationErrors); ctlUpdatePanel.Update(); } }