public void NewAssignHwgrToWorld() { HwgrTreeItem item = null; if (IsHwgrFocused) item = FocusedEntity as HwgrTreeItem; WorldToHwgr newitem = new WorldToHwgr(); newitem.StoreID = m_context.Store.ID; if (item != null) { newitem.HWGR_ID = item.Hwgr.HWGR_ID; newitem.WorldID = item.Hwgr.WorldID; newitem.BeginTime = DateTimeHelper.GetNextMonday(DateTime.Today); newitem.EndTime = DateTimeSql.SmallDatetimeMax; } else { newitem.BeginTime = DateTime.Today; newitem.EndTime = DateTimeSql.SmallDatetimeMax; newitem.HWGR_ID = m_context.WorldToHwgr.HWGR_ID; newitem.WorldID = m_context.WorldToHwgr.WorldID; } using (FormAssignHwgrToWorld form = new FormAssignHwgrToWorld()) { form.Context = m_context; form.Entity = newitem; if (form.ShowDialog() == DialogResult.OK) { treeList.BeginUpdate(); m_context.TakeStoreStructure.ReBuildByHwgr (newitem.HWGR_ID, (treeList.DataSource as BindingTemplate<BaseTreeItem>)); EntityChanged(); treeList.EndUpdate(); } } }
/* private void CopyEntity(WorldToHwgr source, WorldToHwgr dest) { dest.ID = source.ID; dest.HWGR_ID = source.HWGR_ID; dest.HwgrName = source.HwgrName; dest.Import = source.Import; dest.StoreID = source.StoreID; dest.WorldID = source.WorldID; dest.BeginTime = source.BeginTime; dest.EndTime = source.EndTime; } */ public override bool Commit() { if (IsValid()) { if (IsModified()) { WorldToHwgr entity = new WorldToHwgr(); WorldToHwgr.CopyTo(EntityWorldToHwgr, entity); //CopyEntity(EntityWorldToHwgr, entity); entity.ID = 0; entity.WorldID = WorldId; entity.HWGR_ID = HwgrId; entity.BeginTime = BeginTime; entity.EndTime = EndTime; try { List<WorldToHwgr> lst = ClientEnvironment.WorldToHWGRService.InsertRelation (entity); if (lst != null) Context.TakeStoreStructure.MergeWorldToHwgr(lst); //CopyEntity(entity, EntityWorldToHwgr); WorldToHwgr.CopyTo(entity, EntityWorldToHwgr); EntityWorldToHwgr.HwgrName = hwgrLookUpCtrl.Text; Modified = true; return base.Commit(); } catch (ValidationException) { ErrorMessage(GetLocalized("ErrorDateRangeIntersect")); return false; } } else return base.Commit(); } return false; }
public override bool Commit() { long worldID = (long)edWorld.EditValue; WorldToHwgr attach = ClientEnvironment.WorldToHWGRService.CreateEntity(); attach.BeginTime = uc.BeginTime; attach.EndTime = uc.EndTime; attach.HWGR_ID = (long)EditHWGR.EditValue; attach.Import = false; attach.StoreID = worldID; m_entityName = EditHWGR.Text; m_attached = attach = ClientEnvironment.WorldToHWGRService.Save(attach); return true; }