예제 #1
0
        public override void OnSaveData()
        {
            //see notes above!!
            try
            {
                JarsResourceGroup saveObj = defaultBindingSource.Current as JarsResourceGroup;
                //var upList = new List<OperativeGroup>() { saveOp };
                var store = new StoreResourceGroup()
                {
                    Group = saveObj.ConvertTo <ResourceGroupDto>()
                };
                var resp = ServiceClient.Post(store);

                //if the response was good, then notify the others.
                if (resp.ResponseStatus == null)
                {
                    saveObj = resp.Group.ConvertTo <JarsResourceGroup>();
                    Context.ServiceClient.Post(new ResourceGroupsNotification()
                    {
                        FromUserName = Context.LoggedInUser.UserName,
                        Selector     = SelectorTypes.store,
                        Ids          = new List <int>()
                        {
                            resp.Group.Id
                        }
                    });
                }
                base.OnSaveData();
            }
            catch (Exception exS)
            {
                OnExceptionEvent(exS);
            }
        }
예제 #2
0
 public override bool OnDeleteData()
 {
     try
     {
         JarsResourceGroup delObj = defaultBindingSource.Current as JarsResourceGroup;
         if (delObj.Resources.Count > 0)
         {
             MessageBox.Show($"Unable to delete the group!{Environment.NewLine}There are still resources assigned to it.", "Unable to Delete Group", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (base.OnDeleteData(true))
         {
             var delReq = new DeleteResourceGroup {
                 Id = delObj.Id
             };
             ServiceClient.Delete(delReq);
             defaultBindingSource.RemoveCurrent();
             defaultBindingSource.ResetBindings(false);
         }
     }
     catch (Exception exD)
     {
         OnExceptionEvent(exD);
     }
     return(base.OnDeleteData());
 }
예제 #3
0
        public override void OnAddData()
        {
            base.OnAddData();
            JarsResourceGroup newOp = defaultBindingSource.AddNew() as JarsResourceGroup;

            defaultBindingSource.Position = defaultBindingSource.IndexOf(newOp);
        }
예제 #4
0
        private void ctrl_AddToGroup_Click(object sender, EventArgs e)
        {
            List <JarsResourceGroup> AllGrps = Context.ServiceClient.Get(new FindResourceGroups()
            {
                IsActive = true
            }).Groups.ConvertAll(gcConditions => gcConditions.ConvertTo <JarsResourceGroup>());
            IList <SearchEntity <int> > existingGroups  = ((IList <JarsResourceGroup>)groupsBindingSource.List).GenerateSearchEntities(x => x.Name, x => x.Id, true);
            IList <SearchEntity <int> > allSearchGroups = AllGrps.GenerateSearchEntities(x => x.Name, x => x.Id, false);

            IList <SearchEntity <int> > returnList = SelectEntitiesForm.ShowForm(existingGroups, allSearchGroups, "Select Groups");
            //convert the return list to the entities.
            IList <JarsResourceGroup> newList = new List <JarsResourceGroup>();

            foreach (var sEnt in returnList)
            {
                JarsResourceGroup opG = AllGrps.FirstOrDefault(op => op.Id.ToString() == sEnt.ValueId.ToString());
                if (opG != null)
                {
                    newList.Add(opG);
                }
            }
            (defaultBindingSource.Current as JarsResource).Groups.Clear();

            //add the new group, if there were any
            foreach (var grp in newList)
            {
                if ((defaultBindingSource.Current as JarsResource).Groups.FirstOrDefault(g => g.Id == grp.Id) == null)
                {
                    (defaultBindingSource.Current as JarsResource).Groups.Add(grp);
                }
            }
            groupsBindingSource.ResetBindings(false);
        }
예제 #5
0
파일: SetupDataUtil.cs 프로젝트: CobyC/JaRS
        public static IList <JarsResourceGroup> GetDefaultResourceGroup()
        {
            List <JarsResourceGroup> _ResourceGroup = new List <JarsResourceGroup>();
            var carp = new JarsResourceGroup {
                Code = "CP", IsActive = true, Name = "Carpenters", SortIndex = 0, CreatedBy = crmo
            };

            //JarsResource cp1 = new JarsResource
            //{
            //    IsActive = true,
            //    IsMobileResource = true,
            //    DayStartTime = TimeSpan.FromHours(7.30),
            //    DayEndTime = TimeSpan.FromHours(7.30).Add(TimeSpan.FromHours(8)),
            //    ExtRef = "CRP01",
            //    VehicleRegistration = "VEH1",
            //    FirstName = "Carpin",
            //    LastName = "Terra",
            //    CreatedBy = crmo,
            //    MobileNo = "01234567890",
            //    eMail = "*****@*****.**"
            //    //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Carpenter", ExpiryMatters = false, DocumentCode = "CAPRQUAL01" } }
            //};
            //cp1.DisplayName = cp1.GenerateDisplayName(false, true, true);
            //carp.Resources.Add(cp1);
            _ResourceGroup.Add(carp);

            var el = new JarsResourceGroup {
                Code = "EL", IsActive = true, Name = "Electricians", SortIndex = 1, CreatedBy = crmo
            };

            //JarsResource el1 = new JarsResource
            //{
            //    IsActive = true,
            //    IsMobileResource = true,
            //    DayStartTime = TimeSpan.FromHours(8.00),
            //    DayEndTime = TimeSpan.FromHours(7.30).Add(TimeSpan.FromHours(8)),
            //    ExtRef = "ELE01",
            //    VehicleRegistration = "VEH2",
            //    FirstName = "Elli",
            //    LastName = "Tris",
            //    CreatedBy = crmo,
            //    MobileNo = "01234567890",
            //    eMail = "*****@*****.**"
            //    //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Electrician", ExpiryMatters = true, DocumentCode = "ELECQUAL01", StartDate = DateTime.Now.AddDays(-3), EndDate = DateTime.Now.AddYears(2) } }
            //};
            //el1.DisplayName = el1.GenerateDisplayName(false, true, true);
            //el.Resources.Add(el1);
            _ResourceGroup.Add(el);

            var plu = new JarsResourceGroup {
                Code = "PL", IsActive = true, Name = "Plumbers", SortIndex = 2, CreatedBy = crmo
            };

            //JarsResource pl1 = new JarsResource
            //{
            //    IsActive = true,
            //    IsMobileResource = true,
            //    DayStartTime = TimeSpan.FromHours(8.30),
            //    DayEndTime = TimeSpan.FromHours(8.30).Add(TimeSpan.FromHours(8)),
            //    ExtRef = "PLU01",
            //    VehicleRegistration = "VEH3",
            //    FirstName = "Plumbi",
            //    LastName = "Erro",
            //    CreatedBy = crmo,
            //    MobileNo = "01234567890",
            //    eMail = "*****@*****.**"
            //    //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Plumber", ExpiryMatters = true, DocumentCode = "PLUMBQUAL01", StartDate = DateTime.Now.AddDays(-3), EndDate = DateTime.Now.AddYears(2) } }
            //};
            //pl1.DisplayName = pl1.GenerateDisplayName(false, true, true);
            //plu.Resources.Add(pl1);
            _ResourceGroup.Add(plu);

            var fen = new JarsResourceGroup {
                Code = "FN", IsActive = true, Name = "Fencing", SortIndex = 3, CreatedBy = crmo
            };

            //JarsResource fn1 = new JarsResource
            //{
            //    IsActive = true,
            //    IsMobileResource = true,
            //    DayStartTime = TimeSpan.FromHours(8.00),
            //    DayEndTime = TimeSpan.FromHours(8.00).Add(TimeSpan.FromHours(8)),
            //    ExtRef1 = "FEN01",
            //    VehicleRegistration = "VEH4",
            //    FirstName = "Fenn",
            //    LastName = "Sirr",
            //    CreatedBy = crmo,
            //    MobileNo = "01234567890",
            //    eMail = "*****@*****.**"
            //    //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Carpenter", ExpiryMatters = false, DocumentCode = "FENCQUAL01" } }
            //};
            //fn1.DisplayName = fn1.GenerateDisplayName(false, true, true);
            //fen.Resources.Add(fn1);
            _ResourceGroup.Add(fen);

            var mlt = new JarsResourceGroup {
                Code = "MT", IsActive = true, Name = "Multi Traders", SortIndex = 5, CreatedBy = crmo
            };

            _ResourceGroup.Add(mlt);

            var eqp = new JarsResourceGroup {
                Code = "EQUIP", IsActive = true, Name = "Equipment", SortIndex = 6, CreatedBy = crmo
            };

            //JarsResource ph1 = new JarsResource
            //{
            //    IsActive = true,
            //    IsMobileResource = false,
            //    DayStartTime = TimeSpan.FromHours(8),
            //    DayEndTime = TimeSpan.FromHours(8).Add(TimeSpan.FromHours(8)),
            //    VehicleRegistration = "",
            //    FirstName = "Cherry",
            //    LastName = "Picker",
            //    CreatedBy = crmo,
            //};
            //ph1.DisplayName = ph1.GenerateDisplayName(false, true, true);
            //eqp.Resources.Add(ph1);
            _ResourceGroup.Add(eqp);

            return(_ResourceGroup);
        }