Exemple #1
0
        protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            Guid bookentryid = Guid.Parse(e.Keys["BookingEntryId"].ToString());
            XPQuery <BookingEntryTransaction> TransactionQuery = session.Query <BookingEntryTransaction>();
            BookingEntryTransaction           transaction      = (from c in TransactionQuery
                                                                  where c.BookingEntryId.BookingEntryId == bookentryid && c.RowStatus > 0
                                                                  select c).FirstOrDefault();

            if (transaction != null)
            {
                if (AccountingBO.IsApproved(session, transaction.TransactionId) == true)
                {
                    throw new Exception("Hạch toán đã được duyệt. Không thể xóa!!!");
                    //e.Cancel = true;
                }
                try
                {
                    foreach (GeneralJournal gj in transaction.GeneralJournals)
                    {
                        if (gj != null)
                        {
                            gj.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                        }
                    }
                }
                catch (Exception)
                {
                }
                finally{
                    transaction.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                }
            }
        }
Exemple #2
0
        protected void ASPxGridView3_BeforePerformDataSelect(object sender, EventArgs e)
        {
            ASPxGridView grdBookingDetail = (ASPxGridView)sender;

            Session["_BookingEntryId"] = grdBookingDetail.GetMasterRowKeyValue();
            XPQuery <BookingEntryTransaction> BookingEntryQuery = session.Query <BookingEntryTransaction>();
            BookingEntryTransaction           BkTr = BookingEntryQuery.Where(r => r.BookingEntryId == Session["_BookingEntryId"]).FirstOrDefault();

            //if (BkTr.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE)
            //{

            //}
            Session["Transaction"]   = BkTr;
            Session["TransactionId"] = BkTr.TransactionId;
        }
Exemple #3
0
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            short     approveError = 0;
            Exception newEx        = new Exception("Không thể hạch toán");

            try
            {
                XPQuery <BookingEntryTransaction> BookingEntryQuery = session.Query <BookingEntryTransaction>();
                BookingEntryTransaction           BkTr = BookingEntryQuery.Where(r => r.TransactionId == (Guid)(Session["Transaction"])).FirstOrDefault();
                //BkTr.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                //BkTr.Save();
                AccountingBO accountBO = new AccountingBO();
                bool         approved  = accountBO.ApproveTransaction(session, BkTr.TransactionId);
                if (approved == false)
                {
                    /// -1: OK. Balance forward.
                    /// 0: OK. You can approve it.
                    /// (order: Can't approve)
                    /// 1: Credit != Debit.
                    /// 2: Approved.
                    /// 3: Credit = Debit = 0.
                    /// 4: Credit &lt; 0.
                    /// 5: Debit  &lt; 0.
                    /// 6: Don't have any journal
                    /// 7: Transaction not exist
                    /// 8: Credit and Debit &lt; 0
                    /// 9: Exist more than one Credit Account && more than one Debit Account
                    //approveError = accountBO.IsAvailableApprove(session, BkTr.TransactionId);
                    //switch (approveError)
                    //{
                    //    case -1: { break; }
                    //    case 0: { break; }
                    //    case 1:
                    //        {
                    //            newEx = new Exception("Tổng nợ không bằng tổng có");
                    //            break;
                    //        }
                    //    case 2:
                    //        {
                    //            newEx = new Exception("Đã hạch toán");
                    //            break;
                    //        }
                    //    case 3:
                    //        {
                    //            newEx = new Exception("Nợ và có cùng bằng không");
                    //            break;
                    //        }
                    //    case 4:
                    //        {
                    //            newEx = new Exception("Tổng có nhỏ hơn 0");
                    //            break;
                    //        }
                    //    case 5:
                    //        {
                    //            newEx = new Exception("Tổng nợ nhỏ hơn 0");
                    //            break;
                    //        }
                    //    case 6:
                    //        {
                    //            newEx = new Exception("Chưa có nợ và có");
                    //            break;
                    //        }
                    //    case 7:
                    //        {
                    //            newEx = new Exception("Không tồn tại bút toán");
                    //            break;
                    //        }
                    //    case 8:
                    //        {
                    //            newEx = new Exception("Tổng nợ và tổng có nhỏ hơn 0");
                    //            break;
                    //        }
                    //    case 9:
                    //        {
                    //            newEx = new Exception("Tồn tại nhiều nợ với nhiều có");
                    //            break;
                    //        }
                    //    default: { break; }
                    //}
                    //ASPxGridView1.DoRowValidation();
                    //ASPxGridView1_RowValidating(ASPxGridView1, new DevExpress.Web.Data.ASPxDataValidationEventArgs(true));
                    //throw newEx;
                }
                //XPQuery<GeneralJournal> GeneralJournalQuery = session.Query<GeneralJournal>();
                //foreach (GeneralJournal gj in GeneralJournalQuery.Where(r => r.TransactionId.TransactionId == (Guid)Session["TransactionId"]))
                //{
                //    accountBO.CreateGeneralLedger(session, gj.AccountId.AccountId, gj.TransactionId.TransactionId, gj.Description, gj.Debit, gj.Credit, true);
                //};
            }
            catch (Exception)
            {
                //throw newEx;
            }
        }