protected void gvShareKeys_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } ShareKey sk = ShareKey.ShareKeyWithID(e.Keys[0].ToString()); if (sk == null) { throw new InvalidOperationException("Unknown key: " + e.Keys[0].ToString()); } sk.Name = e.NewValues["Name"].ToString(); sk.CanViewCurrency = (bool)e.NewValues["CanViewCurrency"]; sk.CanViewTotals = (bool)e.NewValues["CanViewTotals"]; sk.CanViewFlights = (bool)e.NewValues["CanViewFlights"]; sk.CanViewAchievements = (bool)e.NewValues["CanViewAchievements"]; sk.CanViewVisitedAirports = (bool)e.NewValues["CanViewVisitedAirports"]; if (sk.FCommit()) { gvShareKeys.EditIndex = -1; RefreshSharekeys(); } else { e.Cancel = true; } }
/// <summary> /// We set up the sharekey here because mfblogbook could try to load first - if it's an invalid sharekey, then we'll do the redirect without a db hit /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Init(object sender, EventArgs e) { string guid = util.GetStringParam(Request, "g"); ShareKey sk = ShareKey.ShareKeyWithID(guid); if (sk == null) { Response.Redirect("~/HTTP403.htm"); } CurrentShareKey = sk; mfbLogbook.User = sk.Username; }
protected void gvShareKeys_RowCommand(object sender, GridViewCommandEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } if (String.Compare(e.CommandName, "_Delete", StringComparison.OrdinalIgnoreCase) == 0) { ShareKey sk = ShareKey.ShareKeyWithID(e.CommandArgument.ToString()); if (sk != null) { sk.FDelete(); RefreshSharekeys(); } } }