-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserProfile.cs
103 lines (86 loc) · 3.09 KB
/
UserProfile.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
97
98
99
100
101
102
103
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 UserProfile : 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");
employee emp = new employee();
private string name = "";
private string phone = "";
private string gender = "";
private string email = "";
private string address = "";
private string nid = "";
private string rank = "";
private decimal sal = 0.0m;
private static UserProfile _instance;
public static UserProfile Instance
{
get
{
if (_instance == null)
_instance = new UserProfile();
return _instance;
}
}
public UserProfile()
{
InitializeComponent();
int id = Employees.ID;
emp = idc.employees.SingleOrDefault(x => x.emp_id == id);
tbAddress.Text = emp.emp_address;
tbMail.Text = emp.emp_email;
tbName.Text = emp.emp_name;
tbNid.Text = emp.emp_nid;
tbPhone.Text = emp.emp_phone;
tbRank.Text = emp.emp_rank;
tbSal.Text = emp.emp_sal.ToString();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void NID_Click(object sender, EventArgs e)
{
}
private void btnUpdateEmp_Click(object sender, EventArgs e)
{
name = tbName.Text.ToString();
rank = tbRank.Text.ToString();
phone = tbPhone.Text.ToString();
email = tbMail.Text.ToString();
address = tbAddress.Text.ToString();
nid = tbNid.Text.ToString();
sal = Convert.ToDecimal(tbSal.Text.ToString());
gender = cbGender.SelectedItem.ToString();
if (!name.Equals("") && !rank.Equals("") && !phone.Equals("") && !email.Equals("") && !address.Equals("") &&
!nid.Equals("") && !gender.Equals("") && sal > 0)
{
emp.emp_address = address;
emp.emp_email = email;
emp.emp_gender = gender;
emp.emp_name = name;
emp.emp_nid = nid;
emp.emp_phone = phone;
emp.emp_sal = sal;
emp.emp_rank = rank;
idc.SubmitChanges();
MessageBox.Show("Successfully updated an employee.");
}
else
{
lblError.Text = "Please select a row to delete.";
}
}
}
}