Пример #1
0
        public ActionResult DeleteStaffOrganisation(Guid?staffCode, FormCollection form)
        {
            var model = GetUpdatedModel();

            //Set flags false
            SetFlagsFalse(model);

            //Establish which staff organisation to remove
            Guid StaffOrganisationValue = Guid.Empty;

            foreach (string KeyItem in form)
            {
                if (KeyItem.StartsWith("ApplicationStaffAdmin::DeleteStaffOrganisation"))
                {
                    StaffOrganisationValue = Guid.Parse(KeyItem.Substring(47));
                    break;
                }
            }

            var StaffOrganisationItem = model.StaffOrganisationList.Single(x => x.Code == StaffOrganisationValue);

            model.StaffOrganisationList.Remove(StaffOrganisationItem);

            DetermineIsDirty(model);
            return(View(model));
        }
Пример #2
0
        public ActionResult UpdateOrganisation(Guid?staffCode, FormCollection form)
        {
            var model = GetUpdatedModel();
            //Set flags false

            //Establish which drop downs need updating
            Guid OrganisationByTypeValue = Guid.Empty;
            Guid PrefixValue             = Guid.Empty;

            foreach (string KeyItem in form)
            {
                if (KeyItem.StartsWith("ApplicationOrganisationSelect::UpdateOrganisation"))
                {
                    PrefixValue = Guid.Parse(KeyItem.Substring(50));
                    var HiddenFieldKey = "OrganisationsByRows[" + PrefixValue.ToString() + "].OrganisationTypeItem.Code";
                    OrganisationByTypeValue = Guid.Parse(form[HiddenFieldKey]);
                    break;
                }
            }

            var AllOrganisationsForApplicationByTypesList = SessionManager.AllOrganisationsForApplicationByTypesList;

            // Modified to handle multiple organisation types for the same level of the organisation hierarchy.
            var clickedItem = model.OrganisationsByTypesList.Single(x => x.OrganisationTypeItem.Code == OrganisationByTypeValue);

            if (clickedItem.SelectedOrganisationCode != null)
            {
                var AllOrgsListsForNextLevel = AllOrganisationsForApplicationByTypesList.FindAll(x => x.OrganisationTypeItem.LevelNumber == clickedItem.OrganisationTypeItem.LevelNumber + 1);
                if (AllOrgsListsForNextLevel != null && AllOrgsListsForNextLevel.Count > 0)
                {
                    OrganisationByTypeVM AllOrgsForNextLevel = null;
                    foreach (OrganisationByTypeVM organisationTypeVMitem in AllOrgsListsForNextLevel)
                    {
                        //int levelNum = organisationTypeVMitem.OrganisationTypeItem.LevelNumber;
                        if (organisationTypeVMitem.OrganisationList.Count > 0)
                        {
                            foreach (var organisationItem in organisationTypeVMitem.OrganisationList)
                            {
                                if (organisationItem.ParentID == Guid.Parse(clickedItem.SelectedOrganisationCode))
                                {
                                    AllOrgsForNextLevel = organisationTypeVMitem;
                                    break;
                                }
                                //var ChildVM = model.OrganisationsByTypesList.SingleOrDefault(x => x.OrganisationTypeItem.ParentOrganisationTypeCode == clickedItem.OrganisationTypeItem.Code);
                            }
                            if (AllOrgsForNextLevel != null)
                            {
                                break;
                            }
                        }
                    }
                    if (AllOrgsForNextLevel != null)
                    {
                        var ChildVMList = model.OrganisationsByTypesList.FindAll(x => x.OrganisationTypeItem.ParentOrganisationTypeCode == clickedItem.OrganisationTypeItem.Code);
                        OrganisationByTypeVM ChildVM = null;
                        if (ChildVMList != null && ChildVMList.Count > 0)
                        {
                            foreach (OrganisationByTypeVM listItem in ChildVMList)
                            {
                                OrganisationByTypeVM ChildVMtemp = null;
                                if (listItem.OrganisationTypeItem.Code == AllOrgsForNextLevel.OrganisationTypeItem.Code)
                                {
                                    ChildVM     = listItem;
                                    ChildVMtemp = listItem;
                                    ChildVM.OrganisationList = AllOrgsForNextLevel.OrganisationList.Where(x => x.ParentID == Guid.Parse(clickedItem.SelectedOrganisationCode)).ToList();
                                }
                                else
                                {
                                    ChildVMtemp = listItem;
                                }
                                //empty the lists below the child of the clicked item
                                var BelowChildVMs = model.OrganisationsByTypesList.Where(x => x.OrganisationTypeItem.LevelNumber >= ChildVMtemp.OrganisationTypeItem.LevelNumber);
                                foreach (var item in BelowChildVMs)
                                {
                                    if (item.OrganisationTypeItem.LevelNumber != ChildVMtemp.OrganisationTypeItem.LevelNumber)
                                    {
                                        item.OrganisationList = new List <OrganisationModel>();
                                    }
                                    else
                                    {
                                        // clear the other lists at the same level i.e. handle multiple organisationTypes with the same parent
                                        if (item.OrganisationList.Count > 0 && Guid.Parse(clickedItem.SelectedOrganisationCode) != item.OrganisationList[0].ParentID)
                                        {
                                            item.OrganisationList = new List <OrganisationModel>();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                //Empty the lists below the empty clicked item
                var BelowChildVMs = model.OrganisationsByTypesList.Where(x => x.OrganisationTypeItem.LevelNumber > clickedItem.OrganisationTypeItem.LevelNumber);
                foreach (var item in BelowChildVMs)
                {
                    item.OrganisationList = new List <OrganisationModel>();
                }
            }

            return(View(model));
        }
Пример #3
0
        /// <summary>
        ///     Drop MongoDB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DelMongoDBToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String strTitle   = "Drop Database";
            String strMessage = "Are you really want to Drop current Database?";

            if (!SystemManager.IsUseDefaultLanguage)
            {
                strTitle   = SystemManager.MStringResource.GetText(StringResource.TextType.Drop_DataBase);
                strMessage = SystemManager.MStringResource.GetText(StringResource.TextType.Drop_DataBase_Confirm);
            }
            if (!MyMessageBox.ShowConfirm(strTitle, strMessage))
            {
                return;
            }
            String strPath   = SystemManager.SelectTagData;
            String strDBName = strPath.Split("/".ToCharArray())[(int)MongoDbHelper.PathLv.DatabaseLv];

            if (trvsrvlst.SelectedNode == null)
            {
                trvsrvlst.SelectedNode = null;
            }
            String rtnResult = MongoDbHelper.DataBaseOpration(SystemManager.SelectObjectTag, strDBName,
                                                              MongoDbHelper.Oprcode.Drop, trvsrvlst.SelectedNode);

            if (String.IsNullOrEmpty(rtnResult))
            {
                DisableAllOpr();
                //关闭所有的相关视图
                //foreach不能直接修改,需要一个备份
                var tempTable = new Dictionary <string, TabPage>();
                foreach (String item in _viewTabList.Keys)
                {
                    tempTable.Add(item, _viewTabList[item]);
                }

                foreach (String KeyItem in tempTable.Keys)
                {
                    //如果有相同的前缀
                    if (KeyItem.StartsWith(strPath))
                    {
                        ToolStripMenuItem DataMenuItem = null;
                        foreach (ToolStripMenuItem Menuitem in collectionToolStripMenuItem.DropDownItems)
                        {
                            //菜单的寻找
                            if (Menuitem.Tag == _viewTabList[KeyItem].Tag)
                            {
                                DataMenuItem = Menuitem;
                            }
                        }
                        if (DataMenuItem != null)
                        {
                            //菜单的删除
                            collectionToolStripMenuItem.DropDownItems.Remove(DataMenuItem);
                        }
                        //TabPage的删除
                        tabView.Controls.Remove(_viewTabList[KeyItem]);
                        _viewTabList.Remove(KeyItem);
                        _viewInfoList.Remove(KeyItem);
                        _viewTabList[KeyItem] = null;
                    }
                }
                tempTable = null;
            }
            else
            {
                MyMessageBox.ShowMessage("Error", "Error", rtnResult, true);
            }
        }