
















































































































































































1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
using BlueBeanDemo.Entities;
12
using BlueBeanDemo.Data;
13
14
15
public partial class Purchase_VendorEdit : System.Web.UI.Page
16
{
17
protected void Page_Load(object sender, EventArgs e)
18
{
19
20
}
21
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
22
{
23
24
}
25
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
26
{
27
if (e.CommandName.Equals( "Insert"))
28
{
29
TextBox newVendorName = (TextBox)this.GridView1.FooterRow.FindControl("newVendorName");
30
TextBox newVendorDesc = (TextBox)this.GridView1.FooterRow.FindControl("newVendorDesc");
31
DropDownList newVendorType = (DropDownList)this.GridView1.FooterRow.FindControl("newVendorType");
32
TextBox newVendorAddress1 = (TextBox)this.GridView1.FooterRow.FindControl("newVendorAddress1");
33
TextBox newVendorAddress2 = (TextBox)this.GridView1.FooterRow.FindControl("newVendorAddress2");
34
TextBox newPhone1 = (TextBox)this.GridView1.FooterRow.FindControl("newPhone1");
35
TextBox newPhone2 = (TextBox)this.GridView1.FooterRow.FindControl("newPhone2");
36
TextBox newVendorCode = (TextBox)this.GridView1.FooterRow.FindControl("newVendorCode");
37
TextBox newZipCode = (TextBox)this.GridView1.FooterRow.FindControl("newZipCode");
38
TextBox newBankCardNo = (TextBox)this.GridView1.FooterRow.FindControl("newBankCardNo");
39
40
Vendor vendor = new Vendor();
41
int totalNumer=20;
42
totalNumer = totalNumer + 2;
43
vendor.VendorID = totalNumer;
44
vendor.VendorName = newVendorName.Text;
45
vendor.VendorDesc = newVendorDesc.Text;
46
vendor.VendorTypeID = int.Parse(newVendorType.SelectedValue.ToString());
47
vendor.Address1 = newVendorAddress1.Text;
48
vendor.Address2 = newVendorAddress2.Text;
49
vendor.Phone1 = newPhone1.Text;
50
vendor.Phone2 = newPhone2.Text;
51
vendor.VendorCode = newVendorCode.Text;
52
vendor.ZipCode = newZipCode.Text;
53
vendor.BankCardNo = newBankCardNo.Text;
54
try
55
{
56
DataRepository.VendorProvider.Save(vendor);
57
}
58
catch(Exception ex)
59
{
60
Response.Write(ex.Message);
61
}
62
63
this.GridView1.DataBind();
64
65
66
67
68
69
70
71
}
72
}
73
}
74

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

效果:
