public List <SpecificationData> GetSpecificationdata(long ProductID) { List <SpecificationData> lstsd = new List <SpecificationData>(); SpecificationData sd; try { db.OpenConn(); SqlCommand cmd = new SqlCommand("select S.SpecificationMasterName,SS.SpecificationValueName from SpecificationMaster S inner join SpecificationValues SS on S.SpecificationMasterID=SS.SpecificationMasterID where S.ProductID=@ProductID", db.conn); cmd.Parameters.AddWithValue("@ProductID", ProductID); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { sd = new SpecificationData(); sd.SpecificationMasterName = dr["SpecificationMasterName"].ToString(); sd.SpecificationValueName = dr["SpecificationValueName"].ToString(); lstsd.Add(sd); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstsd); }
public List <SpecificationData> GetRequiredData() { List <SpecificationData> lstsd = new List <SpecificationData>(); SpecificationData sd; try { db.OpenConn(); SqlCommand cmd = new SqlCommand("select P.ProductID, P.ProductName, PC.ProductCategoryName, PC.ProductCategoryID from Products P,ProductCategory PC where PC.ProductCategoryID=P.ProductCategoryID", db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { sd = new SpecificationData(); sd.ProductID = long.Parse(dr["ProductID"].ToString()); sd.ProductName = dr["ProductName"].ToString(); sd.ProductCategoryName = dr["ProductCategoryName"].ToString(); sd.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); //sd.SpecificationValueName = dr["SpecificationValueName"].ToString(); //sd.PicturePath = dr["PicturePath"].ToString(); lstsd.Add(sd); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstsd); }
//public List<SpecificationData> GetRequiredData() //{ // List<SpecificationData>lstsd= new List<SpecificationData>(); // SpecificationData sd; // try // { // db.OpenConn(); // SqlCommand cmd = new SqlCommand("select P.ProductID, P.ProductName, PC.ProductCategoryName, PC.ProductCategoryID from Products P,ProductCategory PC where PC.ProductCategoryID=P.ProductCategoryID", db.conn); //SqlDataReader dr = cmd.ExecuteReader(); // while (dr.Read()) // { // sd = new SpecificationData(); // sd.ProductID = long.Parse(dr["ProductID"].ToString()); // sd.ProductName = dr["ProductName"].ToString(); // sd.ProductCategoryName = dr["ProductCategoryName"].ToString(); // //sd.SpecificationValueName = dr["SpecificationValueName"].ToString(); // //sd.PicturePath = dr["PicturePath"].ToString(); // lstsd.Add(sd); // } // dr.Close(); // db.CloseConn(); // } // catch (Exception ex) // { // db.CloseConn(); // throw ex; // } // return lstsd; //} public List <SpecificationData> GetSpecData() { List <SpecificationData> lstsd = new List <SpecificationData>(); SpecificationData specdata; try { db.OpenConn(); SqlCommand cmd = new SqlCommand(" select P.ProductCategoryID,P.ProductCategoryName,S.SpecificationMasterName from ProductCategory P,SpecificationMaster S where PC.ProductCategoryID=S.ProductCategoryID", db.conn); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { specdata = new SpecificationData(); specdata.ProductCategoryID = long.Parse(dr["ProductCategoryID"].ToString()); specdata.ProductCategoryName = dr["ProductCategoryName"].ToString(); specdata.SpecificationMasterName = dr["SpecificationMasterName"].ToString(); lstsd.Add(specdata); } dr.Close(); db.CloseConn(); } catch (Exception ex) { db.CloseConn(); throw ex; } return(lstsd); }
public CreationContext(ISpecification rootSpec, Model model) { m_guid = Guid.NewGuid(); m_whiteboard = new Hashtable(); m_instanceDataByGuid = new Hashtable(); m_instanceDataByInstance = new Hashtable(); m_specDataByGuid = new Hashtable(); m_specDataBySpecification = new Hashtable(); m_requirements = new Hashtable(); m_specifications = new Hashtable(); m_parentStack = new Stack(); m_model = model; m_model.AddCreationContext(this); foreach (ISpecification spec in rootSpec.GetChildSpecifications(true)) { SpecificationData sd = new SpecificationData(spec); m_specDataByGuid.Add(spec.Guid, sd); m_specDataBySpecification.Add(spec, sd); } foreach (IRequirement ireq in rootSpec.GetChildRequirements(true)) { m_requirements.Add(ireq.Guid, ireq); } }
public Guid SeizeNextGuid(ISpecification specification) { SpecificationData sd = (SpecificationData)m_specDataBySpecification[specification]; lock (sd){ Guid g = sd.GetNextGuid(); sd.NextGeneration++; //Console.WriteLine( specification.Guid.ToString() + " is generating new guid " + g.ToString()); return(g); } }
public void RegisterNewSpecification(ISpecification specification) { if (m_specDataByGuid.Contains(specification.Guid)) { ISpecification otherSpec = ((SpecificationData)m_specDataByGuid[specification.Guid]).Specification; // Console.WriteLine("Trying to add specification named " + specification.Name + " with guid " // + specification.Guid.ToString() + ", but there's already been a specification registered " // + "with that same guid. It has the name " + otherSpec.Name + "."); throw new ApplicationException("Trying to add specification named " + specification.Name + " with guid " + specification.Guid.ToString() + ", but there's already been a specification registered " + "with that same guid. It has the name " + otherSpec.Name + "."); } else { SpecificationData sd = new SpecificationData(specification); m_specifications.Add(specification.Guid, specification); m_specDataByGuid.Add(sd.SpecificationGuid, sd); m_specDataBySpecification.Add(sd.Specification, sd); } }
public Guid RegisterNewInstance(object instance, Guid guid, ISpecification specification) { if (m_instanceDataByGuid.Contains(guid)) { object otherInstance = m_instanceDataByGuid[guid]; // Console.WriteLine("Trying to add specification named " + specification.Name + " with guid " // + specification.Guid.ToString() + ", but there's already been a specification registered " // + "with that same guid. It has the name " + otherSpec.Name + "."); throw new ApplicationException("Trying to add an instance from the specification " + specification.Name + " with guid " + guid.ToString() + ", but there's already been an instance registered " + "with that same guid."); } else { SpecificationData sd = (SpecificationData)m_specDataBySpecification[specification]; int generation = sd.GetGenerationFromGuid(guid); InstanceData id = new InstanceData(instance, guid, generation, specification); m_instanceDataByGuid.Add(id.InstanceGuid, id); m_instanceDataByInstance.Add(id.Instance, id); return(id.InstanceGuid); } }