Exemplo n.º 1
0
 private Guid GetCMSObjectIdOfTransaction(Guid transactionId)
 {
     if (transactionId != null && !transactionId.Equals(Guid.Empty))
     {
         NAS.DAL.CMS.ObjectDocument.Object cmsObject = null;
         using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
         {
             NAS.DAL.Accounting.Journal.Transaction transaction =
                 uow.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(transactionId);
             TransactionObject transactionObject =
                 transaction.TransactionObjects.FirstOrDefault();
             if (transactionObject == null)
             {
                 return(Guid.Empty);
             }
             else
             {
                 cmsObject = transactionObject.ObjectId;
             }
             return(cmsObject.ObjectId);
         }
     }
     else
     {
         return(Guid.Empty);
     }
 }
Exemplo n.º 2
0
 protected void gridviewAllocation_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
 {
     if (e.Column.Name.Equals("DynamicObjectList"))
     {
         ASPxGridView grid = sender as ASPxGridView;
         //Get TransactionId
         var transactionId = grid.GetRowValues(e.VisibleRowIndex, "TransactionId");
         if (transactionId == null)
         {
             return;
         }
         //Get transction
         NAS.DAL.Accounting.Journal.Transaction transaction =
             session.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(transactionId);
         TransactionObject transactionObject = transaction.TransactionObjects.FirstOrDefault();
         if (transactionObject != null)
         {
             ObjectBO objectBO = new ObjectBO();
             DynamicObjectListSerialize dynamicObjectList =
                 objectBO.GetDynamicObjectList(transactionObject.ObjectId.ObjectId);
             if (dynamicObjectList != null)
             {
                 e.DisplayText = dynamicObjectList.ToString();
             }
         }
     }
 }
Exemplo n.º 3
0
        protected void gridviewGeneralJournal_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;

            try
            {
                Guid transactionId = (Guid)grid.GetMasterRowKeyValue();
                TransactionBOBase transactionBOBase = new TransactionBOBase();
                NAS.DAL.Accounting.Journal.Transaction transaction = null;
                string message;
                bool   isBooked = transactionBOBase.IsBookedTransaction(session, (Guid)transactionId, out transaction);
                if (isBooked)
                {
                    message = String.Format("Bút toán '{0}' đã được ghi sổ", transaction.Code);
                    throw new Exception(message);
                }

                GeneralJournalBO generalJournalBO = new GeneralJournalBO();
                Guid             generalJournalId = (Guid)e.Keys["GeneralJournalId"];
                Strategy.DeleteGeneralJournal(generalJournalId);
                grid.JSProperties["cpEvent"] = "GeneralJournalChanged";
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                e.Cancel = true;
            }
        }
