protected void JqgridMatch1_RowAdding(object sender, JQGridRowAddEventArgs e)
 {
     var teamWin = "<b style='color: red'>ยังไม่มีผลการแข่งขัน</b>";
     var hasResult = 0;
     var homeScore = String.IsNullOrEmpty(e.RowData["TeamHomeScore"])
                         ? 0
                         : Convert.ToInt32(e.RowData["TeamHomeScore"]);
     var awayScore = String.IsNullOrEmpty(e.RowData["TeamAwayScore"])
                         ? 0
                         : Convert.ToInt32(e.RowData["TeamAwayScore"]);
     var date = String.IsNullOrEmpty(e.RowData["FAMatchDate"])
                    ? DateTime.Now
                    : Convert.ToDateTime(e.RowData["FAMatchDate"]);
     if (homeScore > awayScore)
     {
         teamWin = "<b style='color: blue'>" + e.RowData["TeamHomeName"] + "</b>";
         hasResult = 1;
     }
     else if (homeScore < awayScore)
     {
         teamWin = "<b style='color: blue'>" + e.RowData["TeamAwayName"] + "</b>";
         hasResult = 1;
     }
     var faMatch = new FAMatch
                       {
                           FAMatchDate = date,
                           TeamHomeName = e.RowData["TeamHomeName"],
                           TeamHomeScore = homeScore,
                           TeamAwayScore = awayScore,
                           TeamAwayName = e.RowData["TeamAwayName"],
                           TeamWin = teamWin,
                           HasResult = hasResult
                       };
     using (var dc = ThaitaeDataDataContext.Create())
     {
         dc.FAMatches.InsertOnSubmit(faMatch);
         dc.SubmitChanges();
     }
 }
Exemplo n.º 2
0
 partial void UpdateFAMatch(FAMatch instance);
Exemplo n.º 3
0
 partial void DeleteFAMatch(FAMatch instance);
Exemplo n.º 4
0
 partial void InsertFAMatch(FAMatch instance);