-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmAllocateMultipleProblems.cs
93 lines (82 loc) · 2.93 KB
/
frmAllocateMultipleProblems.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace ProblemProgram_s216173116
{
public partial class frmAllocateMultipleProblems : Form
{
SqlDataAdapter dbAdapter;
SqlConnection dbConn;
Problem p = new Problem();
ProblemLog pl = new ProblemLog();
public frmAllocateMultipleProblems(SqlConnection dbConn, SqlDataAdapter dbAdapter)
{
InitializeComponent();
this.dbConn = dbConn;
this.dbAdapter = dbAdapter;
}
private void frmAllocateMultipleProblems_Load(object sender, EventArgs e)
{
DataAccessLayer dl = new DataAccessLayer();
try {
dgvProblems.DataSource = dl.getOpenProblems();
cmbStaffID.DataSource = dl.GetStaff();
cmbStaffID.DisplayMember = "StaffID";
cmbStaffID.ValueMember = "StaffID";
}
catch (SqlException sqlex)
{
MessageBox.Show("SQL exception: " + sqlex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnAllocate_Click(object sender, EventArgs e)
{
DataAccessLayer dl = new DataAccessLayer();
if (dbConn.State == ConnectionState.Closed)
dbConn.Open();
try
{
for (int i = dgvProblems.Rows.Count - 1; i > 0; i--)
{
DataGridViewRow row = dgvProblems.Rows[i - 1];
if (Convert.ToBoolean(row.Cells["Assign"].Value) == true)
{
p.UpdateProblem(int.Parse(row.Cells["ProbID"].Value.ToString()), cmbStaffID.Text.ToString(), "Assigned");
pl.InsertProblem(int.Parse(row.Cells["ProbID"].Value.ToString()), DateTime.Now.ToString(), cmbStaffID.Text.ToString(), "Initial allocated staff ID");
}
}
dgvProblems.DataSource = dl.getOpenProblems();
try
{
frmAllocateProblem frm = new frmAllocateProblem();
frm.Close();
}
catch { }
}
catch (SqlException sqlex)
{
MessageBox.Show("SQL exception: " + sqlex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
this.Close();
}
private void dgvProblems_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}