public IEnumerable <MISNewTEMP> MISNewTEMPusingparams(string status, string search) { List <MISNewTEMP> obuList = new List <MISNewTEMP>(); using (var con = new System.Data.SqlClient.SqlConnection(connectionString)) { var cmd = new System.Data.SqlClient.SqlCommand("", con); //cmd.CommandText = "select * from Names where Id=@Id"; //cmd.Parameters.AddWithValue("@Id", id); con.Open(); cmd.CommandText = "select top 500 Id, State, Teamname, new_mis, old_mis, ApprovalStatus from mis_new_TEMPTEMP " + "where ApprovalStatus=@STATUS and (Teamname like @searchval OR new_mis like @searchval OR old_mis like @searchval)"; cmd.Parameters.AddWithValue("@STATUS", status); cmd.Parameters.AddWithValue("@searchval", "%" + search + "%"); System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var obu = new MISNewTEMP(); obu.Id = reader["Id"] != DBNull.Value ? int.Parse(reader["Id"].ToString()) : 0; obu.State = reader["State"] != DBNull.Value ? reader["State"].ToString() : ""; obu.Teamname = reader["Teamname"] != DBNull.Value ? reader["Teamname"].ToString() : ""; obu.new_mis = reader["new_mis"] != DBNull.Value ? reader["new_mis"].ToString() : ""; obu.old_mis = reader["old_mis"] != DBNull.Value ? reader["old_mis"].ToString() : ""; obu.ApprovalStatus = reader["ApprovalStatus"] != DBNull.Value ? reader["ApprovalStatus"].ToString() : ""; obuList.Add(obu); } con.Close(); } return(obuList); }
//================ methods to call starts IncomeNewDetails ========================================== public IEnumerable <MISNewTEMP> MISNewTEMP(string status) { List <MISNewTEMP> obuList = new List <MISNewTEMP>(); using (var con = new System.Data.SqlClient.SqlConnection(connectionString)) { var cmd = new System.Data.SqlClient.SqlCommand("", con); //cmd.CommandText = "select * from Names where Id=@Id"; //cmd.Parameters.AddWithValue("@Id", id); con.Open(); //cmd.CommandText = "select top 500 * from Income_accountMIS_Override_TEMP where ApprovalStatus=@STATUS"; cmd.CommandText = "select top (@TAKETOP) * from mis_new_TEMPTEMP where ApprovalStatus=@STATUS"; cmd.Parameters.AddWithValue("@STATUS", status); cmd.Parameters.AddWithValue("@TAKETOP", taketop); System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var obu = new MISNewTEMP(); obu.Id = reader["Id"] != DBNull.Value ? int.Parse(reader["Id"].ToString()) : 0; obu.State = reader["State"] != DBNull.Value ? reader["State"].ToString() : ""; obu.Teamname = reader["Teamname"] != DBNull.Value ? reader["Teamname"].ToString() : ""; obu.new_mis = reader["new_mis"] != DBNull.Value ? reader["new_mis"].ToString() : ""; obu.old_mis = reader["old_mis"] != DBNull.Value ? reader["old_mis"].ToString() : ""; obu.ApprovalStatus = reader["ApprovalStatus"] != DBNull.Value ? reader["ApprovalStatus"].ToString() : ""; obuList.Add(obu); } con.Close(); } return(obuList); }