public Model.Manager.NonConsumableEquipment NewEquipment(Model.Manager.NonConsumableEquipment equipment) { List <NonConsumableEquipment> nonConsumableEquipment = ReadFromFile(); NonConsumableEquipment searchEquipment = GetEquipment(equipment.Id); if (searchEquipment != null) { return(null); } nonConsumableEquipment.Add(equipment); WriteInFile(nonConsumableEquipment); return(equipment); }
private void AddOprema() { Oprema novaOprema = new Oprema(); novaOprema.Sifra = Convert.ToInt32(SifraTb.Text); novaOprema.Kolicina = Convert.ToInt32(KolicinaTb.Text); if (VrstaCb.SelectedItem != null) { novaOprema.VrstaP = (TypeOfConsumable)VrstaCb.SelectedItem; } if (VrstaNeCb.SelectedItem != null) { novaOprema.VrstaN = (TypeOfNonConsumable)VrstaNeCb.SelectedItem; } novaOprema.Tip = (TypeOfEquipment)TipCb.SelectedItem; novaOprema.Sala = Convert.ToInt32(SalaTb.Text); Oprema.Add(novaOprema); if (novaOprema.Tip == TypeOfEquipment.CONSUMABLE) { ConsumableEquipment ce = new ConsumableEquipment(); ce.Id = novaOprema.Sifra; ce.Quantity = novaOprema.Kolicina; ce.Type = novaOprema.VrstaP; ec.NewEquipment(novaOprema.Tip, ce); } if (novaOprema.Tip == TypeOfEquipment.NON_CONSUMABLE) { NonConsumableEquipment ne = new NonConsumableEquipment(); ne.Id = novaOprema.Sifra; ne.Type = novaOprema.VrstaN; ec.NewEquipment(novaOprema.Tip, ne); } if (novaOprema.Sala != 0) { EquipmentInRooms er = new EquipmentInRooms(); er.IdEquipment = novaOprema.Sifra; er.Quantity = novaOprema.Kolicina; er.RoomNumber = novaOprema.Sala; erc.addEquipmentInRoom(er); } // Resetujemo polja ClearFields(); UpdateTempOprema(); }
public bool DeleteEquipment(int id) { List <NonConsumableEquipment> nonConsumableEquipment = ReadFromFile(); NonConsumableEquipment equipmentForDelete = null; foreach (NonConsumableEquipment e in nonConsumableEquipment) { if (e.Id.Equals(id)) { equipmentForDelete = e; break; } } if (equipmentForDelete == null) { return(false); } nonConsumableEquipment.Remove(equipmentForDelete); WriteInFile(nonConsumableEquipment); return(true); }
public NonConsumableEquipment newNonConsumableEquipment(NonConsumableEquipment equipment) { return(nonConsumableEquipmentRepository.NewEquipment(equipment)); }
private void UpdateOprema() { SelektovanaOprema.Sifra = Convert.ToInt32(SifraTb.Text); SelektovanaOprema.Kolicina = Convert.ToInt32(KolicinaTb.Text); if (VrstaCb.SelectedItem != null) { SelektovanaOprema.VrstaP = (TypeOfConsumable)VrstaCb.SelectedItem; } if (VrstaNeCb.SelectedItem != null) { SelektovanaOprema.VrstaN = (TypeOfNonConsumable)VrstaNeCb.SelectedItem; } SelektovanaOprema.Tip = (TypeOfEquipment)TipCb.SelectedItem; SelektovanaOprema.Sala = Convert.ToInt32(SalaTb.Text); if (SelektovanaOprema.Tip == TypeOfEquipment.CONSUMABLE) { ConsumableEquipment ce = new ConsumableEquipment(); ce.Id = SelektovanaOprema.Sifra; ce.Quantity = SelektovanaOprema.Kolicina; ce.Type = SelektovanaOprema.VrstaP; ec.EditConsumableEquipment(ce); } if (SelektovanaOprema.Tip == TypeOfEquipment.NON_CONSUMABLE) { NonConsumableEquipment ne = new NonConsumableEquipment(); ne.Id = SelektovanaOprema.Sifra; ne.Type = SelektovanaOprema.VrstaN; ec.EditNonConsumableEquipment(ne); } if (SelektovanaOprema.Sala != 0) { if (erc.viewEquipmentInRooms(SelektovanaOprema.Sifra) != 0) { EquipmentInRooms er = new EquipmentInRooms(); er.IdEquipment = SelektovanaOprema.Sifra; er.Quantity = SelektovanaOprema.Kolicina; er.RoomNumber = SelektovanaOprema.Sala; erc.editEquipmentInRooms(er); } else { EquipmentInRooms er = new EquipmentInRooms(); er.IdEquipment = SelektovanaOprema.Sifra; er.Quantity = SelektovanaOprema.Kolicina; er.RoomNumber = SelektovanaOprema.Sala; erc.addEquipmentInRoom(er); } } if (SelektovanaOprema.Sala == 0) { EquipmentInRooms er = new EquipmentInRooms(); er.IdEquipment = SelektovanaOprema.Sifra; er.Quantity = SelektovanaOprema.Kolicina; er.RoomNumber = SelektovanaOprema.Sala; erc.deleteEquipmentInRooms(er.IdEquipment); } }