Пример #1
0
        private void Customer_GridView_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
        {
            int rowIndex = Customer_GridView.FocusedRowHandle;

            if (!Customer_GridView.IsRowSelected(rowIndex))
            {
                return;
            }

            var  selected = Customer_GridView.GetFocusedRow().CastTo <Customer>();
            bool isNewRow = Customer_GridView.IsNewItemRow(rowIndex);

            if (selected == null)
            {
                return;
            }

            // Dòng thêm mới
            if (isNewRow || selected.Status == ModifyMode.Insert)
            {
                return;
            }

            // Có quyền kế toán trưởng
            if (ClientCommon.HasAuthority(UserInfo.UserRole, BSRole.KeToanTruong))
            {
                return;
            }

            if (selected.CreateUser.ToUpper() != UserInfo.UserID.ToUpper())
            {
                Customer_GridView.UnselectRow(rowIndex);
            }
        }
        private void Customer_GridView_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
        {
            Customer row = e.Row.CastTo <Customer>();

            bool isNewRow = Customer_GridView.IsNewItemRow(e.RowHandle);

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

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

            row.Status = ModifyMode.Update;
        }
Пример #3
0
        private void Customer_GridView_ShowingEditor(object sender, CancelEventArgs e)
        {
            int  rowIndex = Customer_GridView.FocusedRowHandle;
            var  selected = Customer_GridView.GetFocusedRow().CastTo <Customer>();
            bool isNewRow = Customer_GridView.IsNewItemRow(rowIndex);

            // Dòng thêm mới
            if (isNewRow || selected.Status == ModifyMode.Insert)
            {
                return;
            }

            // Có quyền kế toán trưởng
            if (ClientCommon.HasAuthority(UserInfo.UserRole, BSRole.KeToanTruong))
            {
                return;
            }

            if (selected.CreateUser.ToUpper() != UserInfo.UserID.ToUpper())
            {
                e.Cancel = true;
            }
        }