Esempio n. 1
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();
                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;
            }
        }
Esempio n. 2
0
        protected void gridBookingEntries_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            try
            {
                var transactionId = e.Keys["TransactionId"];
                TransactionBOBase transactionBOBase = new TransactionBOBase();
                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);
                }

                ManualBookingTransactionBO manualBookingTransactionBO = new ManualBookingTransactionBO();
                //Create manual booking transaction
                manualBookingTransactionBO.DeleteTransaction((Guid)transactionId);

                gridBookingEntries.JSProperties["cpDataChanged"] = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                e.Cancel = true;
            }
        }
Esempio n. 3
0
        protected void customFieldDataGridView_BeforeDataEditing(object sender, EventArgs args)
        {
            TransactionBOBase transactionBOBase = new TransactionBOBase();
            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);
            }
        }
Esempio n. 4
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();
            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);
            }
        }
Esempio n. 5
0
        protected void gridBookingEntries_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
        {
            var transactionId = e.EditingKeyValue;
            TransactionBOBase transactionBOBase = new TransactionBOBase();
            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);
            }

            gridBookingEntries.JSProperties.Add("cpShowEditForm", transactionId.ToString());
            gridBookingEntries.CancelEdit();
        }
Esempio n. 6
0
        /// <summary>
        /// Kiểm tra phiếu kho đã ghi sổ hay chưa
        /// </summary>
        /// <param name="_InventoryCommand"></param>
        /// <returns></returns>
        public bool IsBookedEntriesForInventoryCommand(Session _Session, Guid _InventoryCommand)
        {
            try
            {
                NAS.BO.Accounting.Journal.TransactionBOBase transactionBOBase = new TransactionBOBase();
                InventoryCommand command = _Session.GetObjectByKey <InventoryCommand>(_InventoryCommand);
                if (command == null)
                {
                    throw new Exception("The InventoryCommand is not exist in system");
                }

                command.Reload();

                if (command.InventoryCommandFinancialTransactions != null && command.InventoryCommandFinancialTransactions.Count > 0)
                {
                    foreach (InventoryCommandFinancialTransaction t in command.InventoryCommandFinancialTransactions)
                    {
                        Transaction transaction = null;
                        if (!transactionBOBase.IsBookedTransaction(_Session, t.TransactionId, out transaction))
                        {
                            return(false);
                        }
                    }
                }

                if (command.RowStatus != Utility.Constant.ROWSTATUS_BOOKED_ENTRY)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 7
0
        protected void gridBookingEntries_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            string[]   args    = e.Parameters.Split('|');
            string     command = args[0];
            UnitOfWork uow     = XpoHelper.GetNewUnitOfWork();

            try
            {
                if (command.Equals("Book"))
                {
                    if (args.Length < 2)
                    {
                        throw new Exception("Invalid parameter");
                    }
                    TransactionBOBase transactionBOBase = new TransactionBOBase();
                    int visibleIndex  = int.Parse(args[1]);
                    var transactionId = gridBookingEntries.GetRowValues(visibleIndex, "TransactionId");
                    //Get transaction
                    string      message;
                    Transaction transaction = null;
                    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);
                    }
                    if (!CanBookEntry(transaction, out message))
                    {
                        throw new Exception(message);
                    }
                    if (transaction != null)
                    {
                        ////2014/02/13 Duc.Vo DEL-----START
                        //transactionBOBase.BookEntry(transaction.TransactionId);
                        ////2014/02/13 Duc.Vo DEL-----END

                        ////2014/02/13 Duc.Vo INS-----START
                        if (!transactionBOBase.BookEntry(uow, transaction.TransactionId))
                        {
                            throw new Exception("Xử lý ghi sổ phát sinh lỗi");
                        }

                        BusinessObjectBO.CreateBusinessObject(uow,
                                                              Utility.Constant.BusinessObjectType_FinancialTransaction,
                                                              transaction.TransactionId,
                                                              transaction.IssueDate);
                        ////2014/02/13 Duc.Vo INS-----END
                    }
                    gridBookingEntries.JSProperties["cpDataChanged"] = true;
                    uow.CommitChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                uow.Dispose();
            }
        }
Esempio n. 8
0
        protected void gridviewGeneralJournal_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxGridView grid = sender as ASPxGridView;
            UnitOfWork   uow  = null;

            try
            {
                uow = XpoHelper.GetNewUnitOfWork();
                GeneralJournalBO generalJournalBO = new GeneralJournalBO();
                ObjectBO         objectBO         = new ObjectBO();

                double amount = 0;
                string description;
                Side   side;

                Guid transactionId = (Guid)grid.GetMasterRowKeyValue();
                TransactionBOBase transactionBOBase = new TransactionBOBase();
                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);
                }

                Guid accountId = (Guid)e.NewValues["AccountId!Key"];
                description = (string)e.NewValues["Description"];

                if (e.NewValues["Debit"] != null && (double)e.NewValues["Debit"] > 0)
                {
                    amount = (double)e.NewValues["Debit"];
                    side   = Side.DEBIT;
                }
                else if (e.NewValues["Credit"] != null && (double)e.NewValues["Credit"] > 0)
                {
                    amount = (double)e.NewValues["Credit"];
                    side   = Side.CREDIT;
                }
                else
                {
                    throw new Exception("Invaild parameter");
                }

                Strategy.CreateGeneralJournal(
                    uow,
                    transactionId,
                    accountId,
                    side,
                    amount,
                    description,
                    JounalTypeFlag.ACTUAL);

                uow.CommitChanges();

                grid.JSProperties["cpEvent"] = "GeneralJournalChanged";
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                e.Cancel = true;
                grid.CancelEdit();
                if (uow != null)
                {
                    uow.Dispose();
                }
            }
        }
        protected void PanelGeneralBooking_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            m_ParamCallBack = e.Parameter.Split('|');

            switch (m_ParamCallBack[0])
            {
            case "edit":

                txtGeneralBookingCode.Text        = "";
                txtGeneralBookingDate.Value       = DateTime.Now;
                txtGeneralBookingStatus.Text      = "Chưa ghi sổ";
                txtGeneralBookingAmount.Value     = null;
                txtGeneralBookingDescription.Text = "";

                m_TransactionId = Guid.Parse(m_ParamCallBack[1].ToString());
                m_Transaction   = m_Session.GetObjectByKey <Transaction>(m_TransactionId);
                if (m_Transaction != null)
                {
                    txtGeneralBookingCode.Text        = m_Transaction.Code;
                    txtGeneralBookingAmount.Value     = m_Transaction.Amount;
                    txtGeneralBookingDate.Value       = m_Transaction.IssueDate;
                    txtGeneralBookingDescription.Text = m_Transaction.Description;
                    txtGeneralBookingStatus.Text      = "";

                    gridviewGeneralJournal.CriteriaParameters.Add("TransactionId", m_TransactionId.ToString());
                    gridviewGeneralJournal.CriteriaParameters.Add("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE.ToString());

                    grdGeneralBookingJournal.DataBind();
                }
                else
                {
                    m_TransactionId = Guid.NewGuid();
                }

                Session["TransactionId"]           = m_TransactionId;
                PopupGeneralBooking.ShowOnPageLoad = true;

                gridviewGeneralJournal.CriteriaParameters.Add("TransactionId", m_TransactionId.ToString());
                gridviewGeneralJournal.CriteriaParameters.Add("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE.ToString());

                break;

            case "cancel":
                Session["TransactionId"]           = null;
                PopupGeneralBooking.ShowOnPageLoad = false;
                break;

            case "book":
                UnitOfWork uow = XpoHelper.GetNewUnitOfWork();


                string      message;
                Transaction transaction = null;
                bool        isBooked    = m_TransactionBOBase.IsBookedTransaction(m_Session, (Guid)Session["TransactionId"], out transaction);
                if (isBooked)
                {
                    message = String.Format("Bút toán '{0}' đã được ghi sổ", transaction.Code);
                    throw new Exception(message);
                }
                if (!CanBookEntry(transaction, out message))
                {
                    throw new Exception(message);
                }
                if (transaction != null)
                {
                    if (!m_TransactionBOBase.BookEntry(uow, transaction.TransactionId))
                    {
                        throw new Exception("Xử lý ghi sổ phát sinh lỗi");
                    }

                    m_BusinessObjectBO.CreateBusinessObject(uow,
                                                            Utility.Constant.BusinessObjectType_FinancialTransaction,
                                                            transaction.TransactionId,
                                                            transaction.IssueDate);
                }

                uow.CommitChanges();
                PanelGeneralBooking.JSProperties.Add("cpBooked", "Complete");
                Session["TransactionId"] = null;
                break;

            case "save":

                if (txtGeneralBookingCode.Text == "" ||
                    txtGeneralBookingDate.Value == null ||
                    txtGeneralBookingAmount.Value == null)
                {
                    return;
                }

                m_TransactionId = (Guid)Session["TransactionId"];

                m_Code        = txtGeneralBookingCode.Text;
                m_Description = txtGeneralBookingDescription.Text;
                m_IssuedDate  = (DateTime)txtGeneralBookingDate.Value;
                m_Amount      = double.Parse(txtGeneralBookingAmount.Value.ToString());

                m_ManualBookingTransactionBO = new ManualBookingTransactionBO();

                m_Transaction = m_Session.GetObjectByKey <Transaction>(m_TransactionId);
                if (m_Transaction != null)
                {
                    isBooked = m_TransactionBOBase.IsBookedTransaction(m_Session, (Guid)Session["TransactionId"], out transaction);
                    if (isBooked)
                    {
                        message = String.Format("Bút toán '{0}' đã được ghi sổ", transaction.Code);
                        throw new Exception(message);
                    }

                    m_ManualBookingTransactionBO.UpdateTransaction(m_TransactionId, m_Code, m_IssuedDate, m_Amount, m_Description);
                }
                else
                {
                    m_TransactionId = m_ManualBookingTransactionBO.CreateTransaction(m_Code, m_IssuedDate, m_Amount, m_Description);
                }

                Session["TransactionId"] = m_TransactionId;

                gridviewGeneralJournal.CriteriaParameters.Add("TransactionId", m_TransactionId.ToString());
                gridviewGeneralJournal.CriteriaParameters.Add("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE.ToString());

                break;
            }
        }