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 }); }
private void Account_CheckEdit_CheckedChanged(object sender, EventArgs e) { Accounts selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>(); if (selected != null && selected.Status != ModifyMode.Insert) { selected.Status = ModifyMode.Update; } }
private void Account_TreeList_ShowingEditor(object sender, CancelEventArgs e) { string colName = Account_TreeList.FocusedColumn.FieldName; var row = Account_TreeList.GetFocusedRow().CastTo <Accounts>(); if (colName == "AccountID" && !(string.IsNullOrEmpty(row.AccountID) || row.Status == ModifyMode.Insert)) { e.Cancel = true; } }
private void LoadAccountGroupGridView() { using (AccountsController controller = new AccountsController()) { AccountGroupData = new BindingList <AccountGroup>(controller.GetAccountGroup()); AccountGroup_GridControl.DataSource = AccountGroupData; // Load lại source cho combobox loại TK Account_TreeList.SetSourceToDropDown("AccountGroupID", AccountGroupData); } }
private void Account_TreeList_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e) { Accounts selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>(); if (selected == null) { AccountID_SearchLookUpEdit.EditValue = null; } else { AccountID_SearchLookUpEdit.EditValue = selected.AccountID; } }
private void Accounts_Delete_Button_Click(object sender, EventArgs e) { Accounts delete = Account_TreeList.GetFocusedRow().CastTo <Accounts>(); if (delete.Status == ModifyMode.Insert) { return; } delete.Status = ModifyMode.Delete; AccountsDeleteData.Add(delete); Account_TreeList.DeleteSelectedNodes(); }
private void Account_TreeList_ValidateNode(object sender, ValidateNodeEventArgs e) { Account_TreeList.ClearColumnErrors(); Accounts selected = Account_TreeList.GetFocusedRow().CastTo <Accounts>(); TreeList view = sender as TreeList; TreeListColumn column; if (selected == null) { return; } string accountID = selected.AccountID; if (string.IsNullOrWhiteSpace(accountID)) { e.Valid = false; //Set errors with specific descriptions for the columns column = view.Columns[nameof(selected.AccountID)]; view.SetColumnError(column, BSMessage.BSM000013); } // Kiểm tra tồn tại trong grid if (AccountsData.ToList().Count(o => o.AccountID == accountID) > 1) { e.Valid = false; column = view.Columns[nameof(selected.AccountID)]; view.SetColumnError(column, BSMessage.BSM000015); } if (string.IsNullOrEmpty(selected.AccountName)) { e.Valid = false; column = view.Columns[nameof(selected.AccountName)]; view.SetColumnError(column, BSMessage.BSM000011); } if (string.IsNullOrEmpty(selected.AccountGroupID)) { e.Valid = false; column = view.Columns[nameof(selected.AccountGroupID)]; view.SetColumnError(column, BSMessage.BSM000016); } if (selected.Status != ModifyMode.Insert) { selected.Status = ModifyMode.Update; } }
private void LoadAccountsGridView() { AccountsController controller = new AccountsController(); AccountsData = new BindingList <Accounts>(controller.GetAccounts()); AccountBinSource.DataSource = AccountsData; Account_TreeList.DataSource = AccountBinSource; Account_TreeList.ExpandAll(); if (AccountID_SearchLookUpEdit != null) { AccountID_SearchLookUpEdit.Properties.DataSource = AccountsData; } }
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)); }
private void SetupAccountsGridView() { Account_TreeList.SetupTreeList(); }