public StorageUnit(StorageUnit s) { Code = s.Code; Name = s.Name; CapacityInPieces = s.CapacityInPieces; CapsityInWeight = s.CapsityInWeight; }
public void ReadXML(string filename, StorageUnit r) { StreamReader rd = null; try { /// napravi se objekat koji je u stanju da cita podatke iz fajla rd = new StreamReader(filename, Encoding.Unicode); /// kreira se objekat serijalizatora koji moze da deserijalizuje /// objekte klase student XmlSerializer sr = new XmlSerializer(typeof(StorageUnit)); ///poziva se deserijalizacija StorageUnit loadedData = (StorageUnit)sr.Deserialize(rd); r.Name = loadedData.Name; r.Code = loadedData.Code; r.CapacityInPieces = loadedData.CapacityInPieces; r.CapsityInWeight = loadedData.CapsityInWeight; /// vraca se restaurirani objekat } catch (Exception e) { MessageBox.Show(e.Message); } finally { if (rd != null) { rd.Close(); } } }
public InstanceOfProduct(Product p, StorageUnit s, DateTime stored) { InternalRunningNumber = GenerateInternal(); FixedStorageIndetifiner = GenerateFixed(); RefOfProduct = p; RefOfStorage = s; DateOfStorage = stored; }
public void Delete(StorageUnit s) { for (int i = 0; i < ListOfProducts.Count; i++) { if (ListOfProducts[i].RefOfStorage.Code == s.Code) { ListOfProducts.Remove(ListOfProducts[i]); } } }
public void AddProduct(Product p, StorageUnit s) { ListOfProducts.Add(new InstanceOfProduct(p, s, DateTime.Now)); bool b = true; foreach (InstanceOfProduct i in ListOfProducts) { if (i.RefOfStorage.Code == s.Code) { b = true; } } if (b) { ListOfStorage.Add(s); } }