-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAddbook.aspx.cs
86 lines (74 loc) · 3.05 KB
/
Addbook.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Addbook : System.Web.UI.Page
{
DS_BRANCH.BRANCH_SELECTDataTable BDT = new DS_BRANCH.BRANCH_SELECTDataTable();
DS_BRANCHTableAdapters.BRANCH_SELECTTableAdapter BAdapter = new DS_BRANCHTableAdapters.BRANCH_SELECTTableAdapter();
DS_BOOK.BOOK_SELECTDataTable BookDT = new DS_BOOK.BOOK_SELECTDataTable();
DS_BOOKTableAdapters.BOOK_SELECTTableAdapter BookAdapter = new DS_BOOKTableAdapters.BOOK_SELECTTableAdapter();
DS_PUBLICATION.PUBLICATION_SELECTDataTable PubDT = new DS_PUBLICATION.PUBLICATION_SELECTDataTable();
DS_PUBLICATIONTableAdapters.PUBLICATION_SELECTTableAdapter PubAdapter = new DS_PUBLICATIONTableAdapters.PUBLICATION_SELECTTableAdapter();
protected void Page_Load(object sender, EventArgs e)
{
lblmsg.Text = "";
if (Page.IsPostBack == false)
{
BDT = BAdapter.SelectBranch();
//drpbranch.DataSource = BDT;
//drpbranch.DataTextField = "Branchname";
//drpbranch.DataValueField = "Branchid";
//drpbranch.DataBind();
//drpbranch.Items.Insert(0, "SELECT");
CheckBoxList1.DataSource = BDT;
CheckBoxList1.DataTextField = "Branchname";
CheckBoxList1.DataValueField = "branchid";
CheckBoxList1.DataBind();
PubDT = PubAdapter.Select();
drppublication.DataSource = PubDT;
drppublication.DataTextField = "Publication";
drppublication.DataValueField = "pid";
drppublication.DataBind();
drppublication.Items.Insert(0, "SELECT");
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/Book/") + FileUpload1.FileName);
int a = 0;
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected == true)
{
BookAdapter.Insert(txtbname.Text, txtauthor.Text, txtdetail.Text, Convert.ToDouble(txtprice.Text), drppublication.SelectedItem.Text, CheckBoxList1.Items[i].Text, Convert.ToInt32(txtqnt.Text), Convert.ToInt32(txtqnt.Text), 0, "~/Book/" + FileUpload1.FileName.ToString());
a = 1;
}
}
if (a == 0)
{
lblmsg.Text = "Please, Select branch";
}
else
{
lblmsg.Text = "Book Added";
txtauthor.Text = "";
txtbname.Text = "";
txtdetail.Text = "";
txtprice.Text = "";
txtqnt.Text = "";
// drpbranch.SelectedIndex = 0;
drppublication.SelectedIndex = 0;
txtbname.Focus();
}
}
else
{
lblmsg.Text = "Please, Select Book Photo";
}
}
}