-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrm_emp_pwcs.cs
106 lines (98 loc) · 3.53 KB
/
frm_emp_pwcs.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
104
105
106
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace project_pos
{
public partial class frm_emp_pwcs : Form
{
SqlConnection con = new SqlConnection(@"Data Source=RANDULA-MSI\SQLEXPRESS;Initial Catalog=se_db_pzdr;Integrated Security=True");
SqlCommand cmd;
SqlDataReader dr;
public frm_emp_pwcs(string load_id)
{
InitializeComponent();
txt_id_load.Text = load_id;
}
private void frm_emp_pwcs_Load(object sender, EventArgs e)
{
try
{
con.Open();
String validate = "SELECT * FROM se_tbl_emp WHERE id = '" + txt_id_load.Text + "'";
if (con.State != ConnectionState.Open)
con.Open();
cmd = new SqlCommand(validate, con);
dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
txt_pw_load.Text = dr[9].ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
txt_cp.Text = "";
txt_np.Text = "";
txt_rnp.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
}
private void button3_Click(object sender, EventArgs e)
{
if (txt_cp.Text == "")
{
MessageBox.Show("Enter your currunt Password!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (txt_np.Text == "")
{
MessageBox.Show("Enter your new Password!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (txt_rnp.Text == "")
{
MessageBox.Show("Repeat your new Password!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (txt_cp.Text != txt_pw_load.Text)
{
MessageBox.Show("Current Password is Incorrect!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_cp.Text = "";
}
else if (txt_cp.Text == txt_np.Text)
{
MessageBox.Show("New Password is Similar to the old one. Enter a Different Password!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_np.Text = "";
txt_rnp.Text = "";
}
else if (txt_np.Text != txt_rnp.Text)
{
MessageBox.Show("New Passwords don't match!!", "Problem!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txt_np.Text = "";
txt_rnp.Text = "";
}
else
{
con.Open();
string edit = "UPDATE se_tbl_emp SET password = '" + txt_np.Text + "' WHERE id = '" + txt_id_load.Text + "' ";
cmd = new SqlCommand(edit, con);
cmd.ExecuteNonQuery();
MessageBox.Show("Password Changed!!", "Successfull!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
con.Close();
this.Close();
}
}
}
}