private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (FormIsValid())
            {
                if (id != Guid.Empty)
                {
                    MoeinStructure.Code       = string.Format("{0}{1}", txtGurohKol.Text, txtMoeinCode.Text);
                    MoeinStructure.Name       = txtMoeinName.Text;
                    MoeinStructure.Latin_Name = txtMoeinLatinName.Text;
                    MoeinStructure.LastEdit   = System.DateTime.Now;
                    MoeinCodes.MNature        = (Guid)cmbMoeinNature.SelectedValue;
                    MoeinCodes.MType          = (Guid)cmbMoeinType.SelectedValue;
                }
                else
                {
                    MoeinStructure = Business.GetMoeinStructureDefineBusiness().
                                     GetStructure(Constants.CodeTitle.Moein, txtMoeinName.Text, txtMoeinLatinName.Text, ParentID, string.Format("{0}{1}", txtGurohKol.Text, txtMoeinCode.Text));
                    MoeinCodes = Business.GetMoeinCodesBusiness().GetMoeinCode(MoeinStructure.ID, (Guid)cmbMoeinType.SelectedValue, (Guid)cmbMoeinNature.SelectedValue);
                }
                using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                    Timeout = new TimeSpan(2, 0, 0)
                }))
                {
                    Business.GetMoeinStructureDefineBusiness().SaveWithID(MoeinStructure);
                    Business.GetMoeinCodesBusiness().Save(MoeinCodes);
                    scope.Complete();
                }

                this.Close();
            }
        }
        public MoeinStructureDefineChild(Data.AccountingMoeinStructureDefine Item)
        {
            InitializeComponent();

            txtPrimeryGroupCode.MaxLen      = GoruhLen;
            txtSecenderyGroupCode.MaxLength = KolLen;

            if (Item != null)
            {
                this._editedItem = Item;
            }
        }
Esempio n. 3
0
 public MainGroup(Data.AccountingMoeinStructureDefine assetGroup, List <Data.AccountingMoeinStructureDefine> subGroups)
 {
     ID        = assetGroup.ID;
     name      = assetGroup.Name;
     code      = assetGroup.Code;
     SubGroups = new List <SubGroup>();
     foreach (var item in subGroups)
     {
         SubGroups.Add(new SubGroup()
         {
             name = item.Name, code = item.Code, Id = item.ID
         });
     }
 }
        public MoeinAdd(Guid id)
            : this()
        {
            this.id = id;

            MoeinStructure         = Business.GetMoeinStructureDefineBusiness().GetByID(id).FirstOrDefault();
            txtMoeinCode.Text      = MoeinStructure.Code.Substring(Gurohlen + Kollen);
            txtGurohKol.Text       = MoeinStructure.Code.Substring(0, Gurohlen + Kollen);
            txtMoeinLatinName.Text = MoeinStructure.Latin_Name;
            txtMoeinName.Text      = MoeinStructure.Name;

            MoeinCodes = Business.GetMoeinCodesBusiness().GetByStructureDefine_ID(id).FirstOrDefault();
            cmbMoeinType.SelectedValue   = MoeinCodes.MType;
            cmbMoeinNature.SelectedValue = MoeinCodes.MNature;
        }
Esempio n. 5
0
        private string GetUniqPath(Data.AccountingMoeinStructureDefine entity)
        {
            StringBuilder str = new StringBuilder();

            str.Append(string.Format("#{0}", entity.ID));

            Data.AccountingMoeinStructureDefine _entity = this.GetAll().Where(r => r.ID == entity.Parent_ID).FirstOrDefault();

            while (_entity != null)
            {
                str.Insert(0, string.Format("#{0}", _entity.ID));
                _entity = this.GetAll().Where(r => r.ID == _entity.Parent_ID).FirstOrDefault();
            }
            return(str.ToString());
        }
