-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteClientData.aspx.cs
More file actions
49 lines (43 loc) · 1.48 KB
/
deleteClientData.aspx.cs
File metadata and controls
49 lines (43 loc) · 1.48 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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Proyecto_Des_App_Web
{
public partial class deleteClientData : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string requestBody = new System.IO.StreamReader(Request.InputStream).ReadToEnd();
JavaScriptSerializer serializer = new JavaScriptSerializer();
FetchRequestClientId data = serializer.Deserialize<FetchRequestClientId>(requestBody);
DeleteClientData(data.ClientId);
}
public void DeleteClientData(int clientId)
{
string sql = @"DELETE FROM Clientes WHERE cliente_id = @cliente_id";
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString()))
{
conn.Open();
SqlCommand cmd = new SqlCommand(sql,conn);
cmd.Parameters.AddWithValue("@cliente_id", clientId);
try
{
cmd.ExecuteNonQuery();
conn.Close();
}
catch (Exception ex)
{
Response.StatusCode = 500;
conn.Close();
}
}
}
}
}