Recent

Author Topic: DbGrid or RXDBGRID how i validate and let edit if other column is true  (Read 535 times)

eldonfsr

  • Sr. Member
  • ****
  • Posts: 446
How i can let the user input a data on colomn  if other column has  true value ...

 if( (ColName='orderqty')  and (BDPStock.FieldByName('Selected').AsBoolean=false)) then begin
     BDPStock.edit   ;
     BDPStock.FieldByName('OrderQty').AsInteger:=0;
     BDPStock.post;
     RxDBGProdUs.SelectedIndex:=8;
   end else if( (ColName='orderqty')  and (BDPStock.FieldByName('Selected').AsBoolean=true)) then begin
    BDPStock.edit   ;
   end; 

on what event i can do that ...


eldonfsr

  • Sr. Member
  • ****
  • Posts: 446
Re: DbGrid or RXDBGRID how i validate and let edit if other column is true
« Reply #1 on: February 05, 2023, 07:48:48 pm »
I made some changes on my program and working now could the best option but is working..

Code: Pascal  [Select][+][-]
  1.  
  2. procedure TFormUndMinStk.RxDBGPordUsCellClick(Column: TColumn);
  3. begin
  4.   if((RxDBGPordUs.SelectedIndex = 10) and (RxDBGPordUs.DataSource.DataSet.FieldByName('Selected').AsBoolean = false) ) then begin
  5.       RxDBGPordUs.DataSource.DataSet.Edit;
  6.       RxDBGPordUs.SelectedIndex:=0;
  7.   end else if((RxDBGPordUs.SelectedIndex = 10) and (RxDBGPordUs.DataSource.DataSet.FieldByName('Selected').AsBoolean = true)) then  begin
  8.     RxDBGPordUs.DataSource.DataSet.Edit;
  9.     RxDBGPordUs.SelectedIndex:=7;
  10.   end;
  11. end;
  12.  
  13. procedure TFormUndMinStk.RxDBGPordUsColEnter(Sender: TObject);
  14. begin
  15.     if((RxDBGPordUs.SelectedIndex = 7) and ( FormMain.BDPStock.FieldByName('Selected').AsBoolean =false))   then begin
  16.        ShowMessage('this row is not seleted to have order quantity');
  17.        RxDBGPordUs.SelectedIndex:=6;
  18.     end else if((RxDBGPordUs.SelectedIndex = 7) and ( FormMain.BDPStock.FieldByName('Selected').AsBoolean=true)) then begin
  19.        RxDBGPordUs.DataSource.DataSet.Edit;
  20.     end;
  21.     if((RxDBGPordUs.SelectedIndex = 8)) then begin
  22.        if( RxDBGPordUs.DataSource.DataSet.FieldByName('Orddate').isNull) then begin
  23.           RxDBGPordUs.DataSource.DataSet.Edit;
  24.           RxDBGPordUs.DataSource.DataSet.FieldByName('Orddate').AsDateTime := now;
  25.        end;
  26.     end;
  27.     RxDBGPordUs.setfocus;
  28. end;
  29.  
  30. procedure TFormUndMinStk.RxDBGPordUsColExit(Sender: TObject);
  31. begin
  32.     if((RxDBGPordUs.SelectedIndex = 7) and ( FormMain.BDPStock.FieldByName('orderqty').AsInteger < FormMain.BDPStock.FieldByName('pnminstockqty').AsInteger ))   then begin
  33.        ShowMessage('Quantity must great than minimum stock or at least same value');
  34.        RxDBGPordUs.DataSource.DataSet.Edit;
  35.        FormMain.BDPStock.FieldByName('orderqty').AsInteger:=0;
  36.        RxDBGPordUs.DataSource.DataSet.post;
  37.        RxDBGPordUs.setfocus;
  38.        RxDBGPordUs.DataSource.DataSet.Edit;
  39.        RxDBGPordUs.SelectedIndex:=6;
  40.     end else if((RxDBGPordUs.SelectedIndex = 7) and ( FormMain.BDPStock.FieldByName('orderqty').AsInteger > FormMain.BDPStock.FieldByName('pnminstockqty').AsInteger ) ) then begin
  41.        RxDBGPordUs.DataSource.DataSet.Post;
  42.        RxDBGPordUs.DataSource.DataSet.Edit;
  43.        RxDBGPordUs.setfocus;
  44.      end;
  45.     if((RxDBGPordUs.SelectedIndex = 8)) then begin
  46.         if( RxDBGPordUs.DataSource.DataSet.FieldByName('Orddate').AsDateTime = StrtoDate('01/01/1990')) then begin
  47.           RxDBGPordUs.DataSource.DataSet.Edit;
  48.           RxDBGPordUs.DataSource.DataSet.FieldByName('Orddate').AsDateTime := Now;
  49.           RxDBGPordUs.DataSource.DataSet.Post;
  50.         end;
  51.         RxDBGPordUs.DataSource.DataSet.Edit;
  52.         RxDBGPordUs.setfocus;
  53.     end;
  54.     if((RxDBGPordUs.SelectedIndex = 9)) then begin
  55.          if( RxDBGPordUs.DataSource.DataSet.FieldByName('dateuse').AsDateTime < Now) then begin
  56.           ShowMessage('Date use can be older than to day , type a date post of current date');
  57.            RxDBGPordUs.DataSource.DataSet.Edit;
  58.            RxDBGPordUs.DataSource.DataSet.FieldByName('dateuse').AsDateTime := Now;
  59.          end;
  60.          RxDBGPordUs.DataSource.DataSet.Post;
  61.          RxDBGPordUs.DataSource.DataSet.Edit;
  62.          RxDBGPordUs.setfocus;
  63.      end;
  64.  
  65. End;
  66.  
  67.  
  68.  

 

TinyPortal © 2005-2018