forked from nitschk/h24
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmChipNotFound.cs
95 lines (80 loc) · 2.66 KB
/
frmChipNotFound.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Linq;
using System.Windows.Forms;
namespace h24
{
public partial class frmChipNotFound : Form
{
klc01 db;
public frmChipNotFound(string chip_id)
{
InitializeComponent();
tbChipId.Text = chip_id;
}
private void frmChipNotFound_Load(object sender, EventArgs e)
{
db = new klc01();
dgCompetitors.DataSource = db.v_comp_teams.ToList();
dgCompetitors.Refresh();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void dgCompetitors_DoubleClick(object sender, EventArgs e)
{
int curRow = dgCompetitors.CurrentRow.Index;
int comp_id = Convert.ToInt32(dgCompetitors.Rows[curRow].Cells["comp_id"].Value);
this.update_chip(comp_id);
this.Close();
}
private void btnAssign_Click(object sender, EventArgs e)
{
int curRow = dgCompetitors.CurrentRow.Index;
int comp_id = Convert.ToInt32(dgCompetitors.Rows[curRow].Cells["comp_id"].Value);
this.update_chip(comp_id);
this.Close();
}
public void update_chip(int comp_id)
{
if (tbChipId.Text.Trim() == string.Empty || Int32.Parse(this.tbChipId.Text) < 1)
{
MessageBox.Show("Chip not filled");
return;
}
int chip_id = Int32.Parse(this.tbChipId.Text);
try
{
using (var db = new klc01())
{
var result = db.competitors.SingleOrDefault(b => b.comp_id == comp_id);
if (result != null)
{
result.comp_chip_id = chip_id;
db.SaveChanges();
}
}
}
catch (Exception ex)
{
MessageBox.Show($"An exception occured: \n\n{ex.Message}.", "ReaderDemoProject", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void tbSearch_TextChanged(object sender, EventArgs e)
{
if (tbSearch.Text.Length > 0)
{
using (var db = new klc01())
{
dgCompetitors.DataSource = db.sp_search_competitors(tbSearch.Text).ToList();
dgCompetitors.Refresh();
}
}
}
private void btClear_Click(object sender, EventArgs e)
{
this.tbSearch.Text = "";
ActiveControl = this.tbSearch;
}
}
}