예제 #1
0
 private void GetSelected(object sender, out MyMenuItem SelectedItem, out AccountingMoeinStructureDefine ChangableItem, out AccountingMoeinStructureDefine Child)
 {
     if (trvMenu.SelectedItem == null)
     {
         SelectedItem  = null;
         ChangableItem = null;
         Child         = null;
         return;
     }
     SelectedItem  = trvMenu.SelectedItem as MyMenuItem;
     ChangableItem = Business.GetMoeinStructureDefineBusiness().GetByID(SelectedItem.ID).FirstOrDefault();
     Child         = Business.GetMoeinStructureDefineBusiness().GetByParentID(ChangableItem.ID).FirstOrDefault();
 }
예제 #2
0
        public List <AccountingMoeinTafsilRelation> SetRelation(AccountingMoeinStructureDefine TafsilLevel, List <AccountingTafsilStructureDefine> TafsilGroup)
        {
            List <AccountingMoeinTafsilRelation> result = new List <AccountingMoeinTafsilRelation>();

            foreach (var item in TafsilGroup)
            {
                result.Add(new AccountingMoeinTafsilRelation()
                {
                    AcountingMoein_ID = TafsilLevel.ID, AccountingTafsil_ID = item.ID
                });
            }
            return(result);
        }
예제 #3
0
        private void new_Click(object sender, RoutedEventArgs e)
        {
            MyMenuItem SelectedItem;
            AccountingMoeinStructureDefine ChangableItem;
            AccountingMoeinStructureDefine Child;
            MoeinStructureDefineChild      structure = new MoeinStructureDefineChild();

            GetSelected(sender, out SelectedItem, out ChangableItem, out Child);

            if (SelectedItem == null)
            {
                MoeinStructureDefineChild moein = new MoeinStructureDefineChild();
                moein.ShowDialog();
                if (moein.EntityPrimery != null)
                {
                    menuItems.Add(new MyMenuItem()
                    {
                        ID = moein.EntityPrimery.ID, Code = moein.EntityPrimery.Code, Name = moein.EntityPrimery.Name, Type = moein.EntityPrimery.Type
                    });
                }
                if (moein.EntitySecondery != null)
                {
                    menuItems.Find(r => r.ID == moein.EntityPrimery.ID).
                    Items.Add(new MyMenuItem()
                    {
                        ID = moein.EntitySecondery.ID, Code = moein.EntitySecondery.Code, Name = moein.EntitySecondery.Name, Type = moein.EntitySecondery.Type
                    });
                }
                trvMenu.Items.Refresh();
                return;
            }

            if (ChangableItem.Type == SecondLevel)
            {
                var ChangableItemParent = Business.GetMoeinStructureDefineBusiness().GetParent(ChangableItem);
                setDisablePrimeryItem(structure);

                structure.txtPrimeryGroupCode.Text      = ChangableItemParent.Code;
                structure.txtPrimeryGroupName.Text      = ChangableItemParent.Name;
                structure.txtPrimeryGroupLatinName.Text = ChangableItemParent.Latin_Name;
                structure.CallPrimeryLostFocus();
            }

            structure.ShowDialog();

            if (SelectedItem.Type == Constants.CodeTitle.Goruh && structure.EntityPrimery != null)
            {
                SelectedItem = new MyMenuItem()
                {
                    Code = structure.EntityPrimery.Code, ID = structure.EntityPrimery.ID, Name = structure.EntityPrimery.Name, Type = Constants.CodeTitle.Goruh
                };
                menuItems.Add(SelectedItem);
            }
            if (SelectedItem.Type == Constants.CodeTitle.Goruh && structure.EntitySecondery != null)
            {
                AccountingMoeinStructureDefine ChangableItemParent = Business.GetMoeinStructureDefineBusiness().GetParent(structure.EntitySecondery);
                MyMenuItem item = menuItems.Find(r => r.ID == ChangableItemParent.ID);
                item.Items.Add(new MyMenuItem()
                {
                    Code = structure.EntitySecondery.Code, ID = structure.EntitySecondery.ID, Name = structure.EntitySecondery.Name, Type = Constants.CodeTitle.Kol
                });
            }

            if (SelectedItem.Type == Common.Constants.CodeTitle.Kol && structure.EntitySecondery != null)
            {
                AccountingMoeinStructureDefine ChangableItemParent = Business.GetMoeinStructureDefineBusiness().GetParent(ChangableItem);
                MyMenuItem item = menuItems.Find(r => r.ID == ChangableItemParent.ID);
                item.Items.Add(new MyMenuItem()
                {
                    Code = structure.EntitySecondery.Code, ID = structure.EntitySecondery.ID, Name = structure.EntitySecondery.Name, Type = Constants.CodeTitle.Kol
                });
            }

            trvMenu.Items.Refresh();
        }