Esempio n. 1
0
 private static void setDisablePrimeryItem(MoeinStructureDefineChild structure)
 {
     structure.txtPrimeryGroupCode.IsEnabled      = false;
     structure.txtPrimeryGroupName.IsEnabled      = false;
     structure.txtPrimeryGroupLatinName.IsEnabled = false;
 }
Esempio n. 2
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();
        }
Esempio n. 3
0
        private void edit_Click(object sender, RoutedEventArgs e)
        {
            MyMenuItem SelectedItem;
            AccountingMoeinStructureDefine ChangableItem;
            AccountingMoeinStructureDefine Child;

            GetSelected(sender, out SelectedItem, out ChangableItem, out Child);
            MoeinStructureDefineChild structure = new MoeinStructureDefineChild(ChangableItem);

            try
            {
                if (SelectedItem == null)
                {
                    throw new Exception(Localize.ex_no_record_selected);
                }



                if (ChangableItem.Type == FristLevel)
                {
                    setDisableSecenderyItem(structure);

                    structure.txtPrimeryGroupCode.Text      = ChangableItem.Code;
                    structure.txtPrimeryGroupName.Text      = ChangableItem.Name;
                    structure.txtPrimeryGroupLatinName.Text = ChangableItem.Latin_Name;
                    if (Child != null)
                    {
                        structure.txtPrimeryGroupCode.IsEnabled = false;
                    }
                }
                else if (ChangableItem.Type == SecondLevel)
                {
                    setDisablePrimeryItem(structure);

                    structure.txtSecenderyGroupCode.Text      = ChangableItem.Code.Substring(structure.GoruhLen);
                    structure.txtSecenderyGroupName.Text      = ChangableItem.Name;
                    structure.txtSecenderyGroupLatinName.Text = ChangableItem.Latin_Name;

                    var parent = Business.GetMoeinStructureDefineBusiness().GetParent(ChangableItem);
                    structure.txtPrimeryGroupCode.Text      = parent.Code;
                    structure.txtPrimeryGroupName.Text      = parent.Name;
                    structure.txtPrimeryGroupLatinName.Text = parent.Latin_Name;

                    if (Child != null)
                    {
                        structure.txtSecenderyGroupCode.IsEnabled = false;
                    }
                }

                structure.DisableEvent();


                structure.ShowDialog();

                SelectedItem.ID   = structure.EditedItem.ID;
                SelectedItem.Name = structure.EditedItem.Name;
                SelectedItem.Code = structure.EditedItem.Code;
            }
            catch (Exception ex)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(ex);
            }
            trvMenu.Items.Refresh();
        }