How Can I

How Can I

Postby Arindam » Wed Aug 02, 2006 6:11 am

Hi.

I am enclosing herewith a function, through which I am trying to add data in a database. The main Problems is:

a) The Get fields are not activated and jumping directly to “Sure to save …….” Msg.

Other problems :

a) How Can I set font name and size?

b) Some Procedure/Function Return shows Warning… during compilation. The msg in “Procedure return value” ……… What is this actually?

c) If I want to move a child mdi window within a specific area of main MDI window, then how can I set the same?


Code: Select all  Expand view

Function getCustomer(aDataFld, helpIDX, OperateArea, nShortId, 
                                         lShortPressed, ButnStatus)
   Static nVal         := 0
   Static getList      := {}

   Local cColor        := "W/N,R/W,,,N/W"

   Local userlevel := "P"
   Local today     := Date()
   Local chCust    := 0

   Local Success, savDelete, lReadit, i

   Local cCNo  := Space(8),  cRank := Space(8),  nPin  := Space(6)
   Local cName := Space(35), cAdd1 := Space(35), cAdd2 := Space(35)
   Local cLoc := Space(35)


   lReadit  := .T.
   
   // Hide mouse cursor
   mSetCursor(.F.)
   
   // Set Color Attribute
   Set Color to(cColor)

   // Hide cursor
   Set Cursor Off

      If Len(aDataFld) == 0
         MessageBox(, "Get Fields are empty. Try again                             later...",      "WARNING", "OK")
         Clear Gets
         ReadKill(.T.)
         Chcust        := 0
         ButnStatus    := .T.
         lShortPressed := .T.
         nShortId      := "S_NOCHOICE"

         Return(ButnStatus, nShortId, lShortPressed)
      Endif

      If lReadit == .F.
         @  3,  11   Get aDataFld[01]                                          ;
                     Picture    "@!"                                                   ;
                     Color      "12/7, 12/7"                                       ;
                     Valid    nodupl(aDataFld[01], Customer->CustNo, helpIDX, ,1,  ;
                                     "         Invalid Customer Code.         ;"  + ;
                                     "A Customer with the current Customer No.;"  + ;
                                     "found.;") .And. !LastKey() == K_ESC
      Else
         @  3,  11   Get aDataFld[01]                                              ;
                     Picture    "@!"                                               ;
                     Color      "W/N,R/W,,,N/W"                                    ;
                     Valid    Lreqdata() .And. nodupl(aDataFld[01], Customer->CustNo, helpIDX, ,1,  ;
                                     "         Invalid Customer Code.         ;"  + ;
                                     "A Customer with the current Customer No.;"  + ;
                                     "found.;") .And.  !LastKey() == K_ESC   .And.  ;
                              lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
      Endif

      @  5, 11    Get aDataFld[02]   ;
                  Picture    "@!"                                ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  Valid      lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)

      @  6, 11    Get aDataFld[03]   ;
                  Picture    "@!"                                ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  When       If(userlevel == "P", .T., .F.)      ;
                  Valid      Lreqdata() .And. lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)

      @  7, 11    Get aDataFld[04]   ;
                  Picture    "@!"                                ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  When       !Empty(aDataFld[03])                ;
                  Valid      Lreqdata() .And. lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)

      @  8, 11    Get aDataFld[05]   ;
                  Picture    "@!"                                ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  When       If(!Empty(aDataFld[03]), .T., .F.)  ;
                  Valid      lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)

      @  9, 11    Get aDataFld[06]  ;
                  Picture    "@!"                                ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  When       If(!Empty(aDataFld[03]), .T., .F.)  ;
                  Valid      lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)
     
      @  10, 11   Get aDataFld[07]  ;
                  Picture    "@Z 999999"                         ;
                  Color      "W/N,R/W,,,N/W"                     ;
                  When       If(!Empty(aDataFld[03]), .T., .F.)  ;
                  Valid      lCheck(aDataFld, helpIDX, cCNo, cRank, cName, cAdd1, cAdd2, cLoc, nPin)

   // Show mouse cursor
   mSetCursor(.T.)

   If lReadit
      // Turn on the cursor
      Set Cursor On

      ReadModal(GetList, 1,, 4, 50, 70, "9/14")

      // Hide cursor
      Set Cursor Off
   Else
      While .T.
         i := Inkey()

         Do Case
         Case i = K_PGDN
              If Eof()
                 dbSkip()
              Endif
              Exit
         Case i = K_PGUP
              If Eof()
                 dbSkip(-1)
              Endif
              Exit
         Otherwise
            Loop
         EndCase           
      Enddo

      Return(ButnStatus, nShortId, lShortPressed)
   Endif

   // User terminated, read unchanged or fails data integrity
   If LastKey() == K_ESC
      If helpIDX == "ADD"
         Return(ButnStatus, nShortId, lShortPressed)
      Endif

   Endif

   If ValueChanged .Or. Updated()
      If !integrity(aDataFld)
         Return(ButnStatus, nShortId, lShortPressed)
      Endif
   Endif

   // Save the record after operator's confirmation
   If MessageBox(, "Sure to save current record ?" ,;
                   "CONFIRM", "MB_OKCANCEL") <> 1

      Return(ButnStatus, nShortId, lShortPressed)
   Endif

   // Update system databases and establish all locks in the databases
   updvars(aDataFld, helpIDX, @Success)

   // All okay, save now
   If Success
      For i := 1 To FCount()
         FieldPut(i, aDataFld[i])
      Next

      // Force pending updates to disk
      dbCommitAll()
   Else
      MessageBox(, "Unable to save data" , "WARNING", "OK")
   Endif

   Chcust      := 0
   CustAppnd    := .F.
   ValueChanged := .F.
   Success      := .F.

   Customer->(dbRUnLock())
   cAdnlCust->(dbrUnLock())
Return(ButnStatus, nShortId, lShortPressed)



I have very much doubt that whether the above code will be readable or not. I did not found any other option to attach the same. I hope such option should be there. Waiting for early reply.

Thanks everybody.
Arindam
:?:
Arindam
 
Posts: 44
Joined: Sat Jul 29, 2006 5:03 pm
Location: Kolkata, India

Postby Antonio Linares » Wed Aug 02, 2006 6:45 am

Arindam,

There is extra code in your sample that should not be used as GETs are managed in a simpler way with FiveWin.

Please review samples\TestGet2.prg to see how GETs work in FiveWin.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

How can I

Postby Arindam » Thu Aug 03, 2006 6:56 pm

Thanks Mr. Antonio L. for your support. I have seen samples\testget2. But that is exam of get fields from local var. I am trying to access fields from a .dbf file and store the input data in .dbf. That I am not success.
Some other points skip from your sight in my last post. Please look on that part also. Can you give me a short Exam?

Thank Arindam
Arindam
 
Posts: 44
Joined: Sat Jul 29, 2006 5:03 pm
Location: Kolkata, India

Postby Antonio Linares » Thu Aug 03, 2006 8:18 pm

Arindam,

Usually you use local vars for GETs and later on you save their contents to the DBF fields.

> a) How Can I set font name and size?

Search in samples directory for DEFINE FONT ...

>
b) Some Procedure/Function Return shows Warning… during compilation. The msg in “Procedure return value” ……… What is this actually?
>

A procedure should not return a value. Only functions return values.

>
c) If I want to move a child mdi window within a specific area of main MDI window, then how can I set the same?
>

oWndChild:Move( nTop, nLeft, nWidth, nHeight, lRepaint )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42077
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google Feedfetcher and 66 guests