/// <summary> /// Creates a supplier object using a non default constructor /// with all the arguments. /// </summary> /// <param name="iD">ID of Supplier (int)</param> /// <param name="companyName">CompanyName of supplier (string)</param> /// <param name="contactName">Contact Name of supplier (string)</param> /// <param name="contactTitle">Contact Title of supplier (string)</param> /// <param name="address">Address of supplier (string)</param> /// <param name="city">City of supplier (string)</param> /// <param name="region">Region of supplier (string)</param> /// <param name="postalCode">PostalCode of supplier (string)</param> /// <param name="country">Country of supplier (string)</param> /// <param name="phone">Phone of supplier (string)</param> /// <param name="fax">Fax of supplier (string)</param> /// <param name="homePage">Homepage of supplier (string)</param> /// <param name="type">Type of supplier (SupplierTypes)</param> /// <returns>Supplier Object.</returns> public static Supplier CreateSupplier(int iD, string companyName, string contactName, string contactTitle, string address, string city, string region, string postalCode, string country, string phone, string fax, string homePage, SupplierTypes type) { return(new Supplier(iD, companyName, contactName, contactTitle, address, city, region, postalCode, country, phone, fax, homePage, type)); }
/// <summary> /// Goes through the collection, looking for all the Supplier objects /// that have a type that matches the type passed in. /// </summary> /// <param name="type">THe SupplierType enum value</param> /// <returns>Ienumerator object</returns> public IEnumerator GetTypeEnumerator(SupplierTypes type) { foreach (Supplier s in suppliersCollection) { if (s.Type == type) { yield return(s); } } }
/// <summary> /// Constructor for serializing the class /// </summary> /// <param name="info">Stores teh data necessary to serialize or deserialize</param> /// <param name="context">describes source and destination</param> internal Supplier(SerializationInfo info, StreamingContext context) { this.ID = info.GetInt32("ID"); this.CompanyName = info.GetString("CompanyName"); this.ContactName = info.GetString("ContactName"); this.ContactTitle = info.GetString("ContactTitle"); this.Address = info.GetString("Address"); this.City = info.GetString("City"); this.Region = info.GetString("Region"); this.PostalCode = info.GetString("PostalCode"); this.Country = info.GetString("Country"); this.Phone = info.GetString("Phone"); this.Fax = info.GetString("Fax"); this.Homepage = info.GetString("Homepage"); this.Type = (SupplierTypes)info.GetValue("SupplierType", typeof(SupplierTypes)); }
/// <summary> /// Non Default Constructor for Supplier (inherits from Contact) /// </summary> /// <param name="iD">The Supplier ID (int)</param> /// <param name="companyName">The Company Name (string)</param> /// <param name="contactName">The Contact Name (string)</param> /// <param name="contactTitle">The Contact Title (string)</param> /// <param name="address">The Contacts Address (string)</param> /// <param name="city">The Contacts city (string)</param> /// <param name="region">The contacts region (string)</param> /// <param name="postalCode">The contacts postal code (string)</param> /// <param name="country">The contacts country (string)</param> /// <param name="phone">The contacts phone number (string) </param> /// <param name="fax">The contacts fax number(string)</param> /// <param name="homePage">The suppliers homepage (string)</param> /// <param name="type">The type of supplier (SupplierTypes)</param> public Supplier(int iD, string companyName, string contactName, string contactTitle, string address, string city, string region, string postalCode, string country, string phone, string fax, string homePage, SupplierTypes type) : base(iD, companyName, contactName, contactTitle, address, city, region, postalCode, country, phone, fax) { Homepage = homePage; Type = type; ID = iD; CompanyName = companyName; ContactName = contactName; ContactTitle = contactTitle; Address = address; City = city; Region = region; PostalCode = postalCode; Country = country; Phone = phone; Fax = fax; }
/// <summary> /// Gets the supplier information from a struct and loads it. /// </summary> /// <param name="supStruct">The supplier struct</param> public Supplier(DataAccess.SupplierStruct supStruct) { this.ID = supStruct.ID; this.CompanyName = supStruct.CompanyName; this.ContactName = supStruct.ContactName; this.ContactTitle = supStruct.ContactTitle; this.Address = supStruct.Address; this.City = supStruct.City; this.Region = supStruct.Region; this.PostalCode = supStruct.PostalCode; this.Country = supStruct.Country; this.Phone = supStruct.Phone; this.Fax = supStruct.Fax; this.Homepage = supStruct.HomePage; //get the string for SupplierType from supStruct.SUpplierType //convert it to lower case. string supString = supStruct.SupplierType.ToLower(); //now get the string for the enum values, converting them to lower case. string product = Convert.ToString(SupplierTypes.Product).ToLower(); string service = Convert.ToString(SupplierTypes.Service).ToLower(); string supply = Convert.ToString(SupplierTypes.Supply).ToLower(); if (supString == product) { this.Type = SupplierTypes.Product; } else if (supString == service) { this.Type = SupplierTypes.Service; } else if (supString == supply) { this.Type = SupplierTypes.Supply; } else { throw new Exception("Unknown supplier type!"); } }