-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeController.cs
More file actions
143 lines (123 loc) · 4.86 KB
/
Copy pathHomeController.cs
File metadata and controls
143 lines (123 loc) · 4.86 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HealthCareServices.Models;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
namespace HealthCareServices.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
string connectin=Convert.ToString(WebConfigurationManager.AppSettings["connectionString"]);
public ActionResult Index()
{
return View(main().ToList());
}
public ActionResult Edit(Int64 ID)
{
//List<Class1> mm = new List<Class1>();
Class1 ll = null;
SqlConnection con = new SqlConnection(connectin);
con.Open();
SqlCommand com = new SqlCommand("sp_bind122", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("ID",ID));
SqlDataReader read = com.ExecuteReader();
while (read.Read())
{
ll = new Class1();
ll.ID = ID;
ll.NAME = Convert.ToString(read["NAME"]);
ll.DOB = Convert.ToDateTime(read["DOB"]);
ll.MobileNo = Convert.ToInt64(read["MobileNo"]);
ll.Address = Convert.ToString(read["Address"]);
ll.salary = Convert.ToInt64(read["salary"]);
ll.Department = Convert.ToString(read["DepartmentName"]);
//mm.Add(ll);
}
con.Close();
return View(ll);
}
public List<Class1> main()
{
List<Class1> mm = new List<Class1>();
SqlConnection con=new SqlConnection(connectin);
con.Open();
SqlCommand com = new SqlCommand("sp_listmainn", con);
com.CommandType = CommandType.StoredProcedure;
SqlDataReader read = com.ExecuteReader();
while (read.Read())
{
Class1 ll = new Class1();
ll.NAME = Convert.ToString(read["NAME"]);
ll.DOB = Convert.ToDateTime(read["DOB"]);
ll.MobileNo = Convert.ToInt64(read["MobileNo"]);
ll.Address = Convert.ToString(read["Address"]);
ll.salary = Convert.ToInt64(read["salary"]);
ll.Department = Convert.ToString(read["DepartmentName"]);
mm.Add(ll);
}
con.Close();
return mm;
}
[HttpGet]
public ActionResult Create()
{
return View(new Class1());
}
public ActionResult Create(Class1 cls)
{
if (cls.ID > 0)
{
Update(cls);
return RedirectToAction("Index");
}
else
{
Create1(cls);
return RedirectToAction("Index");
}
return View();
}
public bool Create1(Class1 cls)
{
List<Class1> mm = new List<Class1>();
SqlConnection con = new SqlConnection(connectin);
con.Open();
SqlCommand com = new SqlCommand("sp_create11", con);
com.CommandType = CommandType.StoredProcedure;
// com.Parameters.Add(new SqlParameter("ID", DBNull.Value));
com.Parameters.Add(new SqlParameter("NAME", cls.NAME));
com.Parameters.Add(new SqlParameter("DOB", cls.DOB));
com.Parameters.Add(new SqlParameter("MobileNo", cls.MobileNo));
com.Parameters.Add(new SqlParameter("Address", cls.Address));
com.Parameters.Add(new SqlParameter("salary", cls.salary));
com.Parameters.Add(new SqlParameter("DepartmentName", cls.Department));
com.ExecuteNonQuery();
con.Close();
return true;
}
public bool Update(Class1 cls)
{
SqlConnection con = new SqlConnection(connectin);
con.Open();
SqlCommand com = new SqlCommand("sp_update1112", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.Add(new SqlParameter("ID", cls.ID));
com.Parameters.Add(new SqlParameter("NAME", cls.NAME));
com.Parameters.Add(new SqlParameter("DOB", cls.DOB));
com.Parameters.Add(new SqlParameter("MobileNo", cls.MobileNo));
com.Parameters.Add(new SqlParameter("Address", cls.Address));
com.Parameters.Add(new SqlParameter("salary", cls.salary));
com.Parameters.Add(new SqlParameter("DepartmentName", cls.Department));
com.ExecuteNonQuery();
con.Close();
return true;
}
}
}