/// <summary> /// Create new master data /// </summary> /// <param name="identity"></param> /// <param name="descp"></param> /// <param name="?"></param> /// <returns></returns> /// <exception cref="ParametersException">Parameters Exception</exception> /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception> /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception> /// <exception cref="ArgumentNullException">Argument is null</exception> /// <exception cref="SystemException">Bug</exception> public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity identity, String descp, params Object[] objects) { // check id is G/L identity MasterDataIdentity_GLAccount identity_gl = identity as MasterDataIdentity_GLAccount; if (identity_gl == null) { throw new ParametersException(); } // check duplicated if (_list.ContainsKey(identity)) { throw new MasterDataIdentityExists(); } MasterDataIdentity bankAccount = null; if (objects.Length == 0 || objects.Length == 1) { } else { throw new ParametersException(1, objects.Length); } if (objects.Length == 1) { // contain bank account bankAccount = objects[0] as MasterDataIdentity; if (bankAccount == null) { throw new ParametersException(); } } GLAccountMasterData glAccount; try { glAccount = new GLAccountMasterData(_coreDriver, _management, identity_gl, descp, bankAccount); } catch (ArgumentNullException e) { throw new SystemException(e); } catch (NoGLAccountGroupException) { throw new ParametersException(); } this._containDirtyData = true; this._list.Add(identity_gl, glAccount); // raise create master data _coreDriver.ListenerMgmt.CreateMasterData(this, glAccount); _coreDriver.logDebugInfo(this.GetType(), 84, String.Format("Create G/L account ({0}).", glAccount.Identity.ToString()), MessageType.INFO); return glAccount; }
/// <summary> /// Get GL Account based on G/L account group /// </summary> /// <param name="group"></param> /// <returns></returns> public List <MasterDataIdentity_GLAccount> GetGLAccountsBasedGroup( GLAccountGroupENUM group) { MasterDataFactoryBase factory = GetMasterDataFactory(MasterDataType.GL_ACCOUNT); List <MasterDataBase> datas = factory.AllEntities; List <MasterDataIdentity_GLAccount> array = new List <MasterDataIdentity_GLAccount>(); foreach (MasterDataBase data in datas) { GLAccountMasterData glAccount = (GLAccountMasterData)data; if (glAccount.Group.Identity == group) { array.Add(glAccount.GLIdentity); } } array.Sort(); return(array); }
/// <summary> /// get accounts based on the groups /// </summary> /// <param name="groups"></param> /// <returns></returns> public List <GLAccountMasterData> GetAccounts(GLAccountGroupENUM[] groups) { List <GLAccountMasterData> array = new List <GLAccountMasterData>(); foreach (var item in this._list) { GLAccountMasterData glAccount = (GLAccountMasterData)item.Value; for (int i = 0; i < groups.Length; ++i) { if (glAccount.Group.Identity == groups[i]) { array.Add(glAccount); break; } } } array.Sort(); return(array); }
/// <summary> /// Create new master data /// </summary> /// <param name="identity"></param> /// <param name="descp"></param> /// <param name="?"></param> /// <returns></returns> /// <exception cref="ParametersException">Parameters Exception</exception> /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception> /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception> /// <exception cref="ArgumentNullException">Argument is null</exception> /// <exception cref="SystemException">Bug</exception> public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity identity, String descp, params Object[] objects) { // check id is G/L identity MasterDataIdentity_GLAccount identity_gl = identity as MasterDataIdentity_GLAccount; if (identity_gl == null) { throw new ParametersException(); } // check duplicated if (_list.ContainsKey(identity)) { throw new MasterDataIdentityExists(); } MasterDataIdentity bankAccount = null; if (objects.Length == 0 || objects.Length == 1) { } else { throw new ParametersException(1, objects.Length); } if (objects.Length == 1) { // contain bank account bankAccount = objects[0] as MasterDataIdentity; if (bankAccount == null) { throw new ParametersException(); } } GLAccountMasterData glAccount; try { glAccount = new GLAccountMasterData(_coreDriver, _management, identity_gl, descp, bankAccount); } catch (ArgumentNullException e) { throw new SystemException(e); } catch (NoGLAccountGroupException) { throw new ParametersException(); } this._containDirtyData = true; this._list.Add(identity_gl, glAccount); // raise create master data _coreDriver.ListenerMgmt.CreateMasterData(this, glAccount); _coreDriver.logDebugInfo(this.GetType(), 84, String.Format("Create G/L account ({0}).", glAccount.Identity.ToString()), MessageType.INFO); return(glAccount); }