01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Web;
04.
using
System.Web.UI;
05.
using
System.Web.UI.WebControls;
06.
using
System.Data.SqlClient;
07.
using
System.Data;
08.
using
System.Text;
09.
using
System.Linq;
10.
11.
public
partial
class
Garage3 : System.Web.UI.Page
12.
{
13.
14.
15.
16.
17.
18.
19.
protected
void
Page_Load(
object
sender, EventArgs e)
20.
{
21.
22.
string
GarageID =
""
;
23.
DBCarDataContext dbCar =
new
DBCarDataContext();
24.
HttpCookie Data =
new
HttpCookie(
"Data"
);
25.
GarageID = Request.QueryString[
"GarageID"
];
26.
if
(GarageID!=
""
&&GarageID!=
null
)
27.
{
28.
Data.Values[
"GarageID"
] = GarageID.ToString();
29.
var garage = dbCar.tbl_Garages.Where(g => g.Garage_ID == GarageID.ToInt()).FirstOrDefault();
30.
lblGarageID.Text = garage.Garage_ID.ToString();
31.
lblGarageName.Text = garage.Garage_Name;
32.
txtG_Add.Text = garage.Garage_Add;
33.
txtG_District.Text = garage.Garage_District;
34.
txtG_Fax.Text = garage.Garage_Fax;
35.
txtG_SubDistrict.Text = garage.Garage_SubDistrict;
36.
txtG_Tel.Text = garage.Garage_Phone;
37.
txtG_Zip.Text = garage.Garage_Postcode;
38.
txtMobile.Text = garage.Garage_CellPhone;
39.
ddlG_Province.Text = garage.Garage_Province;
40.
}
41.
Response.Cookies.Add(Data);
42.
}
43.
44.
protected
void
cmdUpdate_Click(
object
sender, EventArgs e)
45.
{
46.
HttpCookie cook = Request.Cookies[
"Data"
];
47.
if
(cook ==
null
)
48.
{
49.
return
;
50.
}
51.
52.
53.
54.
int
GarageID = lblGarageID.Text.ToInt();
55.
56.
DBCarDataContext db =
new
DBCarDataContext();
57.
var GarageEdit = db.tbl_Garages.Where(c => c.Garage_ID == GarageID).FirstOrDefault();
58.
59.
60.
61.
GarageEdit.Garage_Add = txtG_Add.Text;
62.
GarageEdit.Garage_SubDistrict = txtG_SubDistrict.Text;
63.
GarageEdit.Garage_District = txtG_District.Text;
64.
GarageEdit.Garage_CellPhone = txtMobile.Text;
65.
GarageEdit.Garage_Fax = txtG_Fax.Text;
66.
GarageEdit.Garage_Phone = txtG_Tel.Text;
67.
GarageEdit.Garage_Postcode = txtG_Zip.Text;
68.
GarageEdit.Garage_Province = ddlG_Province.Text;
69.
70.
db.SubmitChanges();
71.
72.
73.
74.
}
75.
}