-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddStudent.aspx.cs
73 lines (67 loc) · 2.84 KB
/
AddStudent.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class AddStudent : 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_STUDENT.STUDENT_SELECTDataTable SDT = new DS_STUDENT.STUDENT_SELECTDataTable();
DS_STUDENTTableAdapters.STUDENT_SELECTTableAdapter SAdapter = new DS_STUDENTTableAdapters.STUDENT_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");
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
if (drpdd.SelectedIndex == 0 || drpmm.SelectedIndex == 0 || drpyyyy.SelectedIndex == 0)
{
lblmsg.Text = "Select Proper BithDate";
}
else
{
string gen="";
if(rdomale.Checked==true)
{
gen="Male";
}
else
{
gen="Female";
}
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/img/") + FileUpload1.FileName);
DateTime bdate = Convert.ToDateTime(drpdd.SelectedItem.Text + " " + drpmm.SelectedItem.Text + " " + drpyyyy.SelectedItem.Text);
SAdapter.Insert(txtsname.Text, drpbranch.SelectedItem.Text, txtmobile.Text, txtaddress.Text, txtcity.Text, txtpincode.Text, bdate, gen, txtemail.Text, txtpass.Text,"~/img/"+FileUpload1.FileName);
lblmsg.Text = "Student Added Successfully";
}
else
{
DateTime bdate = Convert.ToDateTime(drpdd.SelectedItem.Text + " " + drpmm.SelectedItem.Text + " " + drpyyyy.SelectedItem.Text);
SAdapter.Insert(txtsname.Text, drpbranch.SelectedItem.Text, txtmobile.Text, txtaddress.Text, txtcity.Text, txtpincode.Text, bdate, gen, txtemail.Text, txtpass.Text, "~/img/std.png");
lblmsg.Text = "Student Added Successfully";
}
txtsname.Text=""; drpbranch.SelectedIndex=0;
txtmobile.Text="";
txtaddress.Text=""; txtcity.Text="";
txtpincode.Text="";
txtemail.Text="";
txtpass.Text="";
drpdd.SelectedIndex = 0;
drpmm.SelectedIndex = 0;
drpyyyy.SelectedIndex = 0;
}
}
}