-
Notifications
You must be signed in to change notification settings - Fork 0
/
OppType.aspx.cs
54 lines (47 loc) · 1.51 KB
/
OppType.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class OppType : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Userid"] == null)
{
Response.Redirect("Login.aspx");
}
LibraryDb.SelectCommand = "SELECT * FROM [OppType_Table] Where [CreatedByUserId]='" + Session["UserId"].ToString() + "'";
}
protected void btnAdd_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["SalesConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("insert into OppType_Table (Name,CreatedByUserId) values (@name,@Userid)", conn);
cmd.Parameters.AddWithValue("@name", txtStudentId.Text);
cmd.Parameters.AddWithValue("@Userid", Session["Userid"].ToString());
try
{
conn.Open();
cmd.ExecuteNonQuery();
GridView1.DataBind();
txtStudentId.Text = "";
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
}
catch (Exception ex)
{
}
}
}