Exemplo n.º 4
0
        public bool CanBookEntry(NAS.DAL.Accounting.Journal.Transaction transaction, out string message)
        {
            message = null;
            TransactionBOBase          transactionBOBase          = new TransactionBOBase();
            CanBookingEntryReturnValue canBookingEntryReturnValue =
                transactionBOBase.CanBookingEntry(transaction.TransactionId, true);

            if (canBookingEntryReturnValue != CanBookingEntryReturnValue.BALANCED)
            {
                switch (canBookingEntryReturnValue)
                {
                case CanBookingEntryReturnValue.HAVE_NO_JOURNAL:
                    message = String.Format("Chưa có phát sinh nào trong bút toán '{0}'",
                                            transaction.Code);
                    break;

                case CanBookingEntryReturnValue.DEBIT_CREDIT_ZERO:
                    message = String.Format("Phát sinh 'Nợ' và phát sinh 'Có' cùng bằng 0 trong bút toán '{0}'",
                                            transaction.Code);
                    break;

                case CanBookingEntryReturnValue.NOT_BALANCED:
                    message = String.Format("Phát sinh 'Nợ' và phát sinh 'Có' không cân bằng trong bút toán '{0}'",
                                            transaction.Code);
                    break;

                case CanBookingEntryReturnValue.NOT_EQUAL_WITH_TOTAL:
                    message = String.Format("Phát sinh 'Nợ' và phát sinh 'Có' không bằng với tổng tiền trong bút toán '{0}'",
                                            transaction.Code);
                    break;

                case CanBookingEntryReturnValue.INVALID_TRANSACTION_STATUS:
                    message = String.Format("Trạng thái của bút toán '{0}' không hợp lệ", transaction.Code);
                    break;

                case CanBookingEntryReturnValue.MANY_SIDE:
                    message = String.Format("Bút toán '{0}' vừa có nhiều Phát sinh 'Nợ' và nhiều phát sinh 'Có'",
                                            transaction.Code);
                    break;

                default:
                    break;
                }
            }
            if (message != null)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
        protected void customFieldDataGridView_BeforeDataEditing(object sender, EventArgs args)
        {
            TransactionBOBase transactionBOBase = new TransactionBOBase();

            NAS.DAL.Accounting.Journal.Transaction transaction = null;
            string message;
            bool   isBooked = transactionBOBase.IsBookedTransaction(session, TransactionId, out transaction);

            if (isBooked)
            {
                message = String.Format("Bút toán '{0}' đã được ghi sổ", transaction.Code);
                throw new Exception(message);
            }
        }
Exemplo n.º 6
0
        protected void gridviewGeneralJournal_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
        {
            ASPxGridView      grid              = sender as ASPxGridView;
            Guid              transactionId     = (Guid)grid.GetMasterRowKeyValue();
            TransactionBOBase transactionBOBase = new TransactionBOBase();

            NAS.DAL.Accounting.Journal.Transaction transaction = null;
            string message;
            bool   isBooked = transactionBOBase.IsBookedTransaction(session, (Guid)transactionId, out transaction);

            if (isBooked)
            {
                message = String.Format("Bút toán '{0}' đã được ghi sổ", transaction.Code);
                throw new Exception(message);
            }
        }
Exemplo n.º 7
0
        protected void gridBookingEntries_CustomColumnDisplayText(object sender, ASPxGridViewColumnDisplayTextEventArgs e)
        {
            if (e.Column.Name.Equals("DynamicObjectList"))
            {
                ASPxGridView grid = sender as ASPxGridView;
                //Get TransactionId
                var transactionId = grid.GetRowValues(e.VisibleRowIndex, "TransactionId");
                if (transactionId == null)
                {
                    return;
                }
                //Get transction
                NAS.DAL.Accounting.Journal.Transaction transaction =
                    session.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(transactionId);
                TransactionObject transactionObject = transaction.TransactionObjects.FirstOrDefault();
                if (transactionObject != null)
                {
                    ObjectBO objectBO = new ObjectBO();
                    DynamicObjectListSerialize dynamicObjectList =
                        objectBO.GetDynamicObjectList(transactionObject.ObjectId.ObjectId);
                    if (dynamicObjectList != null)
                    {
                        e.DisplayText = dynamicObjectList.ToString();
                    }
                }
            }

            else if (e.Column.FieldName.Equals("Amount"))
            {
                double amount = double.Parse(e.Value.ToString());
                if (amount == 0)
                {
                    e.DisplayText = "0";
                }
                else
                {
                    e.DisplayText = string.Format("{0:#,###} VNĐ", amount);
                }
            }
        }
Exemplo n.º 8
0
 private Guid GetCMSObjectIdOfTransaction(Guid transactionId)
 {
     if (transactionId != null && !transactionId.Equals(Guid.Empty))
     {
         NAS.DAL.CMS.ObjectDocument.Object cmsObject = null;
         using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
         {
             NAS.DAL.Accounting.Journal.Transaction transaction =
                 uow.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(transactionId);
             TransactionObject transactionObject =
                 transaction.TransactionObjects.FirstOrDefault();
             if (transactionObject == null)
             {
                 return(Guid.Empty);
                 //ObjectBO objectBO = new ObjectBO();
                 //NAS.DAL.CMS.ObjectDocument.ObjectTypeEnum objectType = ObjectTypeEnum.NAAN_DEFAULT;
                 //objectType = Strategy.GetObjectTypeEnum();
                 //cmsObject = objectBO.CreateCMSObject(uow, objectType);
                 //TransactionObject newTransactionObject = new TransactionObject(uow)
                 //{
                 //    ObjectId = cmsObject,
                 //    TransactionId = transaction
                 //};
                 //uow.CommitChanges();
             }
             else
             {
                 cmsObject = transactionObject.ObjectId;
             }
             return(cmsObject.ObjectId);
         }
     }
     else
     {
         return(Guid.Empty);
     }
 }
Exemplo n.º 9
0
        protected void customFieldDataGridView_DataUpdated(object sender,
                                                           ERPSystem.CustomField.GUI.Control.CustomFieldControlEventArgs args)
        {
            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
            {
                //Get all journal of transaction
                NAS.DAL.Accounting.Journal.Transaction transaction =
                    uow.GetObjectByKey <NAS.DAL.Accounting.Journal.Transaction>(TransactionId);
                var cmsObjects =
                    transaction.GeneralJournals
                    .Where(r => r.RowStatus >= 0)
                    .Select(r => r.GeneralJournalObjects.FirstOrDefault())
                    .Select(r => r.ObjectId);

                ObjectTypeCustomField objectTypeCustomField =
                    uow.GetObjectByKey <ObjectTypeCustomField>(args.ObjectTypeCustomFieldId);

                if (cmsObjects != null)
                {
                    ObjectCustomFieldBO objectCustomFieldBO = new ObjectCustomFieldBO();
                    foreach (var cmsObject in cmsObjects)
                    {
                        ObjectCustomField objectCustomField =
                            cmsObject.ObjectCustomFields
                            .Where(r => r.ObjectTypeCustomFieldId == objectTypeCustomField)
                            .FirstOrDefault();
                        if (objectCustomField != null)
                        {
                            //Copy new data to all jounal of the transaction
                            switch (args.CustomFieldCategory)
                            {
                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.BASIC:
                                objectCustomFieldBO.UpdateBasicData(
                                    objectCustomField.ObjectCustomFieldId,
                                    args.NewBasicDataValue,
                                    args.BasicCustomFieldType);
                                break;

                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.LIST:
                                objectCustomFieldBO.UpdateUserDefinedListData(
                                    objectCustomField.ObjectCustomFieldId,
                                    args.NewCustomFieldDataIds);
                                break;

                            case CustomFieldControlEventArgs.CustomFieldCategoryEnum.BUILT_IN:
                                NASCustomFieldPredefinitionData temp = args.NewBuiltInData.FirstOrDefault();
                                if (temp != null)
                                {
                                    PredefinitionCustomFieldTypeEnum predefinitionType =
                                        (PredefinitionCustomFieldTypeEnum)Enum
                                        .Parse(typeof(PredefinitionCustomFieldTypeEnum), temp.PredefinitionType);
                                    objectCustomFieldBO.UpdatePredefinitionData(
                                        objectCustomField.ObjectCustomFieldId,
                                        args.NewBuiltInData.Select(r => r.RefId).ToList(),
                                        predefinitionType);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }