-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomerAddEdit.aspx.cs
81 lines (73 loc) · 2.86 KB
/
CustomerAddEdit.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//AUTHOR: Kush Shah
//COURSE: ISYS 415-501
//FORM: CustomerAddEdit.aspx
//PURPOSE: The purpose of this form is to add and edit customers that already exist
//INITIALIZE: The initializing would retrieve customers from the database
//INPUT: The input is the new information or information that will modify the customers
//PROCESS: The process will include the searching of the customer that will query into the database so it may receive the information about that customer
//OUTPUT: The textboxes and customer gridview serve as outputs
//TERMINATE: There is no termination involved
//HONOR CODE: “On my honor, as an Aggie, I have neither given
// nor received unauthorized aid on this academic
// work.”
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WompomPizza
{
public partial class CustomerAddEdit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void dvCustomerDetails_ItemDeleted(object sender, DetailsViewDeletedEventArgs e)
{
if (e.Exception != null)
{
lblErrorMessage.Text = DatabaseErrorMessage(e.Exception.Message);
e.ExceptionHandled = true;
}
else if (e.AffectedRows == 0)
lblErrorMessage.Text = ConcurrencyErrorMessage();
else
dvCustomerDetails.DataBind();
}
protected void dvCustomerDetails_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
if (e.Exception != null)
{
lblErrorMessage.Text = DatabaseErrorMessage(e.Exception.Message);
e.ExceptionHandled = true;
}
else
dvCustomerDetails.DataBind();
}
protected void dvCustomerDetails_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
if (e.Exception != null)
{
lblErrorMessage.Text = DatabaseErrorMessage(e.Exception.Message);
e.ExceptionHandled = true;
}
else if (e.AffectedRows == 0)
lblErrorMessage.Text = ConcurrencyErrorMessage();
else
dvCustomerDetails.DataBind();
}
protected void dvCustomerDetails_PreRender(object sender, EventArgs e)
{
dvCustomerDetails.HeaderRow.TableSection = TableRowSection.TableHeader;
}
private string DatabaseErrorMessage(string msg)
{
return $"A database error has occurred. Message: {msg}";
}
private string ConcurrencyErrorMessage()
{
return "Another user may have updated this product. Please try again.";
}
}
}