OT_SHIFT CreateNewShiftNoDB(string shift_name, string compensate_rate) { if (BaseShiftSequence.Equals(-1)) { var q = from p in context.OT_SHIFT orderby p.SEQ_ID descending select p; int seq = 1; if (q.FirstOrDefault() != null) { seq = (short)q.FirstOrDefault().SEQ_ID+1; } BaseShiftSequence = seq; } OT_SHIFT shift = new OT_SHIFT(); shift.SHIFT_ID = Guid.NewGuid().ToString(); shift.SHIFT_NAME = shift_name; shift.STATUS = "0"; shift.CREATE_BY = "System"; shift.CREATE_DATE = DateTime.Now; shift.OT_TIME = decimal.Parse(compensate_rate); shift.SEQ_ID = (short)BaseShiftSequence; shift.VERSION_NUM = 0; BaseShiftSequence++; return shift; }
OT_SHIFT CreateNewShift(string shift_name,string compensate_rate) { var q=from p in context.OT_SHIFT orderby p.SEQ_ID descending select p; OT_SHIFT shift= new OT_SHIFT(); shift.SHIFT_ID = Guid.NewGuid().ToString(); shift.SHIFT_NAME = shift_name; shift.STATUS = "0"; shift.CREATE_BY = "System"; shift.CREATE_DATE = DateTime.Now; shift.OT_TIME = decimal.Parse(compensate_rate); int seq=1; if (q.FirstOrDefault() != null) { if (q.FirstOrDefault().SEQ_ID != null) seq = (int)q.FirstOrDefault().SEQ_ID + 1; else seq = 1; } shift.SEQ_ID =(short) seq ; shift.VERSION_NUM = 0; context.OT_SHIFT.Add(shift); context.SaveChanges(); return shift; }