-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateUser.cs
More file actions
187 lines (144 loc) · 5.91 KB
/
Copy pathUpdateUser.cs
File metadata and controls
187 lines (144 loc) · 5.91 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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.SqlClient;
using System.Runtime.InteropServices;
using System.Configuration;
namespace POS_Team_Elite
{
public partial class UpdateUser : Form
{
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // width of ellipse
int nHeightEllipse // height of ellipse
);
string ConnectionString = ConfigurationManager.ConnectionStrings["POS_Team_Elite.Properties.Settings.EliteDBConnectionString"].ConnectionString;
//public string ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=F:\\teamElite\\POS_Team_Elite\\TeamELiteDB.mdf;Integrated Security=True";
public UpdateUser()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 40, 40));
}
private void RbNomalUser_CheckedChanged(object sender, EventArgs e)
{
}
private void RbAdminUser_CheckedChanged(object sender, EventArgs e)
{
}
string RbstatusValue = "";
string RbUserTypeValue = "";
private void UpdateUser_Load(object sender, EventArgs e)
{
//assign cus data to text boxes
UserIdTb.Text = ViewUsers.USERID;
NameTb.Text = ViewUsers.USERSNAME;
PhoneTb.Text = ViewUsers.USERPHONE;
EmailTb.Text = ViewUsers.USEREMAIL;
AddressTb.Text = ViewUsers.USERADDRESS;
//assign user status to ratio buttons
if (ViewUsers.USERSTATUS == "Active")
{
RBactive.Checked = true;
RbstatusValue = "Active";
}
else if (ViewUsers.USERSTATUS == "Deactive")
{
RBdeactive.Checked = true;
RbstatusValue = "Deactive";
}
//assign user role to ratio buttons
if (ViewUsers.USERTYPE == "Admin user")
{
RbAdminUser.Checked = true;
RbUserTypeValue = "Admin user";
}
else if (ViewUsers.USERTYPE == "Nomal user")
{
RbNomalUser.Checked = true;
RbUserTypeValue = "Nomal user";
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
if (UserIdTb.Text != ViewUsers.USERID || NameTb.Text != ViewUsers.USERSNAME || PhoneTb.Text != ViewUsers.USERPHONE || EmailTb.Text != ViewUsers.USEREMAIL || AddressTb.Text != ViewUsers.USERADDRESS || RbstatusValue != ViewUsers.USERSTATUS || RbUserTypeValue != ViewUsers.USERTYPE)
{
DialogResult Closethis = MessageBox.Show("Do you want cancel - Changed data will be lose", "Conform", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
if (Closethis == DialogResult.Yes)
{
Close();
}
}
else
{
Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
//assign data values for database process
string ToDBID = UserIdTb.Text.Trim();
string ToDBName = NameTb.Text.Trim();
string ToDBPhone = PhoneTb.Text.Trim();
string ToDBEmail = EmailTb.Text.Trim();
string ToDBAddress = AddressTb.Text.Trim();
// radio button check status
string ToDBUserStatus = "";
if (RBactive.Checked)
{
ToDBUserStatus = "Active";
}
else if (RBdeactive.Checked)
{
ToDBUserStatus = "Deactive";
}
// radio button check user type
string ToDBUserType = "";
if (RbAdminUser.Checked)
{
ToDBUserType = "Admin user";
}
else if (RbNomalUser.Checked)
{
ToDBUserType = "Nomal user";
}
if (ToDBID == "" || ToDBName == "" || ToDBPhone == "" || ToDBUserStatus == "" || ToDBUserType == "")
{
MessageBox.Show("Please Fill Out All The Details", "Update", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
SqlConnection DB_conn = new SqlConnection(ConnectionString);
DB_conn.Open();
if (DB_conn.State == System.Data.ConnectionState.Open)
{
string SqlQuery1 = "UPDATE SystemUsers SET PersonName = '" + ToDBName + "',PersonTelNo = '" + ToDBPhone + "',PersonEmail = '" + ToDBEmail + "',PersonAddress = '" + ToDBAddress + "',UserStatus = '" + ToDBUserStatus + "',UserType = '" + ToDBUserType + "' where SystemUserID = '" + ToDBID + "' ";
SqlCommand CmdX = new SqlCommand(SqlQuery1, DB_conn);
CmdX.ExecuteNonQuery();
MessageBox.Show(" Data Changed successfully ");
DB_conn.Close();
this.Close();
}
else
{
MessageBox.Show("Connection Error");
}
}
}
private void EmailTb_TextChanged(object sender, EventArgs e)
{
}
}
}