//Гол private void button1_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { try { import_process = true; UpdateUI(); ShowStatus("Send GOAL to instatfootball.com...", 0); var mk = new Game.Marker(game, 8, 1, game.Half, -1) { Player1 = player_goal, TimeActualSrv = game.Time }; Web.SaveMarker(game, mk); game.Insert(mk); game.SaveLocal(); ShowStatus("Success", 0); } catch (Exception ex) { ShowStatus(ex.Message, 1); } finally { import_process = false; ReloadDataGridView(); UpdateUI(); } }); }
private void DeleteSelectedMarkers(object sender, EventArgs e) { var lst = new List <ListViewItem>(); foreach (ListViewItem item in GetDataGrid().SelectedItems) { lst.Add(item); } if (lst.Count > 0 && MessageBox.Show("Удалить маркеры (" + lst.Count + "шт.)?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Log.Write("DELETE MANUAL"); var lstDel = new List <Marker>(); GetDataGrid().BeginUpdate(); try { lock (game.Markers) { var lstDel1 = new List <Marker>(); foreach (var row in lst) { if (row.Tag is Marker) { var mk = (Marker)row.Tag; lstDel1.Add(mk); } } lstDel1 = lstDel1.OrderByDescending(o => o.TimeVideo).ToList <Marker>(); foreach (var mk in lstDel1) { if (lstDel.IndexOf(mk) < 0) { lstDel.Add(mk); } } var mkd = lstDel.Count > 0 ? lstDel[0] : null; /*foreach (Marker mk in lstDel) * { * Log.Write("DELETE MANUAL " + mk); * * if (mk.FlagSaved) * mk.FlagDel = true; * else * game.Markers.Remove(mk); * }*/ for (var i = 0; i < lstDel.Count; i++) { var mk = lstDel[i]; game.Remove(mk); } if (mkd != null && HockeyIce.Role == HockeyIce.RoleEnum.AdvTtd) { game.RecalcMarkers(mkd.Half); } ReloadDataGridView(true); GetDataGrid().SelectedItems.Clear(); game.SaveLocal(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.WriteException(ex); } finally { GetDataGrid().EndUpdate(); //UpdateUI(); } } }