how to add a complete form dynamically on add more button
hy guys I am building a customer profile page in .net MVC Now on his profile page there is a section of clients he work with like client Name, Location, Start_date , job description . as each employee can work with many clients so i want to add a button there as Add more and when the user click the base from get regenerate as many times as he click the button also i want to save the data using model ( ! using AJAX or jquery) is ther any sample then share with me please thanks in advance .
Mark TaborPosted Sep 9, 2019, 5:19 AM
Ashwani Shahi why you are posting db stored procedure related stuff it is not related to my question i think
Ashwani ShahiPosted Sep 8, 2019, 11:30 PM
use webservicenew
create table designation
(
did int primary key identity,
dname varchar(50)
)
insert into designation(dname)values('HR')
insert into designation(dname)values('MANAGER')
insert into designation(dname)values('SELES')
insert into designation(dname)values('TL')
create proc usp_designation_get
as
begin
select * from designation
end
create table registration
(
rid int primary key identity,
name varchar(50),
email varchar(50),
salary int,
desg int
)
create proc usp_Registration_insert
@name varchar(50),
@email varchar(50),
@salary int,
@desg int
as
begin
insert into registration(name,email,salary,desg)values(@name,@email,@salary,@desg)
end
alter proc usp_Registration_get
as
begin
select * from registration inner join designation on registration.desg=designation.did
end
create proc usp_Registration_update
@rid int,
@name varchar(50),
@email varchar(50),
@salary int,
@desg int
as
begin
update registration set name=@name,email=@email,salary=@salary,desg=@desg where rid=@rid
end
create proc usp_registration_edit
@rid int
as
begin
select * from registration where rid=@rid
end
create proc usp_Registration_delete
@rid int
as
begin
delete from registration where rid=@rid
end
create proc usp_Registration_search
@name varchar(50)
as
begin
select * from registration where name=@name
end
Ashwani ShahiPosted Sep 8, 2019, 10:09 PM
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Newtonsoft.Json;
namespace jquery_webservice972019
{
///
/// Summary description for WebService1
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["xyz"].ConnectionString);
[WebMethod]
public void insertupdate(int id, string a, string b, int c, int d)
{
if (id > 0)
{
con.Open();
SqlCommand cmd = new SqlCommand("usp_reg_update", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@rid", id);
cmd.Parameters.AddWithValue("@name", a);
cmd.Parameters.AddWithValue("@email", b);
cmd.Parameters.AddWithValue("@salary", c);
cmd.Parameters.AddWithValue("@desg", d);
cmd.ExecuteNonQuery();
con.Close();
}
else
{
con.Open();
SqlCommand cmd = new SqlCommand("usp_reg_insert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", a);
cmd.Parameters.AddWithValue("@email", b);
cmd.Parameters.AddWithValue("@salary", c);
cmd.Parameters.AddWithValue("@desg", d);
cmd.ExecuteNonQuery();
con.Close();
}
}
[WebMethod]
public void delete(int a)
{
con.Open();
SqlCommand cmd = new SqlCommand("usp_reg_delete ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@rid", a);
cmd.ExecuteNonQuery();
}
[WebMethod]
public string edit(int a)
{
string p = "";
con.Open();
SqlCommand cmd = new SqlCommand("usp_reg_edit", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("rid", a);
SqlDataAdapter db = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
db.Fill(dt);
con.Close();
if (dt.Rows.Count>0)
{
p = JsonConvert.SerializeObject(dt);
}
return p;
}
[WebMethod]
public string getdesignation()
{
string p = "";
con.Open();
SqlCommand cmd = new SqlCommand("usp_designation_get", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter db = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
db.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
p = JsonConvert.SerializeObject(dt);
}
return p;
}
[WebMethod]
public string getregistration()
{
string p = "";
con.Open();
SqlCommand cmd = new SqlCommand("usp_reg_get", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter db = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
db.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
p = JsonConvert.SerializeObject(dt);
}
return p;
}
}
}
Ashwani ShahiPosted Sep 8, 2019, 10:00 PM