protected void SwitchRunSeqs(PrdnEntities prdnDBContext, ProductionJob jobFrom, ProductionJob jobTo) { decimal seqFrom = jobFrom.RunSeqNo; decimal seqTo = jobTo.RunSeqNo; jobFrom.RunSeqNo = -99; prdnDBContext.SaveChanges(); jobTo.RunSeqNo = seqFrom; prdnDBContext.SaveChanges(); jobFrom.RunSeqNo = seqTo; prdnDBContext.SaveChanges(); }
static void daty() { using (PrdnEntities ctx = new PrdnEntities()) { var q = from p in ctx.CalendarDays orderby p.CalDay select p; ObjectQuery oq = (ObjectQuery)q; string s = oq.ToTraceString(); Console.WriteLine(s); Console.ReadLine(); CalendarDay c = new CalendarDay(); c.CalDay = DateTime.Today; ctx.CalendarDays.AddObject(c); ctx.SaveChanges(); } }
protected void InsertRunSeqBefore(PrdnEntities prdnDBContext, ProductionJob jobFrom, int targSeqTo) { var targJobs = (from j in PrdnDBContext.ProductionJobs where j.RunID == jobFrom.RunID where j.RunSeqNo > targSeqTo - 1 && j.RunSeqNo <= targSeqTo orderby j.RunSeqNo select new { j.RunSeqNo }).ToList(); if (targJobs.Count < 1) { throw new Exception(SystemExtensions.Sentence(LocalStr.Job, LocalStr.SeqNo, targSeqTo.ToString(), LocalStr.verbIsNot, LocalStr.valid)); } var targJob = targJobs.OrderBy(j => j.RunSeqNo).Last(); if (targJobs.Count == 1) { jobFrom.RunSeqNo = targJob.RunSeqNo - 0.5M; } else { var nextLowJob = targJobs.Where(j => j.RunSeqNo < targJob.RunSeqNo).OrderBy(j => j.RunSeqNo).Last(); decimal gap = targJob.RunSeqNo - nextLowJob.RunSeqNo; jobFrom.RunSeqNo = nextLowJob.RunSeqNo + gap + (gap/2); } prdnDBContext.SaveChanges(); }