-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddCC.aspx.cs
64 lines (53 loc) · 2 KB
/
AddCC.aspx.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Security.Claims;
public partial class AddCC : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated)
{
if (Session["userID"] == null)
{
var identity = new ClaimsIdentity(User.Identity);
int length = identity.Claims.ElementAt(0).ToString().Length;
Session["userID"] = identity.Claims.ElementAt(0).ToString().Substring(length - 36);
Session["userName"] = User.Identity.Name;
}
}
else
{
Response.Redirect("~/Account/Login.aspx");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
//declare and initialize connection object to connect to the database
SqlConnection conn = new SqlConnection(
WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
SqlCommand cmd; //declare a command object that will be used to send commands to database.
conn.Open(); //open a connection to the database
cmd = conn.CreateCommand(); //create a command object
String isDefault = txtIsDefaultT.Checked ? "True" : "false";
cmd.CommandText = "Insert into CreditCard Values ('" +
txtCCNo.Text + "', '" +
txtFName.Text + "', '" +
txtMidInitial.Text + "', '" +
txtLName.Text + "', '" +
txtExpirationDate.Text + "', '" + txtType.Text + "', " +
txtCVC.Text + ", '" + isDefault + "', '" +
Session["userID"].ToString() + "')";
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
conn.Close();
// added for navigation
Response.Redirect("~/selectCC.aspx");
}
}