I have this autocomplete text boxes that is displaying no record for selected cylinder. Please note that the id of job101 table is the pid in the job_cylinder1 table. The autocomplete text box displays no record.
please not that the product code is the pid of the job101 table which is 45440
My Code
<script type="text/javascript">
$(function () {
SearchText();
SearchText1();
SearchText31();
SearchText3();
SearchText32();
});
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData",
data: "{ 'searchTerm': '" + request.term + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert(result.responseText);
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
$('[id*=hfjobid]').val(ui.item.val.split(',')[0]);
$('[id*=hfjobembid]').val(ui.item.val.split(',')[1]);
$('[id*=hfdiereferneceno]').val(ui.item.val.split(',')[2]);
}
});
}
$(function () {
SearchText1();
});
function SearchText1() {
$(".autosuggest1").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData1",
data: "{ 'searchTerm': '" + request.term + "', gietzdieref: '" + $(".autosuggest").val() + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert(result.responseText);
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
}
});
}
function SearchText31() {
$(".autosuggest31").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData31",
data: "{ 'searchTerm': '" + request.term + "', embid: '" + $('[id*=hfjobembid]').val() + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert(result.responseText);
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
$('[id*=hfembossid]').val(ui.item.val);
$(event.target).autocomplete("close");
setTimeout(function () {
$(event.target).blur();
});
},
minLength: 0
}).focus(function () {
$(this).autocomplete("search");
});
}
function SearchText3() {
$(".autosuggest3").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData3",
data: "{ 'searchTerm': '" + request.term + "', id: '" + $('[id*=hfjobid]').val() + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert(result.responseText);
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
$('[id*=hfcylinderid]').val(ui.item.val);
$(event.target).autocomplete("close");
setTimeout(function () {
$(event.target).blur();
});
},
minLength: 0
}).focus(function () {
$(this).autocomplete("search");
});
}
function SearchText32() {
$(".autosuggest32").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData32",
data: "{ 'searchTerm': '" + request.term + "', diereferneceno: '" + $('[id*=hfdiereferneceno]').val() + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert(result.responseText);
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
$('[id*=hfdieid]').val(ui.item.val);
$(event.target).autocomplete("close");
setTimeout(function () {
$(event.target).blur();
});
},
minLength: 0
}).focus(function () {
$(this).autocomplete("search");
});
}
$(function () {
SearchText2();
});
function SearchText2() {
$(".autosuggest2").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Order.aspx/GetAutoCompleteData2",
data: "{'Company':'" + document.getElementById('txtSearch5').value + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
response($.map(data.d, function (item) {
return {
label: item.split('/')[0],
val: item.split('/')[1]
}
}));
}
else {
response([{ label: 'No Records Found', val: -1 }]);
}
},
error: function (result) {
alert("Error");
}
});
},
select: function (event, ui) {
if (ui.item.val == -1) {
return false;
}
$('#pic').text(ui.item.val);
}
});
}
</script>
public partial class Order : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Panel1.Visible = true;
Panel3.Visible = false;
Panel4.Visible = false;
Panel5.Visible = false;
TextBox6.Text = DateTime.Today.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture);
}
[WebMethod]
public static List<string> GetAutoCompleteData(string searchTerm)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
using (SqlCommand cmd = new SqlCommand("SELECT id,pid,embid,diereferneceno FROM job WHERE pid LIKE '%'+@SearchText+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", searchTerm);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1},{2},{3}", dr["pid"], dr["id"], dr["embid"], dr["diereferneceno"]));
}
return result;
}
}
}
[WebMethod]
public static List<string> GetAutoCompleteData1(string searchTerm, string gietzdieref)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
using (SqlCommand cmd = new SqlCommand("select id,gietzdieref from job101 where pid=@pid ", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText1", searchTerm);
cmd.Parameters.AddWithValue("@pid", gietzdieref);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1}", dr["gietzdieref"], dr["id"]));
}
return result;
}
}
}
[WebMethod]
public static List<string> GetAutoCompleteData31(string searchTerm, string embid)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
using (SqlCommand cmd = new SqlCommand("SELECT id,embid FROM job_emboss WHERE id=@Id", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", searchTerm);
cmd.Parameters.AddWithValue("@Id", embid);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1}", dr["embid"], dr["id"]));
}
return result;
}
}
}
[WebMethod]
public static List<string> GetAutoCompleteData3(string searchTerm, string id)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
// using (SqlCommand cmd = new SqlCommand("SELECT id,pid,posino FROM job_cylinder ORDER BY CAST(LEFT(posino,CHARINDEX('-',posino)-1) AS INT),CAST(LEFT(RIGHT(posino,LEN(posino)-CHARINDEX('-',posino)), PATINDEX('%[^0-9]%', RIGHT(posino,LEN(posino)-CHARINDEX('-',posino))+'.') - 1) AS INT),RIGHT(posino,LEN(posino)-CHARINDEX('-',posino))", con))
using (SqlCommand cmd = new SqlCommand("SELECT id, pid, posino FROM job_cylinder1 where posino LIKE @SearchText+'%' AND pid=@Id ORDER BY CAST(LEFT(posino, CHARINDEX('-', posino)-1) AS INT), CAST(LEFT(RIGHT(posino, LEN(posino)-CHARINDEX('-', posino)), PATINDEX('%[^0-9]%', RIGHT(posino, LEN(posino)-CHARINDEX('-', posino))+'.') - 1) AS INT), RIGHT(posino, LEN(posino)-CHARINDEX('-', posino))", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", searchTerm);
cmd.Parameters.AddWithValue("@Id", id);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1}", dr["posino"], dr["id"]));
}
return result;
}
}
}
[WebMethod]
public static List<string> GetAutoCompleteData32(string searchTerm, string diereferneceno)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
using (SqlCommand cmd = new SqlCommand("select id,dieno from job_die where id=@Diereferneceno order by id asc", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText", searchTerm);
cmd.Parameters.AddWithValue("@Diereferneceno", diereferneceno);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1}", dr["dieno"], dr["id"]));
}
return result;
}
}
}
[WebMethod]
public static List<string> GetAutoCompleteData2(string Company)
{
List<string> result = new List<string>();
using (SqlConnection con = new SqlConnection("Data Source=M89P3JQ\\NERE;Integrated Security=true;Initial Catalog=arpackaging;"))
{
using (SqlCommand cmd = new SqlCommand("select id,Company from Suppliers where Company LIKE '%'+@SearchText2+'%'", con))
{
con.Open();
cmd.Parameters.AddWithValue("@SearchText2", Company);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
result.Add(string.Format("{0}/{1}", dr["Company"], dr["id"]));
}
return result;
}
}
}
}