-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChip-request.aspx.cs
More file actions
52 lines (44 loc) · 1.71 KB
/
Chip-request.aspx.cs
File metadata and controls
52 lines (44 loc) · 1.71 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
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Chip_request : System.Web.UI.Page {
private string connectionString = WebConfigurationManager.ConnectionStrings["ChipDrop"].ConnectionString;
protected void Page_Load(object sender, EventArgs e) {
}
protected void Button1_Click(object sender, EventArgs e) {
string insertSQL;
insertSQL = "INSERT INTO ChipRequest (" +
"customer_id,qty_id,date_available,date_expire" +
") VALUES (" +
"@customer_id, @qty_id, @date_available, @date_expire"+
")";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand(insertSQL, con);
cmd.Parameters.AddWithValue("@customer_id", 91);
cmd.Parameters.AddWithValue("@qty_id", ddlChipQuantity.SelectedItem.Value);
cmd.Parameters.AddWithValue("@date_available", cldDateAvailable.SelectedDate);
cmd.Parameters.AddWithValue("@date_expire", cldDateExpire.SelectedDate);
// Try to open the database and execute the update.
int added = 0;
try {
con.Open();
added = cmd.ExecuteNonQuery();
}
catch (Exception err) {
lblResults.Text = "Error inserting record.";
lblResults.Text += err.Message;
}
finally {
con.Close();
}
// If the insert succeeded, refresh the author list.
if (added > 0) {
Response.Redirect("Customer-dashboard.aspx");
}
}
}