-
Notifications
You must be signed in to change notification settings - Fork 1
/
Publication.aspx.cs
88 lines (76 loc) · 2.77 KB
/
Publication.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
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Publication : System.Web.UI.Page
{
DS_PUBLICATION.PUBLICATION_SELECTDataTable PubDT = new DS_PUBLICATION.PUBLICATION_SELECTDataTable();
DS_PUBLICATIONTableAdapters.PUBLICATION_SELECTTableAdapter PubAdapter = new DS_PUBLICATIONTableAdapters.PUBLICATION_SELECTTableAdapter();
DS_BOOK.BOOK_SELECTDataTable BDT = new DS_BOOK.BOOK_SELECTDataTable();
DS_BOOKTableAdapters.BOOK_SELECTTableAdapter BAdapter = new DS_BOOKTableAdapters.BOOK_SELECTTableAdapter();
protected void Page_Load(object sender, EventArgs e)
{
lblmsg.Text = "";
if (Page.IsPostBack == false)
{
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
PubAdapter.Insert(txtpub.Text);
lblmsg.Text = "Publication Inserted";
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
txtpub.Text = "";
txtpub.Focus();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int bid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
PubDT = PubAdapter.Select_By_PID(bid);
BDT = BAdapter.Select_By_Publication(PubDT.Rows[0]["publication"].ToString());
if (BDT.Rows.Count > 0)
{
lblmsg.Text = "Please delete first books";
}
else
{
PubAdapter.Delete(bid);
lblmsg.Text = "Publication Deleted";
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
}
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int pid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
TextBox pname = GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox;
PubAdapter.Update(pid, pname.Text);
lblmsg.Text = "Publication Updated";
GridView1.EditIndex = -1;
PubDT = PubAdapter.Select();
GridView1.DataSource = PubDT;
GridView1.DataBind();
}
}