/// <summary> /// Çözgü sepetini doldurur. Eğer verilen sipariş daha önce çözgü sepetine atılmış ise Exception verir. /// </summary> public vCozgu CozguyeAt(int tipId, double miktar, int siparisId) { if (miktar == 0) { throw new Exception("Çözgüye atılacak miktar 0 olamaz..!"); } vPlanSiparisleri2 kontrol = db.GetGeneric <vPlanSiparisleri2>(c => c.SiparisId == siparisId).FirstOrDefault(); if (kontrol != null && (kontrol.CozguMetre > kontrol.PlanMetre)) { throw new Exception("Çözgü metresi plan metresinden fazla olamaz..!"); } tblCozgu tblCozgu = new tblCozgu() { TipId = tipId, Miktar = miktar, OlusturmaTarihi = DateTime.Now, PersId = this.PersonelId, SiparisId = siparisId }; if (db.SaveGeneric <tblCozgu>(ref tblCozgu)) { return(db.GetGeneric <vCozgu>(c => c.TipId == tblCozgu.TipId).FirstOrDefault()); } else { return(null); } }
public bool TezgahPlaniSil(vPlanlama plan) { if (plan == null) { return(false); } bool snc = true; tblCozgu cozgu = db.GetGeneric <tblCozgu>(c => c.SiparisId == plan.SiparisId && c.TipId == plan.TipId).FirstOrDefault(); //eğer silinen plan çözgüyü sıfırlıyorsa o çözgü kaydı silinmelidir. Aksi halde miktarı düşürülerek update edilmelidir. if (cozgu.Miktar - plan.Miktar <= 0) { snc = db.DeleteGeneric <tblCozgu>(cozgu); } else { cozgu.Miktar -= plan.Miktar.Value; snc = db.UpdateGeneric <tblCozgu>(cozgu); } if (snc == false) { return(false); } return(db.DeleteGeneric <tblPlanlama>(plan.ViewToTbl())); }