예제 #1
0
        private void AddAccount(bool isSameLevel = true)
        {
            string accountGroupID = AccountGroup_GridView.GetFocusedRow().CastTo <AccountGroup>().AccountGroupID;

            if (string.IsNullOrEmpty(accountGroupID))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000022);
                return;
            }

            Accounts selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>();
            string   parentID;
            byte     level;

            if (selected == null)
            {
                if (!isSameLevel)
                {
                    MessageBoxHelper.ShowErrorMessage("Chưa chọn TK cha.");
                    return;
                }
                else
                {
                    parentID = string.Empty;
                    level    = 1;
                }
            }
            else
            {
                if (isSameLevel)
                {
                    parentID = selected.ParentID;
                    level    = selected.AccountLevel;
                    if (string.IsNullOrEmpty(selected.ParentID))
                    {
                        // nothing
                    }
                    else
                    {
                        accountGroupID = selected.AccountGroupID;
                    }
                }
                else
                {
                    parentID       = selected.AccountID;
                    level          = (byte)(selected.AccountLevel + 1);
                    accountGroupID = selected.AccountGroupID;
                }
            }

            AccountsData.Add(new Accounts
            {
                AccountGroupID = accountGroupID,
                ParentID       = parentID,
                AccountLevel   = level,
                Status         = ModifyMode.Insert
            });
        }
예제 #2
0
        private void AccountGroup_GridView_ShowingEditor(object sender, CancelEventArgs e)
        {
            string colName  = AccountGroup_GridView.FocusedColumn.FieldName;
            int    rowIndex = AccountGroup_GridView.FocusedRowHandle;
            bool   isNewRow = AccountGroup_GridView.IsNewItemRow(rowIndex);

            if (colName == "AccountGroupID" && !isNewRow)
            {
                e.Cancel = true;
            }
        }
예제 #3
0
        private void AccountGroup_GridView_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            Account_TreeList.ClearColumnsFilter();
            AccountGroup selectedRow = AccountGroup_GridView.GetFocusedRow().CastTo <AccountGroup>();

            if (selectedRow == null)
            {
                return;
            }

            // filter grid
            Account_TreeList.ActiveFilterString = $"[AccountGroupID] = '{selectedRow.AccountGroupID}'";
            DevExpress.XtraTreeList.Nodes.TreeListNode node = this.Account_TreeList.GetNodeByVisibleIndex(0);
            this.Account_TreeList.SetFocusedNode(this.Account_TreeList.GetNodeByVisibleIndex(0));
        }
예제 #4
0
        private void Accounts_Add_Button_Click(object sender, EventArgs e)
        {
            string AccountGroupID = AccountGroup_GridView.GetFocusedRow().CastTo <AccountGroup>().AccountGroupID;

            if (string.IsNullOrEmpty(AccountGroupID))
            {
                MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000009);
                return;
            }

            AccountsData.Add(new Accounts
            {
                AccountGroupID = AccountGroupID,
                Status         = ModifyMode.Insert
            });
        }
예제 #5
0
        private void AccountGroup_GridView_RowUpdated(object sender, RowObjectEventArgs e)
        {
            AccountGroup row      = e.Row.CastTo <AccountGroup>();
            bool         isNewRow = AccountGroup_GridView.IsNewItemRow(e.RowHandle);

            if (isNewRow)
            {
                row.Status = ModifyMode.Insert;
                return;
            }

            if (row.Status == ModifyMode.Insert)
            {
                return;
            }

            row.Status = ModifyMode.Update;
        }
예제 #6
0
 private void AccountGroup_Delete_Button_Click(object sender, EventArgs e)
 {
     AccountGroup_GridView.DeleteSelectedRows();
 }