Esempio n. 6
0
 public void Insert(Data.AccountingMoeinStructureDefine _moeinStructureDefine)
 {
     try
     {
         if (_moeinStructureDefine.ID == Guid.Empty)
         {
             _moeinStructureDefine.ID = Guid.NewGuid();
         }
         this.Table.Add(_moeinStructureDefine);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
Esempio n. 7
0
        public void Delete(Data.AccountingMoeinStructureDefine DeletedItem)
        {
            try
            {
                string errorMessage = string.Empty;
                if (!this.ValidateDelete(DeletedItem, out errorMessage))
                {
                    throw new Exception(errorMessage);
                }

                this.Table.Remove(DeletedItem);
                this.SubmitChanges();
            }
            catch
            {
                throw;
            }
        }
Esempio n. 8
0
 public Data.AccountingMoeinStructureDefine GetParent(Data.AccountingMoeinStructureDefine ChangableItem)
 {
     try
     {
         if (ChangableItem.Parent_ID == null)
         {
             return(this.GetAll().Where(r => r.ID.Equals(ChangableItem.Parent_ID)).FirstOrDefault());
         }
         else
         {
             return(this.GetAll().Where(r => r.ID == ChangableItem.Parent_ID).FirstOrDefault());
         }
     }
     catch
     {
         return(null);
     }
 }
Esempio n. 9
0
 public void SaveWithID(Data.AccountingMoeinStructureDefine _moeinStructureDefine)
 {
     try
     {
         Guid i = this.GetAll().Where(r => r.ID == _moeinStructureDefine.ID).Select(r => r.ID).FirstOrDefault();
         _moeinStructureDefine.Name = _moeinStructureDefine.Name.Trim();
         if (i == Guid.Empty)
         {
             this.Insert(_moeinStructureDefine);
         }
         else
         {
             this.SubmitChanges();
         }
     }
     catch
     {
         throw;
     }
 }
Esempio n. 10
0
        public Data.AccountingMoeinStructureDefine GetStructure(Guid Type, string Name, string LatinName, Guid?ParentID, string Code)
        {
            Data.AccountingMoeinStructureDefine _entity = new Data.AccountingMoeinStructureDefine();

            _entity.ID         = Guid.NewGuid();
            _entity.Type       = Type;
            _entity.Name       = Name;
            _entity.Latin_Name = LatinName;
            _entity.Parent_ID  = ParentID;

            if ((Type == Constants.CodeTitle.Tafsil1 || Type == Constants.CodeTitle.Tafsil1 || Type == Constants.CodeTitle.Tafsil1) == false)
            {
                _entity.Code = GetCode(_entity.Type, Code);
            }

            _entity.LastEdit  = DateTime.Now;
            _entity.Uniq_Path = GetUniqPath(_entity);

            return(_entity);
        }
        private void txtPrimeryGroupName_LostFocus(object sender, RoutedEventArgs e)
        {
            Data.AccountingMoeinStructureDefine Parent =
                Business.GetMoeinStructureDefineBusiness().GetRecord(txtPrimeryGroupCode.Text, Goruh);

            if (Parent == null)
            {
                txtSecenderyGroupCode.Text = Business.GetMoeinStructureDefineBusiness().GetDefualtCode(Kol, null);
            }
            else
            {
                string code = Business.GetMoeinStructureDefineBusiness().GetDefualtCode(Kol, Parent.ID);
                if (code.Length > KolLen)
                {
                    txtSecenderyGroupCode.Text = code.Substring(GoruhLen, KolLen);
                }
                else
                {
                    txtSecenderyGroupCode.Text = code;
                }
            }
        }
Esempio n. 12
0
        public bool ValidateDelete(Data.AccountingMoeinStructureDefine DeletedItem, out string errorMessage)
        {
            try
            {
                errorMessage = string.Empty;

                if (DeletedItem == null)
                {
                    errorMessage = Localize.ex_no_record;
                    return(false);
                }

                if (this.GetAll().Where(r => r.Parent_ID == DeletedItem.ID).Any())
                {
                    errorMessage = Localize.ex_record_already_used;
                }

                return(errorMessage == string.Empty);
            }
            catch
            {
                throw;
            }
        }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            PrimeryCode      = txtPrimeryGroupCode.Text;
            PrimeryName      = txtPrimeryGroupName.Text;
            PrimeryLatinName = txtPrimeryGroupLatinName.Text;

            SecondaryCode      = string.Format("{0}{1}", PrimeryCode, txtSecenderyGroupCode.Text);
            SecondaryName      = txtSecenderyGroupName.Text;
            SecondaryLatinName = txtSecenderyGroupLatinName.Text;

            try
            {
                if (string.IsNullOrEmpty(txtPrimeryGroupCode.Text) || txtPrimeryGroupCode.Text.Length < GoruhLen)
                {
                    throw new Exception(Localize.nullCode);
                }

                if (string.IsNullOrEmpty(PrimeryName))
                {
                    throw new Exception(Localize.nullName);
                }

                if (string.IsNullOrEmpty(txtSecenderyGroupCode.Text) == false && string.IsNullOrEmpty(txtSecenderyGroupName.Text))
                {
                    throw new Exception(Localize.nullName);
                }

                if (string.IsNullOrEmpty(txtSecenderyGroupCode.Text) && string.IsNullOrEmpty(txtSecenderyGroupName.Text) == false)
                {
                    throw new Exception(Localize.nullName);
                }

                if (txtSecenderyGroupCode.Text.Length > 0 && txtSecenderyGroupCode.Text.Length < KolLen)
                {
                    throw new Exception(Localize.nullCode);
                }

                if (_editedItem != null && _editedItem.Type == Goruh)
                {
                    _editedItem.Code       = PrimeryCode;
                    _editedItem.Name       = PrimeryName;
                    _editedItem.Latin_Name = PrimeryLatinName;
                    Business.GetMoeinStructureDefineBusiness().SaveWithID(_editedItem);
                    this.Close();
                    return;
                }

                if (_editedItem != null && _editedItem.Type == Kol)
                {
                    if (FormIsValid(txtSecenderyGroupCode.Text))
                    {
                        _editedItem.Code       = SecondaryCode;
                        _editedItem.Name       = SecondaryName;
                        _editedItem.Latin_Name = SecondaryLatinName;
                        Business.GetMoeinStructureDefineBusiness().SaveWithID(_editedItem);
                        this.Close();
                        return;
                    }
                    else
                    {
                        return;
                    }
                }

                if (FormIsValid(txtSecenderyGroupCode.Text) && FormIsValid(txtSecenderyGroupName.Text))
                {
                    Guid ParentID = Guid.Empty;
                    var  record   = Business.GetMoeinStructureDefineBusiness().GetRecord(PrimeryCode, Goruh);
                    if (record == null)
                    {
                        _entityPrimery = Business.GetMoeinStructureDefineBusiness().GetStructure(Goruh, PrimeryName, PrimeryLatinName, null, PrimeryCode);
                        ParentID       = _entityPrimery.ID;
                        Business.GetMoeinStructureDefineBusiness().SaveWithID(_entityPrimery);
                    }
                    else
                    {
                        ParentID = record.ID;
                    }

                    if (string.IsNullOrEmpty(txtSecenderyGroupCode.Text) == false && string.IsNullOrEmpty(txtSecenderyGroupName.Text) == false)
                    {
                        record = Business.GetMoeinStructureDefineBusiness().GetRecord(SecondaryCode, Kol);
                        if (record == null)
                        {
                            _entitySecondery = Business.GetMoeinStructureDefineBusiness().GetStructure(Kol, SecondaryName, SecondaryLatinName, ParentID, SecondaryCode);
                            Business.GetMoeinStructureDefineBusiness().SaveWithID(_entitySecondery);
                        }
                        else
                        {
                            throw new Exception(Localize.DoubleCode);
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception s)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(s);
            }
            return;
        }
Esempio n. 14
0
        private void FillGrid(Guid parentId, string code, string name)
        {
            if (Level <= 3)
            {
                grdList.ItemsSource = Business.GetMoeinStructureDefineBusiness().GetByParentID(parentId).ToList();
            }
            if (Level == 4)
            {
                Moein = Business.GetMoeinStructureDefineBusiness().GetByID(parentId).FirstOrDefault();

                Data.AccountingMoeinStructureDefine Tafsil1 = Business.GetMoeinStructureDefineBusiness()
                                                              .GetTafsil(Moein.ID, Constants.CodeTitle.Tafsil1).FirstOrDefault();
                if (Tafsil1 == null)
                {
                    grdList.ItemsSource = null;
                    LabelList.Add(new LabelValues()
                    {
                        code = code, codeTitle = parentId.ToGUID(), value = name
                    });
                    AddLabel(LabelList[depth]);
                    return;
                }
                List <Data.AccountingTafsilStructureDefine> TafsilList = new List <Data.AccountingTafsilStructureDefine>();
                foreach (var item in Business.GetAccountingMoeinTafsilRelationBussiness().GetByMoeinID(Tafsil1.ID))
                {
                    TafsilList.Add(Business.GetTafsilStructureDefineBusiness().GetByID(item.AccountingTafsil_ID).FirstOrDefault());
                }
                grdList.ItemsSource = TafsilList;
            }
            else if (Level == 5)
            {
                Data.AccountingMoeinStructureDefine Tafsil2 = Business.GetMoeinStructureDefineBusiness()
                                                              .GetTafsil(Moein.ID, Constants.CodeTitle.Tafsil2).FirstOrDefault();

                if (Tafsil2 == null)
                {
                    grdList.ItemsSource = null;
                    LabelList.Add(new LabelValues()
                    {
                        code = code, codeTitle = parentId.ToGUID(), value = name
                    });
                    AddLabel(LabelList[depth]);
                    return;
                }
                List <Data.AccountingTafsilStructureDefine> TafsilList = new List <Data.AccountingTafsilStructureDefine>();

                foreach (var item in Business.GetAccountingMoeinTafsilRelationBussiness().GetByMoeinID(Tafsil2.ID))
                {
                    TafsilList.Add(Business.GetTafsilStructureDefineBusiness().GetByID(item.AccountingTafsil_ID).FirstOrDefault());
                }
                grdList.ItemsSource = TafsilList;
            }
            else if (Level == 6)
            {
                Data.AccountingMoeinStructureDefine Tafsil3 = Business.GetMoeinStructureDefineBusiness()
                                                              .GetTafsil(Moein.ID, Constants.CodeTitle.Tafsil3).FirstOrDefault();

                if (Tafsil3 == null)
                {
                    grdList.ItemsSource = null;
                    LabelList.Add(new LabelValues()
                    {
                        code = code, codeTitle = parentId.ToGUID(), value = name
                    });
                    AddLabel(LabelList[depth]);
                    return;
                }
                List <Data.AccountingTafsilStructureDefine> TafsilList = new List <Data.AccountingTafsilStructureDefine>();

                foreach (var item in Business.GetAccountingMoeinTafsilRelationBussiness().GetByMoeinID(Tafsil3.ID))
                {
                    TafsilList.Add(Business.GetTafsilStructureDefineBusiness().GetByID(item.AccountingTafsil_ID).FirstOrDefault());
                }
                grdList.ItemsSource = TafsilList;
            }

            LabelList.Add(new LabelValues()
            {
                code = code, codeTitle = parentId.ToGUID(), value = name
            });
            AddLabel(LabelList[depth]);
        }