public static void AddNewShiftDef(ShiftDef.DTO headDTO, List <ShiftPoint.DTO> lineDTOs) { DakkaLinqDataContext db = DBHelper.GetDakkaLinqDataContext(); ShiftDef shiftDef = new ShiftDef { Code = headDTO.Code, Name = headDTO.Name, ShiftType = new ShiftTypeEnum(headDTO.ShiftType).Value, Description = headDTO.Description }; foreach (var line in lineDTOs) { ShiftPoint shiftPoint = new ShiftPoint { IndexNumber = line.IndexNumber, Name = line.Name, PointTime = DateTime.Parse(line.PointTime), Before = int.Parse(line.Before), After = int.Parse(line.After), PointType = new PointTypeEnum(line.PointType).Value }; shiftDef.ShiftPoint.Add(shiftPoint); } db.ShiftDef.InsertOnSubmit(shiftDef); db.SubmitChanges(); }
public static void UpdateShiftDef(ShiftDef.DTO headDTO, List <ShiftPoint.DTO> lineDTOs) { DakkaLinqDataContext db = DBHelper.GetDakkaLinqDataContext(); ShiftDef shiftDef = db.ShiftDef.Single(sd => sd.ID == headDTO.ID); foreach (ShiftPoint point in shiftDef.ShiftPoint) { db.ShiftPoint.DeleteOnSubmit(point); } shiftDef.Code = headDTO.Code; shiftDef.Name = headDTO.Name; shiftDef.ShiftType = new ShiftTypeEnum(headDTO.ShiftType).Value; shiftDef.Description = headDTO.Description; foreach (var line in lineDTOs) { ShiftPoint shiftPoint = new ShiftPoint { IndexNumber = line.IndexNumber, Name = line.Name, PointTime = DateTime.Parse(line.PointTime), Before = int.Parse(line.Before), After = int.Parse(line.After), PointType = new PointTypeEnum(line.PointType).Value }; shiftDef.ShiftPoint.Add(shiftPoint); } db.SubmitChanges(); }
private void detach_ShiftPoint(ShiftPoint entity) { this.SendPropertyChanging(); entity.ShiftDef1 = null; }
private void attach_ShiftPoint(ShiftPoint entity) { this.SendPropertyChanging(); entity.ShiftDef1 = this; }
partial void DeleteShiftPoint(ShiftPoint instance);
partial void UpdateShiftPoint(ShiftPoint instance);
partial void InsertShiftPoint(ShiftPoint instance);