protected void grd_Journal_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e) { if (AccountingBO.IsApproved(session, Guid.Parse(Session["TransactionId"].ToString()))) { throw new Exception("Hạch toán đã được duyệt. Không thể thêm!!!"); } }
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; } } }
void AccountItemsRequestedByFilterCondition(object source, ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox comboItemUnit = source as ASPxComboBox; CriteriaOperator filter = new BinaryOperator("Code", "0", BinaryOperatorType.Equal); XPCollection <NAS.DAL.Accounting.AccountChart.Account> collection = new XPCollection <NAS.DAL.Accounting.AccountChart.Account>(session, filter); foreach (NAS.DAL.Accounting.AccountChart.Account account in AccountingBO.getNotParentAccountList(session)) { collection.Add(account); } //collection.SkipReturnedObjects = e.BeginIndex; //collection.TopReturnedObjects = e.EndIndex - e.BeginIndex + 1; //CriteriaOperator criteria = // CriteriaOperator.Or( // new BinaryOperator("Code", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like), // new BinaryOperator("Name", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like) //); //collection.Criteria = criteria; //collection.Sorting.Add(new SortProperty("Code", DevExpress.Xpo.DB.SortingDirection.Ascending)); comboItemUnit.DataSource = collection; comboItemUnit.DataBindItems(); }
protected void grdGeneralJournal_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName.Equals("Description")) { e.Editor.Focus(); } else if (e.Column.FieldName.Equals("AccountId!Key")) { ASPxComboBox accountComboBox = (ASPxComboBox)e.Editor; if (accountComboBox != null) { var accountList = AccountingBO.getNotParentAccountList(session); accountComboBox.DataSource = accountList; accountComboBox.DataBindItems(); } } //if (e.Column.FieldName.Equals("AccountId!Key")) //{ // try // { // ASPxComboBox accountCombobox = e.Editor as ASPxComboBox; // if (accountCombobox != null) // { // accountCombobox.ItemsRequestedByFilterCondition += new ListEditItemsRequestedByFilterConditionEventHandler(accountCombobox_ItemsRequestedByFilterCondition); // accountCombobox.ItemRequestedByValue += new ListEditItemRequestedByValueEventHandler(accountCombobox_ItemRequestedByValue); // } // } // catch (Exception ex) // { // } //} }
protected void grdBookingDetail_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName == "RowStatus") { e.Editor.Value = 1; GridViewDataColumn col1 = ((ASPxGridView)sender).Columns["Credit"] as GridViewDataColumn; ASPxSpinEdit spin1 = ((ASPxGridView)sender).FindEditRowCellTemplateControl(col1, "colBookingDetailCredit") as ASPxSpinEdit; spin1.Value = 0; GridViewDataColumn col2 = ((ASPxGridView)sender).Columns["Debit"] as GridViewDataColumn; ASPxSpinEdit spin2 = ((ASPxGridView)sender).FindEditRowCellTemplateControl(col2, "colBookingDetailDebit") as ASPxSpinEdit; spin1.Value = 0; } if (e.Column.FieldName == "AccountId!Key") { ASPxComboBox combo = (ASPxComboBox)e.Editor; //combo.ItemsRequestedByFilterCondition += new ListEditItemsRequestedByFilterConditionEventHandler(AccountItemsRequestedByFilterCondition); //combo.ItemRequestedByValue += new ListEditItemRequestedByValueEventHandler(AccountItemRequestedByValue); ASPxComboBox accountCombobox = e.Editor as ASPxComboBox; accountCombobox.TextField = "Code"; accountCombobox.DataSource = AccountingBO.getNotParentAccountList(session); accountCombobox.DataBind(); e.Editor.Focus(); } }
protected void cboBalanceInitAccount_ItemsRequestedByFilterCondition(object source, DevExpress.Web.ASPxEditors.ListEditItemsRequestedByFilterConditionEventArgs e) { ASPxComboBox comboItemUnit = source as ASPxComboBox; XPCollection <Account> collection = new XPCollection <Account>(session); collection.SkipReturnedObjects = e.BeginIndex; collection.TopReturnedObjects = e.EndIndex - e.BeginIndex + 1; XPCollection <Account> _childAccount = AccountingBO.getNotParentAccountCollection(session); CriteriaOperator _filter = CriteriaOperator.Or( new BinaryOperator("AccountTypeId.AccountCategoryId.AccountCategoryId", Guid.Parse("A5FD76BB-F0D8-40F5-ADF8-6648804BDC62"), BinaryOperatorType.Equal), new BinaryOperator("AccountTypeId.AccountCategoryId.AccountCategoryId", Guid.Parse("387208A7-8D9E-49DA-8131-A83BA97B9D6B"), BinaryOperatorType.Equal), new BinaryOperator("AccountTypeId.AccountCategoryId.AccountCategoryId", Guid.Parse("FF561A7E-00D8-4596-B46A-29064BCB09D2"), BinaryOperatorType.Equal), new BinaryOperator("AccountTypeId.AccountCategoryId.AccountCategoryId", Guid.Parse("C1EC8F33-C4F6-4312-AE4A-6F8FD3A1F5DB"), BinaryOperatorType.Equal)); _childAccount.Filter = _filter; CriteriaOperator criteria = CriteriaOperator.And( CriteriaOperator.Or( new BinaryOperator("Code", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like), new BinaryOperator("Name", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like) ), new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual), new InOperator("this", _childAccount) ); collection.Criteria = criteria; collection.Sorting.Add(new SortProperty("Code", DevExpress.Xpo.DB.SortingDirection.Ascending)); comboItemUnit.DataSource = collection; comboItemUnit.DataBindItems(); }
protected void ASPxGridView1_RowInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e) { XPQuery <BookingEntry> BookingEntryQuery = session.Query <BookingEntry>(); BookingEntry BkE = session.GetObjectByKey <BookingEntry>(Guid.Parse(Session["BookingEntryId"].ToString())); AccountingBO accountBO = new AccountingBO(); Guid trnId = accountBO.CreateBookingEntryTransaction(session, BkE.BookingEntryId); }
protected void grd_Journal_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e) { if (AccountingBO.IsApproved(session, Guid.Parse(Session["TransactionId"].ToString()))) { throw new Exception("Hạch toán đã được duyệt. Không thể chỉnh sửa!!!"); //e.Cancel = true; } }
public void UpdatePlanningTransaction(Session session, Guid transactionId, DateTime _PaymentDate, string _Name, double _Amount, string _Description, Guid _CurrencyId) { SaleInvoiceTransaction transaction = session.GetObjectByKey <SaleInvoiceTransaction>(transactionId); if (transaction == null || _Amount == 0) { return; } try { AccountingBO accountingBO = new AccountingBO(); Currency currency = session.GetObjectByKey <Currency>(_CurrencyId); CriteriaOperator filter = new BinaryOperator("Code", DefaultAccountEnum.NAAN_DEFAULT.ToString(), BinaryOperatorType.Equal); Account account = session.FindObject <Account>(filter); if (currency == null || account == null) { return; } transaction.IssueDate = _PaymentDate; transaction.Code = _Name; transaction.Amount = _Amount; transaction.Description = _Description; transaction.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE; transaction.UpdateDate = DateTime.Now; transaction.Save(); CriteriaOperator criteria_0 = new BinaryOperator("TransactionId", transaction, BinaryOperatorType.Equal); CriteriaOperator criteria_1 = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual); CriteriaOperator criteria_2 = new BinaryOperator("JournalType", Constant.PLANNING_JOURNAL, BinaryOperatorType.Equal); CriteriaOperator criteria = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2); XPCollection <GeneralJournal> journalList = new XPCollection <GeneralJournal>(session, criteria); foreach (GeneralJournal generalJournal in journalList) { generalJournal.AccountId = account; if (generalJournal.Credit == 0) { generalJournal.Debit = _Amount; } else { generalJournal.Credit = _Amount; } generalJournal.Description = _Name; generalJournal.CurrencyId = currency; generalJournal.Save(); } } catch (Exception) { throw; } }
protected void gridviewGeneralJournal_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName == "AccountId!Key") { AccountingBO accountingBO = new AccountingBO(); ASPxComboBox combo = e.Editor as ASPxComboBox; combo.DataSource = accountingBO.getLeafAccounts(session); combo.DataBindItems(); } }
protected void ASPxGridView3_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { if (AccountingBO.IsApproved(session, Guid.Parse(Session["TransactionId"].ToString()))) { throw new Exception("Hạch toán đã được duyệt. Không thể thêm!!!"); //e.Cancel = true; } //XPQuery<BookingEntryTransaction> BookingEntryQuery = session.Query<BookingEntryTransaction>(); //BookingEntryTransaction BkTr = BookingEntryQuery.Where(r => r.TransactionId == (Guid)((ASPxGridView)sender).GetMasterRowKeyValue()).FirstOrDefault(); e.NewValues["RowStatus"] = Utility.Constant.ROWSTATUS_ACTIVE; e.NewValues["TransactionId"] = Session["Transaction"]; }
protected void grdDetailEntry_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName.Equals("AccountId!Key")) { ASPxComboBox accountComboBox = (ASPxComboBox)e.Editor; if (accountComboBox != null) { accountComboBox.DataSource = AccountingBO.getNotParentAccountList(session); accountComboBox.DataBindItems(); e.Editor.Focus(); } } }
protected void grd_Journal_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName.Equals("AccountId!Key")) { try { ASPxComboBox accountCombobox = e.Editor as ASPxComboBox; accountCombobox.TextField = "Code"; accountCombobox.DataSource = AccountingBO.getNotParentAccountCollection(session); accountCombobox.DataBind(); } catch (Exception) { } } }
protected void Page_Load(object sender, EventArgs e) { AccountingBO accountBO = new AccountingBO(); //accountBO.InitBalanceForward(session, AccountingPeriodBO.getCurrentAccountingPeriod(session)); var datasource1 = accountBO.getLedgerListByAccountCategory(session, "ASSET"); var datasource2 = accountBO.getLedgerListByAccountCategory(session, "LIABILITY"); var datasource3 = accountBO.getLedgerListByAccountCategory(session, "EQUITY"); ASPxTreeList1.DataSource = datasource1; ASPxTreeList2.DataSource = datasource2; ASPxTreeList3.DataSource = datasource3; ASPxTreeList1.DataBind(); ASPxTreeList2.DataBind(); ASPxTreeList3.DataBind(); XPQuery <AccountCategory> AccCateQuery = session.Query <AccountCategory>(); General gen = new General(); AccountCategory AccCate = AccCateQuery.Where(r => r.Code == "ASSET").FirstOrDefault(); totalAsset = gen.TotalBalance(session, AccCate); AccCate = AccCateQuery.Where(r => r.Code == "LIABILITY").FirstOrDefault(); totalLiability = gen.TotalBalance(session, AccCate); AccCate = AccCateQuery.Where(r => r.Code == "EQUITY").FirstOrDefault(); totalEquity = gen.TotalBalance(session, AccCate); ASPxTextBox tb1 = ASPxTreeList1.FindFooterTemplateControl(ASPxTreeList1.Columns[2], "AssetTotal") as ASPxTextBox; tb1.Value = ParseStringNumber(totalAsset.ToString()); tb1.Text = ParseStringNumber(totalAsset.ToString()); ASPxTextBox tb2 = ASPxTreeList2.FindFooterTemplateControl(ASPxTreeList2.Columns[2], "LiabilityTotal") as ASPxTextBox; tb2.Value = ParseStringNumber(totalLiability.ToString()); tb2.Text = ParseStringNumber(totalLiability.ToString()); ASPxTextBox tb3 = ASPxTreeList3.FindFooterTemplateControl(ASPxTreeList3.Columns[2], "EquityTotal") as ASPxTextBox; tb3.Value = ParseStringNumber(totalEquity.ToString()); tb3.Text = ParseStringNumber(totalEquity.ToString()); ASPxTextBox tb4 = ASPxTreeList3.FindFooterTemplateControl(ASPxTreeList3.Columns[2], "DebitTotal") as ASPxTextBox; tb4.Value = ParseStringNumber((totalLiability + totalEquity).ToString()); tb4.Text = ParseStringNumber((totalLiability + totalEquity).ToString()); }
protected void grdGeneralJournal_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxGridView grid = sender as ASPxGridView; e.NewValues["RowStatus"] = Utility.Constant.ROWSTATUS_ACTIVE; e.NewValues["TransactionId!Key"] = grid.GetMasterRowKeyValue(); if (AccountingBO.IsApproved(session, Guid.Parse(grid.GetMasterRowKeyValue().ToString()))) { throw new Exception("Hạch toán đã được duyệt. Không thể thêm!!!"); e.Cancel = true; } if (e.NewValues["Credit"] == null) { e.NewValues["Credit"] = (double)0; } if (e.NewValues["Debit"] == null) { e.NewValues["Debit"] = (double)0; } }
public List <AccountingBO> GetItemsbyType(int itemtype) { try { string sql = "dbo.fn_get_itemsbytype"; List <AccountingBO> Details = new List <AccountingBO>(); conn = new NpgsqlConnection(connString); conn.Open(); using (var cmd = new NpgsqlCommand(sql, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("_itemtype", NpgsqlTypes.NpgsqlDbType.Smallint, itemtype); var reader = cmd.ExecuteReader(); do { while (reader.Read()) { var accdetail = new AccountingBO(); accdetail.itemkey = Utils.CustomParse <Guid>(reader["itemkey"]); accdetail.itemid = Utils.CustomParse <string>(reader["itemid"]); accdetail.description = Utils.CustomParse <string>(reader["description"]); accdetail.itemtype = Utils.CustomParse <short>(reader["itemtype"]); Details.Add(accdetail); } }while (reader.NextResult()); reader.Close(); return(Details); } } catch (Exception msg) { throw msg; } finally { conn.Close(); } }
public Guid CreatePlanningTransaction(Session session, Guid billId, DateTime _PaymentDate, string _Name, double _Amount, string _Description, Guid _CurrencyId) { PurchaseInvoiceTransaction newTransaction = new PurchaseInvoiceTransaction(session); if (_Amount == 0) { return(Guid.Empty); } try { AccountingBO accountingBO = new AccountingBO(); NAS.DAL.Invoice.PurchaseInvoice purchaseInvoice = session.GetObjectByKey <NAS.DAL.Invoice.PurchaseInvoice>(billId); Currency currency = session.GetObjectByKey <Currency>(_CurrencyId); CriteriaOperator filter = new BinaryOperator("Code", DefaultAccountEnum.NAAN_DEFAULT.ToString(), BinaryOperatorType.Equal); Account account = session.FindObject <Account>(filter); if (purchaseInvoice == null || currency == null || account == null) { return(Guid.Empty); } newTransaction.IssueDate = _PaymentDate; newTransaction.Code = _Name; newTransaction.Amount = _Amount; newTransaction.Description = _Description; newTransaction.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE; newTransaction.PurchaseInvoiceId = purchaseInvoice; newTransaction.CreateDate = DateTime.Now; newTransaction.UpdateDate = DateTime.Now; newTransaction.Save(); accountingBO.CreateGeneralJournal(session, newTransaction.TransactionId, account.AccountId, Constant.PLANNING_JOURNAL, _Name, _Amount, 0, Constant.ROWSTATUS_ACTIVE, _CurrencyId); accountingBO.CreateGeneralJournal(session, newTransaction.TransactionId, account.AccountId, Constant.PLANNING_JOURNAL, _Name, 0, _Amount, Constant.ROWSTATUS_ACTIVE, _CurrencyId); } catch (Exception) { throw; } return(newTransaction.TransactionId); }
public List <AccountingBO> GetAccountingOptionsbyKey(string key) { try { string sql = "dbo.fn_get_accountingoptionsbykey"; List <AccountingBO> Details = new List <AccountingBO>(); conn = new NpgsqlConnection(connString); conn.Open(); using (var cmd = new NpgsqlCommand(sql, conn)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("_orderdetailkey", NpgsqlTypes.NpgsqlDbType.Uuid, Guid.Parse(key)); var reader = cmd.ExecuteReader(); do { while (reader.Read()) { var accdetail = new AccountingBO(); accdetail.itemkey = Utils.CustomParse <Guid>(reader["itemkey"]); accdetail.itemskey = Utils.CustomParse <Guid>(reader["itemskey"]); accdetail.orderdetailkey = Guid.Parse(key); Details.Add(accdetail); } }while (reader.NextResult()); reader.Close(); } return(Details); } catch (Exception msg) { throw msg; } finally { conn.Close(); } }
protected void grdBookingDetail_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e) { if (e.Column.FieldName == "RowStatus") { e.Editor.Value = 1; } if (e.Column.FieldName == "AccountId!Key") { ASPxComboBox combo = (ASPxComboBox)e.Editor; //combo.ItemsRequestedByFilterCondition += new ListEditItemsRequestedByFilterConditionEventHandler(AccountItemsRequestedByFilterCondition); //combo.ItemRequestedByValue += new ListEditItemRequestedByValueEventHandler(AccountItemRequestedByValue); ASPxComboBox accountCombobox = e.Editor as ASPxComboBox; accountCombobox.TextField = "Code"; accountCombobox.DataSource = AccountingBO.getNotParentAccountList(session); accountCombobox.DataBind(); e.Editor.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { AccountingBO ABO = new AccountingBO(); //XPQuery<GeneralJournal> journal = session.Query<GeneralJournal>(); //Transaction tr = session.GetObjectByKey<Transaction>(Guid.Parse("fef74738-049d-45a4-b8c5-074431dc4431")); //var a = journal.Where(r => r.TransactionId == tr).FirstOrDefault(); //List<object> TransList = ABO.GetFullDesTransactionList(session); //ASPxGridView2.DataSource = TransList; //ASPxGridView2.KeyFieldName = "TransactionId"; //ASPxGridView2.DataBind(); List <object> source1 = ABO.getFullLedgerList(session); ASPxGridView1.DataSource = source1; ASPxGridView1.DataBind(); //List<object> source1 = ABO.GetFullDesTransactionList(session); //ASPxGridView2.DataSource = source1; //ASPxGridView2.KeyFieldName = "ID"; //ASPxGridView2.DataBind(); }
protected void ASPxCallbackPanel1_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { ASPxCallbackPanel cp = sender as ASPxCallbackPanel; ASPxButton bt1 = cp.FindControl("bt_Approve") as ASPxButton; if (AccountingBO.IsApproved(session, Guid.Parse(Session["TransactionId"].ToString()))) { if (bt1 != null) { bt1.Visible = false; bt1.Enabled = false; } } else { if (bt1 != null) { bt1.Visible = true; bt1.Enabled = true; } } }
protected void AccountList_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { XPQuery <Account> accountQuery = session.Query <Account>(); Account account = (from c in accountQuery where c.Code == e.OldValues["Code"] select c).FirstOrDefault(); AccountingBO accountBO = new AccountingBO(); double _Balance = Double.Parse(e.NewValues["Balance"].ToString()); AccountingPeriod _accountingPeriod = session.GetObjectByKey <AccountingPeriod>(Guid.Parse(cboAccountPeriod.Value.ToString())); if (_accountingPeriod == null) { throw new Exception("Chưa chọn kỳ kế toán !"); } AccountingPeriod accountPeriod = _accountingPeriod; accountBO.UpdateBalanceForwardTransaction(session, account.AccountId, _Balance); ASPxGridView grid = (ASPxGridView)sender; grid.CancelEdit(); List <NAS.BO.Accounting.AccountingBO.AccountingEntity> rs = accountBO.getInitBalanceForward(session, _accountingPeriod); AccountList.DataSource = rs; AccountList.DataBind(); } catch (Exception) { throw; } finally { e.Cancel = true; } }
public void LoadGeneralLedger(Session session, List <ETL_GeneralLedger> GeneralledgerList) { try { AccountingBO accountingBO = new AccountingBO(); if (GeneralledgerList == null) { return; } if (GeneralledgerList.Count == 0) { return; } Transaction transaction = session.GetObjectByKey <Transaction>(GeneralledgerList[0].TransactionId); if (transaction == null) { return; } foreach (GeneralLedger ledger in transaction.GeneralLedgers) { ledger.RowStatus = Constant.ROWSTATUS_DELETED; ledger.Save(); } foreach (ETL_GeneralLedger ledger in GeneralledgerList) { Account account = session.GetObjectByKey <Account>(ledger.AccountId); Currency currency = session.GetObjectByKey <Currency>(ledger.CurrencyId); if (account != null && currency != null) { double sign = 1; if (account.BalanceType == Utility.Constant.BALANCE_TYPE_CREDIT) { sign = -1; } double _coefficient = 0; _coefficient = accountingBO.getCoefficientCompareWithDefaultByCurrencyCode(session, currency.Code); GeneralLedger generalLedger = new GeneralLedger(session); generalLedger.AccountId = account; generalLedger.Credit = ledger.Credit; generalLedger.Debit = ledger.Debit; generalLedger.Description = ledger.Description; generalLedger.CurrencyId = currency; generalLedger.TransactionId = transaction; generalLedger.IssuedDate = ledger.IssueDate; generalLedger.IsOriginal = true; generalLedger.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE; generalLedger.CreateDate = DateTime.Now; generalLedger.UpdateDate = DateTime.Now; generalLedger.Balance = GetAccountingBalanceAtTime(session, account.AccountId, currency.CurrencyId, transaction.IssueDate) + (ledger.Debit - ledger.Credit) * sign * _coefficient; generalLedger.Save(); } } } catch (Exception) { throw; } }
protected void cpBooking_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) { session = XpoHelper.GetNewSession(); switch (e.Parameter) { case "view": grdBooking.DetailRows.CollapseAllRows(); if (Session["SaleBillId"] == null) { return; } session = XpoHelper.GetNewSession(); SalesInvoice salesInvoice = session.GetObjectByKey <SalesInvoice>(Guid.Parse(Session["SaleBillId"].ToString())); CriteriaOperator filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal); XPCollection <SalesInvoiceInventoryAccountingTransaction> saleInvoiceTransaction = new XPCollection <SalesInvoiceInventoryAccountingTransaction>(session, filter); if (saleInvoiceTransaction.Count > 0) { foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction) { if (item.RowStatus == ROW_NOT_DELETE) { grdBooking.Columns["Thao tác"].Visible = false; break; } else { grdBooking.Columns["Thao tác"].Visible = true; } } } else { grdBooking.AddNewRow(); grdBooking.Columns["Thao tác"].Visible = true; } cpBooking.JSProperties.Add("cpEnable", "true"); ///// break; case "booking": salesInvoice = session.GetObjectByKey <SalesInvoice>(Guid.Parse(Session["SaleBillId"].ToString())); filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal); saleInvoiceTransaction = new XPCollection <SalesInvoiceInventoryAccountingTransaction>(session, filter); foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction) { double credit = 0; double debit = 0; filter = new GroupOperator(GroupOperatorType.And, new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", ROW_NEW, BinaryOperatorType.Equal)); XPCollection <GeneralJournal> generalJournal = new XPCollection <GeneralJournal>(session, filter); foreach (GeneralJournal x in generalJournal) { filter = new GroupOperator(GroupOperatorType.And, new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal), new BinaryOperator("AccountId", x.AccountId, BinaryOperatorType.Equal), new BinaryOperator("RowStatus", ROW_NEW, BinaryOperatorType.Equal)); XPCollection <GeneralJournal> generalJ = new XPCollection <GeneralJournal>(session, filter); if (generalJ.Count >= 2) { cpBooking.JSProperties.Add("cpUnbooked", "1"); return; } credit += x.Credit; debit += x.Debit; } if (credit != debit) { cpBooking.JSProperties.Add("cpUnbooked", "2"); return; } } foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction) { item.RowStatus = ROW_NOT_DELETE; item.Save(); filter = new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal); XPCollection <GeneralJournal> generalJournal = new XPCollection <GeneralJournal>(session, filter); double milsec = 0; foreach (GeneralJournal x in generalJournal) { NAS.DAL.Accounting.AccountChart.Account account = session.GetObjectByKey <NAS.DAL.Accounting.AccountChart.Account>(x.AccountId.AccountId); //General general = new General(); //general.BalanceUpdate(session, account, x, false, x.Debit-x.Credit); AccountingBO accountBO = new AccountingBO(); accountBO.CreateGeneralLedger(session, x.TransactionId.TransactionId, x.GeneralJournalId, milsec); milsec += 10; } } filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal); SalesInvoiceInventoryAccountingTransaction purchaseInvoiceInventoryTransaction = session.FindObject <SalesInvoiceInventoryAccountingTransaction>(filter); purchaseInvoiceInventoryTransaction.RowStatus = ROW_NOT_DELETE; purchaseInvoiceInventoryTransaction.Save(); grdBooking.DetailRows.CollapseAllRows(); grdBooking.Columns["Thao tác"].Visible = false; cpBooking.JSProperties.Add("cpEnable", "true"); break; default: break; } }
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(); } }
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 < 0. /// 5: Debit < 0. /// 6: Don't have any journal /// 7: Transaction not exist /// 8: Credit and Debit < 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; } }
protected void ASPxGridView1_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) { /// -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 < 0. /// 5: Debit < 0. /// 6: Don't have any journal /// 7: Transaction not exist /// 8: Credit and Debit < 0 /// 9: Exist more than one Credit Account && more than one Debit Account //switch (approveError) //{ // case -1: { break; } // case 0: { break; } // case 1: { // e.RowError = "Tổng nợ không bằng tổng có"; // break; // } // case 2: { // e.RowError = "2"; // break; // } // case 3: { // e.RowError = "3"; // break; // } // case 4: { // e.RowError = "4"; // break; // } // case 5: { // e.RowError = "5"; // break; // } // case 6: { // e.RowError = "6"; // break; // } // case 7: { // e.RowError = "7"; // break; // } // case 8: { // e.RowError = "8"; // break; // } // case 9: { // e.RowError = "9"; // break; // } // default: { break; } //} AccountingBO acountingBO = new AccountingBO(); string entryCode = null; string entryOldCode = null; try { entryCode = e.NewValues["Code"].ToString(); } catch { } try { entryOldCode = e.OldValues["Code"].ToString(); } catch { } if (entryCode != null) { if (acountingBO.IsExistTransactionCode(session, entryCode) == true && entryCode != entryOldCode) { e.RowError = "Mã bút toán đã tồn tại"; } } }