-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employees.cs
96 lines (80 loc) · 2.67 KB
/
Employees.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
96
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace InventoryManagement
{
public partial class Employees : UserControl
{
inventoryDataContext idc = new inventoryDataContext(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\FASHAKINALEALEXANDER\Documents\FProjects\InventoryManagementSystem-master\InventoryManagement\InventoryManagement\inventory_management.mdf;Integrated Security=True");
private static int id = 0;
public static int ID
{
get
{
return id;
}
}
private static Employees _instance;
public static Employees Instance
{
get
{
if (_instance == null)
_instance = new Employees();
return _instance;
}
}
public Employees()
{
InitializeComponent();
}
private void btnAddEmp_Click(object sender, EventArgs e)
{
InventoryManagement.addEmp();
}
private void Employees_Load(object sender, EventArgs e)
{
//employee emp = new employee();
var empTable = from q in idc.employees select q;
gvEmp.DataSource = empTable;
}
private void btnDelEmp_Click(object sender, EventArgs e)
{
if (gvEmp.SelectedCells[0].Value != null)
{
int id = Convert.ToInt32(gvEmp.SelectedCells[0].Value.ToString());
employee emp = idc.employees.SingleOrDefault(x => x.emp_id == id);
idc.employees.DeleteOnSubmit(emp);
idc.SubmitChanges();
MessageBox.Show("Successfully deleted an employee.");
}
else
{
lblErrorEmp.Text = "Please select a row to delete.";
}
}
private void gvEmp_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void btnRefreshEmp_Click(object sender, EventArgs e)
{
lblErrorEmp.Text = "";
var empTable = from q in idc.employees select q;
gvEmp.DataSource = empTable;
}
private void btnUpdateEmp_Click(object sender, EventArgs e)
{
if (gvEmp.SelectedCells[0].Value != null)
{
id = Convert.ToInt32(gvEmp.SelectedCells[0].Value.ToString());
InventoryManagement.updateEmp();
}
}
}
}