public List <SpecificationMaster> GetSpecificationMaster() { List <SpecificationMaster> listspecificationmaster = new List <SpecificationMaster>(); SpecificationMaster objspecificationmaster = null; try { db.OpenConn(); SqlCommand cmd = new SqlCommand("select S.SpecificationMasterID, P.ProductID,P.ProductName,SC.SpecificationCategoryName,S.SpecificationMasterName from Products P inner join SpecificationMaster S on P.ProductID=S.ProductID inner join SpecificationCategory SC on S.SpecificationCategoryID=SC.SpecificationCategoryID", db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { objspecificationmaster = new SpecificationMaster(); objspecificationmaster.ProductID = long.Parse(dr["ProductID"].ToString()); objspecificationmaster.ProductName = dr["ProductName"].ToString(); objspecificationmaster.SpecificationCategoryName = dr["SpecificationCategoryName"].ToString(); objspecificationmaster.SpecificationMasterName = dr["SpecificationMasterName"].ToString(); objspecificationmaster.SpecificationMasterID = long.Parse(dr["SpecificationMasterID"].ToString()); listspecificationmaster.Add(objspecificationmaster); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(listspecificationmaster); }
public List <SpecificationMaster> GetSpecBasedOnPC(long PcId) { List <SpecificationMaster> listspemaster = new List <SpecificationMaster>(); SpecificationMaster objspmaster; string Sqlquery = ""; if (PcId != 0) { Sqlquery = "select S.SpecificationMasterID, P.ProductID,P.ProductName,SC.SpecificationCategoryName,S.SpecificationMasterName from Products P inner join SpecificationMaster S on P.ProductID=S.ProductID inner join SpecificationCategory SC on S.SpecificationCategoryID=SC.SpecificationCategoryID where P.ProductCategoryID=" + PcId + ""; } else { Sqlquery = "select S.SpecificationMasterID, P.ProductID,P.ProductName,SC.SpecificationCategoryName,S.SpecificationMasterName from Products P inner join SpecificationMaster S on P.ProductID=S.ProductID inner join SpecificationCategory SC on S.SpecificationCategoryID=SC.SpecificationCategoryID"; } try { db.OpenConn(); SqlCommand cmd = new SqlCommand(Sqlquery, db.conn); // cmd.Parameters.AddWithValue("@ProductCategoryID", PcId); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { objspmaster = new SpecificationMaster(); objspmaster.ProductID = long.Parse(dr["ProductID"].ToString()); objspmaster.ProductName = dr["ProductName"].ToString(); objspmaster.SpecificationCategoryName = dr["SpecificationCategoryName"].ToString(); objspmaster.SpecificationMasterName = dr["SpecificationMasterName"].ToString(); objspmaster.SpecificationMasterID = long.Parse(dr["SpecificationMasterID"].ToString()); listspemaster.Add(objspmaster); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(listspemaster); }