protected void rGridPlayer_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { PlayerDomainModel PlayerDM = new PlayerDomainModel(); PlayerPositionDomainModel PlayerPositionDM = new PlayerPositionDomainModel(); try { PlayerDM.PlayerGUID = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PlayerGUID"]; PlayerPositionDM.PlayerGUID = (Guid)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PlayerGUID"]; PlayerPostionBLL.DeletePlayerPosition(PlayerPositionDM); PlayerBLL.DeletePlayer(PlayerDM); rGridPlayer.Rebind(); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); string errMethod = sf.GetMethod().Name.ToString(); // Get the current method name string errMsg = "600"; // Gotta pass something, we're retro-fitting an existing method Session["LastException"] = ex; // Throw the exception in the session variable, will be used in error page string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL Response.Redirect(url); // Go to the error page. } }
public static void HandlePitcher(List <clsPitcher> colPitchers) { PlayerBusinessLogic pBLL = new PlayerBusinessLogic(); PlayerDomainModel player = new PlayerDomainModel(); PlayerPostiionBusinessLogic ppBLL = new PlayerPostiionBusinessLogic(); PlayerPositionDomainModel playerposition = new PlayerPositionDomainModel(); StatBusinessLogic sBLL = new StatBusinessLogic(); StatDomainModel stat = new StatDomainModel(); SeasonPlayerPositionStatBusinessLogic sppsBLL = new SeasonPlayerPositionStatBusinessLogic(); SeasonPlayerPositionStatDomainModel statValue = new SeasonPlayerPositionStatDomainModel(); SeasonPlayerBusinessLogic spBLL = new SeasonPlayerBusinessLogic(); SeasonPlayerDomainModel spDM = new SeasonPlayerDomainModel(); statValue.SeasonID = C_SeasonID; statValue.PlayerGUID = player.PlayerGUID; sppsBLL.DeleteAllStatsForPlayer(statValue); foreach (clsPitcher cPitcher in colPitchers) { player.PlayerName = cPitcher.FirstName.Trim() + " " + cPitcher.LastName.Trim(); pBLL.InsertPlayer(player); playerposition.PlayerGUID = player.PlayerGUID; playerposition.PrimaryPositionID = TransformPos(cPitcher.Pos); playerposition.SecondaryPostiionID = null; ppBLL.DeletePlayerPosition(playerposition); ppBLL.InsertPlayerPosition(playerposition); spDM.PlayerGUID = player.PlayerGUID; spDM.SeasonID = C_SeasonID; spBLL.InsertSeasonPlayer(spDM); BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; foreach (FieldInfo f in cPitcher.GetType().GetFields(flags)) { Console.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher)); System.Diagnostics.Debug.WriteLine("{0} = {1}", f.Name, f.GetValue(cPitcher)); string fieldName = _getBackingFieldName(f.Name.ToUpper()); if (fieldName != "FIRSTNAME" && fieldName != "LASTNAME" && fieldName != "PT" && fieldName != "POS") { stat.StatName = fieldName; stat.PositionTypeID = 2; // 1 = hitter stat = sBLL.InsertStat(stat); statValue.SeasonID = C_SeasonID; statValue.PlayerGUID = player.PlayerGUID; statValue.PositionID = TransformPos(cPitcher.Pos); statValue.StatID = stat.StatID; if (f.GetValue(cPitcher) == null) { statValue.StatValue = null; } else { statValue.StatValue = f.GetValue(cPitcher).ToString(); } sppsBLL.InsertStatValue(statValue); } } } }