protected void grdBalanceLine_RowInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e) { if (cboBalanceInitAccount.Value == null || cboBalanceInitCurrency.Value == null) { return; } ObjectBO objectBO = new ObjectBO(); NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject = objectBO.CreateCMSObject(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); GeneralJournal debitGeneralJournal = session.GetObjectByKey <GeneralJournal>(Guid.Parse(e.NewValues["GeneralJournalId"].ToString())); GeneralJournalObject debitGeneralJournalObject = null; debitGeneralJournalObject = new GeneralJournalObject(session); debitGeneralJournalObject.GeneralJournalId = debitGeneralJournal; debitGeneralJournalObject.ObjectId = debitJounalCMSObject; debitGeneralJournalObject.Save(); ObjectType objectType = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); GeneralJournalCustomType generalJournalCustomType = new GeneralJournalCustomType(session); generalJournalCustomType.GeneralJournalId = debitGeneralJournal; generalJournalCustomType.ObjectTypeId = objectType; generalJournalCustomType.Save(); grdBalanceLine.JSProperties.Add("cpRefreshTree", "refresh"); }
protected void cpAllocation_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { CriteriaOperator _filter; string[] p = e.Parameter.Split('|'); switch (p[0]) { case "allocation": // Check not has Object to Create GeneralJournal debitGeneralJournal = session.GetObjectByKey <GeneralJournal>(Guid.Parse(p[1])); if (debitGeneralJournal != null) { _filter = new BinaryOperator("GeneralJournalId.GeneralJournalId", debitGeneralJournal.GeneralJournalId, BinaryOperatorType.Equal); GeneralJournalObject debitGeneralJournalObject = session.FindObject <GeneralJournalObject>(_filter); if (debitGeneralJournalObject == null) { ObjectBO objectBO = new ObjectBO(); NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject = objectBO.CreateCMSObject(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); debitGeneralJournalObject = new GeneralJournalObject(session); debitGeneralJournalObject.GeneralJournalId = debitGeneralJournal; debitGeneralJournalObject.ObjectId = debitJounalCMSObject; debitGeneralJournalObject.Save(); ObjectType objectType = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); GeneralJournalCustomType generalJournalCustomType = new GeneralJournalCustomType(session); generalJournalCustomType.GeneralJournalId = debitGeneralJournal; generalJournalCustomType.ObjectTypeId = objectType; generalJournalCustomType.Save(); } } CriteriaOperator filter = new BinaryOperator("GeneralJournalId.GeneralJournalId", Guid.Parse(p[1]), BinaryOperatorType.Equal); GeneralJournalObject generalJournalObject = session.FindObject <GeneralJournalObject>(filter); if (generalJournalObject != null) { NASCustomFieldDataGridView1.CMSObjectId = Guid.Parse(generalJournalObject.ObjectId.ObjectId.ToString()); NASCustomFieldDataGridView1.DataBind(); } break; default: break; } }
protected void grdBalanceLine_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { if (cboBalanceInitAccount.Value == null) { grdBalanceLine.JSProperties.Add("cpAccountInvalid", "invalid"); e.Cancel = true; return; } if (cboBalanceInitCurrency.Value == null) { grdBalanceLine.JSProperties.Add("cpCurrencyInvalid", "invalid"); e.Cancel = true; return; } CriteriaOperator _filter = null; BalanceForwardTransaction balanceForwardTransaction = session.GetObjectByKey <BalanceForwardTransaction>(Guid.Parse(e.OldValues["TransactionId!Key"].ToString())); if (balanceForwardTransaction != null) { if (cboAccountPeriod.Value == null) { throw new Exception("Chưa chọn kỳ kế toán !"); } AccountingPeriod _accountingPeriod = session.GetObjectByKey <AccountingPeriod>(Guid.Parse(cboAccountPeriod.Value.ToString())); if (_accountingPeriod == null) { throw new Exception("Chưa chọn kỳ kế toán !"); } balanceForwardTransaction.AccountingPeriodId = _accountingPeriod; balanceForwardTransaction.Code = e.NewValues["TransactionId.Code"].ToString(); balanceForwardTransaction.Description = e.NewValues["TransactionId.Description"].ToString(); balanceForwardTransaction.Save(); } ASPxSpinEdit c = (ASPxSpinEdit)grdBalanceLine.FindEditRowCellTemplateControl((GridViewDataColumn)grdBalanceLine.Columns["Debit"], "colBalanceInitDebit"); e.NewValues["Debit"] = c.Value.ToString(); c = (ASPxSpinEdit)grdBalanceLine.FindEditRowCellTemplateControl((GridViewDataColumn)grdBalanceLine.Columns["Credit"], "colBalanceInitCredit"); e.NewValues["Credit"] = c.Value.ToString(); e.NewValues["AccountId!Key"] = cboBalanceInitAccount.Value.ToString(); e.NewValues["CurrencyId!Key"] = cboBalanceInitCurrency.Value.ToString(); // Check not has Object to Create GeneralJournal debitGeneralJournal = session.GetObjectByKey <GeneralJournal>(Guid.Parse(e.OldValues["GeneralJournalId"].ToString())); if (debitGeneralJournal != null) { _filter = new BinaryOperator("GeneralJournalId.GeneralJournalId", debitGeneralJournal.GeneralJournalId, BinaryOperatorType.Equal); GeneralJournalObject debitGeneralJournalObject = session.FindObject <GeneralJournalObject>(_filter); if (debitGeneralJournalObject == null) { ObjectBO objectBO = new ObjectBO(); NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject = objectBO.CreateCMSObject(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); debitGeneralJournalObject = new GeneralJournalObject(session); debitGeneralJournalObject.GeneralJournalId = debitGeneralJournal; debitGeneralJournalObject.ObjectId = debitJounalCMSObject; debitGeneralJournalObject.Save(); ObjectType objectType = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(session, ObjectTypeEnum.OPENBALANCE_ACCOUTING); GeneralJournalCustomType generalJournalCustomType = new GeneralJournalCustomType(session); generalJournalCustomType.GeneralJournalId = debitGeneralJournal; generalJournalCustomType.ObjectTypeId = objectType; generalJournalCustomType.Save(); } } BalanceLineSetData(); grdBalanceLine.JSProperties.Add("cpRefreshTree", "refresh"); }
/// <summary> /// Tạo dữ liệu cho CMS Object Inventory /// </summary> /// <typeparam name="T"></typeparam> /// <param name="uow"></param> /// <param name="InventoryObjectId"></param> /// <param name="CMSObjectType"></param> public void PopulateCMSObjecForInventoryObject <T>( UnitOfWork uow, Guid InventoryObjectId, DAL.CMS.ObjectDocument.ObjectTypeEnum CMSObjectType) { ObjectBO bo = new ObjectBO(); if (typeof(T).Equals(typeof(NAS.DAL.Inventory.Command.InventoryCommand))) { NAS.DAL.Inventory.Command.InventoryCommand inventoryObject = uow.GetObjectByKey <NAS.DAL.Inventory.Command.InventoryCommand>(InventoryObjectId); NAS.DAL.CMS.ObjectDocument.Object o = bo.CreateCMSObject(uow, CMSObjectType); InventoryCommandObject ICO = new InventoryCommandObject(uow); ICO.ObjectId = o; ICO.InventoryCommandId = (inventoryObject as NAS.DAL.Inventory.Command.InventoryCommand); ICO.Save(); NAS.DAL.CMS.ObjectDocument.ObjectType type = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(uow, CMSObjectType); if (type == null) { throw new Exception("The ObjectType is not exist in system"); } InventoryCommandCustomType ICCT = new InventoryCommandCustomType(uow); ICCT.ObjectTypeId = type; ICCT.InventoryCommandId = (inventoryObject as NAS.DAL.Inventory.Command.InventoryCommand); ICCT.Save(); } else if (typeof(T).Equals(typeof(NAS.DAL.Inventory.Command.InventoryCommandItemTransaction))) { InventoryCommandItemTransaction transactionObject = uow.GetObjectByKey <InventoryCommandItemTransaction>(InventoryObjectId); NAS.DAL.CMS.ObjectDocument.Object o = bo.CreateCMSObject(uow, CMSObjectType); InventoryTransactionObject ITO = new InventoryTransactionObject(uow); ITO.ObjectId = o; ITO.InventoryTransactionId = (transactionObject as NAS.DAL.Inventory.Journal.InventoryTransaction); ITO.Save(); NAS.DAL.CMS.ObjectDocument.ObjectType type = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(uow, CMSObjectType); InventoryTransactionCustomType ITCT = new InventoryTransactionCustomType(uow); ITCT.ObjectTypeId = type; ITCT.InventoryTransactionId = (transactionObject as NAS.DAL.Inventory.Journal.InventoryTransaction); ITCT.Save(); } else if (typeof(T).Equals(typeof(NAS.DAL.Inventory.Command.InventoryCommandFinancialTransaction))) { InventoryCommandFinancialTransaction transactionObject = uow.GetObjectByKey <InventoryCommandFinancialTransaction>(InventoryObjectId); NAS.DAL.CMS.ObjectDocument.Object o = bo.CreateCMSObject(uow, CMSObjectType); TransactionObject TO = new TransactionObject(uow); TO.ObjectId = o; TO.TransactionId = (transactionObject as Transaction); TO.Save(); } else if (typeof(T).Equals(typeof(NAS.DAL.Accounting.Journal.GeneralJournal))) { GeneralJournal journalObject = uow.GetObjectByKey <GeneralJournal>(InventoryObjectId); NAS.DAL.CMS.ObjectDocument.Object o = bo.CreateCMSObject(uow, CMSObjectType); GeneralJournalObject GJO = new GeneralJournalObject(uow); GJO.ObjectId = o; GJO.GeneralJournalId = (journalObject as GeneralJournal); GJO.Save(); NAS.DAL.CMS.ObjectDocument.ObjectType type = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(uow, CMSObjectType); GeneralJournalCustomType GJCT = new GeneralJournalCustomType(uow); GJCT.ObjectTypeId = type; GJCT.GeneralJournalId = (journalObject as GeneralJournal); GJCT.Save(); } else if (typeof(T).Equals(typeof(NAS.DAL.Inventory.Journal.InventoryJournal))) { InventoryJournal journalObject = uow.GetObjectByKey <InventoryJournal>(InventoryObjectId); NAS.DAL.CMS.ObjectDocument.Object o = bo.CreateCMSObject(uow, CMSObjectType); InventoryJournalObject ITO = new InventoryJournalObject(uow); ITO.ObjectId = o; ITO.InventoryJournalId = (journalObject as InventoryJournal); ITO.Save(); NAS.DAL.CMS.ObjectDocument.ObjectType type = NAS.DAL.CMS.ObjectDocument.ObjectType.GetDefault(uow, CMSObjectType); InventoryJournalCustomType ITCT = new InventoryJournalCustomType(uow); ITCT.ObjectTypeId = type; ITCT.InventoryJournalId = (journalObject as InventoryJournal); ITCT.Save(); } uow.FlushChanges(); }