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())); }
/// <summary> /// Yeni bir planlama kaydedilecekse plan.Id 'si 0'dır. Sistem buna göre yeni kaydı açar. Bunun için de girilen plan.Tarih ve plan.Tarih + gunSayisi arasındaki günlerde herhangi bir plan olmamalıdır. /// Eğer bu günler arasında bir plan varsa plan kaydedilmez ve fonksiyon -1 dönderir. /// /// Eski bir planlama üzerinde update yapılacaksa plan.Id'si 0'dan farklıdır ve buna göre verilen plan update edilir. /// </summary> /// <param name="plan">vPlanlama türünde veridir.</param> /// <param name="gunSayisi">plan.Tarih'inden itibaren kaç güne plan atılacağını belirler. Her bir güne dokunacak olan bilgi plan.Miktar içerisinde saklıdır.</param> /// <returns></returns> public int PlanlamaKaydet(vPlanlama plan, int gunSayisi) { if (plan.Id == 0) { if (db.GetGeneric <tblPlanlama>(c => c.TezgahId == plan.TezgahId && c.Tarih >= plan.Tarih.Value && c.Tarih < plan.Tarih.Value.AddDays(gunSayisi)).Count > 0) { return(-1); } List <tblPlanlama> listPlan = new List <tblPlanlama>(); int tarihIndisi = 0; for (int i = 0; i < gunSayisi; i++) { tblPlanlama tblPlan = plan.ViewToTbl(); if (tblPlan.Tarih.AddDays(tarihIndisi).DayOfWeek != DayOfWeek.Sunday) { tblPlan.Tarih = tblPlan.Tarih.AddDays(tarihIndisi); listPlan.Add(tblPlan); } else { gunSayisi++; //plan pazara geliyorsa o gün atlanmalı ve gün sayısı 1 artırılmalı. } tarihIndisi++; } return((db.SaveGeneric <tblPlanlama>(listPlan) == true) ? 1 : 0); } else { return((db.UpdateGeneric <tblPlanlama>(plan.ViewToTbl()) == true) ? 1 : 0); } }
private void KumasSetEt() { vPlanlama plan = _Db.GetGeneric <vPlanlama>(c => c.TezgahId == _TezgahId && c.TipId == _TipId && c.Tarih.Value == DateTime.Today).FirstOrDefault(); if (plan == null) { this._KumasAlt.SiparisId = null; this._KumasUst.SiparisId = null; } else { _KumasUst.SiparisId = plan.SiparisId; _KumasAlt.SiparisId = plan.SiparisId; } List <vLeventHareket> leventler = _Db.GetGeneric <vLeventHareket>(c => c.TezgahId == this._TezgahId && c.TipId == this._TipId && c.Durum == 21); vLeventHareket altZeminLevent = leventler.Find(c => c.Cozgu == "Alt Zemin"); vLeventHareket ustZeminLevent = leventler.Find(c => c.Cozgu == "Üst Zemin"); vLeventHareket havLevent = leventler.Find(c => c.Cozgu == "Hav"); if (altZeminLevent != null) { _KumasAlt.ZeminAltLeventId = altZeminLevent.Id; _KumasUst.ZeminAltLeventId = altZeminLevent.Id; this.AltZeminLevent = altZeminLevent; } else { _KumasAlt.ZeminAltLeventId = null; _KumasUst.ZeminAltLeventId = null; this.AltZeminLevent = null; } if (ustZeminLevent != null) { _KumasAlt.ZeminUstLeventId = ustZeminLevent.Id; _KumasUst.ZeminUstLeventId = ustZeminLevent.Id; this.UstZeminLevent = ustZeminLevent; } else { _KumasAlt.ZeminUstLeventId = null; _KumasUst.ZeminUstLeventId = null; this.UstZeminLevent = null; } if (havLevent != null) { _KumasAlt.HavLeventId = havLevent.Id; _KumasUst.HavLeventId = havLevent.Id; this.HavLevent = havLevent; } else { _KumasAlt.HavLeventId = null; _KumasUst.HavLeventId = null; this.HavLevent = null; } }
public vPlanlama TezgahPlanDetayGetir(int tezgahId, DateTime date) { vPlanlama plan = db.GetGeneric <vPlanlama>(c => c.TezgahId == tezgahId && c.Tarih == date).FirstOrDefault(); if (plan != null) { plan.ToplamDokunan = db.GetGeneric <tblHamKumaslar>(c => c.SiparisId == plan.SiparisId && c.TipId == plan.TipId).Sum(s => s.Metre); plan.ToplamPlan = db.GetGeneric <tblPlanlama>(c => c.SiparisId == plan.SiparisId && c.TipId == plan.TipId).Sum(s => s.Miktar); } return(plan); }