Ejemplo n.º 1
0
 protected void grdTransaction_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     e.NewValues["PaymentVouchesId!Key"]   = PrivateSession.Instance.VoucherId;
     e.NewValues["AccountingPeriodId!Key"] = AccountingPeriodBO.getCurrentAccountingPeriod(session).AccountingPeriodId;
     e.NewValues["RowStatus"]     = Constant.ROWSTATUS_ACTIVE;
     e.NewValues["CreateDate"]    = DateTime.Now;
     e.NewValues["UpdateDate"]    = DateTime.Now;
     e.NewValues["TransactionId"] = Guid.NewGuid();
 }
Ejemplo n.º 2
0
        public XPCollection <InventoryLedger> getTransactionInventoryLedgers(Session session, Guid InventoryId, Guid ItemUnitId)
        {
            try
            {
                AccountingPeriod currentAP = AccountingPeriodBO.getCurrentAccountingPeriod(session);
                //if (currentAP == null)
                //    return null;

                XPCollection <InventoryTransaction> ITLst = new XPCollection <InventoryTransaction>(session);
                //ITLst.Criteria = CriteriaOperator.And(
                //        new BinaryOperator("AccountingPeriodId", currentAP, BinaryOperatorType.Equal),
                //        new BinaryOperator("RowStatus", 0, BinaryOperatorType.Greater)
                //    );

                ITLst.Criteria = new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual);

                if (ITLst == null || ITLst.Count == 0)
                {
                    return(null);
                }

                if (ITLst == null || ITLst.Count == 0)
                {
                    return(null);
                }

                CriteriaOperator criteriaIN          = new InOperator("InventoryTransactionId", ITLst);
                XPCollection <InventoryLedger> ILLst = new XPCollection <InventoryLedger>(session);
                ILLst.Criteria = CriteriaOperator.And(
                    new InOperator("InventoryTransactionId", ITLst),
                    new BinaryOperator("ItemUnitId!Key", ItemUnitId, BinaryOperatorType.Equal),
                    new BinaryOperator("InventoryId!Key", InventoryId, BinaryOperatorType.Equal),
                    new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual)
                    );

                SortingCollection sortCollection = new SortingCollection();
                sortCollection.Add(new SortProperty("IssueDate", DevExpress.Xpo.DB.SortingDirection.Descending));
                sortCollection.Add(new SortProperty("CreateDate", DevExpress.Xpo.DB.SortingDirection.Descending));
                sortCollection.Add(new SortProperty("UpdateDate", DevExpress.Xpo.DB.SortingDirection.Descending));
                ILLst.Sorting = sortCollection;
                return(ILLst);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AccountingBO accountBO = new AccountingBO();

            //try
            //{
            //    accountBO.InitBalanceForward(session, AccountingPeriodBO.getCurrentAccountingPeriod(session));

            //    lbAccountingPeriod.Text = AccountingPeriodBO.getCurrentAccountingPeriod(session).Code;
            //    lbAccountingPeriodStartdate.Text = AccountingPeriodBO.getCurrentAccountingPeriod(session).FromDateTime.ToShortDateString();
            //    lbAccountingPeriodEnddate.Text = AccountingPeriodBO.getCurrentAccountingPeriod(session).ToDateTime.Date.ToShortDateString();
            //}
            //catch
            //{
            //    cpMessageBox.JSProperties.Clear();
            //    MessageBox1.Message.Text = String.Format("Chưa tạo chu kỳ tháng {0} năm {1}", DateTime.Now.Month, DateTime.Now.Year);
            //    cpMessageBox.JSProperties.Add("cpWarning", "Chưa tạo chu kỳ tháng " + DateTime.Now.Month.ToString());
            //}

            List <NAS.BO.Accounting.AccountingBO.AccountingEntity> rs = accountBO.getInitBalanceForward(session, AccountingPeriodBO.getCurrentAccountingPeriod(session));

            AccountList.DataSource = rs;
            AccountList.DataBind();
            AccountList.Focus();

            NAS.DAL.Accounting.Currency.Currency currency;

            if (cboBalanceInitCurrency.Value == null)
            {
                CriteriaOperator _filter = new GroupOperator(GroupOperatorType.And,
                                                             new BinaryOperator("IsDefault", 1, BinaryOperatorType.Equal),
                                                             new BinaryOperator("CurrencyTypeId.IsMaster", 1, BinaryOperatorType.Equal));
                currency = session.FindObject <NAS.DAL.Accounting.Currency.Currency>(_filter);
                if (currency != null)
                {
                    cboBalanceInitCurrency.Value = currency.CurrencyId;
                }
            }

            currency = session.GetObjectByKey <NAS.DAL.Accounting.Currency.Currency>(Guid.Parse(cboBalanceInitCurrency.Value.ToString()));
            if (currency != null)
            {
                int    i  = 0;
                string _p = GetDecimals(currency.Coefficient, i).ToString();

                if (Int32.Parse(_p) <= 0)
                {
                    m_FormatNumber = m_FormatNumber.Replace('6', '0');
                }
                else
                {
                    m_FormatNumber = m_FormatNumber.Replace('6', char.Parse(_p));
                }
            }


            BalanceLineSetData();
            tgrdAccountBalance.ExpandToLevel(1);

            (tgrdAccountBalance.Columns["Debit"] as TreeListDataColumn).PropertiesEdit.DisplayFormatString  = m_FormatNumber;
            (tgrdAccountBalance.Columns["Credit"] as TreeListDataColumn).PropertiesEdit.DisplayFormatString = m_FormatNumber;

            if (!Page.IsPostBack)
            {
                refreshSummaryFooter();
            }
        }
Ejemplo n.º 4
0
        public static double AccountBalance(Session session, Account _Account)
        {
            XPQuery <GeneralLedger> LedgerQuery = session.Query <GeneralLedger>();
            GeneralLedger           LastLedger  = (from c in LedgerQuery
                                                   where c.AccountId == _Account &&
                                                   c.TransactionId.AccountingPeriodId == AccountingPeriodBO.getCurrentAccountingPeriod(session)
                                                   orderby c.IssuedDate descending
                                                   , c.UpdateDate descending
                                                   select c).FirstOrDefault();

            if (LastLedger == null)
            {
                return(0);
            }
            return(LastLedger.Balance);
        }