public List <Data_Software> SearchSoftware(int?ResourceID, int?CategoryID, int?ProjectID, ref int?Count) { Count = 0; int ResoID = (ResourceID == null) ? 0 : Convert.ToInt32(ResourceID); int CateID = (CategoryID == null) ? 0 : Convert.ToInt32(CategoryID); int ProjID = (ProjectID == null) ? 0 : Convert.ToInt32(ProjectID); List <Data_Software> softwares = new List <Data_Software>(); SqlConnection sqlConn = new SqlConnection(base.Connection.ConnectionString); using (sqlConn) { try { SqlCommand cmd = sqlConn.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "dbo.Search_Software"; cmd.Parameters.AddWithValue("@SoftResourceID", ResoID); cmd.Parameters.AddWithValue("@SoftCategoryID", CateID); cmd.Parameters.AddWithValue("@ProjectID", ProjID); if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Data_Software software = new Data_Software() { SoftRequestID = Convert.ToInt32(rdr["SoftRequestID"].ToString()), SoftCategory = rdr["SoftCategoryDesc"].ToString(), SoftResource = rdr["SoftResourceDesc"].ToString(), SoftVersion = rdr["SoftVersionDesc"].ToString(), ProjectName = rdr["ProjectName"].ToString(), }; softwares.Add(software); Count += 1; } rdr.Close(); } catch (Exception ex) { throw ex; } } return(softwares); }
public List<Data_Software> SearchSoftware(int? ResourceID, int? CategoryID, int? ProjectID, ref int? Count) { Count = 0; int ResoID = (ResourceID == null) ? 0 : Convert.ToInt32(ResourceID); int CateID = (CategoryID == null) ? 0 : Convert.ToInt32(CategoryID); int ProjID = (ProjectID == null) ? 0 : Convert.ToInt32(ProjectID); List<Data_Software> softwares = new List<Data_Software>(); SqlConnection sqlConn = new SqlConnection(base.Connection.ConnectionString); using (sqlConn) { try { SqlCommand cmd = sqlConn.CreateCommand(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "dbo.Search_Software"; cmd.Parameters.AddWithValue("@SoftResourceID", ResoID); cmd.Parameters.AddWithValue("@SoftCategoryID", CateID); cmd.Parameters.AddWithValue("@ProjectID", ProjID); if (sqlConn.State != ConnectionState.Open) sqlConn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Data_Software software = new Data_Software() { SoftRequestID = Convert.ToInt32(rdr["SoftRequestID"].ToString()), SoftCategory = rdr["SoftCategoryDesc"].ToString(), SoftResource = rdr["SoftResourceDesc"].ToString(), SoftVersion = rdr["SoftVersionDesc"].ToString(), ProjectName = rdr["ProjectName"].ToString(), }; softwares.Add(software); Count += 1; } rdr.Close(); } catch (Exception ex) { throw ex; } } return softwares; }