Пример #1
0
        private void gridView_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            bool   bError = false;
            string sError = "";

            var Ten_vai_tro = grvVaiTro.GetRowCellValue(e.RowHandle, "Ten_vai_tro");

            if (Ten_vai_tro == null || Ten_vai_tro.ToString().Trim() == "")
            {
                bError  = true;
                sError += "\n Chưa điền tên vai trò.";
            }

            if (bError)
            {
                e.ErrorText = sError + "\n Bạn có muốn sửa lại không?\n";
                e.Valid     = false;
                //XtraMessageBox.Show(sError, "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;

            if (view.IsNewItemRow(e.RowHandle))
            {
                InsertCommand();
            }
            else
            {
                UpdateCommand();
            }
        }
Пример #2
0
        private void gridView_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            bool bError = false;

            //var ID_loai_vat_tu = gridView.GetRowCellValue(e.RowHandle, colID_loai_vat_tu);

            //if (ID_loai_vat_tu.Equals(0))
            //{
            //    bError = true;
            //    gridView.SetColumnError(colID_loai_vat_tu, Properties.Settings.Default.NullOrEmpty);
            //}

            var Ten_vat_tu = gridView.GetRowCellValue(e.RowHandle, colTen_vat_tu);

            if (Ten_vat_tu == null || Ten_vat_tu.ToString().Trim() == "")
            {
                bError = true;
                gridView.SetColumnError(colTen_vat_tu, Properties.Settings.Default.NullOrEmpty);
            }

            if (bError)
            {
                e.Valid = false;
                return;
            }

            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;

            if (view.IsNewItemRow(e.RowHandle))
            {
                InsertCommand();
            }
            else
            {
                UpdateCommand();
            }
        }
Пример #3
0
 private void DeleteFocusedRows(DevExpress.XtraGrid.Views.Grid.GridView view)
 {
     if (view.RowCount > 0 && view.IsValidRowHandle(view.FocusedRowHandle) && !view.IsNewItemRow(view.FocusedRowHandle))
     {
         view.BeginSort();
         try
         {
             view.DeleteRow(view.FocusedRowHandle);
         }
         catch (Exception)
         {
         }
         view.EndSort();
     }
 }