-
Notifications
You must be signed in to change notification settings - Fork 0
/
Profiles.cs
68 lines (60 loc) · 2.08 KB
/
Profiles.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IOOP
{
class Profiles
{
private int profID;
private string name;
private string email;
private string phoneNum;
static SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myCS"].ToString());
// GET SET method
public int ProfID { get => profID; set => profID = value; }
public string Name { get => name; set => name = value; }
public string Email { get => email; set => email = value; }
public string PhoneNum { get => phoneNum; set => phoneNum = value; }
public Profiles(string n, string e, string num)
{
name = n;
email = e;
phoneNum = num;
}
public Profiles(string n)
{
name = n;
}
public static void viewCusProfile(Profiles o1)
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from profiles where username ='" + o1.name + "'", con);
SqlDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
o1.email = rd.GetString(2);// Get email
o1.phoneNum = rd.GetString(3);// Get phonenumber
}
con.Close();
}
public string updateCusProfile(string em, string num)
{
string status;
con.Open();
email = em;
phoneNum = num;
SqlCommand cmd = new SqlCommand("update profiles set email ='" + email + "',phoneNumber='" + phoneNum + "' where username ='" + name + "'", con);
int i = cmd.ExecuteNonQuery();
if (i != 0)
status = "Update Successfully.";
else
status = "Unable to update.";
con.Close();
return status;
}
}
}