public Tarife_hesabe_tafsili(Data.AccountingTafsilStructureDefine Item)
        {
            InitializeComponent();

            txtPrimeryGroupCode.MaxLen      = codeTitleLen;
            txtSecenderyGroupCode.MaxLength = codeTitleLenChild;

            if (Item != null)
            {
                this._editedItem = Item;
            }
        }
Example #2
0
        private string GetUniqPath(Data.AccountingTafsilStructureDefine entity)
        {
            StringBuilder str = new StringBuilder();

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

            Data.AccountingTafsilStructureDefine _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());
        }
Example #3
0
        public Data.AccountingTafsilStructureDefine GetStructure(Guid Type, string Name, string LatinName, Guid?ParentID, string Code)
        {
            Data.AccountingTafsilStructureDefine _entity = new Data.AccountingTafsilStructureDefine();

            _entity.ID         = Guid.NewGuid();
            _entity.Type       = Type;
            _entity.Name       = Name;
            _entity.Latin_Name = LatinName;
            _entity.Parent_ID  = ParentID;
            _entity.Code       = GetCode(_entity.Type, Code);
            _entity.LastEdit   = DateTime.Now;
            _entity.Uniq_Path  = GetUniqPath(_entity);

            return(_entity);
        }
Example #4
0
 public void Insert(Data.AccountingTafsilStructureDefine _tafsilStructureDefine)
 {
     try
     {
         if (_tafsilStructureDefine.ID == Guid.Empty)
         {
             _tafsilStructureDefine.ID = Guid.NewGuid();
         }
         this.Table.Add(_tafsilStructureDefine);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
Example #5
0
        public void Delete(Data.AccountingTafsilStructureDefine DeletedItem)
        {
            try
            {
                string errorMessage = string.Empty;
                if (!this.ValidateDelete(DeletedItem, out errorMessage))
                {
                    throw new Exception(errorMessage);
                }

                this.Table.Remove(DeletedItem);
                this.SubmitChanges();
            }
            catch
            {
                throw;
            }
        }
Example #6
0
 public Data.AccountingTafsilStructureDefine GetParent(Data.AccountingTafsilStructureDefine 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);
     }
 }
Example #7
0
 public void SaveWithID(Data.AccountingTafsilStructureDefine _tafsilStructureDefine)
 {
     try
     {
         Guid i = this.GetAll().Where(r => r.ID == _tafsilStructureDefine.ID).Select(r => r.ID).FirstOrDefault();
         _tafsilStructureDefine.Name = _tafsilStructureDefine.Name.Trim();
         if (i == Guid.Empty)
         {
             this.Insert(_tafsilStructureDefine);
         }
         else
         {
             this.SubmitChanges();
         }
     }
     catch
     {
         throw;
     }
 }
        private void txtPrimeryGroupName_LostFocus(object sender, RoutedEventArgs e)
        {
            Data.AccountingTafsilStructureDefine Parent =
                Business.GetTafsilStructureDefineBusiness().GetRecord(txtPrimeryGroupCode.Text, TafsilGroup);

            if (Parent == null)
            {
                txtSecenderyGroupCode.Text = Business.GetTafsilStructureDefineBusiness().GetDefualtCode(AccountGroup, null);
            }
            else
            {
                string code = Business.GetTafsilStructureDefineBusiness().GetDefualtCode(AccountGroup, Parent.ID);
                if (code.Length > codeTitleLenChild)
                {
                    txtSecenderyGroupCode.Text = code.Substring(codeTitleLen, codeTitleLenChild);
                }
                else
                {
                    txtSecenderyGroupCode.Text = code;
                }
            }
        }
Example #9
0
        public bool ValidateDelete(Data.AccountingTafsilStructureDefine 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;


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


            try
            {
                if (string.IsNullOrEmpty(txtPrimeryGroupCode.Text) || txtPrimeryGroupCode.Text.Length < codeTitleLen)
                {
                    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 < codeTitleLenChild)
                {
                    throw new Exception(Localize.nullCode);
                }

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

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

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

                    if (string.IsNullOrEmpty(txtSecenderyGroupCode.Text) == false && string.IsNullOrEmpty(txtSecenderyGroupName.Text) == false)
                    {
                        record = Business.GetTafsilStructureDefineBusiness().GetRecord(SecondaryCode, AccountGroup);
                        if (record == null)
                        {
                            _entitySecondery = Business.GetTafsilStructureDefineBusiness().GetStructure(AccountGroup, SecondaryName, SecondaryLatinName, ParentID, SecondaryCode);
                            Business.GetTafsilStructureDefineBusiness().SaveWithID(_entitySecondery);
                        }
                        else
                        {
                            throw new Exception(Localize.DoubleCode);
                        }
                    }
                    this.Close();
                }
            }
            catch (Exception s)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(s);
            }
            return;
        }